Skip to content

Commit 3193373

Browse files
fix(clients): say "Starting Claude" until the provider actually starts
The server marks a run running before the adapter opens the provider, so a slow provider boot (Claude CLI start, setMcpServers waiting out its timeout) showed a live "Thinking" row with no provider turn and nothing generating. summarizeThreadRun now sets providerStartingLabel ("Starting <provider>") for a starting or running run whose attempt has no provider turn yet. Web and mobile show it in place of "Thinking" in the live row, and it clears as soon as the adapter reports the provider turn. Fixes #14244 AI-assisted; verified with the tests and tools listed above.
1 parent b68aedf commit 3193373

10 files changed

Lines changed: 105 additions & 10 deletions

File tree

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,7 @@ function renderFeedEntry(
17141714
rowSizing={props.workRowSizing}
17151715
iconSubtleColor={iconSubtleColor}
17161716
label={entry.label}
1717+
providerStartingLabel={entry.providerStartingLabel}
17171718
/>
17181719
);
17191720
}

‎apps/mobile/src/features/threads/thread-work-log.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,8 +1416,10 @@ export function ThreadThinkingRow(props: {
14161416
readonly rowSizing: ReturnType<typeof deriveThreadWorkLogSizing>;
14171417
readonly iconSubtleColor: ColorValue;
14181418
readonly label?: string;
1419+
/** Replaces "Thinking" while the provider has not started a turn. */
1420+
readonly providerStartingLabel?: string | undefined;
14191421
}) {
1420-
const label = props.label ?? "Thinking";
1422+
const label = props.providerStartingLabel ?? props.label ?? "Thinking";
14211423
return (
14221424
<View
14231425
accessible

‎apps/mobile/src/lib/threadActivity.ts‎

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,8 @@ type ThreadFeedEntryContent =
249249
readonly createdAt: string;
250250
readonly runId: RunId | null;
251251
readonly label?: string;
252+
/** Shown instead of "Thinking" while the provider has not started a turn. */
253+
readonly providerStartingLabel?: string;
252254
};
253255

254256
export interface ThreadFeedLatestRun {
@@ -257,6 +259,7 @@ export interface ThreadFeedLatestRun {
257259
readonly startedAt: string | null;
258260
readonly completedAt: string | null;
259261
readonly turnEnded?: boolean;
262+
readonly providerStartingLabel?: string;
260263
}
261264

262265
/** Long Android headers can ANR despite one-line display; cap labels only, preserving expanded and copied text. */
@@ -1340,7 +1343,8 @@ function latestRunsEqual(left: ThreadFeedLatestRun | null, right: ThreadFeedLate
13401343
left.status === right.status &&
13411344
left.startedAt === right.startedAt &&
13421345
left.completedAt === right.completedAt &&
1343-
left.turnEnded === right.turnEnded)
1346+
left.turnEnded === right.turnEnded &&
1347+
left.providerStartingLabel === right.providerStartingLabel)
13441348
);
13451349
}
13461350

@@ -1741,7 +1745,12 @@ export function deriveThreadFeedPresentation(
17411745
)
17421746
) {
17431747
result.push(
1744-
thinkingRow(activeWorkStartedAt, activeRunId, zen ? liveAnswerPreview(feed) : null),
1748+
thinkingRow(
1749+
activeWorkStartedAt,
1750+
activeRunId,
1751+
zen ? liveAnswerPreview(feed) : null,
1752+
latestRun?.providerStartingLabel,
1753+
),
17451754
);
17461755
}
17471756
const checkpointByRunId = new Map<RunId, ThreadCheckpointSummary>();
@@ -1846,18 +1855,25 @@ function isWorkLogFeedRow(row: ThreadFeedEntry | undefined): boolean {
18461855

18471856
const LIVE_ACTIVITY_ROW_ID = "live-activity-row";
18481857

1849-
function thinkingRow(createdAt: string, runId: RunId | null, label: string | null) {
1858+
function thinkingRow(
1859+
createdAt: string,
1860+
runId: RunId | null,
1861+
label: string | null,
1862+
providerStartingLabel: string | undefined,
1863+
) {
18501864
if (
18511865
cachedThinkingRow?.createdAt !== createdAt ||
18521866
cachedThinkingRow.runId !== runId ||
1853-
(cachedThinkingRow.label ?? null) !== label
1867+
(cachedThinkingRow.label ?? null) !== label ||
1868+
cachedThinkingRow.providerStartingLabel !== providerStartingLabel
18541869
) {
18551870
cachedThinkingRow = {
18561871
type: "thinking",
18571872
id: LIVE_ACTIVITY_ROW_ID,
18581873
createdAt,
18591874
runId,
18601875
...(label === null ? {} : { label }),
1876+
...(providerStartingLabel === undefined ? {} : { providerStartingLabel }),
18611877
};
18621878
}
18631879
return cachedThinkingRow;

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3432,6 +3432,7 @@ export default function ChatView(props: ChatViewProps) {
34323432
activePendingApproval?.requestId ?? activePendingUserInput?.requestId ?? null
34333433
}
34343434
activeTurnStartedAt={activeWorkStartedAt}
3435+
providerStartingLabel={activeActivityRun?.providerStartingLabel ?? null}
34353436
worktreeSetup={worktreeSetup}
34363437
onCancelWorktreeSetup={onCancelWorktreeSetupStable}
34373438
retryableWorkspacePreparationRunIds={retryableWorkspacePreparationRunIds}

‎apps/web/src/components/chat/MessagesTimeline.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,8 @@ interface MessagesTimelineProps {
232232
isWorking: boolean;
233233
runlessWorkActive?: boolean;
234234
activeTurnStartedAt?: string | null;
235+
/** Replaces "Thinking" while the active run's provider has not started a turn. */
236+
providerStartingLabel?: string | null;
235237
worktreeSetup?: WorktreeSetupSnapshot | null;
236238
onCancelWorktreeSetup?: () => void;
237239
retryableWorkspacePreparationRunIds?: ReadonlySet<RunId>;
@@ -349,6 +351,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
349351
isWorking,
350352
runlessWorkActive = false,
351353
activeTurnStartedAt = null,
354+
providerStartingLabel = null,
352355
worktreeSetup = null,
353356
footer = null,
354357
onCancelWorktreeSetup,
@@ -1158,6 +1161,7 @@ const ConversationTimeline = memo(function ConversationTimeline({
11581161
backgroundWorktreeSetup,
11591162
awaitingUser: awaitingUser !== null,
11601163
isPreparingWorktree,
1164+
providerStartingLabel,
11611165
latestRunId: latestRun?.runId ?? null,
11621166
liveAnswerPreview:
11631167
isWorking && toolCallVisibility === "zen" ? liveAnswerPreview(timelineEntries) : null,

‎apps/web/src/components/chat/TimelineWorkGroupRows.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,14 @@ function CompactingLabel({ createdAt }: { createdAt: string | null }) {
373373

374374
export function ThinkingTimelineRow({ row }: { row: Extract<TimelineRow, { kind: "thinking" }> }) {
375375
const ctx = use(TimelineRowCtx);
376-
const { isCompacting, isPreparingWorktree, liveAnswerPreview } = use(TimelineRowActivityCtx);
376+
const { isCompacting, isPreparingWorktree, liveAnswerPreview, providerStartingLabel } =
377+
use(TimelineRowActivityCtx);
377378
if (isPreparingWorktree || isCompacting) return <WorkLogRow label="" />;
378379
// A failed group keeps this disclosure while an approval waits, but nothing is thinking then.
379380
const live = ctx.pendingApprovals.size === 0;
380381
const activity = (
381382
<LiveActivityRow
382-
label={liveAnswerPreview ?? "Thinking"}
383+
label={providerStartingLabel ?? liveAnswerPreview ?? "Thinking"}
383384
iconName="brain"
384385
active={live}
385386
shimmer={live}

‎apps/web/src/components/chat/timelineRowContext.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ export interface TimelineRowActivityState {
112112
isRevertingCheckpoint: boolean;
113113
awaitingUser: boolean;
114114
isPreparingWorktree: boolean;
115+
providerStartingLabel: string | null;
115116
latestRunId: RunId | null;
116117
backgroundWorktreeSetup: WorktreeSetupSnapshot | null;
117118
liveAnswerPreview: string | null;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,12 @@ export interface ThreadRunSummary {
8989
* generating while the server settles it.
9090
*/
9191
readonly turnEnded?: boolean;
92+
/**
93+
* Set while the run is open but its provider has not started a turn, so the
94+
* provider is still launching and nothing is generating. Clients show it
95+
* instead of "Thinking".
96+
*/
97+
readonly providerStartingLabel?: string;
9298
readonly sourcePlanRef?: {
9399
readonly threadId: ThreadId;
94100
readonly planId: PlanId;

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,49 @@ describe("thread execution presentation", () => {
301301
});
302302
});
303303

304+
// The server marks a run running before the provider opens, which can take minutes.
305+
it("labels an open run whose provider has not started a turn", () => {
306+
const attemptId = RunAttemptId.make("attempt-starting");
307+
const openRun = { ...run("run-starting", 1, "running"), activeAttemptId: attemptId };
308+
const session = {
309+
id: ProviderSessionId.make("session-starting"),
310+
driver: ProviderDriverKind.make("claudeAgent"),
311+
providerInstanceId: openRun.providerInstanceId,
312+
status: "starting" as const,
313+
cwd: "/repo",
314+
model: null,
315+
// The label reads only the driver.
316+
capabilities: {} as never,
317+
createdAt: now,
318+
updatedAt: now,
319+
lastError: null,
320+
};
321+
const starting = { ...v2Projection, runs: [openRun], providerSessions: [session] };
322+
323+
expect(deriveThreadActivityRun(starting)?.providerStartingLabel).toBe("Starting Claude");
324+
expect(
325+
deriveThreadActivityRun({ ...starting, providerSessions: [] })?.providerStartingLabel,
326+
).toBe("Starting");
327+
expect(
328+
deriveThreadActivityRun({
329+
...starting,
330+
providerTurns: [
331+
{
332+
id: ProviderTurnId.make("provider-turn-starting"),
333+
providerThreadId: ProviderThreadId.make("provider-thread-starting"),
334+
nodeId: NodeId.make("node-starting"),
335+
runAttemptId: attemptId,
336+
nativeTurnRef: null,
337+
ordinal: 1,
338+
status: "running",
339+
startedAt: now,
340+
completedAt: null,
341+
},
342+
],
343+
})?.providerStartingLabel,
344+
).toBeUndefined();
345+
});
346+
304347
it("presents a held queue as the stopped run instead of queued work", () => {
305348
const interrupted = { ...run("run-interrupted", 1, "interrupted"), completedAt: now };
306349
const held = { ...run("run-held", 2, "queued"), queueHeld: true };

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
isOrchestrationV2WorkActive,
1010
isProviderNativeSubagentThread,
1111
latestProviderTurnForAttempt,
12+
PROVIDER_DISPLAY_NAMES,
1213
type ModelSelection,
1314
type OrchestrationV2NotificationSource,
1415
type OrchestrationV2PendingBackgroundTask,
@@ -50,6 +51,8 @@ import { formatSubagentDisplayTitle } from "./subagentDisplay.ts";
5051

5152
const ACTIVITY_RUN_STATUSES = new Set(["preparing", "starting", "running", "waiting"]);
5253
const INTERRUPTIBLE_RUN_STATUSES = new Set(["preparing", "starting", "running"]);
54+
// Preparing runs show their workspace setup instead.
55+
const PROVIDER_STARTING_RUN_STATUSES = new Set(["starting", "running"]);
5356

5457
const EMPTY_EXTENSION_STATUSES: NonNullable<OrchestrationV2ProviderSession["extensionStatuses"]> =
5558
[];
@@ -103,6 +106,17 @@ function latestMatchingRun(
103106
);
104107
}
105108

109+
function providerStartingLabel(
110+
projection: ThreadStructure,
111+
run: OrchestrationV2ThreadProjection["runs"][number],
112+
): string {
113+
const driver = projection.providerSessions.findLast(
114+
(session) => session.providerInstanceId === run.providerInstanceId,
115+
)?.driver;
116+
const name = driver === undefined ? undefined : PROVIDER_DISPLAY_NAMES[driver];
117+
return name === undefined ? "Starting" : `Starting ${name}`;
118+
}
119+
106120
function summarizeThreadRun(
107121
projection: ThreadStructure,
108122
run: OrchestrationV2ThreadProjection["runs"][number],
@@ -120,9 +134,15 @@ function summarizeThreadRun(
120134
projection.messages.findLast(
121135
(message) => message.runId === run.id && message.role === "assistant",
122136
)?.id ?? null,
123-
...(turnStatus === undefined || turnStatus === "pending" || turnStatus === "running"
124-
? {}
125-
: { turnEnded: true }),
137+
// A run counts as running before its provider opens; until a turn appears,
138+
// the provider can still be launching for minutes.
139+
...(turnStatus === undefined
140+
? PROVIDER_STARTING_RUN_STATUSES.has(run.status)
141+
? { providerStartingLabel: providerStartingLabel(projection, run) }
142+
: {}
143+
: turnStatus === "pending" || turnStatus === "running"
144+
? {}
145+
: { turnEnded: true }),
126146
...(run.sourcePlanRef === undefined ? {} : { sourcePlanRef: run.sourcePlanRef }),
127147
};
128148
}

0 commit comments

Comments
 (0)