Skip to content

feat(cli): implement exp task status command - #19533

Merged
johnstcn merged 11 commits into
mainfrom
cj/exp-cli-status
Aug 26, 2025
Merged

johnstcn merged 11 commits into
mainfrom
cj/exp-cli-status

Conversation

@johnstcn

@johnstcn johnstcn commented Aug 25, 2025 •

Copy link
Copy Markdown
Member

Closes coder/internal#900

  • Implements coder exp task status
  • Adds testutil.MustURL helper

No robots were harmed in the making of this PR.

- Implements `coder exp task status`
- Adds `testutil.MustURL` helper
@johnstcn johnstcn self-assigned this Aug 25, 2025
Comment thread cli/exp_task_status_test.go Outdated
args []string
expectOutput string
expectError string
hf func(context.Context) func(http.ResponseWriter, *http.Request)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

review: I elected to mock the API response instead of standing up a whole coderdtest. We have too many of these as it is.

Comment thread testutil/url.go
"testing"
)

func MustURL(t testing.TB, raw string) *url.URL {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

review: I figured this might be useful.

Comment thread cli/exp_task_status_test.go Outdated
State: codersdk.TaskStateWorking,
},
})
c.Add(1)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm just sad I couldn't write c++ here 😢

@DanielleMaywood DanielleMaywood left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@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.

I think it'd be nice to have a /status endpoint in coderd that allows follow without polling, but I'm fine with the current implementation for now. Some comments/suggestions inline.

Comment thread cli/exp_task_status.go Resolved
Comment thread cli/exp_task_status.go Outdated

// TODO: right now tasks are still "workspaces" under the hood.
// We should update this once we have a proper task model.
ws, err := namedWorkspace(ctx, client, id)

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.

Is this lookup necessary, is it mainly to support e.g. workspace name rather than plain uuid lookups?

We should perhaps consider supporting name lookup in the get task endpoint.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah this is basically for convenience due to the current task <-> workspace relationship

Comment thread cli/exp_task_status.go Resolved
Comment thread cli/exp_task_status.go Resolved
Comment thread cli/exp_task_status.go Resolved
Comment thread cli/exp_task_status_internal_test.go Resolved
Comment thread cli/exp_task_status.go Resolved
@johnstcn
johnstcn requested a review from mafredri August 26, 2025 12:15

var (
ctx = testutil.Context(t, testutil.WaitShort)
now = time.Now().UTC() // TODO: replace with quartz

@johnstcn johnstcn Aug 26, 2025 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

review: this is unfortunately flake-prone unless we just test the JSON output which omits the relative time.

@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.

I think switching to the table approach was a good call, nice. A few suggestions pertaining to JSON output but otherwise LGTM.

Comment thread cli/exp_task_status.go Outdated
Handler: func(i *serpent.Invocation) error {
ctx := i.Context()
ec := codersdk.NewExperimentalClient(client)
id := i.Args[0]

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.

Just realized this could support multiple args (tasks) as well, and watching each. But let's leave that for future.

Comment thread cli/exp_task_status.go Resolved
@johnstcn
johnstcn merged commit 5baaf27 into main Aug 26, 2025
@johnstcn
johnstcn deleted the cj/exp-cli-status branch August 26, 2025 15:01
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 26, 2025
@johnstcn johnstcn added the cherry-pick/v2.26 Needs to be cherry-picked to the 2.26 release branch label Aug 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cherry-pick/v2.26 Needs to be cherry-picked to the 2.26 release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tasks CLI: Add status command

3 participants