Skip to content

feat(cli): add exp task create command - #19492

Merged
DanielleMaywood merged 6 commits into
mainfrom
danielle/tasks/cli-create
Aug 26, 2025
Merged

DanielleMaywood merged 6 commits into
mainfrom
danielle/tasks/cli-create

Conversation

@DanielleMaywood

@DanielleMaywood DanielleMaywood commented Aug 22, 2025 •

Copy link
Copy Markdown
Contributor

Partially implements coder/internal#893

This isn't the full implementation of coder exp tasks create as defined in the issue, but it is the minimum required to create a task.

Comment thread cli/root.go Resolved
@DanielleMaywood
DanielleMaywood force-pushed the danielle/tasks/cli-create branch from 3220cc1 to 9196c38 Compare August 22, 2025 17:58
@DanielleMaywood
DanielleMaywood force-pushed the danielle/tasks/cli-create branch from 9196c38 to 14ee5c9 Compare August 26, 2025 08:20
@DanielleMaywood DanielleMaywood changed the title feat(cli): add task create command feat(cli): add exp task create command Aug 26, 2025
templateVersionPresetID = uuid.New()
)

templateAndVersionFoundHandler := func(t *testing.T, ctx context.Context, templateName, templateVersionName, presetName, prompt string) http.HandlerFunc {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to create a small helper here instead of writing the same handler over-and-over again. This is following in the footsteps of #19533 by using a http handler to mock coderd behavior instead of using coderdtest.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to add a single "integration"-style test at the end in a separate PR so we know we've all our bases covered.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me

@DanielleMaywood
DanielleMaywood marked this pull request as ready for review August 26, 2025 12:30

@mafredri mafredri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions/nits inline, but approach seems fine. We may want to consider moving some of the logic to the API endpoint if we want to make API usage more convenient, but this works for now.

Comment thread cli/exp_taskcreate.go Resolved
Comment thread cli/exp_taskcreate.go Resolved
Comment thread cli/exp_taskcreate.go Resolved
Comment thread cli/exp_taskcreate.go Resolved
Comment thread cli/exp_taskcreate.go
workspace, err := expClient.CreateTask(ctx, codersdk.Me, codersdk.CreateTaskRequest{
TemplateVersionID: templateVersionID,
TemplateVersionPresetID: templateVersionPresetID,
Prompt: taskInput,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Not sure if we're too far gone to do this, but potential for rename: Prompt -> Input depending on how we want to standardize this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As it is all experimental we technically still have time

@DanielleMaywood
DanielleMaywood merged commit 63c1325 into main Aug 26, 2025
@DanielleMaywood
DanielleMaywood deleted the danielle/tasks/cli-create branch August 26, 2025 14:24
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 26, 2025

@mafredri mafredri left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post-merge approve and one more suggestion.

Comment thread cli/exp_taskcreate.go
inv.Stdout,
"The task %s has been created at %s!\n",
cliui.Keyword(workspace.Name),
cliui.Timestamp(time.Now()),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

workspace.CreatedAt?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way I've implemented it is how we currently do it for workspace creation but I'm happy to create a quick follow up PR to address this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up to you tbh, I'm good with either just thought it made sense so threw it out there. 👍🏻

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants