- Notifications
You must be signed in to change notification settings - Fork1.1k
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
base:main
Are you sure you want to change the base?
Conversation
…-initializing-state-message
…-initializing-state-message
…-initializing-state-message
| // 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 { |
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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
| message="Workspacebuildispending" | |
| message=fmt.Sprintf("Workspace is%s",ws.LatestBuild.Status) |
| casetaskAgentLifecycle!=nil: | ||
| switch*taskAgentLifecycle { | ||
| casecodersdk.WorkspaceAgentLifecycleCreated: | ||
| message="Agent is connecting" |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
Uh oh!
There was an error while loading.Please reload this page.
Problem
With the new tasks data model, a task starts with an
initializingstatus. However, the API returnscurrent_state: nullto represent the agent state, causing the frontend to display "No message available". This PR updatescodersdk.Taskto return acurrent_statewhen the task is initializing with meaningful messages about what's happening during task initialization.Previous message
New message
Changes
current_statewith descriptive initialization messages when task status isinitializingand no valid app status exists for the current buildWorkspaceBuildbuilder to properly handle pending/running jobs by linking tasks without requiring agent/app resourcesNote: UI Storybook changes to reflect these new messages will be addressed in a follow-up PR.
Closes:coder/internal#1063