Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: set codersdk.Task current_state during task initialization#20692

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
ssncferreira wants to merge7 commits intomain
base:main
Choose a base branch
Loading
fromssncferreira/fix-task-initializing-state-message

Conversation

@ssncferreira
Copy link
Contributor

@ssncferreirassncferreira commentedNov 10, 2025
edited
Loading

Problem

With the new tasks data model, a task starts with aninitializing status. However, the API returnscurrent_state: null to represent the agent state, causing the frontend to display "No message available". This PR updatescodersdk.Task to return acurrent_state when the task is initializing with meaningful messages about what's happening during task initialization.

Previous message

Screenshot 2025-11-07 at 09 06 13

New message

Screenshot 2025-11-12 at 11 00 15

Changes

  • Populatecurrent_state with descriptive initialization messages when task status isinitializing and no valid app status exists for the current build
  • dbfake: FixWorkspaceBuild builder to properly handle pending/running jobs by linking tasks without requiring agent/app resources

Note: UI Storybook changes to reflect these new messages will be addressed in a follow-up PR.

Closes:coder/internal#1063

@ssncferreirassncferreira marked this pull request as ready for reviewNovember 12, 2025 11:05

// If no valid agent state was found for the current build and the task is initializing,
// provide a descriptive initialization message.
ifcurrentState==nil&&codersdk.TaskStatus(dbTask.Status)==codersdk.TaskStatusInitializing {
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: extract this to its own function


switch {
casews.LatestBuild.Status==codersdk.WorkspaceStatusPending:
message="Workspace build is pending"
Copy link
Member

Choose a reason for hiding this comment

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

We could reduce some duplication here

Suggested change
message="Workspacebuildispending"
message=fmt.Sprintf("Workspace is%s",ws.LatestBuild.Status)

casetaskAgentLifecycle!=nil:
switch*taskAgentLifecycle {
casecodersdk.WorkspaceAgentLifecycleCreated:
message="Agent is connecting"
Copy link
Member

Choose a reason for hiding this comment

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

We could also probably generate this using the workspace agent lifecycle status?

assert.NotEqual(t,"all done",updated.CurrentState.Message)
})

t.Run("InitializingAgentState",func(t*testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

extracting the function will mean we can test it on its own and only need to test a couple cases here

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@johnstcnjohnstcnjohnstcn left review comments

@mafredrimafredriAwaiting requested review from mafredri

@DanielleMaywoodDanielleMaywoodAwaiting requested review from DanielleMaywood

At least 1 approving review is required to merge this pull request.

Assignees

@ssncferreirassncferreira

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

task status is empty when workspace is starting or startup script is running

3 participants

@ssncferreira@johnstcn

[8]ページ先頭

©2009-2025 Movatter.jp