Merge pull request #7796 from continuedev/continue-1758073306896

Highlight first incomplete item in CLI checklist display
This commit is contained in:
Dallin Romney 2025-09-25 15:46:46 -07:00 • committed by GitHub
commit 00a24af571
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 79 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,11 @@ 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>