Skip to content

Commit 5e31e6c

Browse files
fix: settled threads no longer publish a running activity while a monitor holds a wake
The monitor hold reports a completed wake run as running, which skipped the settled guard, so a settled thread with a pending Monitor kept a running Live Activity until the monitor ended. The guard now drops a settled completion that only the monitor hold keeps running. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 175298a commit 5e31e6c

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

‎packages/shared/src/agentAwareness.test.ts‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,21 @@ describe("projectThreadAwarenessV2", () => {
121121
).toMatchObject({ phase: "running", headline: "Agent is working" });
122122
});
123123

124-
it.each(["completed", "failed"] as const)("removes settled %s work", (status) => {
124+
it.each([
125+
["completed", "completed", false],
126+
["failed", "failed", false],
127+
["monitor-held", "completed", true],
128+
] as const)("removes settled %s work", (_, status, latestRunBackgroundWake) => {
125129
expect(
126130
projectThreadAwarenessV2({
127131
environmentId: "env-1" as EnvironmentId,
128132
project,
129-
thread: v2Thread({ status, settledOverride: "settled" }),
133+
thread: v2Thread({
134+
status,
135+
settledOverride: "settled",
136+
latestRunBackgroundWake,
137+
pendingBackgroundTasks: [{ taskId: "watch", kind: "monitor" }],
138+
}),
130139
}),
131140
).toBeNull();
132141
});

‎packages/shared/src/agentAwareness.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,12 @@ export function projectThreadAwarenessV2(
102102
}
103103
if (phase === "completed" && thread.latestRunStopRequested === true) return null;
104104
// Resolve the phase first so live or waiting work stays visible after settlement.
105+
const runStatus = thread.activityRunStatus ?? thread.status;
105106
if (
106107
thread.settledOverride === "settled" &&
107-
(phase === "completed" || phase === "failed") &&
108+
(phase === "completed" ||
109+
phase === "failed" ||
110+
(phase === "running" && runStatus === "completed")) &&
108111
!backgroundWorkHoldsCompletion(thread.pendingBackgroundTasks ?? [])
109112
) {
110113
return null;

0 commit comments

Comments
 (0)