Skip to content

Commit beb1fa6

Browse files
committed
fix(server): 🧟 stop a status-free task update reviving an idle task
The revival guard only covered `progress`, so a status-free `updated` sailed past it and put an already-dropped task back in the live set. Claude's adapter emits exactly that whenever a task patch carries only a description, error, end_time or is_backgrounded, which left the sidebar pill pinned on "working" until session exit. Same bug class as #7128/#7172, which fixed it for `progress` only. `started` stays excluded on purpose so a genuine restart still revives; a second test pins that so the guard can't over-correct.
1 parent 324ddda commit beb1fa6

2 files changed

Lines changed: 57 additions & 4 deletions

File tree

‎apps/server/src/orchestration/ThreadBackgroundLiveness.test.ts‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,58 @@ describe("ThreadBackgroundLiveness", () => {
2828
expect(liveness.getThreadBackgroundLiveness("thread")).toBeNull();
2929
});
3030

31+
it("does not let status-free updated restart an idle task", () => {
32+
const liveness = ThreadBackgroundLiveness.make();
33+
liveness.recordTaskLiveness({
34+
threadId: "thread",
35+
taskId: "task",
36+
taskType: undefined,
37+
status: undefined,
38+
kind: "started",
39+
});
40+
liveness.recordTaskLiveness({
41+
threadId: "thread",
42+
taskId: "task",
43+
taskType: undefined,
44+
status: "idle",
45+
kind: "updated",
46+
});
47+
liveness.recordTaskLiveness({
48+
threadId: "thread",
49+
taskId: "task",
50+
taskType: undefined,
51+
status: undefined,
52+
kind: "updated",
53+
});
54+
expect(liveness.getThreadBackgroundLiveness("thread")).toBeNull();
55+
});
56+
57+
it("a genuine restart (kind: started) still revives an idle task", () => {
58+
const liveness = ThreadBackgroundLiveness.make();
59+
liveness.recordTaskLiveness({
60+
threadId: "thread",
61+
taskId: "task",
62+
taskType: undefined,
63+
status: undefined,
64+
kind: "started",
65+
});
66+
liveness.recordTaskLiveness({
67+
threadId: "thread",
68+
taskId: "task",
69+
taskType: undefined,
70+
status: "idle",
71+
kind: "updated",
72+
});
73+
liveness.recordTaskLiveness({
74+
threadId: "thread",
75+
taskId: "task",
76+
taskType: undefined,
77+
status: undefined,
78+
kind: "started",
79+
});
80+
expect(liveness.getThreadBackgroundLiveness("thread")).toBe("working");
81+
});
82+
3183
it("agents present as working; monitors as monitoring; agents win", () => {
3284
const liveness = ThreadBackgroundLiveness.make();
3385
const threadId = "t-live-1";

‎apps/server/src/orchestration/ThreadBackgroundLiveness.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,11 @@ export function make(): ThreadBackgroundLivenessService["Service"] {
130130
return;
131131
}
132132

133-
// Status-free progress is a description tick, not a restart. A delayed
134-
// progress event after idle must not put the task back in the live set
135-
// (#7128).
136-
if (input.kind === "progress" && input.status === undefined) {
133+
// Status-free progress/updated is a description tick, not a restart. A
134+
// delayed progress or updated event after idle must not put the task
135+
// back in the live set (#7128, #7172). "started" is excluded on
136+
// purpose: a genuine restart must still revive the task.
137+
if ((input.kind === "progress" || input.kind === "updated") && input.status === undefined) {
137138
const existing = stateByThreadId.get(input.threadId);
138139
const stillLive =
139140
existing !== undefined &&

0 commit comments

Comments
 (0)