Highlight first incomplete item in CLI checklist display

- Added visual highlighting (cyan color and bold text) for the first incomplete checkbox item
- This helps users quickly identify what task is currently in progress
- Added comprehensive test coverage for the ChecklistDisplay component

Generated with [Continue](https://continue.dev)

Co-Authored-By: Continue <noreply@continue.dev>
This commit is contained in:
Continue Agent 2025-09-17 01:44:25 +00:00
parent 5f61d188e3
commit 37e7366b53
2 changed files with 77 additions and 1 deletions

View file

@ -0,0 +1,63 @@
import { render } from "ink-testing-library";
import React from "react";
import { ChecklistDisplay } from "./ChecklistDisplay.js";
describe("ChecklistDisplay", () => {
it("should highlight the first incomplete item", () => {
const content = `Task list status:
- [x] Completed task
- [ ] First incomplete task
- [ ] Second incomplete task`;
const { lastFrame } = render(<ChecklistDisplay content={content} />);
const output = lastFrame();
// The output should contain the checkbox symbols and text
expect(output).toContain("✓");
expect(output).toContain("○");
expect(output).toContain("Completed task");
expect(output).toContain("First incomplete task");
expect(output).toContain("Second incomplete task");
});
it("should handle empty checklist", () => {
const content = "Task list status:";
const { lastFrame } = render(<ChecklistDisplay content={content} />);
const output = lastFrame();
expect(output).toBeDefined();
});
it("should handle all completed tasks", () => {
const content = `Task list status:
- [x] Completed task 1
- [x] Completed task 2`;
const { lastFrame } = render(<ChecklistDisplay content={content} />);
const output = lastFrame();
expect(output).toContain("✓");
expect(output).toContain("Completed task 1");
expect(output).toContain("Completed task 2");
});
it("should handle mixed content with headers", () => {
const content = `Task list status:
## Important Tasks
- [x] Done task
- [ ] Todo task
## Other Tasks
- [ ] Another todo`;
const { lastFrame } = render(<ChecklistDisplay content={content} />);
const output = lastFrame();
expect(output).toContain("Important Tasks");
expect(output).toContain("Other Tasks");
expect(output).toContain("✓");
expect(output).toContain("○");
});
});

View file

@ -13,6 +13,17 @@ export const ChecklistDisplay: React.FC<ChecklistDisplayProps> = ({
}) => {
const lines = content.split("\n");
// Find the index of the first incomplete checkbox item
let firstIncompleteIndex = -1;
for (let i = 0; i < lines.length; i++) {
const line = lines[i];
const checkboxMatch = line.match(/^(\s*)-\s*\[([ x])\]\s*(.*)$/);
if (checkboxMatch && checkboxMatch[2] === " ") {
firstIncompleteIndex = i;
break;
}
}
return (
<Box flexDirection="column" paddingLeft={2}>
{lines.map((line, index) => {
@ -25,6 +36,7 @@ export const ChecklistDisplay: React.FC<ChecklistDisplayProps> = ({
if (checkboxMatch) {
const [, indent, status, taskText] = checkboxMatch;
const isCompleted = status === "x";
const isFirstIncomplete = index === firstIncompleteIndex;
return (
<Box key={index}>
@ -34,8 +46,9 @@ export const ChecklistDisplay: React.FC<ChecklistDisplayProps> = ({
</Text>
<Text> </Text>
<Text
color={isCompleted ? "gray" : "white"}
color={isCompleted ? "gray" : isFirstIncomplete ? "cyan" : "white"}
strikethrough={isCompleted}
bold={isFirstIncomplete}
>
{taskText}
</Text>