Skip to content

Commit 4763ac8

Browse files
Ennio Cutericlaude
andcommitted
feat(web): add chat settings to compact the work log and hide reasoning
Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 6524a8d commit 4763ac8

6 files changed

Lines changed: 222 additions & 1 deletion

File tree

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { describe, expect, it } from "vite-plus/test";
2+
import { applyTimelineDensity, type MessagesTimelineRow } from "./MessagesTimeline.logic";
3+
4+
type WorkEntry = Extract<MessagesTimelineRow, { kind: "work" }>["groupedEntries"][number];
5+
const entry = (id: string, itemType: string) =>
6+
({ id, itemType, createdAt: "2026-01-01T00:00:00Z" }) as unknown as WorkEntry;
7+
const work = (id: string, entries: WorkEntry[]): MessagesTimelineRow => ({
8+
kind: "work",
9+
id,
10+
createdAt: "2026-01-01T00:00:00Z",
11+
groupedEntries: entries,
12+
isExpandedToolGroup: true,
13+
});
14+
const assistant = (id: string, showAssistantMeta: boolean) =>
15+
({
16+
kind: "message",
17+
id,
18+
createdAt: "2026-01-01T00:00:00Z",
19+
message: { id, role: "assistant", runId: "run-1" },
20+
showAssistantMeta,
21+
}) as unknown as MessagesTimelineRow;
22+
23+
describe("applyTimelineDensity", () => {
24+
const rows = [
25+
work("w1", [entry("r1", "reasoning"), entry("c1", "command_execution")]),
26+
assistant("m1", false),
27+
work("w2", [entry("c2", "command_execution"), entry("c3", "command_execution")]),
28+
assistant("m2", true),
29+
];
30+
31+
it("is identity when both settings are off", () => {
32+
expect(applyTimelineDensity(rows, { compactWorkLog: false, hideReasoning: false })).toBe(rows);
33+
});
34+
35+
it("hides reasoning and commentary, then compacts to one updating line", () => {
36+
const result = applyTimelineDensity(rows, { compactWorkLog: true, hideReasoning: true });
37+
expect(result.map((row) => row.id)).toEqual(["w2", "m2"]);
38+
const last = result[0] as Extract<MessagesTimelineRow, { kind: "work" }>;
39+
expect(last.groupedEntries.map((e) => e.id)).toEqual(["c3"]);
40+
expect(last.isExpandedToolGroup).toBe(false);
41+
});
42+
43+
it("hideReasoning alone keeps tool rows and the final answer", () => {
44+
const result = applyTimelineDensity(rows, { compactWorkLog: false, hideReasoning: true });
45+
expect(result.map((row) => row.id)).toEqual(["w1", "w2", "m2"]);
46+
});
47+
48+
it("hides live commentary as soon as the next step starts", () => {
49+
const live = [
50+
work("w1", [entry("c1", "command_execution")]),
51+
assistant("m1", false),
52+
work("w2", [entry("c2", "command_execution")]),
53+
];
54+
const result = applyTimelineDensity(live, { compactWorkLog: true, hideReasoning: true });
55+
expect(result.map((row) => row.id)).toEqual(["w2"]);
56+
});
57+
});

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

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,3 +2372,86 @@ export function shouldCollapseUserMessage(text: string): boolean {
23722372
visible.split("\n").length > MAX_COLLAPSED_USER_MESSAGE_LINES
23732373
);
23742374
}
2375+
2376+
const isWorkLogTimelineRow = (row: MessagesTimelineRow) =>
2377+
row.kind === "work" ||
2378+
row.kind === "work-live" ||
2379+
row.kind === "work-toggle" ||
2380+
row.kind === "thinking";
2381+
2382+
/**
2383+
* Display-only pass over derived rows for the `hideReasoning` and
2384+
* `compactWorkLog` client settings. Runs after derivation so the incremental
2385+
* projection state stays untouched.
2386+
*/
2387+
export function applyTimelineDensity(
2388+
rows: MessagesTimelineRow[],
2389+
options: { compactWorkLog: boolean; hideReasoning: boolean },
2390+
): MessagesTimelineRow[] {
2391+
if (!options.compactWorkLog && !options.hideReasoning) return rows;
2392+
let result = rows;
2393+
2394+
if (options.hideReasoning) {
2395+
// Commentary = an assistant message without meta that is followed, within
2396+
// the same turn, by more work or another assistant message. The trailing
2397+
// message (final answer, or the commentary still streaming) stays visible.
2398+
const hiddenCommentaryIds = new Set<string>();
2399+
let laterActivityInTurn = false;
2400+
for (let index = result.length - 1; index >= 0; index -= 1) {
2401+
const row = result[index]!;
2402+
if (row.kind === "message" && row.message.role === "user") {
2403+
laterActivityInTurn = false;
2404+
continue;
2405+
}
2406+
if (row.kind === "message" && row.message.role === "assistant") {
2407+
if (!row.showAssistantMeta && laterActivityInTurn) hiddenCommentaryIds.add(row.id);
2408+
laterActivityInTurn = true;
2409+
} else if (isWorkLogTimelineRow(row)) {
2410+
laterActivityInTurn = true;
2411+
}
2412+
}
2413+
result = result.flatMap((row): MessagesTimelineRow[] => {
2414+
if (hiddenCommentaryIds.has(row.id)) return [];
2415+
if (row.kind === "work") {
2416+
const groupedEntries = row.groupedEntries.filter((entry) => entry.itemType !== "reasoning");
2417+
if (groupedEntries.length === 0) return [];
2418+
return groupedEntries.length === row.groupedEntries.length
2419+
? [row]
2420+
: [{ ...row, groupedEntries }];
2421+
}
2422+
if (row.kind === "work-live") {
2423+
if (row.entry.itemType === "reasoning") {
2424+
return row.active ? [{ kind: "thinking", id: row.id, createdAt: row.createdAt }] : [];
2425+
}
2426+
if (row.thought === undefined) return [row];
2427+
const { thought: _thought, ...rest } = row;
2428+
return [rest];
2429+
}
2430+
return [row];
2431+
});
2432+
}
2433+
2434+
if (options.compactWorkLog) {
2435+
// Each run of consecutive work-log rows collapses to its last row, and a
2436+
// work group to its last entry, so the line updates instead of growing.
2437+
result = result.flatMap((row, index): MessagesTimelineRow[] => {
2438+
if (!isWorkLogTimelineRow(row)) return [row];
2439+
const next = result[index + 1];
2440+
if (next !== undefined && isWorkLogTimelineRow(next)) return [];
2441+
const compactRow: MessagesTimelineRow = { ...row, continuesWorkLog: false };
2442+
if (compactRow.kind === "work") {
2443+
return [
2444+
{
2445+
...compactRow,
2446+
groupedEntries: compactRow.groupedEntries.slice(-1),
2447+
isExpandedToolGroup: false,
2448+
},
2449+
];
2450+
}
2451+
if (compactRow.kind === "work-live") return [{ ...compactRow, expanded: false }];
2452+
return [compactRow];
2453+
});
2454+
}
2455+
2456+
return result;
2457+
}

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ import { useAssistantCitationTarget, type CitationHistoryPage } from "./useAssis
200200
import {
201201
computeStableMessagesTimelineRows,
202202
deriveMessagesTimelineRowsWithState,
203+
applyTimelineDensity,
203204
type MessagesTimelineRowsProjection,
204205
liveWorkEntryLabel,
205206
resolveAssistantMessageCopyState,
@@ -948,7 +949,13 @@ const ConversationTimeline = memo(function ConversationTimeline({
948949
supportsConversationRollback,
949950
worktreeSetup,
950951
]);
951-
const rows = useStableRows(rawRows, listIdentityKey);
952+
const compactWorkLog = useClientSettings((settings) => settings.compactWorkLog);
953+
const hideReasoning = useClientSettings((settings) => settings.hideReasoning);
954+
const densityRows = useMemo(
955+
() => applyTimelineDensity(rawRows, { compactWorkLog, hideReasoning }),
956+
[rawRows, compactWorkLog, hideReasoning],
957+
);
958+
const rows = useStableRows(densityRows, listIdentityKey);
952959
// Run status/timestamps churn on every stream event; the shared row context
953960
// must not change with them or every timeline row re-renders per event.
954961
const runs = useStableHandoffRuns(runsProp);

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,12 @@ export function useSettingsRestore(onRestored?: () => void) {
592592
? ["Snooze limited threads"]
593593
: []),
594594
...(settings.wordWrap !== DEFAULT_UNIFIED_SETTINGS.wordWrap ? ["Word wrap"] : []),
595+
...(settings.compactWorkLog !== DEFAULT_UNIFIED_SETTINGS.compactWorkLog
596+
? ["Compact work log"]
597+
: []),
598+
...(settings.hideReasoning !== DEFAULT_UNIFIED_SETTINGS.hideReasoning
599+
? ["Hide reasoning"]
600+
: []),
595601
...(settings.persistComposerContextStrip !==
596602
DEFAULT_UNIFIED_SETTINGS.persistComposerContextStrip
597603
? ["Composer context"]
@@ -720,6 +726,8 @@ export function useSettingsRestore(onRestored?: () => void) {
720726
settings.notificationMode,
721727
settings.inAppNotificationsEnabled,
722728
settings.wordWrap,
729+
settings.compactWorkLog,
730+
settings.hideReasoning,
723731
followSystem,
724732
theme,
725733
themeHalves,
@@ -796,6 +804,8 @@ export function useSettingsRestore(onRestored?: () => void) {
796804
notificationMode: DEFAULT_UNIFIED_SETTINGS.notificationMode,
797805
inAppNotificationsEnabled: DEFAULT_UNIFIED_SETTINGS.inAppNotificationsEnabled,
798806
wordWrap: DEFAULT_UNIFIED_SETTINGS.wordWrap,
807+
compactWorkLog: DEFAULT_UNIFIED_SETTINGS.compactWorkLog,
808+
hideReasoning: DEFAULT_UNIFIED_SETTINGS.hideReasoning,
799809
persistComposerContextStrip: DEFAULT_UNIFIED_SETTINGS.persistComposerContextStrip,
800810
diffFilesCollapsed: DEFAULT_UNIFIED_SETTINGS.diffFilesCollapsed,
801811
diffIgnoreWhitespace: DEFAULT_UNIFIED_SETTINGS.diffIgnoreWhitespace,
@@ -1737,6 +1747,42 @@ function WordWrapRow() {
17371747
);
17381748
}
17391749

1750+
function ChatDensityToggleRow({
1751+
settingKey,
1752+
searchId,
1753+
label,
1754+
description,
1755+
}: {
1756+
settingKey: "compactWorkLog" | "hideReasoning";
1757+
searchId: "compact-work-log" | "hide-reasoning";
1758+
label: string;
1759+
description: string;
1760+
}) {
1761+
const settings = useScopedSettings();
1762+
const updateSettings = useUpdateScopedSettings();
1763+
return (
1764+
<SettingsRow
1765+
{...searchableSetting(searchId)}
1766+
description={description}
1767+
resetAction={
1768+
settings[settingKey] !== DEFAULT_UNIFIED_SETTINGS[settingKey] ? (
1769+
<SettingResetButton
1770+
label={label}
1771+
onClick={() => updateSettings({ [settingKey]: DEFAULT_UNIFIED_SETTINGS[settingKey] })}
1772+
/>
1773+
) : null
1774+
}
1775+
control={
1776+
<Switch
1777+
checked={settings[settingKey]}
1778+
onCheckedChange={(checked) => updateSettings({ [settingKey]: Boolean(checked) })}
1779+
aria-label={label}
1780+
/>
1781+
}
1782+
/>
1783+
);
1784+
}
1785+
17401786
function FontSettingsGroup() {
17411787
return (
17421788
<>
@@ -1835,6 +1881,18 @@ function TypographySection() {
18351881
>
18361882
{advanced ? <FontSettingsGroup /> : <SimpleFontRows />}
18371883
<WordWrapRow />
1884+
<ChatDensityToggleRow
1885+
settingKey="compactWorkLog"
1886+
searchId="compact-work-log"
1887+
label="Compact work log"
1888+
description="Collapse each run of tool calls into a single line that updates with the latest step."
1889+
/>
1890+
<ChatDensityToggleRow
1891+
settingKey="hideReasoning"
1892+
searchId="hide-reasoning"
1893+
label="Hide reasoning"
1894+
description="Hide model reasoning and intermediate commentary; show only the final answer."
1895+
/>
18381896
</SettingsSection>
18391897
);
18401898
}

‎apps/web/src/components/settings/settingsSearch.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,18 @@ export const SETTINGS_SEARCH_ITEMS = [
326326
to: "/settings/appearance",
327327
searchTerms: ["long lines code blocks tables diffs file previews"],
328328
},
329+
{
330+
id: "compact-work-log",
331+
title: "Compact work log",
332+
to: "/settings/appearance",
333+
searchTerms: ["working tool calls activity single line dense"],
334+
},
335+
{
336+
id: "hide-reasoning",
337+
title: "Hide reasoning",
338+
to: "/settings/appearance",
339+
searchTerms: ["thinking thoughts commentary final answer only"],
340+
},
329341
{
330342
id: "composer-context",
331343
title: "Composer context",

‎packages/contracts/src/settings.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@ export const ClientSettingsSchema = Schema.Struct({
505505
snapShotFlash: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
506506
snapShotAnimations: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
507507
wordWrap: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
508+
compactWorkLog: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
509+
hideReasoning: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(false))),
508510
});
509511
export type ClientSettings = typeof ClientSettingsSchema.Type;
510512

@@ -1751,5 +1753,7 @@ export const ClientSettingsPatch = Schema.Struct({
17511753
snapShotFlash: Schema.optionalKey(Schema.Boolean),
17521754
snapShotAnimations: Schema.optionalKey(Schema.Boolean),
17531755
wordWrap: Schema.optionalKey(Schema.Boolean),
1756+
compactWorkLog: Schema.optionalKey(Schema.Boolean),
1757+
hideReasoning: Schema.optionalKey(Schema.Boolean),
17541758
});
17551759
export type ClientSettingsPatch = typeof ClientSettingsPatch.Type;

0 commit comments

Comments
 (0)