Skip to content

Commit 3c84902

Browse files
committed
fix(coderd): prevent idle state for non-active tasks
Previously, deriveTaskCurrentState would return "idle" state for all tasks regardless of their status. This caused stopped or errored tasks to incorrectly appear in the "Waiting for input" tab. This fix specifically filters out only the "idle" state for non-active tasks, while preserving other important states like "working", "complete", or "failed" which remain meaningful even for stopped tasks. The logic now checks: if the state is "idle" AND the task status is not "active", skip setting that state. All other state/status combinations pass through normally, ensuring we don't lose important state messages. --- 🤖 This change was written by Claude Code using Coder Tasks and reviewed by a human 🏂
1 parent 02bac71 commit 3c84902

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

coderd/aitasks.go

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -347,11 +347,20 @@ func deriveTaskCurrentState(
347347
// still value in showing the latest app status.
348348
if ws.LatestAppStatus != nil {
349349
if ws.LatestBuild.Transition != codersdk.WorkspaceTransitionStart || ws.LatestAppStatus.CreatedAt.After(ws.LatestBuild.CreatedAt) {
350-
currentState = &codersdk.TaskStateEntry{
351-
Timestamp: ws.LatestAppStatus.CreatedAt,
352-
State: codersdk.TaskState(ws.LatestAppStatus.State),
353-
Message: ws.LatestAppStatus.Message,
354-
URI: ws.LatestAppStatus.URI,
350+
appState := codersdk.TaskState(ws.LatestAppStatus.State)
351+
352+
// Don't show "idle" state for non-active tasks since the workspace
353+
// is not actually running and waiting for input. Other states like
354+
// "working", "complete", "failed" are still meaningful for stopped tasks.
355+
shouldShowState := !(appState == codersdk.TaskStateIdle && dbTask.Status != database.TaskStatusActive)
356+
357+
if shouldShowState {
358+
currentState = &codersdk.TaskStateEntry{
359+
Timestamp: ws.LatestAppStatus.CreatedAt,
360+
State: appState,
361+
Message: ws.LatestAppStatus.Message,
362+
URI: ws.LatestAppStatus.URI,
363+
}
355364
}
356365
}
357366
}

0 commit comments

Comments
 (0)