diff --git a/packages/tui/src/feature-plugins/sidebar/todo.tsx b/packages/tui/src/feature-plugins/sidebar/todo.tsx index d1cf0df2dd12..5de2c97accee 100644 --- a/packages/tui/src/feature-plugins/sidebar/todo.tsx +++ b/packages/tui/src/feature-plugins/sidebar/todo.tsx @@ -18,7 +18,7 @@ export function SidebarTodo(props: { context: Plugin.Context; sessionID: string return ( 0}> - + [{ open: true }, async () => {}] }, + data: { + session: { + get: () => ({}), + message: { + list: () => [ + { + type: "assistant", + content: [{ type: "tool", name: "todowrite", state: { status: "completed", input: { todos } } }], + }, + ], + }, + }, + }, + } as unknown as Context +} + +const content = [ + "Review the sample output at several terminal widths and verify all displayed labels", + "Check example descriptions for wrapping and maintain consistent section spacing", + "Run the sample checks, inspect the terminal output, and document expected results", + "Prepare a sample report with before and after captures; record the verification results", +] + +test("sidebar preserves wrapped todo content and spacing before a growing section", async () => { + const todos = content.map( + (content, index): Todo => ({ + content, + status: index === 0 ? "in_progress" : "pending", + }), + ) + const app = await testRender( + () => ( + + + + + + + Next section + + + index)}> + {(index) => ( + + Item {index} + + )} + + + + + + + ), + { width: 40, height: 40 }, + ) + + try { + await app.renderOnce() + const rows = app + .captureCharFrame() + .split("\n") + .map((row) => row.trim()) + const next = rows.indexOf("Next section") + expect(next).toBeGreaterThan(0) + expect(rows[next - 1]).toBe("") + expect(rows[next - 2]).not.toBe("") + expect( + rows + .slice(1, next) + .map((row) => row.replace(/^\[[^\]]+\]\s*/, "")) + .join(" ") + .replace(/\s+/g, ""), + ).toBe( + todos + .map((todo) => todo.content) + .join("") + .replace(/\s+/g, ""), + ) + } finally { + app.renderer.destroy() + } +})