{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "elements-todo-list",
  "type": "registry:component",
  "title": "Todo list",
  "description": "The agent's own working list, rewritten mid-run as it discovers what else is needed.",
  "registryDependencies": [
    "https://r.assistant-ui.com/elements-surfaces.json",
    "https://r.assistant-ui.com/elements-range.json"
  ],
  "dependencies": [
    "lucide-react"
  ],
  "files": [
    {
      "type": "registry:component",
      "path": "components/assistant-ui/elements/todo-list.tsx",
      "sourcePath": "packages/ui/src/components/react/assistant-ui/elements/todo-list.tsx",
      "content": "\"use client\";\n\nimport { useId, useState, type ComponentProps } from \"react\";\nimport { CheckIcon, Loader2Icon, MinusIcon, XIcon } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\nimport { ghostButton, mono } from \"./surfaces\";\nimport { clamp } from \"../utils/range\";\n\nexport type TodoStatus = \"pending\" | \"active\" | \"done\" | \"failed\" | \"cancelled\";\n\nexport interface TodoItem {\n  id: string;\n  text: string;\n  status: TodoStatus;\n  description?: string | undefined;\n  reason?: string | undefined;\n}\n\nexport function TodoList({\n  items,\n  revision,\n  title = \"Todos\",\n  description,\n  maxVisible,\n  className,\n  ...props\n}: Omit<ComponentProps<\"div\">, \"children\" | \"items\" | \"revision\" | \"title\"> & {\n  items: readonly TodoItem[];\n  revision?: number | undefined;\n  title?: string | undefined;\n  description?: string | undefined;\n  maxVisible?: number | undefined;\n}) {\n  const done = items.filter((item) => item.status === \"done\").length;\n  const total = items.filter((item) => item.status !== \"cancelled\").length;\n  const visibleCount = Math.floor(\n    clamp(maxVisible ?? items.length, 0, items.length),\n  );\n  const [expanded, setExpanded] = useState(false);\n  const listId = useId();\n  const hiddenItems = items.filter(\n    (item, index) =>\n      index >= visibleCount &&\n      item.status !== \"active\" &&\n      item.status !== \"failed\",\n  );\n  const canFold = maxVisible !== undefined && hiddenItems.length > 0;\n\n  return (\n    <div\n      data-slot=\"todo-list\"\n      className={cn(\"flex w-full max-w-sm flex-col gap-3\", className)}\n      {...props}\n    >\n      <div className=\"flex items-start justify-between gap-3\">\n        <div className=\"min-w-0\">\n          <span className=\"text-[13.5px] font-medium\">{title}</span>\n          {description ? (\n            <p className=\"text-muted-foreground text-xs leading-4 break-words\">\n              {description}\n            </p>\n          ) : null}\n        </div>\n        <span\n          className={cn(\n            mono,\n            \"text-muted-foreground shrink-0 whitespace-nowrap tabular-nums\",\n          )}\n        >\n          {revision === undefined\n            ? `${done}/${total}`\n            : `${done}/${total} · rev ${revision}`}\n        </span>\n      </div>\n      <ul id={listId} className=\"flex flex-col gap-1\">\n        {items.map((item, index) => {\n          const collapsed =\n            canFold &&\n            index >= visibleCount &&\n            item.status !== \"active\" &&\n            item.status !== \"failed\";\n          const rowClassName =\n            \"fade-in slide-in-from-bottom-1 animate-in fill-mode-both flex items-start gap-2.5 py-0.5 text-[13.5px] duration-300 motion-reduce:animate-none\";\n          const row = (\n            <>\n              <span\n                aria-hidden\n                className=\"flex size-4 h-5 shrink-0 items-center justify-center\"\n              >\n                {item.status === \"done\" ? (\n                  <span className=\"border-foreground/20 bg-foreground/[0.06] flex size-3.5 items-center justify-center rounded-[5px] border\">\n                    <CheckIcon className=\"text-muted-foreground size-2.5\" />\n                  </span>\n                ) : item.status === \"failed\" ? (\n                  <span className=\"flex size-3.5 items-center justify-center rounded-[5px] border border-red-600/25 bg-red-600/[0.08] dark:border-red-400/25 dark:bg-red-400/[0.08]\">\n                    <XIcon className=\"size-2.5 text-red-600 dark:text-red-400\" />\n                  </span>\n                ) : item.status === \"cancelled\" ? (\n                  <span className=\"border-foreground/15 text-muted-foreground flex size-3.5 items-center justify-center rounded-[5px] border\">\n                    <MinusIcon className=\"size-2.5\" />\n                  </span>\n                ) : item.status === \"active\" ? (\n                  <Loader2Icon className=\"size-3.5 animate-spin text-blue-500 motion-reduce:animate-none dark:text-blue-400\" />\n                ) : (\n                  <span className=\"border-foreground/15 size-3.5 rounded-[5px] border\" />\n                )}\n              </span>\n              <span className=\"sr-only\">{item.status}</span>\n              <div className=\"min-w-0 flex-1 leading-5 break-words\">\n                <span\n                  className={cn(\n                    item.status === \"done\" &&\n                      \"text-muted-foreground line-through decoration-[1.5px]\",\n                    item.status === \"active\" && \"text-foreground/90\",\n                    item.status === \"pending\" && \"text-muted-foreground\",\n                    item.status === \"failed\" &&\n                      \"text-red-600 dark:text-red-400\",\n                    item.status === \"cancelled\" &&\n                      \"text-muted-foreground line-through decoration-[1.5px]\",\n                  )}\n                >\n                  {item.text}\n                </span>\n                {item.status === \"failed\" ? (\n                  item.reason ? (\n                    <p className=\"text-muted-foreground text-xs leading-4 break-words\">\n                      {item.reason}\n                    </p>\n                  ) : null\n                ) : item.status !== \"cancelled\" && item.description ? (\n                  <p className=\"text-muted-foreground text-xs leading-4 break-words\">\n                    {item.description}\n                  </p>\n                ) : null}\n              </div>\n            </>\n          );\n\n          if (collapsed && !expanded) return null;\n\n          return (\n            <li\n              key={item.id}\n              data-status={item.status}\n              className={rowClassName}\n            >\n              {row}\n            </li>\n          );\n        })}\n      </ul>\n      {canFold ? (\n        <button\n          type=\"button\"\n          aria-expanded={expanded}\n          aria-controls={listId}\n          onClick={() => setExpanded((current) => !current)}\n          className={cn(\n            ghostButton,\n            \"self-start px-2 py-1 text-xs font-medium\",\n          )}\n        >\n          {expanded ? \"Show less\" : `Show ${hiddenItems.length} more`}\n        </button>\n      ) : null}\n    </div>\n  );\n}\n"
    }
  ]
}