The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 14:30 UTC
fix(web): Steer no longer does nothing while a compaction runs (#25837)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Theo Browne committed
Oct 27, 2026 at 02:51 UTC
ad068d7c93744f11a0ca1e816897b8e3128292ef
9 files changed
+411
-102
apps/mobile/src/lib/threadActivity.test.ts
+71
@@ -116,6 +116,77 @@ it("shows a compact command as one mobile divider before, during, and after comp
116
}
117
});
118
119
+it("shows a skipped compaction as one stopped row, without a separate interrupted row", () => {
120
+ const prompt = projected({ ...userMessage(), text: "/compact", idleCompaction: "onReturn" }, 0);
121
+ const compaction = projected(
122
+ {
123
+ ...base("compaction", "2026-06-20T00:00:02.000Z", 1),
124
+ type: "compaction",
125
+ driver: ProviderDriverKind.make("claude"),
126
+ status: "interrupted",
127
+ },
128
+ 1,
129
+ );
130
+ const interrupted = projected(
131
+ {
132
+ ...base("interrupt-result", "2026-06-20T00:00:03.000Z", 2),
133
+ type: "run_interrupt_result",
134
+ status: "interrupted",
135
+ message: "Skipped compaction to send a queued message",
136
+ },
137
+ 2,
138
+ );
139
+ const rows = deriveThreadFeedPresentation(
140
+ buildThreadFeed([prompt, compaction, interrupted]),
141
+ {
142
+ runId,
143
+ status: "interrupted",
144
+ startedAt: "2026-06-20T00:00:01.000Z",
145
+ completedAt: "2026-06-20T00:00:03.000Z",
146
+ },
147
+ new Set(),
148
+ );
149
+
150
+ expect(rows.map((entry) => entry.type)).toEqual(["activity-group"]);
151
+ expect(
152
+ rows[0]?.type === "activity-group"
153
+ ? rows[0].activities.map((a) => a.projectedItem.item.type)
154
+ : null,
155
+ ).toEqual(["compaction"]);
156
+});
157
+
158
+it("keeps the interrupted row for a compaction stopped before its provider started", () => {
159
+ const rows = deriveThreadFeedPresentation(
160
+ buildThreadFeed([
161
+ projected({ ...userMessage(), text: "/compact" }, 0),
162
+ projected(
163
+ {
164
+ ...base("interrupt-result", "2026-06-20T00:00:03.000Z", 1),
165
+ type: "run_interrupt_result",
166
+ status: "interrupted",
167
+ message: "Run interrupted before provider start",
168
+ },
169
+ 1,
170
+ ),
171
+ ]),
172
+ {
173
+ runId,
174
+ status: "interrupted",
175
+ startedAt: "2026-06-20T00:00:01.000Z",
176
+ completedAt: "2026-06-20T00:00:03.000Z",
177
+ },
178
+ new Set(),
179
+ );
180
+
181
+ expect(
182
+ rows.flatMap((entry) =>
183
+ entry.type === "activity-group"
184
+ ? entry.activities.map((activity) => activity.projectedItem.item.type)
185
+ : [],
186
+ ),
187
+ ).toContain("run_interrupt_result");
188
+});
189
+
190
it.each(["/compact", "Continue"])(
191
"keeps a completed compaction divider visible while other settled work folds for %s",
192
(promptText) => {
apps/mobile/src/lib/threadActivity.ts
+19
-1
@@ -2175,13 +2175,31 @@ export function buildThreadFeed(
2175
2176
const entries: RawThreadFeedEntry[] = [];
2177
const entryRows: number[] = [];
2178
+ // A stopped compaction's own row already says it stopped. A `/compact` run stopped
2179
+ // before its provider started has no such row, so it keeps the interrupted one.
2180
+ const compactPromptRunIds = new Set<RunId>();
2181
+ const compactedRunIds = new Set<RunId>();
2182
+ for (const { item } of visibleTurnItems) {
2183
+ if (item.runId === null) continue;
2184
+ if (item.type === "user_message" && isCompactionCommandMessage({ role: "user", ...item })) {
2185
+ compactPromptRunIds.add(item.runId);
2186
+ } else if (item.type === "compaction") {
2187
+ compactedRunIds.add(item.runId);
2188
+ }
2189
+ }
2190
for (let index = restart?.row ?? 0; index < visibleTurnItems.length; index += 1) {
2191
const row = visibleTurnItems[index]!;
2192
const item = row.item;
2193
if (turnItemIsWorkspacePreparation(item)) continue;
2194
if (item.type === "todo_list" || item.type === "checkpoint") continue;
2195
if (item.type === "user_message" && foldedAnswerMessageIds.has(item.messageId)) continue;
2184
- if (item.type === "run_interrupt_request") {
2196
+ if (
2197
+ item.type === "run_interrupt_request" ||
2198
+ (item.type === "run_interrupt_result" &&
2199
+ item.runId !== null &&
2200
+ compactPromptRunIds.has(item.runId) &&
2201
+ compactedRunIds.has(item.runId))
2202
+ ) {
2203
continue;
2204
}
2205
const attemptId = resolveAttemptId(item);
apps/server/src/orchestration-v2/Orchestrator.ts
+106
-69
@@ -23,6 +23,7 @@ import {
23
type ChatAttachment,
24
CommandId,
25
type GuestMessageId,
26
+ isCompactionCommandMessage,
27
isOrchestrationV2WorkActive,
28
isProviderNativeSubagentThread,
29
MessageId,
@@ -5774,13 +5775,14 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
5775
});
5776
}
5777
if (goalStopRunId !== undefined) {
5777
- return yield* stopRunForGoalCommand({
5778
+ return yield* stopRunForQueuedCommand({
5779
command,
5780
events,
5781
effects,
5782
projection: yield* getProjectionWithPendingEvents(command.threadId, events),
5783
queuedRunId: runId,
5784
targetRunId: goalStopRunId,
5785
+ reason: "Stopped to apply /goal",
5786
now,
5787
});
5788
}
@@ -8355,15 +8357,46 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
8357
(yield* goalDriverFor(command, queuedRun.providerInstanceId)) === undefined
8358
? null
8359
: parsedGoalCommand;
8360
+ const target = projection.runs.find((run) => run.id === command.targetRunId);
8361
+ const targetMessage = projection.messages.find(
8362
+ (message) => message.id === target?.userMessageId,
8363
+ );
8364
+ // A compacting turn cannot take steering input, so steering skips the compaction instead.
8365
+ if (
8366
+ target !== undefined &&
8367
+ targetMessage !== undefined &&
8368
+ isCompactionCommandMessage(targetMessage)
8369
+ ) {
8370
+ if (goalCommand !== null) {
8371
+ yield* ensureGoalCommandSupported(command, queuedMessage, queuedRun.providerInstanceId);
8372
+ }
8373
+ yield* emitEvent({
8374
+ type: "run.updated",
8375
+ threadId: command.threadId,
8376
+ runId: queuedRun.id,
8377
+ nodeId: queuedRootNode.id,
8378
+ providerInstanceId: queuedRun.providerInstanceId,
8379
+ occurredAt: now,
8380
+ payload: { ...queuedRun, queuePosition: 1 },
8381
+ });
8382
+ const stops =
8383
+ isLiveRun(target) && !(yield* stopReachedRun(command, command.threadId, target.id));
8384
+ return yield* stopRunForQueuedCommand({
8385
+ command,
8386
+ events,
8387
+ effects,
8388
+ projection,
8389
+ queuedRunId: queuedRun.id,
8390
+ targetRunId: stops ? target.id : undefined,
8391
+ reason: "Skipped compaction to send a queued message",
8392
+ now,
8393
+ });
8394
+ }
8395
if (goalCommand !== null) {
8396
yield* ensureGoalCommandSupported(command, queuedMessage, queuedRun.providerInstanceId);
8360
- const target = projection.runs.find((run) => run.id === command.targetRunId);
8397
const goal = projection.providerThreads.find(
8398
(candidate) => candidate.id === target?.providerThreadId,
8399
)?.goal;
8364
- const targetMessage = projection.messages.find(
8365
- (message) => message.id === target?.userMessageId,
8366
- );
8400
yield* emitEvent({
8401
type: "run.updated",
8402
threadId: command.threadId,
@@ -8379,13 +8412,14 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
8412
goalCommandStopsActiveRun(goalCommand, goal?.status ?? null) &&
8413
(targetMessage === undefined || !isNativeMaintenanceCommand(targetMessage)) &&
8414
!(yield* stopReachedRun(command, command.threadId, target.id));
8382
- return yield* stopRunForGoalCommand({
8415
+ return yield* stopRunForQueuedCommand({
8416
command,
8417
events,
8418
effects,
8419
projection,
8420
queuedRunId: queuedRun.id,
8421
targetRunId: stops ? target.id : undefined,
8422
+ reason: "Stopped to apply /goal",
8423
now,
8424
});
8425
}
@@ -10496,71 +10530,74 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
10530
);
10531
10532
/** Puts a queued goal command first and, given a target, stops the run in its way. */
10499
- const stopRunForGoalCommand = Effect.fn("Orchestrator.stopRunForGoalCommand")(function* (input: {
10500
- readonly command: Extract<
10501
- OrchestrationV2Command,
10502
- { readonly type: "message.dispatch" | "queued-message.promote-to-steer" }
10503
- >;
10504
- readonly events: Ref.Ref<Array<OrchestrationV2DomainEvent>>;
10505
- readonly effects: Ref.Ref<Array<PendingOrchestrationEffectV2>>;
10506
- readonly projection: Pick<OrchestrationV2ThreadProjection, "runs" | "messages">;
10507
- readonly queuedRunId: RunId;
10508
- readonly targetRunId: RunId | undefined;
10509
- readonly now: DateTime.Utc;
10510
- }) {
10511
- const { command, events, effects, projection, now, targetRunId } = input;
10512
- const others = queuedRunsInDeliveryOrder(projection).filter(
10513
- (run) => run.id !== input.queuedRunId && !isAutomaticCompletionRun(projection, run),
10514
- );
10515
- for (const [index, run] of others.entries()) {
10516
- const queuePosition = index + 2;
10517
- if (run.queuePosition === queuePosition) continue;
10518
- yield* emit(
10519
- events,
10520
- command,
10521
- )({
10522
- type: "run.updated",
10523
- threadId: command.threadId,
10524
- runId: run.id,
10525
- ...(run.rootNodeId === null ? {} : { nodeId: run.rootNodeId }),
10526
- providerInstanceId: run.providerInstanceId,
10527
- occurredAt: now,
10528
- payload: { ...run, queuePosition },
10529
- });
10530
- }
10531
- if (targetRunId === undefined) return undefined;
10532
- const interruptEvents = yield* Ref.make<Array<OrchestrationV2DomainEvent>>([]);
10533
- const interruptEffects = yield* Ref.make<Array<PendingOrchestrationEffectV2>>([]);
10534
- const interrupted = yield* Effect.exit(
10535
- dispatchRunInterrupt(
10536
- {
10537
- type: "run.interrupt",
10538
- commandId: command.commandId,
10533
+ const stopRunForQueuedCommand = Effect.fn("Orchestrator.stopRunForQueuedCommand")(
10534
+ function* (input: {
10535
+ readonly command: Extract<
10536
+ OrchestrationV2Command,
10537
+ { readonly type: "message.dispatch" | "queued-message.promote-to-steer" }
10538
+ >;
10539
+ readonly events: Ref.Ref<Array<OrchestrationV2DomainEvent>>;
10540
+ readonly effects: Ref.Ref<Array<PendingOrchestrationEffectV2>>;
10541
+ readonly projection: Pick<OrchestrationV2ThreadProjection, "runs" | "messages">;
10542
+ readonly queuedRunId: RunId;
10543
+ readonly targetRunId: RunId | undefined;
10544
+ readonly reason: string;
10545
+ readonly now: DateTime.Utc;
10546
+ }) {
10547
+ const { command, events, effects, projection, now, targetRunId } = input;
10548
+ const others = queuedRunsInDeliveryOrder(projection).filter(
10549
+ (run) => run.id !== input.queuedRunId && !isAutomaticCompletionRun(projection, run),
10550
+ );
10551
+ for (const [index, run] of others.entries()) {
10552
+ const queuePosition = index + 2;
10553
+ if (run.queuePosition === queuePosition) continue;
10554
+ yield* emit(
10555
+ events,
10556
+ command,
10557
+ )({
10558
+ type: "run.updated",
10559
+ threadId: command.threadId,
10560
+ runId: run.id,
10561
+ ...(run.rootNodeId === null ? {} : { nodeId: run.rootNodeId }),
10562
+ providerInstanceId: run.providerInstanceId,
10563
+ occurredAt: now,
10564
+ payload: { ...run, queuePosition },
10565
+ });
10566
+ }
10567
+ if (targetRunId === undefined) return undefined;
10568
+ const interruptEvents = yield* Ref.make<Array<OrchestrationV2DomainEvent>>([]);
10569
+ const interruptEffects = yield* Ref.make<Array<PendingOrchestrationEffectV2>>([]);
10570
+ const interrupted = yield* Effect.exit(
10571
+ dispatchRunInterrupt(
10572
+ {
10573
+ type: "run.interrupt",
10574
+ commandId: command.commandId,
10575
+ threadId: command.threadId,
10576
+ runId: targetRunId,
10577
+ reason: input.reason,
10578
+ },
10579
+ interruptEvents,
10580
+ interruptEffects,
10581
+ ),
10582
+ );
10583
+ // A failed interrupt may have written part of its events, so they are kept apart.
10584
+ // The queued command then waits for the turn to end.
10585
+ if (Exit.isFailure(interrupted)) {
10586
+ yield* Effect.logWarning("queued command could not stop the running turn", {
10587
threadId: command.threadId,
10588
runId: targetRunId,
10541
- reason: "Stopped to apply /goal",
10542
- },
10543
- interruptEvents,
10544
- interruptEffects,
10545
- ),
10546
- );
10547
- // A failed interrupt may have written part of its events, so they are kept apart.
10548
- // The goal command then waits for the turn to end.
10549
- if (Exit.isFailure(interrupted)) {
10550
- yield* Effect.logWarning("goal command could not stop the running turn", {
10551
- threadId: command.threadId,
10552
- runId: targetRunId,
10553
- cause: interrupted.cause,
10554
- });
10555
- return undefined;
10556
- }
10557
- const written = yield* Ref.get(interruptEvents);
10558
- const enqueued = yield* Ref.get(interruptEffects);
10559
- yield* Ref.update(events, (existing) => [...existing, ...written]);
10560
- yield* Ref.update(effects, (existing) => [...existing, ...enqueued]);
10561
- // Like Stop: a run stopped before its provider started also abandons that start.
10562
- return interrupted.value;
10563
- });
10589
+ cause: interrupted.cause,
10590
+ });
10591
+ return undefined;
10592
+ }
10593
+ const written = yield* Ref.get(interruptEvents);
10594
+ const enqueued = yield* Ref.get(interruptEffects);
10595
+ yield* Ref.update(events, (existing) => [...existing, ...written]);
10596
+ yield* Ref.update(effects, (existing) => [...existing, ...enqueued]);
10597
+ // Like Stop: a run stopped before its provider started also abandons that start.
10598
+ return interrupted.value;
10599
+ },
10600
+ );
10601
10602
const dispatchThreadStop = Effect.fn("Orchestrator.dispatchThreadStop")(function* (
10603
command: Extract<OrchestrationV2ServerCommand, { readonly type: "thread.stop" }>,
apps/server/src/orchestration-v2/SteeringCompletion.integration.test.ts
+115
-23
@@ -429,6 +429,29 @@ const nextTurnSelectionHarness = Effect.fn("nextTurnSelectionHarness")(function*
429
openSession: (input) =>
430
Effect.gen(function* () {
431
const now = yield* DateTime.now;
432
+ const startTurn = (turn: ProviderAdapter.ProviderAdapterV2TurnInput) =>
433
+ Effect.gen(function* () {
434
+ started.push(turn);
435
+ yield* Queue.offer(events, {
436
+ type: "provider_turn.updated",
437
+ driver,
438
+ providerTurn: {
439
+ id: ProviderTurnId.make(`provider-turn:${turn.attemptId}`),
440
+ providerThreadId: turn.providerThread.id,
441
+ nodeId: turn.rootNodeId,
442
+ runAttemptId: turn.attemptId,
443
+ nativeTurnRef: {
444
+ driver,
445
+ nativeId: `native:${turn.attemptId}`,
446
+ strength: "strong",
447
+ },
448
+ ordinal: turn.providerTurnOrdinal,
449
+ status: "running",
450
+ startedAt: now,
451
+ completedAt: null,
452
+ },
453
+ });
454
+ });
455
return {
456
instanceId,
457
driver,
@@ -465,29 +488,8 @@ const nextTurnSelectionHarness = Effect.fn("nextTurnSelectionHarness")(function*
488
updatedAt: now,
489
}),
490
resumeThread: ({ providerThread }) => Effect.succeed(providerThread),
468
- startTurn: (turn) =>
469
- Effect.gen(function* () {
470
- started.push(turn);
471
- yield* Queue.offer(events, {
472
- type: "provider_turn.updated",
473
- driver,
474
- providerTurn: {
475
- id: ProviderTurnId.make(`provider-turn:${turn.attemptId}`),
476
- providerThreadId: turn.providerThread.id,
477
- nodeId: turn.rootNodeId,
478
- runAttemptId: turn.attemptId,
479
- nativeTurnRef: {
480
- driver,
481
- nativeId: `native:${turn.attemptId}`,
482
- strength: "strong",
483
- },
484
- ordinal: turn.providerTurnOrdinal,
485
- status: "running",
486
- startedAt: now,
487
- completedAt: null,
488
- },
489
- });
490
- }),
491
+ startTurn,
492
+ compactThread: startTurn,
493
steerTurn: (turn) =>
494
Effect.sync(() => {
495
steered.push(turn.message.text);
@@ -1167,6 +1169,96 @@ it.effect("promotes a queued goal by stopping the running turn", () =>
1169
),
1170
);
1171
1172
+it.effect.each(["next", "/goal ship it"])(
1173
+ "promoting %s into a compaction stops it and sends it next",
1174
+ (promoted) =>
1175
+ Effect.scoped(
1176
+ Effect.gen(function* () {
1177
+ const { events, layer, send, read, started, steered, startFirstTurn } = yield* goalHarness(
1178
+ `compaction-promote-${promoted.length}`,
1179
+ );
1180
+ yield* Effect.gen(function* () {
1181
+ const orchestrator = yield* Orchestrator.OrchestratorV2;
1182
+ const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
1183
+ const threadId = yield* startFirstTurn;
1184
+ yield* send("compact", "/compact", "queue");
1185
+ yield* send("queued", "queued", "queue");
1186
+ yield* send("next", promoted, "queue");
1187
+ const settled = yield* orchestrator.streamDomainEvents.pipe(
1188
+ Stream.filter(
1189
+ (event) =>
1190
+ event.type === "run.updated" &&
1191
+ event.payload.id === started[0]!.runId &&
1192
+ event.payload.status === "waiting",
1193
+ ),
1194
+ Stream.take(1),
1195
+ Stream.runDrain,
1196
+ Effect.forkScoped,
1197
+ );
1198
+ const compacting = yield* orchestrator.streamDomainEvents.pipe(
1199
+ Stream.filter(
1200
+ (event) =>
1201
+ event.type === "provider-turn.updated" &&
1202
+ event.payload.status === "running" &&
1203
+ event.payload.runAttemptId !== started[0]!.attemptId,
1204
+ ),
1205
+ Stream.take(1),
1206
+ Stream.runDrain,
1207
+ Effect.forkScoped,
1208
+ );
1209
+ const turn = (yield* orchestrator.getThreadProjection(threadId)).providerTurns[0]!;
1210
+ yield* Queue.offer(events, {
1211
+ type: "provider_turn.updated",
1212
+ driver,
1213
+ providerTurn: { ...turn, status: "completed", completedAt: yield* DateTime.now },
1214
+ });
1215
+ yield* Queue.offer(events, {
1216
+ type: "turn.terminal",
1217
+ driver,
1218
+ providerThreadId: turn.providerThreadId,
1219
+ providerTurnId: turn.id,
1220
+ runOrdinal: started[0]!.runOrdinal,
1221
+ status: "completed",
1222
+ failure: null,
1223
+ threadDisposition: "reusable",
1224
+ });
1225
+ yield* Fiber.join(settled);
1226
+ yield* worker.drain();
1227
+ yield* orchestrator.resumeQueuedRuns;
1228
+ yield* worker.drain();
1229
+ yield* Fiber.join(compacting);
1230
+ const compactRun = (yield* orchestrator.getThreadProjection(threadId)).runs.find(
1231
+ (run) => run.userMessageId === MessageId.make("message:compact"),
1232
+ )!;
1233
+ const nextRun = (yield* orchestrator.getThreadProjection(threadId)).runs.find(
1234
+ (run) => run.userMessageId === MessageId.make("message:next"),
1235
+ )!;
1236
+ yield* orchestrator.dispatch({
1237
+ type: "queued-message.promote-to-steer",
1238
+ commandId: CommandId.make("promote"),
1239
+ threadId,
1240
+ queuedRunId: nextRun.id,
1241
+ targetRunId: compactRun.id,
1242
+ });
1243
+ yield* worker.drain();
1244
+
1245
+ const projection = yield* orchestrator.getThreadProjection(threadId);
1246
+ assert.deepEqual(steered, []);
1247
+ assert.isTrue(
1248
+ projection.turnItems.some(
1249
+ (item) => item.type === "run_interrupt_request" && item.runId === compactRun.id,
1250
+ ),
1251
+ );
1252
+ assert.deepEqual((yield* read(threadId)).queue, ["queued"]);
1253
+ assert.deepEqual(
1254
+ started.map((turn) => turn.message.text),
1255
+ ["first", "/compact", promoted],
1256
+ );
1257
+ }).pipe(Effect.provide(layer));
1258
+ }),
1259
+ ),
1260
+);
1261
+
1262
it.effect("stops a turn that is still starting when a goal is sent into it", () =>
1263
Effect.scoped(
1264
Effect.gen(function* () {
apps/web/src/components/chat/MessagesTimeline.logic.test.ts
+56
@@ -800,6 +800,62 @@ describe("deriveMessagesTimelineRows", () => {
800
);
801
});
802
803
+ it("shows a skipped compaction as stopped, without a separate interrupted divider", () => {
804
+ const fixture = makeStreamingTimelineFixture();
805
+ const [history0, history1, history2, liveUser, , liveAssistant] = fixture.visibleTurnItems;
806
+ if (liveUser?.item.type !== "user_message" || liveAssistant?.item.type !== "assistant_message")
807
+ throw new Error("Expected live fixture items");
808
+ const prompt = {
809
+ ...liveUser,
810
+ item: { ...liveUser.item, text: "/compact", idleCompaction: "onReturn" as const },
811
+ };
812
+ const compaction = {
813
+ ...liveAssistant,
814
+ item: {
815
+ ...liveAssistant.item,
816
+ type: "compaction" as const,
817
+ status: "interrupted" as const,
818
+ driver: null,
819
+ },
820
+ };
821
+ const interruptResult = {
822
+ ...liveAssistant,
823
+ item: {
824
+ ...liveAssistant.item,
825
+ id: TurnItemId.make("interrupt-result"),
826
+ type: "run_interrupt_result" as const,
827
+ status: "interrupted" as const,
828
+ message: "Skipped compaction to send a queued message",
829
+ },
830
+ };
831
+ const liveRowsFor = (visibleTurnItems: OrchestrationV2ProjectedTurnItem[]) => {
832
+ const rows = deriveMessagesTimelineRows({
833
+ timelineEntries: deriveTimelineEntriesFromVisibleTurnItems({
834
+ visibleTurnItems: [history0!, history1!, history2!, ...visibleTurnItems],
835
+ optimisticMessages: [],
836
+ }),
837
+ isWorking: false,
838
+ latestRun: {
839
+ runId: fixture.runId,
840
+ status: "interrupted",
841
+ startedAt: fixture.time(5),
842
+ completedAt: fixture.time(9),
843
+ },
844
+ turnDiffSummaries: [],
845
+ supportsConversationRollback: false,
846
+ });
847
+ return rows.slice(rows.findIndex((row) => row.id.includes("history-assistant")) + 1);
848
+ };
849
+
850
+ expect(liveRowsFor([prompt, compaction, interruptResult])).toMatchObject([
851
+ { kind: "context-compaction", label: "Context compaction stopped" },
852
+ ]);
853
+ // Stopped before the provider started: no compaction row says so, so the interrupt stays.
854
+ expect(liveRowsFor([prompt, interruptResult]).map((row) => row.id)).toContain(
855
+ "interrupt-result",
856
+ );
857
+ });
858
+
859
it("only enables assistant copy for the terminal assistant message in a turn", () => {
860
const rows = deriveMessagesTimelineRows({
861
timelineEntries: [
apps/web/src/components/chat/MessagesTimeline.logic.ts
+6
-1
@@ -1664,9 +1664,14 @@ export function deriveMessagesTimelineRows(input: {
1664
appendActiveWorkRows();
1665
}
1666
1667
+ // A stopped compaction's own divider already says it stopped.
1668
if (
1669
timelineEntry.kind === "event" &&
1669
- timelineEntry.projectedItem.item.type === "run_interrupt_request"
1670
+ (timelineEntry.projectedItem.item.type === "run_interrupt_request" ||
1671
+ (timelineEntry.projectedItem.item.type === "run_interrupt_result" &&
1672
+ timelineEntry.projectedItem.item.runId !== null &&
1673
+ compactionRuns.has(timelineEntry.projectedItem.item.runId) &&
1674
+ compactedRunIds.has(timelineEntry.projectedItem.item.runId)))
1675
) {
1676
continue;
1677
}
apps/web/src/components/chat/QueuedRunsControl.tsx
+1
-1
@@ -297,7 +297,7 @@ export function QueuedRunsControl({
297
</Button>
298
</TooltipTrigger>
299
<TooltipPopup>
300
- {`${workflow?.canSendNow ? "Start a turn with this message" : "Send into the current turn"}${item.serverIndex === 0 && props.steerShortcutLabel ? ` (${props.steerShortcutLabel})` : ""}`}
300
+ {`${workflow?.canSendNow ? "Start a turn with this message" : workflow?.promoteSkipsCompaction ? "Skip compaction and send this message" : "Send into the current turn"}${item.serverIndex === 0 && props.steerShortcutLabel ? ` (${props.steerShortcutLabel})` : ""}`}
301
</TooltipPopup>
302
</Tooltip>
303
<Separator orientation="vertical" className="mx-2 h-4" />
packages/client-runtime/src/state/threadWorkflows.test.ts
+20
@@ -174,6 +174,26 @@ describe("thread workflows", () => {
174
},
175
);
176
177
+ it("offers to skip a running compaction even when the provider cannot steer", () => {
178
+ const state = deriveThreadQueueWorkflowState({
179
+ thread: { id: "thread", activeProviderThreadId: null },
180
+ runs: [
181
+ { id: "compact", status: "running", userMessageId: "message-compact", ordinal: 1 },
182
+ { id: "queued", status: "queued", userMessageId: "message-queued", ordinal: 2 },
183
+ ],
184
+ messages: [
185
+ { id: "message-compact", role: "user", text: "/compact", attachments: [] },
186
+ { id: "message-queued", role: "user", text: "Next", attachments: [] },
187
+ ],
188
+ providerThreads: [],
189
+ providerTurns: [],
190
+ providerSessions: [],
191
+ } as never);
192
+
193
+ expect(state.canPromoteToSteer).toBe(true);
194
+ expect(state.promoteSkipsCompaction).toBe(true);
195
+ });
196
+
197
it("keeps held messages visible and clears the hold when they leave the queue", () => {
198
for (const status of ["queued", "cancelled", "starting"] as const) {
199
const state = deriveThreadQueueWorkflowState({
packages/client-runtime/src/state/threadWorkflows.ts
+17
-7
@@ -1,7 +1,8 @@
1
-import type {
2
- ChatAttachment,
3
- OrchestrationV2ProjectedTurnItem,
4
- OrchestrationV2ProviderCapabilities,
1
+import {
2
+ type ChatAttachment,
3
+ isCompactionCommandMessage,
4
+ type OrchestrationV2ProjectedTurnItem,
5
+ type OrchestrationV2ProviderCapabilities,
6
} from "@t3tools/contracts";
7
import { copySorted } from "@t3tools/shared/Array";
8
@@ -33,6 +34,8 @@ export interface ThreadQueueWorkflowState {
34
readonly queuedRuns: ReadonlyArray<QueuedThreadRun>;
35
readonly isHeld: boolean;
36
readonly canPromoteToSteer: boolean;
37
+ /** The active run is a compaction, so promoting a queued message stops it instead of steering. */
38
+ readonly promoteSkipsCompaction: boolean;
39
readonly canSendNow: boolean;
40
}
41
@@ -127,6 +130,11 @@ export function deriveThreadQueueWorkflowState(projection: Projection): ThreadQu
130
const activeRun = resolveActiveThreadRun(projection);
131
const session = resolveThreadProviderSession(projection);
132
const capabilities = session?.capabilities.turns;
133
+ const activeMessage = projection.messages.find(
134
+ (message) => message.id === activeRun?.userMessageId,
135
+ );
136
+ const promoteSkipsCompaction =
137
+ activeMessage !== undefined && isCompactionCommandMessage(activeMessage);
138
const hasSteerableProviderTurn =
139
activeRun?.status === "running" &&
140
activeRun.activeAttemptId !== null &&
@@ -159,9 +167,11 @@ export function deriveThreadQueueWorkflowState(projection: Projection): ThreadQu
167
projection.thread.archivedAt == null &&
168
projection.thread.deletedAt == null,
169
canPromoteToSteer:
162
- hasSteerableProviderTurn &&
163
- (capabilities?.supportsActiveSteering === true ||
164
- capabilities?.supportsSteeringByInterruptRestart === true),
170
+ promoteSkipsCompaction ||
171
+ (hasSteerableProviderTurn &&
172
+ (capabilities?.supportsActiveSteering === true ||
173
+ capabilities?.supportsSteeringByInterruptRestart === true)),
174
+ promoteSkipsCompaction,
175
};
176
}
177