Skip to content

Commit 6a835f7

Browse files
t3dotggclaude
andcommitted
fix(web,mobile): keep the interrupted row when a compaction never started
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 22247f1 commit 6a835f7

4 files changed

Lines changed: 73 additions & 30 deletions

File tree

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,38 @@ it("shows a skipped compaction as one stopped row, without a separate interrupte
155155
).toEqual(["compaction"]);
156156
});
157157

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+
158190
it.each(["/compact", "Continue"])(
159191
"keeps a completed compaction divider visible while other settled work folds for %s",
160192
(promptText) => {

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

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,16 +2175,18 @@ export function buildThreadFeed(
21752175

21762176
const entries: RawThreadFeedEntry[] = [];
21772177
const entryRows: number[] = [];
2178-
// A stopped compaction's own row already says it stopped.
2179-
const compactionRunIds = new Set(
2180-
visibleTurnItems.flatMap(({ item }) =>
2181-
item.type === "user_message" &&
2182-
item.runId !== null &&
2183-
isCompactionCommandMessage({ role: "user", ...item })
2184-
? [item.runId]
2185-
: [],
2186-
),
2187-
);
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+
}
21882190
for (let index = restart?.row ?? 0; index < visibleTurnItems.length; index += 1) {
21892191
const row = visibleTurnItems[index]!;
21902192
const item = row.item;
@@ -2195,7 +2197,8 @@ export function buildThreadFeed(
21952197
item.type === "run_interrupt_request" ||
21962198
(item.type === "run_interrupt_result" &&
21972199
item.runId !== null &&
2198-
compactionRunIds.has(item.runId))
2200+
compactPromptRunIds.has(item.runId) &&
2201+
compactedRunIds.has(item.runId))
21992202
) {
22002203
continue;
22012204
}

‎apps/web/src/components/chat/MessagesTimeline.logic.test.ts‎

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -828,25 +828,32 @@ describe("deriveMessagesTimelineRows", () => {
828828
message: "Skipped compaction to send a queued message",
829829
},
830830
};
831-
const rows = deriveMessagesTimelineRows({
832-
timelineEntries: deriveTimelineEntriesFromVisibleTurnItems({
833-
visibleTurnItems: [history0!, history1!, history2!, prompt, compaction, interruptResult],
834-
optimisticMessages: [],
835-
}),
836-
isWorking: false,
837-
latestRun: {
838-
runId: fixture.runId,
839-
status: "interrupted",
840-
startedAt: fixture.time(5),
841-
completedAt: fixture.time(9),
842-
},
843-
turnDiffSummaries: [],
844-
supportsConversationRollback: false,
845-
});
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+
};
846849

847-
expect(
848-
rows.slice(rows.findIndex((row) => row.id.includes("history-assistant")) + 1),
849-
).toMatchObject([{ kind: "context-compaction", label: "Context compaction stopped" }]);
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+
);
850857
});
851858

852859
it("only enables assistant copy for the terminal assistant message in a turn", () => {

‎apps/web/src/components/chat/MessagesTimeline.logic.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1670,7 +1670,8 @@ export function deriveMessagesTimelineRows(input: {
16701670
(timelineEntry.projectedItem.item.type === "run_interrupt_request" ||
16711671
(timelineEntry.projectedItem.item.type === "run_interrupt_result" &&
16721672
timelineEntry.projectedItem.item.runId !== null &&
1673-
compactionRuns.has(timelineEntry.projectedItem.item.runId)))
1673+
compactionRuns.has(timelineEntry.projectedItem.item.runId) &&
1674+
compactedRunIds.has(timelineEntry.projectedItem.item.runId)))
16741675
) {
16751676
continue;
16761677
}

0 commit comments

Comments
 (0)