From 863341fbf5e80afa0c12428cf3933f30b255ff7d Mon Sep 17 00:00:00 2001 From: Sviatoslav Abakumov Date: Sun, 10 May 2026 22:14:43 +0400 Subject: [PATCH] fix(tui): render the checkboxes in the to-do list items --- packages/tui/src/components/markdown.ts | 6 ++++-- packages/tui/test/markdown.test.ts | 8 ++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/tui/src/components/markdown.ts b/packages/tui/src/components/markdown.ts index 29d4ff13..0f8ffdfe 100644 --- a/packages/tui/src/components/markdown.ts +++ b/packages/tui/src/components/markdown.ts @@ -556,8 +556,10 @@ export class Markdown implements Component { for (let i = 0; i < token.items.length; i++) { const item = token.items[i]; const bullet = token.ordered ? `${startNumber + i}. ` : "- "; - const firstPrefix = indent + this.theme.listBullet(bullet); - const continuationPrefix = indent + " ".repeat(visibleWidth(bullet)); + const taskMarker = item.task ? `[${item.checked ? "x" : " "}] ` : ""; + const marker = bullet + taskMarker; + const firstPrefix = indent + this.theme.listBullet(marker); + const continuationPrefix = indent + " ".repeat(visibleWidth(marker)); const itemWidth = Math.max(1, width - visibleWidth(firstPrefix)); let renderedAnyLine = false; diff --git a/packages/tui/test/markdown.test.ts b/packages/tui/test/markdown.test.ts index 9c90eff9..4ba33dca 100644 --- a/packages/tui/test/markdown.test.ts +++ b/packages/tui/test/markdown.test.ts @@ -124,6 +124,14 @@ describe("Markdown component", () => { assert.ok(plainLines.some((line) => line.includes("2. Second ordered"))); }); + it("should render task list markers", () => { + const markdown = new Markdown("- [ ] beep\n- [x] boop", 0, 0, defaultMarkdownTheme); + + const lines = markdown.render(80).map((line) => stripAnsi(line).trimEnd()); + + assert.deepStrictEqual(lines, ["- [ ] beep", "- [x] boop"]); + }); + it("should maintain numbering when code blocks are not indented (LLM output)", () => { // When code blocks aren't indented, marked parses each item as a separate list. // We use token.start to preserve the original numbering.