Skip to content

feat(cli): add coder task pause command#22012

Merged
DanielleMaywood merged 10 commits intomainfrom
aitasks-48ny
Feb 13, 2026
Merged

feat(cli): add coder task pause command#22012
DanielleMaywood merged 10 commits intomainfrom
aitasks-48ny

Conversation

@DanielleMaywood
Copy link
Contributor

@DanielleMaywood DanielleMaywood commented Feb 9, 2026

Summary

Add a new coder task pause CLI command that pauses a running task by triggering a workspace build transition to stop.

Features

  • Accepts task identifier as UUID, name, or owner/name format
  • Supports pausing another user's task (e.g. coder task pause alice/my-task)
  • Interactive confirmation prompt with --yes flag to bypass
  • Streams workspace build progress after triggering the pause
  • Consistent with existing task commands (create, delete, etc.)

Testing

Integration tests with a real coderd instance and echo provisioner (4 cases):

  • WithYesFlag: Pauses via --yes, verifies output and server-side task status
  • OtherUserTask: Admin pauses a task owned by another user via owner/name identifier
  • PromptConfirm: Interactive prompt answered "yes", verifies pause and server-side status
  • PromptDecline: Interactive prompt answered "no", verifies command errors and task is not paused

Closes coder/internal#1263 (Closes COCO-2)


Generated by Coder Mux

Add a new CLI command to pause a running task. The command accepts a
task identifier (UUID, name, or owner/name format) and triggers a
workspace build transition to stop the task.

Features:
- Interactive confirmation prompt with --yes flag to bypass
- Build progress streaming when a workspace build is returned
- Supports task resolution by UUID, name, or owner/name

Includes unit tests with mock HTTP server covering happy paths,
error handling, prompt confirmation/decline, and an integration
test in the full task lifecycle sequence.

Closes coder/internal#1263
@DanielleMaywood DanielleMaywood force-pushed the aitasks-48ny branch 2 times, most recently from cf23517 to a6138a8 Compare February 10, 2026 12:16
@DanielleMaywood DanielleMaywood marked this pull request as ready for review February 10, 2026 13:48
Copy link
Contributor

@SasSwart SasSwart left a comment

Choose a reason for hiding this comment

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

Thanks! Only two questions and a couple nits.

return err
}

task, err := client.TaskByIdentifier(ctx, inv.Args[0])
Copy link
Contributor

Choose a reason for hiding this comment

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

The endpoint already fetches the task based on the name/id provided in its middleware. Do we need to fetch it here in the CLI? We're incurring an additional round trip through HTTP and SQL.

Looks like we mostly fetch it to determine its owner for display purposes and then to pass back into the endpoint.

Would it be better to require the user to provide the owner name/id if they're trying to delete a task for a different user?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can do what you're suggesting although it'd require updating the client helper PauseTask defined in codersdk/aitasks.go from user string, id uuid.UUID to user, idOrName string

- Remove punctuation from example descriptions
- Remove dead else branch for nil WorkspaceBuild (never nil on success)
- Regenerate golden file and CLI docs
@coder-tasks
Copy link
Contributor

coder-tasks bot commented Feb 11, 2026

Documentation Check

Updates Needed

  • docs/ai-coder/cli.md - Add task pause command to the list of CLI reference links

The auto-generated CLI reference documentation (docs/reference/cli/task_pause.md) has been added correctly, and the manifest has been updated. However, the user-facing CLI landing page at docs/ai-coder/cli.md should be updated to include a link to the new task pause command to maintain consistency with the other task subcommands.

Suggested addition between task logs and task send:

- [task pause](../reference/cli/task_pause.md) - Pause a task

⚠️ Checked latest PR changes - the documentation was still not added to docs/ai-coder/cli.md


Automated review via Coder Tasks

Add a test case (OtherUserTask) that verifies an admin can pause a
task owned by another user using the "owner/name" identifier format.
Add a corresponding CLI example demonstrating this usage.
@DanielleMaywood DanielleMaywood merged commit 6d41d98 into main Feb 13, 2026
29 checks passed
@DanielleMaywood DanielleMaywood deleted the aitasks-48ny branch February 13, 2026 14:21
@github-actions github-actions bot locked and limited conversation to collaborators Feb 13, 2026
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.

Tasks: CLI pause command

3 participants