X Tutup
Skip to content

fix(coderd): use BuildReasonTaskAutoPause for task workspaces#22126

Merged
johnstcn merged 5 commits intomainfrom
cj/task-lifecycle-autopause
Feb 17, 2026
Merged

fix(coderd): use BuildReasonTaskAutoPause for task workspaces#22126
johnstcn merged 5 commits intomainfrom
cj/task-lifecycle-autopause

Conversation

@johnstcn
Copy link
Member

@johnstcn johnstcn commented Feb 16, 2026

Relates to coder/internal#1252

When a workspace with a TaskID hits its deadline, use BuildReasonTaskAutoPause instead of BuildReasonAutostop. This allows downstream systems to distinguish between regular autostop and task workspace pauses.

Created by Mux using Opus 4.5.

When a workspace with a TaskID hits its deadline, use BuildReasonTaskAutoPause
instead of BuildReasonAutostop. This allows downstream systems to distinguish
between regular autostop and task workspace pauses.
@johnstcn johnstcn self-assigned this Feb 16, 2026
Comment on lines 533 to 534
case isEligibleForAutostart(user, ws, latestBuild, latestJob, templateSchedule, currentTick):
return database.WorkspaceTransitionStart, database.BuildReasonAutostart, nil
Copy link
Member Author

Choose a reason for hiding this comment

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

self-review: assuming that there is no reason to "auto-resume" a task.

Copy link
Member

Choose a reason for hiding this comment

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

We have not defined it yet. But the autostart schedule of the underlying workspace would naturally map to this.

For now, we can leave it out 👍🏻

@johnstcn johnstcn changed the title fix(autobuild): use BuildReasonTaskAutoPause for task workspaces fix(coderd): use BuildReasonTaskAutoPause for task workspaces Feb 16, 2026
@johnstcn johnstcn marked this pull request as ready for review February 17, 2026 12:47
Copilot AI review requested due to automatic review settings February 17, 2026 12:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a new build reason BuildReasonTaskAutoPause to distinguish when AI task workspaces are automatically paused by the lifecycle executor from regular workspace autostops. When a workspace with a TaskID hits its deadline (or needs a failed stop), it now uses BuildReasonTaskAutoPause instead of BuildReasonAutostop, allowing downstream systems to differentiate between these scenarios.

Changes:

  • Added BuildReasonTaskAutoPause constant in backend SDK and database enum
  • Updated lifecycle executor to check for TaskID and use the new build reason for autostop and failedstop transitions
  • Added frontend TypeScript types, system build reasons list, and build reason labels
  • Included comprehensive test coverage for the new behavior

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
codersdk/workspacebuilds.go Added BuildReasonTaskAutoPause constant definition
coderd/autobuild/lifecycle_executor.go Added TaskID checks to use TaskAutoPause reason for task workspaces during autostop and failedstop
coderd/autobuild/lifecycle_executor_test.go Added test to verify task workspaces use TaskAutoPause build reason
coderd/autobuild/lifecycle_executor_internal_test.go Added unit tests for getNextTransition with task workspaces
site/src/api/typesGenerated.ts Added task_auto_pause to BuildReason type and array
site/src/utils/workspace.tsx Added task_auto_pause to systemBuildReasons array and buildReasonLabels map
site/src/pages/TaskPage/TaskPage.stories.tsx Updated TaskPausedTimeout story to use task_auto_pause reason
docs/reference/api/schemas.md Updated BuildReason enum documentation
coderd/apidoc/swagger.json Updated OpenAPI spec with task_auto_pause enum value
coderd/apidoc/docs.go Updated API documentation template

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add task_auto_pause to buildReasonLabels with label 'Task Auto-Pause'
- Add task_auto_pause to systemBuildReasons array
- Add task_auto_pause to getDisplayWorkspaceBuildInitiatedBy (returns 'Coder')
- Add test case for task_auto_pause in getDisplayWorkspaceBuildInitiatedBy
- Update TaskPausedTimeout story to use task_auto_pause reason
Copy link
Member

@mafredri mafredri left a comment

Choose a reason for hiding this comment

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

Looks good to me! 👍🏻

Comment on lines 533 to 534
case isEligibleForAutostart(user, ws, latestBuild, latestJob, templateSchedule, currentTick):
return database.WorkspaceTransitionStart, database.BuildReasonAutostart, nil
Copy link
Member

Choose a reason for hiding this comment

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

We have not defined it yet. But the autostart schedule of the underlying workspace would naturally map to this.

For now, we can leave it out 👍🏻

"autostart",
"autostop",
"dormancy",
"task_auto_pause",
Copy link
Member

Choose a reason for hiding this comment

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

I realize not related to this PR, but something we've overlooked previously. Should we add task_resume and task_manual_pause here as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Can do 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

@johnstcn johnstcn merged commit f8eea54 into main Feb 17, 2026
32 checks passed
@johnstcn johnstcn deleted the cj/task-lifecycle-autopause branch February 17, 2026 15:11
@github-actions github-actions bot locked and limited conversation to collaborators Feb 17, 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.

4 participants

X Tutup