Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(chat): fold a superseded todo list into its tool run; no canned result on the todo card
review9b1ba3219320
diff --git a/src/renderer/lib/chatToolGroups.test.ts b/src/renderer/lib/chatToolGroups.test.tsindex dbc26df6f..35c0f7e19 100644--- a/src/renderer/lib/chatToolGroups.test.ts+++ b/src/renderer/lib/chatToolGroups.test.ts@@ -86,6 +86,18 @@ describe('groupToolCalls', () => {expect(layout.groupAt.size).toBe(0)})+ it('folds a superseded todo list like any call; the latest one (a card) stays a boundary', () => {+ const todo = (body: string): ChatMessage => ({ role: 'assistant', parts: [tool('TodoWrite', { body })] })+ const messages = [call('Bash'), todo('- [ ] old'), call('Bash'), todo('- [x] latest'), call('Bash')]++ const layout = groupToolCalls(messages)++ expect(runs(messages)).toEqual([['0:0', '1:0', '2:0']])+ expect(layout.absorbed.has('1:0')).toBe(true)+ expect(layout.absorbed.has('3:0')).toBe(false)+ expect(layout.absorbed.has('4:0')).toBe(false)+ })+it('a Compaction chip between tool calls splits the run and is never folded (it is a system record)', () => {const compaction: ChatMessage = {role: 'assistant',diff --git a/src/renderer/lib/chatToolGroups.ts b/src/renderer/lib/chatToolGroups.tsindex 3b2105a18..95f02f684 100644--- a/src/renderer/lib/chatToolGroups.ts+++ b/src/renderer/lib/chatToolGroups.ts@@ -8,6 +8,7 @@import type { ChatMessage, ChatPart } from '@shared/types'import { isSystemRecordMessage } from '@shared/chat-system-records'import { isLocalCommandTool } from '@shared/chat-command'+import { latestTodoIndex, staleTodo } from './chatFocus'/** Fewer calls than this stay as plain chips: a block holding one chip only adds a click. */export const TOOL_GROUP_MIN = 2@@ -56,13 +57,18 @@ export interface GroupToolCallsOptions {/*** A tool call the agent made, shown as a chip. Not one:- * - a plan / question card (`body`): that IS the content, never folded away;+ * - a plan / question / latest todo-list card (`body`): that IS the content, never folded away —+ * but a SUPERSEDED todo list (lib/chatFocus.ts) is drawn as its chip, so it folds like one;* - the user's own `/command`, `!` line or command output: the person did that, not the agent;* - a system record (a background task finishing, another agent's message): it is not the agent's* work either, and the thread already treats it as a turn boundary.*/-function isFoldableTool(p: ChatPart): boolean {- return p.kind === 'tool' && p.body === undefined && !isLocalCommandTool(p.name)+function isFoldableTool(p: ChatPart, message: number, latestTodo: number): boolean {+ return (+ p.kind === 'tool' &&+ (p.body === undefined || staleTodo(p, message, latestTodo)) &&+ !isLocalCommandTool(p.name)+ )}/**@@ -75,6 +81,7 @@ function isFoldableTool(p: ChatPart): boolean {export function groupToolCalls(messages: readonly ChatMessage[], opts: GroupToolCallsOptions = {}): ToolGroupLayout {const groupAt = new Map<string, ToolGroup>()const absorbed = new Set<string>()+ const latestTodo = latestTodoIndex(messages)let run: ToolGroupMember[] = []const flush = (): void => {if (run.length >= TOOL_GROUP_MIN) {@@ -90,7 +97,7 @@ export function groupToolCalls(messages: readonly ChatMessage[], opts: GroupToolreturn}m.parts.forEach((p, j) => {- if (isFoldableTool(p)) run.push({ message: i, part: j })+ if (isFoldableTool(p, i, latestTodo)) run.push({ message: i, part: j })else flush()})})diff --git a/src/renderer/nodes/ChatPanel.thread.test.tsx b/src/renderer/nodes/ChatPanel.thread.test.tsxindex 25fa243fc..424346c10 100644--- a/src/renderer/nodes/ChatPanel.thread.test.tsx+++ b/src/renderer/nodes/ChatPanel.thread.test.tsx@@ -348,11 +348,12 @@ describe('⌘M thread look', () => {})describe('⌘M Focus view and the todo-list card', () => {- const todo = (key: number, body: string): ChatMessage => ({+ const todo = (key: number, body: string, result?: string): ChatMessage => ({role: 'assistant',- parts: [{ kind: 'tool', name: 'TodoWrite', arg: '', body }],+ parts: [{ kind: 'tool', name: 'TodoWrite', arg: '', body, ...(result ? { result } : {}) }],key})+ const TODO_RESULT = 'Todos have been modified successfully. Ensure that you continue to use the todo list'const focusOn = (): void => useSettings.setState((s) => ({ settings: { ...s.settings, chatFocusView: true } }))it('only the latest todo list is a card; an older one is the plain chip (Focus off too)', async () => {@@ -360,11 +361,14 @@ describe('⌘M Focus view and the todo-list card', () => {{ role: 'user', parts: [{ kind: 'text', text: 'q' }], key: 0 },todo(10, '- [ ] a\n- [ ] b'),{ role: 'assistant', parts: [{ kind: 'text', text: 'working' }], key: 20 },- todo(30, '- [x] a\n- [ ] **b** _(in progress)_')+ todo(30, '- [x] a\n- [ ] **b** _(in progress)_', TODO_RESULT)])const cards = [...host.querySelectorAll('.term-chat__tool-card')]expect(cards).toHaveLength(1)expect(cards[0].classList.contains('term-chat__todo')).toBe(true)+ // The CLI's canned reply to a TodoWrite is plumbing: the card shows the list, not the result.+ expect(cards[0].querySelector('.term-chat__tool-result')).toBeNull()+ expect(cards[0].textContent).not.toContain('Todos have been modified')expect(cards[0].querySelector('.term-chat__tool-card-title')?.textContent).toBe('Todo list')const boxes = [...cards[0].querySelectorAll<HTMLInputElement>('input[type="checkbox"]')]expect(boxes.map((b) => [b.checked, b.disabled])).toEqual([@@ -378,6 +382,23 @@ describe('⌘M Focus view and the todo-list card', () => {expect(host.querySelector('.term-chat__focus')?.getAttribute('aria-pressed')).toBe('false')})+ it('a superseded todo list folds into the tool block around it, drawn there as its chip', async () => {+ await mount([+ { role: 'user', parts: [{ kind: 'text', text: 'q' }], key: 0 },+ { role: 'assistant', parts: [{ kind: 'tool', name: 'Bash', arg: 'a' }], key: 10 },+ todo(20, '- [ ] old', TODO_RESULT),+ { role: 'assistant', parts: [{ kind: 'tool', name: 'Bash', arg: 'b' }], key: 30 },+ todo(40, '- [x] latest')+ ])+ const groups = [...host.querySelectorAll('.term-chat__tool-group')]+ expect(groups).toHaveLength(1)+ expect(groups[0].querySelector('.term-chat__tool-group-count')?.textContent).toBe('3 tool calls')+ const names = [...groups[0].querySelectorAll('.term-chat__tool-group-body .term-chat__tool-name')].map((n) => n.textContent)+ expect(names).toEqual(['Bash', 'TodoWrite', 'Bash'])+ expect(groups[0].querySelector('.term-chat__tool-card')).toBeNull()+ expect(host.querySelectorAll('.term-chat__tool-card')).toHaveLength(1)+ })+it('Focus hides chips, groups and thinking; keeps text, the latest todo card and a question card', async () => {focusOn()await mount([diff --git a/src/renderer/nodes/ChatPanel.tsx b/src/renderer/nodes/ChatPanel.tsxindex 6fa6b8712..7262f8198 100644--- a/src/renderer/nodes/ChatPanel.tsx+++ b/src/renderer/nodes/ChatPanel.tsx@@ -1038,7 +1038,8 @@ export function ChatPanel({<div key={key} className={`term-chat__tool-card${p.name === TODO_WRITE_TOOL ? ' term-chat__todo' : ''}`}><div className="term-chat__tool-card-title">{toolCardTitle(p.name)}</div><MarkdownText text={p.body} />- {p.result && <pre className="term-chat__tool-result">{p.result}</pre>}+ {/* A TodoWrite's result is the CLI's canned "Todos have been modified…": plumbing, not content. */}+ {p.result && p.name !== TODO_WRITE_TOOL && <pre className="term-chat__tool-result">{p.result}</pre>}{answerCard && answerCard.card.message === i && answerCard.card.part === j && (// Keyed by the BOUND ticket: a new hold on the same card starts from a clean// state, and every answer names the request this card was drawn for.