Elffuss BraidHub

kikocis/continue public

Merge pull request #7796 from continuedev/continue-1758073306896

Highlight first incomplete item in CLI checklist display
Changesetf636b4841cdd1439315e2c1b550a0d3bc0c72a010bf238c62bff346719ab2310
AuthorDallin Romney <dallinromney@gmail.com> · 2025-09-25 15:46 -07:00
CommitterGitHub <noreply@github.com> · 2025-09-25 15:46 -07:00
Parents3ff29c567dd0, ddc2c7a0c5a7

Browse the files at this changeset

2 files changed

added extensions/cli/src/ui/components/ChecklistDisplay.test.tsx +63 −0
@@ -0,0 +1,63 @@
1+import { render } from "ink-testing-library";
2+import React from "react";
3+
4+import { ChecklistDisplay } from "./ChecklistDisplay.js";
5+
6+describe("ChecklistDisplay", () => {
7+ it("should highlight the first incomplete item", () => {
8+ const content = `Task list status:
9+- [x] Completed task
10+- [ ] First incomplete task
11+- [ ] Second incomplete task`;
12+
13+ const { lastFrame } = render(<ChecklistDisplay content={content} />);
14+ const output = lastFrame();
15+
16+ // The output should contain the checkbox symbols and text
17+ expect(output).toContain("✓");
18+ expect(output).toContain("○");
19+ expect(output).toContain("Completed task");
20+ expect(output).toContain("First incomplete task");
21+ expect(output).toContain("Second incomplete task");
22+ });
23+
24+ it("should handle empty checklist", () => {
25+ const content = "Task list status:";
26+
27+ const { lastFrame } = render(<ChecklistDisplay content={content} />);
28+ const output = lastFrame();
29+
30+ expect(output).toBeDefined();
31+ });
32+
33+ it("should handle all completed tasks", () => {
34+ const content = `Task list status:
35+- [x] Completed task 1
36+- [x] Completed task 2`;
37+
38+ const { lastFrame } = render(<ChecklistDisplay content={content} />);
39+ const output = lastFrame();
40+
41+ expect(output).toContain("✓");
42+ expect(output).toContain("Completed task 1");
43+ expect(output).toContain("Completed task 2");
44+ });
45+
46+ it("should handle mixed content with headers", () => {
47+ const content = `Task list status:
48+## Important Tasks
49+- [x] Done task
50+- [ ] Todo task
51+
52+## Other Tasks
53+- [ ] Another todo`;
54+
55+ const { lastFrame } = render(<ChecklistDisplay content={content} />);
56+ const output = lastFrame();
57+
58+ expect(output).toContain("Important Tasks");
59+ expect(output).toContain("Other Tasks");
60+ expect(output).toContain("✓");
61+ expect(output).toContain("○");
62+ });
63+});
modified extensions/cli/src/ui/components/ChecklistDisplay.tsx +16 −1
@@ -13,6 +13,17 @@
1313 }) => {
1414 const lines = content.split("\n");
1515
16+ // Find the index of the first incomplete checkbox item
17+ let firstIncompleteIndex = -1;
18+ for (let i = 0; i < lines.length; i++) {
19+ const line = lines[i];
20+ const checkboxMatch = line.match(/^(\s*)-\s*\[([ x])\]\s*(.*)$/);
21+ if (checkboxMatch && checkboxMatch[2] === " ") {
22+ firstIncompleteIndex = i;
23+ break;
24+ }
25+ }
26+
1627 return (
1728 <Box flexDirection="column" paddingLeft={2}>
1829 {lines.map((line, index) => {
@@ -25,6 +36,7 @@
2536 if (checkboxMatch) {
2637 const [, indent, status, taskText] = checkboxMatch;
2738 const isCompleted = status === "x";
39+ const isFirstIncomplete = index === firstIncompleteIndex;
2840
2941 return (
3042 <Box key={index}>
@@ -34,8 +46,11 @@
3446 </Text>
3547 <Text> </Text>
3648 <Text
37- color={isCompleted ? "gray" : "white"}
49+ color={
50+ isCompleted ? "gray" : isFirstIncomplete ? "cyan" : "white"
51+ }
3852 strikethrough={isCompleted}
53+ bold={isFirstIncomplete}
3954 >
4055 {taskText}
4156 </Text>