Skip to content

Commit 0a483ea

Browse files
authored
feat: add idle app status (#18415)
"Idle" is more accurate than "complete" since: 1. AgentAPI only knows if the screen is active; it has no way of knowing if the task is complete. 2. The LLM might be done with its current prompt, but that does not mean the task is complete either (it likely needs refinement). The "complete" state will be reserved for future definition. Additionally, in the case where the screen goes idle but the LLM never reported a status update, we can get an idle icon without a message, and it looks kinda janky in the UI so if there is no message I display the state text. Closes coder/internal#699
1 parent 0258f1d commit 0a483ea

20 files changed

+115
-16
lines changed

cli/exp_mcp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -585,10 +585,10 @@ func (s *mcpServer) startWatcher(ctx context.Context, inv *serpent.Invocation) {
585585
case event := <-eventsCh:
586586
switch ev := event.(type) {
587587
case agentapi.EventStatusChange:
588-
// If the screen is stable, assume complete.
588+
// If the screen is stable, report idle.
589589
state := codersdk.WorkspaceAppStatusStateWorking
590590
if ev.Status == agentapi.StatusStable {
591-
state = codersdk.WorkspaceAppStatusStateComplete
591+
state = codersdk.WorkspaceAppStatusStateIdle
592592
}
593593
err := s.queue.Push(taskReport{
594594
state: state,

cli/exp_mcp_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ func TestExpMcpReporter(t *testing.T) {
900900
{
901901
event: makeStatusEvent(agentapi.StatusStable),
902902
expected: &codersdk.WorkspaceAppStatus{
903-
State: codersdk.WorkspaceAppStatusStateComplete,
903+
State: codersdk.WorkspaceAppStatusStateIdle,
904904
Message: "doing work",
905905
URI: "https://dev.coder.com",
906906
},
@@ -948,7 +948,7 @@ func TestExpMcpReporter(t *testing.T) {
948948
{
949949
event: makeStatusEvent(agentapi.StatusStable),
950950
expected: &codersdk.WorkspaceAppStatus{
951-
State: codersdk.WorkspaceAppStatusStateComplete,
951+
State: codersdk.WorkspaceAppStatusStateIdle,
952952
Message: "oops",
953953
URI: "",
954954
},

coderd/apidoc/docs.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dump.sql

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- It is not possible to delete a value from an enum, so we have to recreate it.
2+
CREATE TYPE old_workspace_app_status_state AS ENUM ('working', 'complete', 'failure');
3+
4+
-- Convert the new "idle" state into "complete". This means we lose some
5+
-- information when downgrading, but this is necessary to swap to the old enum.
6+
UPDATE workspace_app_statuses SET state = 'complete' WHERE state = 'idle';
7+
8+
-- Swap to the old enum.
9+
ALTER TABLE workspace_app_statuses
10+
ALTER COLUMN state TYPE old_workspace_app_status_state
11+
USING (state::text::old_workspace_app_status_state);
12+
13+
-- Drop the new enum and rename the old one to the final name.
14+
DROP TYPE workspace_app_status_state;
15+
ALTER TYPE old_workspace_app_status_state RENAME TO workspace_app_status_state;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TYPE workspace_app_status_state ADD VALUE IF NOT EXISTS 'idle';

coderd/database/models.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/workspaceagents.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,10 @@ func (api *API) patchWorkspaceAgentAppStatus(rw http.ResponseWriter, r *http.Req
359359
}
360360

361361
switch req.State {
362-
case codersdk.WorkspaceAppStatusStateComplete, codersdk.WorkspaceAppStatusStateFailure, codersdk.WorkspaceAppStatusStateWorking: // valid states
362+
case codersdk.WorkspaceAppStatusStateComplete,
363+
codersdk.WorkspaceAppStatusStateFailure,
364+
codersdk.WorkspaceAppStatusStateWorking,
365+
codersdk.WorkspaceAppStatusStateIdle: // valid states
363366
default:
364367
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
365368
Message: "Invalid state provided.",

codersdk/toolsdk/toolsdk.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ Bad Tasks
191191
Use the "state" field to indicate your progress. Periodically report
192192
progress with state "working" to keep the user updated. It is not possible to send too many updates!
193193
194-
ONLY report a "complete" or "failure" state if you have FULLY completed the task.
194+
ONLY report an "idle" or "failure" state if you have FULLY completed the task.
195195
`,
196196
Schema: aisdk.Schema{
197197
Properties: map[string]any{
@@ -205,10 +205,10 @@ ONLY report a "complete" or "failure" state if you have FULLY completed the task
205205
},
206206
"state": map[string]any{
207207
"type": "string",
208-
"description": "The state of your task. This can be one of the following: working, complete, or failure. Select the state that best represents your current progress.",
208+
"description": "The state of your task. This can be one of the following: working, idle, or failure. Select the state that best represents your current progress.",
209209
"enum": []string{
210210
string(codersdk.WorkspaceAppStatusStateWorking),
211-
string(codersdk.WorkspaceAppStatusStateComplete),
211+
string(codersdk.WorkspaceAppStatusStateIdle),
212212
string(codersdk.WorkspaceAppStatusStateFailure),
213213
},
214214
},

0 commit comments

Comments
 (0)