e30e75b5d4
Changesets / Create Version PR (push) Has been cancelled
Deploy Shadcn Registry / Deploy Production (push) Has been cancelled
Template Metrics / LOC + Bundle Size (push) Has been cancelled
Code Quality / Oxlint + Oxfmt (push) Has been cancelled
Code Quality / Template Sync (push) Has been cancelled
Code Quality / Build Changed Packages (push) Has been cancelled
Code Quality / Test Changed Packages (push) Has been cancelled
Deploy Expo Example / Deploy Production (push) Has been cancelled
Deploy Ink Example / Deploy Production (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-stream, 3.12) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.10) (push) Has been cancelled
Python Tests / pytest (assistant-ui-sync-server-api, 3.12) (push) Has been cancelled
62 lines
1.5 KiB
TypeScript
62 lines
1.5 KiB
TypeScript
"use client";
|
|
|
|
import { useLangChainState } from "@assistant-ui/react-langchain";
|
|
|
|
type Todo = {
|
|
id?: string;
|
|
content: string;
|
|
status?: "pending" | "in_progress" | "completed";
|
|
};
|
|
|
|
const statusIcon = (status: Todo["status"]) => {
|
|
switch (status) {
|
|
case "completed":
|
|
return "✓";
|
|
case "in_progress":
|
|
return "◐";
|
|
default:
|
|
return "○";
|
|
}
|
|
};
|
|
|
|
export function TodosPanel() {
|
|
const todos = useLangChainState<Todo[]>("todos", []);
|
|
|
|
if (todos.length === 0) {
|
|
return (
|
|
<div className="text-muted-foreground text-sm">
|
|
Todos from the agent will appear here. This panel reads{" "}
|
|
<code className="bg-muted rounded px-1">state.todos</code> via{" "}
|
|
<code className="bg-muted rounded px-1">useLangChainState</code>.
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="space-y-2">
|
|
<h2 className="text-muted-foreground text-sm font-semibold tracking-wide uppercase">
|
|
Agent todos
|
|
</h2>
|
|
<ul className="space-y-1">
|
|
{todos.map((todo, i) => (
|
|
<li
|
|
key={todo.id ?? i}
|
|
className="flex items-start gap-2 text-sm leading-relaxed"
|
|
>
|
|
<span aria-hidden>{statusIcon(todo.status)}</span>
|
|
<span
|
|
className={
|
|
todo.status === "completed"
|
|
? "text-muted-foreground line-through"
|
|
: undefined
|
|
}
|
|
>
|
|
{todo.content}
|
|
</span>
|
|
</li>
|
|
))}
|
|
</ul>
|
|
</div>
|
|
);
|
|
}
|