Skip to content

Commit 22247f1

Browse files
t3dotggclaude
andcommitted
fix(web,mobile): a skipped compaction shows one row, not two
The compaction row already says "Context compaction stopped", so the generic "Run interrupted" row for that run only repeated it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 3a9b95e commit 22247f1

4 files changed

Lines changed: 109 additions & 2 deletions

File tree

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

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,45 @@ it("shows a compact command as one mobile divider before, during, and after comp
116116
}
117117
});
118118

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

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2175,13 +2175,28 @@ 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+
);
21782188
for (let index = restart?.row ?? 0; index < visibleTurnItems.length; index += 1) {
21792189
const row = visibleTurnItems[index]!;
21802190
const item = row.item;
21812191
if (turnItemIsWorkspacePreparation(item)) continue;
21822192
if (item.type === "todo_list" || item.type === "checkpoint") continue;
21832193
if (item.type === "user_message" && foldedAnswerMessageIds.has(item.messageId)) continue;
2184-
if (item.type === "run_interrupt_request") {
2194+
if (
2195+
item.type === "run_interrupt_request" ||
2196+
(item.type === "run_interrupt_result" &&
2197+
item.runId !== null &&
2198+
compactionRunIds.has(item.runId))
2199+
) {
21852200
continue;
21862201
}
21872202
const attemptId = resolveAttemptId(item);

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,55 @@ describe("deriveMessagesTimelineRows", () => {
800800
);
801801
});
802802

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 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+
});
846+
847+
expect(
848+
rows.slice(rows.findIndex((row) => row.id.includes("history-assistant")) + 1),
849+
).toMatchObject([{ kind: "context-compaction", label: "Context compaction stopped" }]);
850+
});
851+
803852
it("only enables assistant copy for the terminal assistant message in a turn", () => {
804853
const rows = deriveMessagesTimelineRows({
805854
timelineEntries: [

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1664,9 +1664,13 @@ export function deriveMessagesTimelineRows(input: {
16641664
appendActiveWorkRows();
16651665
}
16661666

1667+
// A stopped compaction's own divider already says it stopped.
16671668
if (
16681669
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)))
16701674
) {
16711675
continue;
16721676
}

0 commit comments

Comments
 (0)