@devries-cameron20 / t3code-1 / commits / c7618f6c10
Fork 0

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

fix(server): a steer that cuts off a streaming Claude reply marks it interrupted (#34597)

Julius Marminge committed Nov 11, 2026 at 15:24 UTC c7618f6c10120bc7e684df6a0d7275679d8c260e
3 files changed +89 -14
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
+22
@@ -6861,6 +6861,15 @@ describe("ClaudeAdapterV2 background wake turns", () => {
6861 });
6862 assert.equal(harness.offeredMessages[1]?.priority, "now");
6863 }
6864 + const partialText = "The audit covers the `integ";
6865 + if (!queryExits)
6866 + yield* Queue.offer(
6867 + harness.sdkMessages,
6868 + makeAssistantTextFrame({
6869 + uuid: "00000000-0000-4000-8000-000000000900",
6870 + text: partialText,
6871 + }),
6872 + );
6873 yield* harness.offerAndWait(
6874 makeResultFrame({
6875 uuid: "00000000-0000-4000-8000-000000000901",
@@ -6897,6 +6906,19 @@ describe("ClaudeAdapterV2 background wake turns", () => {
6906 terminal.status,
6907 queryExits ? "failed" : steered ? "completed" : "interrupted",
6908 );
6909 + if (steered && !queryExits && terminalReason === "aborted_streaming") {
6910 + // The steer cut this reply off mid-stream; it must not read as a finished answer.
6911 + const partial = harness.events.findLast(
6912 + (event) =>
6913 + event.type === "turn_item.updated" &&
6914 + event.turnItem.type === "assistant_message" &&
6915 + event.turnItem.text === partialText,
6916 + );
6917 + assert.equal(
6918 + partial?.type === "turn_item.updated" ? partial.turnItem.status : undefined,
6919 + "interrupted",
6920 + );
6921 + }
6922 if (steered) {
6923 if (!queryExits)
6924 assert.isTrue(
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts
+53 -11
@@ -4271,6 +4271,7 @@ function buildAssistantArtifacts(input: {
4271 readonly nativeItemId: string;
4272 readonly text: string;
4273 readonly ordinal: number;
4274 + readonly status?: "completed" | "interrupted";
4275 readonly startedAt: DateTime.Utc;
4276 readonly completedAt: DateTime.Utc;
4277 }): {
@@ -4304,7 +4305,7 @@ function buildAssistantArtifacts(input: {
4305 parentNodeId: input.turnInput.rootNodeId,
4306 rootNodeId: input.turnInput.rootNodeId,
4307 kind: "assistant_message",
4307 - status: "completed",
4308 + status: input.status ?? "completed",
4309 countsForRun: false,
4310 providerThreadId: input.turnInput.providerThread.id,
4311 providerTurnId: input.providerTurnId,
@@ -4338,7 +4339,7 @@ function buildAssistantArtifacts(input: {
4339 nativeItemRef,
4340 parentItemId: null,
4341 ordinal: input.ordinal,
4341 - status: "completed",
4342 + status: input.status ?? "completed",
4343 title: null,
4344 startedAt: input.startedAt,
4345 completedAt: input.completedAt,
@@ -4408,6 +4409,12 @@ interface ActiveClaudeTurnContext {
4409 fallbackText: string;
4410 fallbackNativeItemId: string;
4411 emittedNativeItemIds: Set<string>;
4412 + // The root reply the latest assistant frame carried; a steer's aborted_streaming cuts it off.
4413 + lastReply: {
4414 + readonly nativeItemId: string;
4415 + readonly text: string;
4416 + readonly startedAt: DateTime.Utc;
4417 + } | null;
4418 // The CLI repeats a notice that ends a prompt as the turn's result text.
4419 noticeTexts: Set<string>;
4420 };
@@ -8518,16 +8525,14 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
8525 });
8526 });
8527
8521 - const emitAssistantTextArtifacts = Effect.fnUntraced(function* (input: {
8528 + const publishAssistantArtifacts = Effect.fnUntraced(function* (input: {
8529 readonly context: ActiveClaudeTurnContext;
8530 readonly nativeItemId: string;
8531 readonly text: string;
8532 + readonly status: "completed" | "interrupted";
8533 + readonly startedAt: DateTime.Utc;
8534 + readonly completedAt: DateTime.Utc;
8535 }) {
8526 - if (input.context.assistant.emittedNativeItemIds.has(input.nativeItemId)) {
8527 - return;
8528 - }
8529 - input.context.assistant.emittedNativeItemIds.add(input.nativeItemId);
8530 - const now = yield* DateTime.now;
8536 const ordinal = yield* resolveItemOrdinal(input.context, input.nativeItemId);
8537 const artifacts = buildAssistantArtifacts({
8538 idAllocator,
@@ -8536,8 +8541,9 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
8541 nativeItemId: input.nativeItemId,
8542 text: input.text,
8543 ordinal,
8539 - startedAt: now,
8540 - completedAt: now,
8544 + status: input.status,
8545 + startedAt: input.startedAt,
8546 + completedAt: input.completedAt,
8547 });
8548 yield* Effect.all(
8549 [
@@ -8561,6 +8567,25 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
8567 );
8568 });
8569
8570 + const emitAssistantTextArtifacts = Effect.fnUntraced(function* (input: {
8571 + readonly context: ActiveClaudeTurnContext;
8572 + readonly nativeItemId: string;
8573 + readonly text: string;
8574 + }) {
8575 + if (input.context.assistant.emittedNativeItemIds.has(input.nativeItemId)) {
8576 + return undefined;
8577 + }
8578 + input.context.assistant.emittedNativeItemIds.add(input.nativeItemId);
8579 + const now = yield* DateTime.now;
8580 + yield* publishAssistantArtifacts({
8581 + ...input,
8582 + status: "completed",
8583 + startedAt: now,
8584 + completedAt: now,
8585 + });
8586 + return now;
8587 + });
8588 +
8589 const endSubagentsOfClosedQuery = Effect.fnUntraced(function* (input: {
8590 readonly closedQuery: ClaudeLiveQueryContext;
8591 readonly context: ActiveClaudeTurnContext;
@@ -10189,6 +10214,9 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
10214 }
10215 }
10216 const assistantText = assistantTextFromSdkMessage(message);
10217 + if (message.type === "assistant" && assistantParentToolUseId === null) {
10218 + context.assistant.lastReply = null;
10219 + }
10220 if (
10221 assistantText !== null &&
10222 assistantText.text.length > 0 &&
@@ -10237,11 +10265,14 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
10265 return;
10266 }
10267 if (assistantText !== null && assistantText.text.length > 0) {
10240 - yield* emitAssistantTextArtifacts({
10268 + const startedAt = yield* emitAssistantTextArtifacts({
10269 context,
10270 nativeItemId: assistantText.nativeItemId,
10271 text: assistantText.text,
10272 });
10273 + if (startedAt !== undefined) {
10274 + context.assistant.lastReply = { ...assistantText, startedAt };
10275 + }
10276 return;
10277 }
10278
@@ -10314,6 +10345,16 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
10345 const interrupted = (yield* Ref.get(interruptedTurns)).has(context.providerTurnId);
10346 const wasSteered = (yield* Ref.get(steeredTurns)).has(context.providerTurnId);
10347 if (!interrupted && wasSteered && isClaudeActiveSteeringAbortResult(message)) {
10348 + const cutOffReply = context.assistant.lastReply;
10349 + context.assistant.lastReply = null;
10350 + if (message.terminal_reason === "aborted_streaming" && cutOffReply !== null) {
10351 + yield* publishAssistantArtifacts({
10352 + context,
10353 + ...cutOffReply,
10354 + status: "interrupted",
10355 + completedAt,
10356 + });
10357 + }
10358 context.steeredSegmentUsage.push(message.usage);
10359 context.steeredLedgerUsage = addClaudeLedgerUsage(
10360 context.steeredLedgerUsage,
@@ -11578,6 +11619,7 @@ export const makeClaudeAdapterV2 = Effect.fn("makeClaudeAdapterV2")(function* (
11619 fallbackText: "",
11620 fallbackNativeItemId: `assistant:${turnInput.runId}`,
11621 emittedNativeItemIds: new Set(),
11622 + lastReply: null,
11623 noticeTexts: new Set(),
11624 },
11625 reasoning: {
apps/web/src/components/chat/TimelineAssistantRows.tsx
+14 -3
@@ -70,6 +70,11 @@ export function AssistantTimelineRow({ row }: { row: Extract<TimelineRow, { kind
70 onOpenTurnDiff={ctx.onOpenTurnDiff}
71 />
72 ) : null}
73 + {!row.showAssistantMeta && row.projectedItem?.item.status === "interrupted" ? (
74 + <div className="mt-1.5 flex">
75 + <AssistantStatusBadge status="interrupted" />
76 + </div>
77 + ) : null}
78 {row.showAssistantMeta ? (
79 <AssistantMessageMeta
80 className="mt-1.5"
@@ -178,9 +183,7 @@ function AssistantMessageMeta({
183 )}
184 >
185 {projectedItem && projectedItem.item.status !== "completed" ? (
181 - <span className="rounded-full border border-border/70 px-1.5 py-0.5 font-mono text-3xs text-muted-foreground">
182 - {projectedItem.item.status}
183 - </span>
186 + <AssistantStatusBadge status={projectedItem.item.status} />
187 ) : null}
188 <AssistantCopyButton
189 message={message}
@@ -204,6 +207,14 @@ function AssistantMessageMeta({
207 );
208 }
209
210 +function AssistantStatusBadge({ status }: { status: string }) {
211 + return (
212 + <span className="rounded-full border border-border/70 px-1.5 py-0.5 font-mono text-3xs text-muted-foreground">
213 + {status}
214 + </span>
215 + );
216 +}
217 +
218 function AssistantCopyButton({
219 message,
220 showCopyButton,