@devries-cameron20 / t3code-1 / commits / 955e2bfbb5
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(clients): questions always move a thread out of Working (#28515)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Theo Browne committed Oct 31, 2026 at 21:48 UTC 955e2bfbb5c092c54ad795c8d379fec99702a6b5
7 files changed +15 -55
packages/client-runtime/src/state/entities.test.ts
+3 -13
@@ -22,7 +22,7 @@ import { canSnooze, effectiveSnoozed } from "./threadSettled.ts";
22 const environmentId = EnvironmentId.make("environment-v2");
23
24 describe("V2 client presentation", () => {
25 - it("keeps async questions in Working until the run completes", () => {
25 + it("an async question blocks snooze and wakes a snoozed thread", () => {
26 const runId = RunId.make("run-async-question");
27 const running = {
28 ...v2ThreadShell,
@@ -39,22 +39,12 @@ describe("V2 client presentation", () => {
39 },
40 };
41 const active = presentThreadShell(environmentId, running);
42 - expect(active.hasPendingUserInput).toBe(false);
43 - expect(isThreadWorking(active)).toBe(true);
42 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);
43 expect(effectiveSnoozed(active, { now: "2026-06-20T00:05:00.000Z" })).toBe(false);
44 });
45
56 - it("keeps blocking and legacy questions out of Working", () => {
57 - for (const capability of [{ blocking: true }, {}]) {
46 + it("moves a running thread with any question out of Working", () => {
47 + for (const capability of [{ blocking: false }, { blocking: true }, {}]) {
48 const shell = presentThreadShell(environmentId, {
49 ...v2ThreadShell,
50 latestRunId: RunId.make("run-blocking-question"),
packages/client-runtime/src/state/models.ts
+2 -12
@@ -216,17 +216,6 @@ function terminalRunStatus(status: OrchestrationV2RunStatus): boolean {
216 );
217 }
218
219 -/** An async question waits for an answer only once its run stops working. */
220 -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 - );
228 -}
229 -
219 // Only work the agent waits on holds it: commands and monitors it left running
220 // unmarked, such as a dev server, present the run's own status. The
221 // server suppresses the roster while an interruptible activity run exists, so a
@@ -321,7 +310,8 @@ export function presentThreadShell(
310 thread.pendingRuntimeRequest !== null &&
311 thread.pendingRuntimeRequest.kind !== "user_input" &&
312 thread.pendingRuntimeRequest.kind !== "auth_refresh",
324 - hasPendingUserInput: shellHasPendingUserInput(thread),
313 + // Async questions count too, so a thread with any open question leaves Working.
314 + hasPendingUserInput: thread.pendingRuntimeRequest?.kind === "user_input",
315 pendingSubagentRequest,
316 pendingGuestMessageCount: thread.pendingGuestMessageCount ?? 0,
317 hasActionableProposedPlan: thread.hasActionableProposedPlan,
packages/client-runtime/src/state/threadSettled.ts
+1 -1
@@ -125,7 +125,7 @@ export function canSnooze(
125 options: { readonly now: string },
126 ): boolean {
127 if (shell.hasPendingApprovals || shell.hasPendingUserInput) return false;
128 - // The server rejects snoozing even for nonblocking questions.
128 + // The server rejects snoozing for any pending request.
129 if (shell.source?.pendingRuntimeRequest != null) return false;
130 if (shell.pendingSubagentRequest != null) return false;
131 // A waiting guest message would wake it at once.
packages/client-runtime/src/state/threadShell.test.ts
+1 -6
@@ -181,7 +181,7 @@ describe("v2 thread shell lists", () => {
181 const disposeNavigation = registry.mount(threads.navigationThreadShellsAtom);
182 const withRequest = (
183 kind: "user_input" | "command",
184 - options: { readonly blocking?: boolean; readonly settled?: boolean } = {},
184 + options: { readonly blocking?: boolean } = {},
185 ) =>
186 registry.set(snapshotAtom(environmentId), {
187 ...v2ShellSnapshot,
@@ -189,7 +189,6 @@ describe("v2 thread shell lists", () => {
189 root,
190 {
191 ...sideChat,
192 - ...(options.settled ? { status: "completed" as const, activityRunStatus: null } : {}),
192 pendingRuntimeRequest: {
193 ...request,
194 kind,
@@ -206,11 +205,7 @@ describe("v2 thread shell lists", () => {
205 root.id,
206 ]);
207
209 - // An async question waits while the side chat works, like its own row's indicator.
208 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 });
209 expect(registry.get(parent)?.pendingSubagentRequest).toBe("user_input");
210
211 withRequest("command");
packages/client-runtime/src/state/threadShell.ts
+3 -7
@@ -15,7 +15,7 @@ import * as Schema from "effect/Schema";
15 import { Atom } from "effect/reactivity";
16
17 import type { EnvironmentThreadShell, PendingSubagentRequest } from "./models.ts";
18 -import { presentThreadShell, shellHasPendingUserInput, threadRuntimeIsActive } from "./models.ts";
18 +import { presentThreadShell, threadRuntimeIsActive } from "./models.ts";
19 import { type EnvironmentCatalogState, enabledEnvironmentIds } from "./connections.ts";
20 import {
21 arrayElementsEqual,
@@ -84,17 +84,13 @@ function subagentRequest(thread: OrchestrationV2ThreadShell): PendingSubagentReq
84 return kind === "user_input" ? "user_input" : "approval";
85 }
86
87 -/**
88 - * A side chat asks its user directly, so questions roll up to the parent as well as approvals,
89 - * when its own row would show them.
90 - */
87 +/** A side chat asks its user directly, so questions roll up to the parent as well as approvals. */
88 function sideChatRequest(thread: OrchestrationV2ThreadShell): PendingSubagentRequest | null {
89 const kind = thread.pendingRuntimeRequest?.kind;
90 if (kind === undefined || kind === "auth_refresh" || thread.lineage.sideChat !== true) {
91 return null;
92 }
96 - if (kind !== "user_input") return "approval";
97 - return shellHasPendingUserInput(thread) ? "user_input" : null;
93 + return kind === "user_input" ? "user_input" : "approval";
94 }
95
96 /**
packages/shared/src/agentAwareness.test.ts
+3 -6
@@ -183,7 +183,7 @@ describe("projectThreadAwarenessV2", () => {
183 ).toMatchObject({ phase });
184 });
185
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", () => {
187 const input = {
188 environmentId: "env-1" as EnvironmentId,
189 project,
@@ -197,12 +197,9 @@ describe("projectThreadAwarenessV2", () => {
197 }),
198 };
199 expect(projectThreadAwarenessV2(input)).toMatchObject({
200 - phase: "running",
201 - headline: "Agent is working",
200 + phase: "waiting_for_input",
201 + headline: "Waiting for input",
202 });
203 - expect(
204 - projectThreadAwarenessV2({ ...input, thread: { ...input.thread, status: "completed" } }),
205 - ).toMatchObject({ phase: "waiting_for_input", headline: "Waiting for input" });
203 });
204
205 it("does not present authentication refreshes as user approvals", () => {
packages/shared/src/agentAwareness.ts
+2 -10
@@ -98,22 +98,14 @@ export function projectThreadAwarenessV2(
98 function resolveThreadAwarenessPhaseV2(
99 thread: ProjectThreadAwarenessV2Input["thread"],
100 ): 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";
102 if (
103 thread.pendingRuntimeRequest !== null &&
111 - thread.pendingRuntimeRequest.kind !== "user_input" &&
104 thread.pendingRuntimeRequest.kind !== "auth_refresh"
105 ) {
106 return "waiting_for_approval";
107 }
116 - switch (runStatus) {
108 + switch (thread.activityRunStatus ?? thread.status) {
109 case "preparing":
110 case "starting":
111 return "starting";