From a5319fb7afb2decd3f1f510fc4cac3601d1d3b42 Mon Sep 17 00:00:00 2001 From: Brooklyn Nicholson Date: Sun, 26 Apr 2026 15:56:08 -0500 Subject: [PATCH] test(tui): cover live todo completion flow --- .../src/__tests__/createGatewayEventHandler.test.ts | 12 ++++++++++++ ui-tui/src/lib/liveLayout.test.ts | 4 ++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ui-tui/src/__tests__/createGatewayEventHandler.test.ts b/ui-tui/src/__tests__/createGatewayEventHandler.test.ts index ad4a8f8e46..7640c2bf91 100644 --- a/ui-tui/src/__tests__/createGatewayEventHandler.test.ts +++ b/ui-tui/src/__tests__/createGatewayEventHandler.test.ts @@ -80,6 +80,18 @@ describe('createGatewayEventHandler', () => { expect(getTurnState().todos).toEqual(todos) }) + it('archives completed todos into transcript flow at end of turn', () => { + const appended: Msg[] = [] + const todos = [{ content: 'Serve tiny latte', id: 'serve', status: 'completed' }] + const onEvent = createGatewayEventHandler(buildCtx(appended)) + + onEvent({ payload: { name: 'todo', todos, tool_id: 'todo-1' }, type: 'tool.start' } as any) + onEvent({ payload: { text: 'done' }, type: 'message.complete' } as any) + + expect(getTurnState().todos).toEqual([]) + expect(appended).toContainEqual({ kind: 'trail', role: 'system', text: '', todos }) + }) + it('keeps the current todo list visible when the next message starts', () => { const appended: Msg[] = [] const todos = [{ content: 'Boil water', id: 'boil', status: 'in_progress' }] diff --git a/ui-tui/src/lib/liveLayout.test.ts b/ui-tui/src/lib/liveLayout.test.ts index 24426efe63..9faa1daea2 100644 --- a/ui-tui/src/lib/liveLayout.test.ts +++ b/ui-tui/src/lib/liveLayout.test.ts @@ -3,7 +3,7 @@ import { describe, expect, it } from 'vitest' import { liveTailOrder } from './liveLayout.js' describe('liveTailOrder', () => { - it('keeps todo before transcript and assistant live output', () => { - expect(liveTailOrder()).toEqual(['todo', 'scroll-history', 'assistant']) + it('anchors live todo after scroll history and assistant output', () => { + expect(liveTailOrder()).toEqual(['scroll-history', 'assistant', 'live-todo']) }) })