Skip to content

Commit 8faea7e

Browse files
committed
feat(ui): move todo list above response, add summary
1 parent cf6ede0 commit 8faea7e

File tree

3 files changed

+74
-54
lines changed

3 files changed

+74
-54
lines changed

typescript/ui/__tests__/unit/TodoList.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,4 +126,21 @@ describe("TodoList", () => {
126126
const ids = childTasks.map((el) => el.getAttribute("data-testid"));
127127
expect(ids).toEqual(["todo-task-c2", "todo-task-c1"]);
128128
});
129+
130+
it("renders task summary when provided", () => {
131+
const tasks = [
132+
makeTask({
133+
id: "with-summary",
134+
description: "Task with summary",
135+
summary: "This is a summary",
136+
}),
137+
];
138+
139+
render(<TodoList tasks={tasks} />);
140+
141+
const task = screen.getByTestId("todo-task-with-summary");
142+
expect(task).toBeInTheDocument();
143+
expect(screen.getByText("Task with summary")).toBeInTheDocument();
144+
expect(screen.getByText("This is a summary")).toBeInTheDocument();
145+
});
129146
});

typescript/ui/src/core/components/ChatMessage/ChatMessage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const ChatMessage = forwardRef<HTMLDivElement, ChatMessageProps>(
9393
classNames={{ liveUpdates: classNames?.liveUpdates }}
9494
/>
9595
)}
96+
{message.tasks && <TodoList tasks={message.tasks} />}
9697
<MarkdownContent
9798
content={content}
9899
classNames={classNames?.content}
@@ -101,7 +102,6 @@ const ChatMessage = forwardRef<HTMLDivElement, ChatMessageProps>(
101102
{showMessageReferences && (
102103
<MessageReferences references={references} />
103104
)}
104-
{message.tasks && <TodoList tasks={message.tasks} />}
105105
{showMessageActions && (
106106
<MessageActions
107107
content={content}

typescript/ui/src/core/components/TodoList.tsx

Lines changed: 56 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,60 +11,63 @@ export default function TodoList({ tasks, depth = 0 }: TodoListProps) {
1111

1212
return (
1313
<div className="space-y-2" data-testid={`todo-list-root-${depth}`}>
14-
{tasksTree.getRoots().map(({ id, description, status, children }) => {
15-
const inProgressIcon = (
16-
<CircularProgress
17-
size="sm"
18-
color="primary"
19-
aria-label="Task is in progress"
20-
className="m-0 p-0"
21-
classNames={{
22-
svg: "w-4 h-4",
23-
}}
24-
/>
25-
);
26-
return (
27-
<div key={id} data-testid={`todo-task-${id}`}>
28-
<div>
29-
<Checkbox
30-
isSelected={status === TaskStatus.Completed}
31-
disabled
32-
className="block"
33-
icon={
34-
status === TaskStatus.InProgress
35-
? () => inProgressIcon
36-
: undefined
37-
}
38-
classNames={{
39-
hiddenInput: "cursor-default",
40-
wrapper:
41-
status === TaskStatus.InProgress && "before:border-none",
42-
base: "pointer-events-none hover:bg-transparent",
43-
label: [
44-
"transition-colors",
45-
status === TaskStatus.Completed &&
46-
"line-through text-default-400",
47-
status === TaskStatus.InProgress && "text-primary italic",
48-
status === TaskStatus.Pending && "text-default-900",
49-
]
50-
.filter(Boolean)
51-
.join(" "),
52-
}}
53-
>
54-
{description}
55-
</Checkbox>
56-
</div>
57-
{children.length > 0 && (
58-
<div
59-
style={{ marginLeft: `${(depth + 1) * 0.5}rem` }}
60-
data-testid={`todo-children-wrapper-${id}`}
61-
>
62-
<TodoList tasks={children} depth={depth + 1} />
14+
{tasksTree
15+
.getRoots()
16+
.map(({ id, description, status, summary, children }) => {
17+
const inProgressIcon = (
18+
<CircularProgress
19+
size="sm"
20+
color="primary"
21+
aria-label="Task is in progress"
22+
className="m-0 p-0"
23+
classNames={{
24+
svg: "w-4 h-4",
25+
}}
26+
/>
27+
);
28+
return (
29+
<div key={id} data-testid={`todo-task-${id}`}>
30+
<div>
31+
<Checkbox
32+
isSelected={status === TaskStatus.Completed}
33+
disabled
34+
className="block"
35+
icon={
36+
status === TaskStatus.InProgress
37+
? () => inProgressIcon
38+
: undefined
39+
}
40+
classNames={{
41+
hiddenInput: "cursor-default",
42+
wrapper:
43+
status === TaskStatus.InProgress && "before:border-none",
44+
base: "pointer-events-none hover:bg-transparent",
45+
label: [
46+
"transition-colors",
47+
status === TaskStatus.Completed &&
48+
"line-through text-default-400",
49+
status === TaskStatus.InProgress && "text-primary italic",
50+
status === TaskStatus.Pending && "text-default-900",
51+
]
52+
.filter(Boolean)
53+
.join(" "),
54+
}}
55+
>
56+
{description}
57+
{summary && <p className="ml-7">{summary}</p>}
58+
</Checkbox>
6359
</div>
64-
)}
65-
</div>
66-
);
67-
})}
60+
{children.length > 0 && (
61+
<div
62+
style={{ marginLeft: `${(depth + 1) * 0.5}rem` }}
63+
data-testid={`todo-children-wrapper-${id}`}
64+
>
65+
<TodoList tasks={children} depth={depth + 1} />
66+
</div>
67+
)}
68+
</div>
69+
);
70+
})}
6871
</div>
6972
);
7073
}

0 commit comments

Comments
 (0)