Elffuss BraidHub

kikocis/continue public

e31fcddb0dec · 1.5 KiBRawPermalink
1import { Box, Text } from "ink";
2import React from "react";
3
4interface ChecklistDisplayProps {
5 content: string;
6}
7
8/**
9 * Renders checklist content with styled checkboxes
10 */
11export const ChecklistDisplay: React.FC<ChecklistDisplayProps> = ({
12 content,
13}) => {
14 const lines = content.split("\n");
15
16 return (
17 <Box flexDirection="column" paddingLeft={2}>
18 {lines.map((line, index) => {
19 if (line.startsWith("Task list")) {
20 return null;
21 }
22 // Match both completed [x] and incomplete [ ] checkboxes
23 const checkboxMatch = line.match(/^(\s*)-\s*\[([ x])\]\s*(.*)$/);
24
25 if (checkboxMatch) {
26 const [, indent, status, taskText] = checkboxMatch;
27 const isCompleted = status === "x";
28
29 return (
30 <Box key={index}>
31 <Text>{indent}</Text>
32 <Text color={isCompleted ? "green" : "yellow"}>
33 {isCompleted ? "✓" : "○"}
34 </Text>
35 <Text> </Text>
36 <Text
37 color={isCompleted ? "gray" : "white"}
38 strikethrough={isCompleted}
39 >
40 {taskText}
41 </Text>
42 </Box>
43 );
44 } else if (line.trim()) {
45 // Non-checkbox lines (headers, etc.)
46 return (
47 <Box key={index}>
48 <Text color="white">{line}</Text>
49 </Box>
50 );
51 } else {
52 // Empty lines
53 return <Box key={index} height={1} />;
54 }
55 })}
56 </Box>
57 );
58};