Skip to content

Commit ea6a3a1

Browse files
t3dotggclaude
andcommitted
refactor(client-runtime): drop dead async-question branches
Inline the one-line pending input check, simplify the side chat rollup, fix a stale snooze comment, and fold the duplicate Working test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c7d6073 commit ea6a3a1

4 files changed

Lines changed: 9 additions & 19 deletions

File tree

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

Lines changed: 3 additions & 5 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("moves a running thread with an async question out of Working", () => {
25+
it("an async question blocks snooze and wakes a snoozed thread", () => {
2626
const runId = RunId.make("run-async-question");
2727
const running = {
2828
...v2ThreadShell,
@@ -39,14 +39,12 @@ describe("V2 client presentation", () => {
3939
},
4040
};
4141
const active = presentThreadShell(environmentId, running);
42-
expect(active.hasPendingUserInput).toBe(true);
43-
expect(isThreadWorking(active)).toBe(false);
4442
expect(canSnooze(active, { now: "2026-06-20T00:05:00.000Z" })).toBe(false);
4543
expect(effectiveSnoozed(active, { now: "2026-06-20T00:05:00.000Z" })).toBe(false);
4644
});
4745

48-
it("keeps blocking and legacy questions out of Working", () => {
49-
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 }, {}]) {
5048
const shell = presentThreadShell(environmentId, {
5149
...v2ThreadShell,
5250
latestRunId: RunId.make("run-blocking-question"),

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

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

219-
/** Any open question, async ones included, puts the thread in Input. */
220-
export function shellHasPendingUserInput(thread: OrchestrationV2ThreadShell): boolean {
221-
return thread.pendingRuntimeRequest?.kind === "user_input";
222-
}
223-
224219
// Only work the agent waits on holds it: commands and monitors it left running
225220
// unmarked, such as a dev server, present the run's own status. The
226221
// server suppresses the roster while an interruptible activity run exists, so a
@@ -315,7 +310,8 @@ export function presentThreadShell(
315310
thread.pendingRuntimeRequest !== null &&
316311
thread.pendingRuntimeRequest.kind !== "user_input" &&
317312
thread.pendingRuntimeRequest.kind !== "auth_refresh",
318-
hasPendingUserInput: shellHasPendingUserInput(thread),
313+
// Async questions count too, so a thread with any open question leaves Working.
314+
hasPendingUserInput: thread.pendingRuntimeRequest?.kind === "user_input",
319315
pendingSubagentRequest,
320316
pendingGuestMessageCount: thread.pendingGuestMessageCount ?? 0,
321317
hasActionableProposedPlan: thread.hasActionableProposedPlan,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export function canSnooze(
125125
options: { readonly now: string },
126126
): boolean {
127127
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.
129129
if (shell.source?.pendingRuntimeRequest != null) return false;
130130
if (shell.pendingSubagentRequest != null) return false;
131131
// A waiting guest message would wake it at once.

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import * as Schema from "effect/Schema";
1515
import { Atom } from "effect/reactivity";
1616

1717
import type { EnvironmentThreadShell, PendingSubagentRequest } from "./models.ts";
18-
import { presentThreadShell, shellHasPendingUserInput, threadRuntimeIsActive } from "./models.ts";
18+
import { presentThreadShell, threadRuntimeIsActive } from "./models.ts";
1919
import { type EnvironmentCatalogState, enabledEnvironmentIds } from "./connections.ts";
2020
import {
2121
arrayElementsEqual,
@@ -84,17 +84,13 @@ function subagentRequest(thread: OrchestrationV2ThreadShell): PendingSubagentReq
8484
return kind === "user_input" ? "user_input" : "approval";
8585
}
8686

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. */
9188
function sideChatRequest(thread: OrchestrationV2ThreadShell): PendingSubagentRequest | null {
9289
const kind = thread.pendingRuntimeRequest?.kind;
9390
if (kind === undefined || kind === "auth_refresh" || thread.lineage.sideChat !== true) {
9491
return null;
9592
}
96-
if (kind !== "user_input") return "approval";
97-
return shellHasPendingUserInput(thread) ? "user_input" : null;
93+
return kind === "user_input" ? "user_input" : "approval";
9894
}
9995

10096
/**

0 commit comments

Comments
 (0)