Skip to content

Commit ebac9e8

Browse files
Ennio Cutericlaude
andcommitted
fix(web): keep relocated terminal answers, expanded runs, and Find matches visible
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 4763ac8 commit ebac9e8

4 files changed

Lines changed: 60 additions & 9 deletions

File tree

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

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,16 @@ import { applyTimelineDensity, type MessagesTimelineRow } from "./MessagesTimeli
44
type WorkEntry = Extract<MessagesTimelineRow, { kind: "work" }>["groupedEntries"][number];
55
const entry = (id: string, itemType: string) =>
66
({ id, itemType, createdAt: "2026-01-01T00:00:00Z" }) as unknown as WorkEntry;
7-
const work = (id: string, entries: WorkEntry[]): MessagesTimelineRow => ({
7+
const work = (
8+
id: string,
9+
entries: WorkEntry[],
10+
isExpandedToolGroup = false,
11+
): MessagesTimelineRow => ({
812
kind: "work",
913
id,
1014
createdAt: "2026-01-01T00:00:00Z",
1115
groupedEntries: entries,
12-
isExpandedToolGroup: true,
16+
isExpandedToolGroup,
1317
});
1418
const assistant = (id: string, showAssistantMeta: boolean) =>
1519
({
@@ -54,4 +58,28 @@ describe("applyTimelineDensity", () => {
5458
const result = applyTimelineDensity(live, { compactWorkLog: true, hideReasoning: true });
5559
expect(result.map((row) => row.id)).toEqual(["w2"]);
5660
});
61+
62+
it("keeps a terminal answer whose meta moved below trailing tools", () => {
63+
const settled = [
64+
assistant("m1", false),
65+
work("w1", [entry("c1", "command_execution")]),
66+
{
67+
kind: "assistant-meta",
68+
id: "assistant-meta:m1",
69+
createdAt: "2026-01-01T00:00:00Z",
70+
message: { id: "m1", role: "assistant", runId: "run-1" },
71+
} as unknown as MessagesTimelineRow,
72+
];
73+
const result = applyTimelineDensity(settled, { compactWorkLog: false, hideReasoning: true });
74+
expect(result.map((row) => row.id)).toEqual(["m1", "w1", "assistant-meta:m1"]);
75+
});
76+
77+
it("leaves a run the user expanded intact", () => {
78+
const expanded = [
79+
work("w1", [entry("c1", "command_execution"), entry("c2", "command_execution")], true),
80+
work("w2", [entry("c3", "command_execution")], true),
81+
];
82+
const result = applyTimelineDensity(expanded, { compactWorkLog: true, hideReasoning: false });
83+
expect(result).toEqual(expanded);
84+
});
5785
});

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

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,6 +2379,12 @@ const isWorkLogTimelineRow = (row: MessagesTimelineRow) =>
23792379
row.kind === "work-toggle" ||
23802380
row.kind === "thinking";
23812381

2382+
const workLogRowIsExpanded = (row: MessagesTimelineRow) =>
2383+
row.kind === "work"
2384+
? row.isExpandedToolGroup
2385+
: (row.kind === "work-live" || row.kind === "work-toggle" || row.kind === "thinking") &&
2386+
row.expanded === true;
2387+
23822388
/**
23832389
* Display-only pass over derived rows for the `hideReasoning` and
23842390
* `compactWorkLog` client settings. Runs after derivation so the incremental
@@ -2392,9 +2398,13 @@ export function applyTimelineDensity(
23922398
let result = rows;
23932399

23942400
if (options.hideReasoning) {
2395-
// Commentary = an assistant message without meta that is followed, within
2401+
// Commentary = a non-terminal assistant message that is followed, within
23962402
// the same turn, by more work or another assistant message. The trailing
23972403
// message (final answer, or the commentary still streaming) stays visible.
2404+
// Terminal answers whose meta moved below trailing tools are still terminal.
2405+
const relocatedMetaMessageIds = new Set(
2406+
result.flatMap((row) => (row.kind === "assistant-meta" ? [row.message.id] : [])),
2407+
);
23982408
const hiddenCommentaryIds = new Set<string>();
23992409
let laterActivityInTurn = false;
24002410
for (let index = result.length - 1; index >= 0; index -= 1) {
@@ -2404,7 +2414,8 @@ export function applyTimelineDensity(
24042414
continue;
24052415
}
24062416
if (row.kind === "message" && row.message.role === "assistant") {
2407-
if (!row.showAssistantMeta && laterActivityInTurn) hiddenCommentaryIds.add(row.id);
2417+
const isTerminal = row.showAssistantMeta || relocatedMetaMessageIds.has(row.message.id);
2418+
if (!isTerminal && laterActivityInTurn) hiddenCommentaryIds.add(row.id);
24082419
laterActivityInTurn = true;
24092420
} else if (isWorkLogTimelineRow(row)) {
24102421
laterActivityInTurn = true;
@@ -2434,8 +2445,20 @@ export function applyTimelineDensity(
24342445
if (options.compactWorkLog) {
24352446
// Each run of consecutive work-log rows collapses to its last row, and a
24362447
// work group to its last entry, so the line updates instead of growing.
2448+
// A run the user expanded stays intact so its disclosure still works.
2449+
const expandedRunRowIds = new Set<string>();
2450+
let run: MessagesTimelineRow[] = [];
2451+
for (const row of [...result, null]) {
2452+
if (row !== null && isWorkLogTimelineRow(row)) {
2453+
run.push(row);
2454+
continue;
2455+
}
2456+
if (run.some(workLogRowIsExpanded))
2457+
for (const runRow of run) expandedRunRowIds.add(runRow.id);
2458+
run = [];
2459+
}
24372460
result = result.flatMap((row, index): MessagesTimelineRow[] => {
2438-
if (!isWorkLogTimelineRow(row)) return [row];
2461+
if (!isWorkLogTimelineRow(row) || expandedRunRowIds.has(row.id)) return [row];
24392462
const next = result[index + 1];
24402463
if (next !== undefined && isWorkLogTimelineRow(next)) return [];
24412464
const compactRow: MessagesTimelineRow = { ...row, continuesWorkLog: false };
@@ -2448,7 +2471,6 @@ export function applyTimelineDensity(
24482471
},
24492472
];
24502473
}
2451-
if (compactRow.kind === "work-live") return [{ ...compactRow, expanded: false }];
24522474
return [compactRow];
24532475
});
24542476
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -951,9 +951,10 @@ const ConversationTimeline = memo(function ConversationTimeline({
951951
]);
952952
const compactWorkLog = useClientSettings((settings) => settings.compactWorkLog);
953953
const hideReasoning = useClientSettings((settings) => settings.hideReasoning);
954+
// Find must reach every row, so density only applies while it is closed.
954955
const densityRows = useMemo(
955-
() => applyTimelineDensity(rawRows, { compactWorkLog, hideReasoning }),
956-
[rawRows, compactWorkLog, hideReasoning],
956+
() => (findActive ? rawRows : applyTimelineDensity(rawRows, { compactWorkLog, hideReasoning })),
957+
[findActive, rawRows, compactWorkLog, hideReasoning],
957958
);
958959
const rows = useStableRows(densityRows, listIdentityKey);
959960
// Run status/timestamps churn on every stream event; the shared row context

‎apps/web/src/components/settings/SettingsPanels.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1891,7 +1891,7 @@ function TypographySection() {
18911891
settingKey="hideReasoning"
18921892
searchId="hide-reasoning"
18931893
label="Hide reasoning"
1894-
description="Hide model reasoning and intermediate commentary; show only the final answer."
1894+
description="Hide model reasoning and intermediate commentary. Tool activity and the final answer stay visible."
18951895
/>
18961896
</SettingsSection>
18971897
);

0 commit comments

Comments
 (0)