feat(web): add chat settings to compact the work log and hide reasoning #18993
ClosedECuteri(GitHub profile, opens in a new tab)wants to merge 6 commits into
main fromrefs/pull/18993/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- @@ -948,4 +949,6 @@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(@@ -2374,0 +2387,21 @@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, within2396+ // the same turn, by more work or another assistant message. The trailing2397+ // 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);
- apps/web/src/components/chat/MessagesTimeline.logic.ts line 2451OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -2374,0 +2431,21 @@2431+ });2432+ }2433+2434+ if (options.compactWorkLog) {2435+ // Each run of consecutive work-log rows collapses to its last row, and a2436+ // 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 }];apps/web/src/components/settings/SettingsPanels.tsx line 1894OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -1835,3 +1881,14 @@18351881 >18361882 {advanced ? <FontSettingsGroup /> : <SimpleFontRows />}18371883 <WordWrapRow />1884+ <ChatDensityToggleRow1885+ 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+ <ChatDensityToggleRow1891+ settingKey="hideReasoning"1892+ searchId="hide-reasoning"1893+ label="Hide reasoning"1894+ description="Hide model reasoning and intermediate commentary; show only the final answer."
- apps/web/src/components/chat/MessagesTimeline.logic.ts lines 2616 to 2618Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -2569,0 +2598,21 @@2598+ rows: MessagesTimelineRow[],2599+ options: { compactWorkLog: boolean; hideReasoning: boolean },2600+): MessagesTimelineRow[] {2601+ if (!options.compactWorkLog && !options.hideReasoning) return rows;2602+ let result = rows;2603+2604+ if (options.hideReasoning) {2605+ // Commentary = a non-terminal assistant message that is followed, within2606+ // the same turn, by more work or another assistant message. The trailing2607+ // message (final answer, or the commentary still streaming) stays visible.2608+ // Terminal answers whose meta moved below trailing tools are still terminal.2609+ const relocatedMetaMessageIds = new Set(2610+ result.flatMap((row) => (row.kind === "assistant-meta" ? [row.message.id] : [])),2611+ );2612+ const hiddenCommentaryIds = new Set<string>();2613+ let laterActivityInTurn = false;2614+ for (let index = result.length - 1; index >= 0; index -= 1) {2615+ const row = result[index]!;2616+ if (row.kind === "message" && row.message.role === "user") {2617+ laterActivityInTurn = false;2618+ continue;apps/web/src/components/chat/MessagesTimeline.logic.ts lines 2695 to 2721Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -2569,0 +2685,21 @@2685+ continue;2686+ }2687+ if (run.some(workLogRowIsExpanded))2688+ for (const runRow of run) expandedRunRowIds.add(runRow.id);2689+ run = [];2690+ }2691+ result = result.flatMap((row, index): MessagesTimelineRow[] => {2692+ if (!isWorkLogTimelineRow(row) || expandedRunRowIds.has(row.id)) return [row];2693+ const next = result[index + 1];2694+ if (next !== undefined && isWorkLogTimelineRow(next)) return [];2695+ const compactRow: MessagesTimelineRow = { ...row, continuesWorkLog: false };2696+ if (compactRow.kind === "work") {2697+ return [2698+ {2699+ ...compactRow,2700+ groupedEntries: compactRow.groupedEntries.slice(-1),2701+ isExpandedToolGroup: false,2702+ },2703+ ];2704+ }2705+ return [compactRow];
- @@ -2569,0 +2694,21 @@2694+ if (next !== undefined && isWorkLogTimelineRow(next)) return [];2695+ const compactRow: MessagesTimelineRow = { ...row, continuesWorkLog: false };2696+ if (compactRow.kind === "work-toggle") {2697+ const latest = compactRow.groupedEntries.at(-1);2698+ if (latest === undefined) return [compactRow];2699+ return [2700+ {2701+ ...compactRow,2702+ summary:2703+ toolGroupAction(latest) === "edit"2704+ ? summarizeToolGroup([latest]).summary2705+ : singleToolCallLabel(latest),2706+ summaryKind: toolGroupSummaryKind([latest]),2707+ toolSurface: latest.toolSurface,2708+ toolIcon: latest.toolIcon ?? latest.toolSource?.icon,2709+ },2710+ ];2711+ }2712+ if (compactRow.kind === "work") {2713+ return [2714+ {
tanstack-source added labelsfeature
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.




macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed