Skip to content

Commit c7d6073

Browse files
t3dotggclaude
andcommitted
fix(clients): async questions move a thread out of Working
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent ce48e45 commit c7d6073

5 files changed

Lines changed: 11 additions & 41 deletions

File tree

‎packages/client-runtime/src/state/entities.test.ts‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { canSnooze, effectiveSnoozed } from "./threadSettled.ts";
2222
const environmentId = EnvironmentId.make("environment-v2");
2323

2424
describe("V2 client presentation", () => {
25-
it("keeps async questions in Working until the run completes", () => {
25+
it("moves a running thread with an async question out of Working", () => {
2626
const runId = RunId.make("run-async-question");
2727
const running = {
2828
...v2ThreadShell,
@@ -39,17 +39,9 @@ describe("V2 client presentation", () => {
3939
},
4040
};
4141
const active = presentThreadShell(environmentId, running);
42-
expect(active.hasPendingUserInput).toBe(false);
43-
expect(isThreadWorking(active)).toBe(true);
42+
expect(active.hasPendingUserInput).toBe(true);
43+
expect(isThreadWorking(active)).toBe(false);
4444
expect(canSnooze(active, { now: "2026-06-20T00:05:00.000Z" })).toBe(false);
45-
46-
const completed = presentThreadShell(environmentId, {
47-
...running,
48-
activeRunId: null,
49-
status: "completed",
50-
});
51-
expect(completed.hasPendingUserInput).toBe(true);
52-
expect(isThreadWorking(completed)).toBe(false);
5345
expect(effectiveSnoozed(active, { now: "2026-06-20T00:05:00.000Z" })).toBe(false);
5446
});
5547

‎packages/client-runtime/src/state/models.ts‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,9 @@ function terminalRunStatus(status: OrchestrationV2RunStatus): boolean {
216216
);
217217
}
218218

219-
/** An async question waits for an answer only once its run stops working. */
219+
/** Any open question, async ones included, puts the thread in Input. */
220220
export function shellHasPendingUserInput(thread: OrchestrationV2ThreadShell): boolean {
221-
const status = shellRuntime(thread)?.status;
222-
// Waiting runs have ended their provider turn and are only draining effects.
223-
const working = status === "preparing" || status === "starting" || status === "running";
224-
return (
225-
thread.pendingRuntimeRequest?.kind === "user_input" &&
226-
(thread.pendingRuntimeRequest.blocking !== false || !working)
227-
);
221+
return thread.pendingRuntimeRequest?.kind === "user_input";
228222
}
229223

230224
// Only work the agent waits on holds it: commands and monitors it left running

‎packages/client-runtime/src/state/threadShell.test.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,14 @@ describe("v2 thread shell lists", () => {
181181
const disposeNavigation = registry.mount(threads.navigationThreadShellsAtom);
182182
const withRequest = (
183183
kind: "user_input" | "command",
184-
options: { readonly blocking?: boolean; readonly settled?: boolean } = {},
184+
options: { readonly blocking?: boolean } = {},
185185
) =>
186186
registry.set(snapshotAtom(environmentId), {
187187
...v2ShellSnapshot,
188188
threads: [
189189
root,
190190
{
191191
...sideChat,
192-
...(options.settled ? { status: "completed" as const, activityRunStatus: null } : {}),
193192
pendingRuntimeRequest: {
194193
...request,
195194
kind,
@@ -206,11 +205,7 @@ describe("v2 thread shell lists", () => {
206205
root.id,
207206
]);
208207

209-
// An async question waits while the side chat works, like its own row's indicator.
210208
withRequest("user_input", { blocking: false });
211-
expect(registry.get(parent)?.pendingSubagentRequest).toBeNull();
212-
expect(registry.get(inputs)).toEqual([]);
213-
withRequest("user_input", { blocking: false, settled: true });
214209
expect(registry.get(parent)?.pendingSubagentRequest).toBe("user_input");
215210

216211
withRequest("command");

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

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ describe("projectThreadAwarenessV2", () => {
183183
).toMatchObject({ phase });
184184
});
185185

186-
it("reports an async question as input only after the working run completes", () => {
186+
it("reports an async question as input while the run keeps working", () => {
187187
const input = {
188188
environmentId: "env-1" as EnvironmentId,
189189
project,
@@ -197,12 +197,9 @@ describe("projectThreadAwarenessV2", () => {
197197
}),
198198
};
199199
expect(projectThreadAwarenessV2(input)).toMatchObject({
200-
phase: "running",
201-
headline: "Agent is working",
200+
phase: "waiting_for_input",
201+
headline: "Waiting for input",
202202
});
203-
expect(
204-
projectThreadAwarenessV2({ ...input, thread: { ...input.thread, status: "completed" } }),
205-
).toMatchObject({ phase: "waiting_for_input", headline: "Waiting for input" });
206203
});
207204

208205
it("does not present authentication refreshes as user approvals", () => {

‎packages/shared/src/agentAwareness.ts‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,14 @@ export function projectThreadAwarenessV2(
9898
function resolveThreadAwarenessPhaseV2(
9999
thread: ProjectThreadAwarenessV2Input["thread"],
100100
): AgentAwarenessPhase | null {
101-
const runStatus = thread.activityRunStatus ?? thread.status;
102-
if (
103-
thread.pendingRuntimeRequest?.kind === "user_input" &&
104-
(thread.pendingRuntimeRequest.blocking !== false ||
105-
!(runStatus === "preparing" || runStatus === "starting" || runStatus === "running"))
106-
) {
107-
return "waiting_for_input";
108-
}
101+
if (thread.pendingRuntimeRequest?.kind === "user_input") return "waiting_for_input";
109102
if (
110103
thread.pendingRuntimeRequest !== null &&
111-
thread.pendingRuntimeRequest.kind !== "user_input" &&
112104
thread.pendingRuntimeRequest.kind !== "auth_refresh"
113105
) {
114106
return "waiting_for_approval";
115107
}
116-
switch (runStatus) {
108+
switch (thread.activityRunStatus ?? thread.status) {
117109
case "preparing":
118110
case "starting":
119111
return "starting";

0 commit comments

Comments
 (0)