{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "elements-thread-list",
  "type": "registry:component",
  "title": "Thread list",
  "description": "Conversation history with unread marks and actions that wait for hover.",
  "registryDependencies": [
    "https://r.assistant-ui.com/elements-surfaces.json"
  ],
  "dependencies": [
    "lucide-react"
  ],
  "files": [
    {
      "type": "registry:component",
      "path": "components/assistant-ui/elements/thread-list.tsx",
      "sourcePath": "packages/ui/src/components/react/assistant-ui/elements/thread-list.tsx",
      "content": "\"use client\";\n\nimport type { ComponentProps } from \"react\";\nimport { PencilIcon, Trash2Icon } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\nimport { field, mono } from \"./surfaces\";\n\nexport interface ThreadItem {\n  id: string;\n  title: string;\n  time: string;\n  unread?: boolean;\n}\n\nexport function ThreadList({\n  threads,\n  activeIndex,\n  onActiveIndexChange,\n  onRename,\n  onDelete,\n  className,\n  ...props\n}: Omit<\n  ComponentProps<\"div\">,\n  | \"children\"\n  | \"threads\"\n  | \"activeIndex\"\n  | \"onActiveIndexChange\"\n  | \"onRename\"\n  | \"onDelete\"\n> & {\n  threads: readonly ThreadItem[];\n  activeIndex: number;\n  onActiveIndexChange?: (index: number) => void;\n  onRename?: (index: number) => void;\n  onDelete?: (index: number) => void;\n}) {\n  return (\n    <div\n      data-slot=\"thread-list\"\n      className={cn(\"flex w-full max-w-[240px] flex-col gap-0.5\", className)}\n\n      {...props}\n    >\n      <div className={cn(mono, \"text-muted-foreground px-3 pb-1.5\")}>Today</div>\n      {threads.map((thread, i) => {\n        const active = i === activeIndex;\n        const hasActions = onRename !== undefined || onDelete !== undefined;\n        const hasTwoActions = onRename !== undefined && onDelete !== undefined;\n        const rowClassName = cn(\n          \"group relative flex w-full items-center rounded-xl text-[13.5px] transition-colors\",\n          active\n            ? field\n            : onActiveIndexChange\n              ? \"hover:bg-foreground/[0.03]\"\n              : undefined,\n        );\n        const contentClassName = cn(\n          \"flex min-w-0 flex-1 items-center justify-between gap-2 rounded-xl px-3 py-2 text-start\",\n          hasActions &&\n            (onActiveIndexChange\n              ? hasTwoActions\n                ? \"group-focus-within:pe-14 group-hover:pe-14\"\n                : \"group-focus-within:pe-9 group-hover:pe-9\"\n              : hasTwoActions\n                ? \"pe-14\"\n                : \"pe-9\"),\n        );\n        const content = (\n          <>\n            <span className=\"flex-1 truncate\">{thread.title}</span>\n            <span\n              className={cn(\n                mono,\n                \"text-muted-foreground flex items-center gap-1.5 tabular-nums\",\n                hasActions &&\n                  onActiveIndexChange &&\n                  \"group-focus-within:hidden group-hover:hidden\",\n              )}\n            >\n              {thread.unread && !active && (\n                <>\n                  <span\n                    aria-hidden\n                    className=\"size-1.5 rounded-full bg-blue-500 dark:bg-blue-400\"\n                  />\n                  <span className=\"sr-only\">unread</span>\n                </>\n              )}\n              {thread.time}\n            </span>\n          </>\n        );\n\n        return (\n          <div key={thread.id} className={rowClassName}>\n            {onActiveIndexChange ? (\n              <button\n                type=\"button\"\n                aria-current={active || undefined}\n                onClick={() => onActiveIndexChange(i)}\n                className={contentClassName}\n              >\n                {content}\n              </button>\n            ) : (\n              <div\n                aria-current={active || undefined}\n                className={contentClassName}\n              >\n                {content}\n              </div>\n            )}\n            {hasActions && (\n              <div\n                className={cn(\n                  \"absolute end-2 flex items-center gap-0.5\",\n                  onActiveIndexChange &&\n                    \"opacity-0 group-focus-within:opacity-100 group-hover:opacity-100\",\n                )}\n              >\n                {onRename && (\n                  <button\n                    type=\"button\"\n                    aria-label={`Rename ${thread.title}`}\n                    onClick={() => onRename(i)}\n                    className=\"text-muted-foreground hover:bg-foreground/[0.06] hover:text-foreground/90 rounded-full p-1\"\n                  >\n                    <PencilIcon className=\"size-3\" />\n                  </button>\n                )}\n                {onDelete && (\n                  <button\n                    type=\"button\"\n                    aria-label={`Delete ${thread.title}`}\n                    onClick={() => onDelete(i)}\n                    className=\"text-muted-foreground hover:bg-foreground/[0.06] hover:text-foreground/90 rounded-full p-1\"\n                  >\n                    <Trash2Icon className=\"size-3\" />\n                  </button>\n                )}\n              </div>\n            )}\n          </div>\n        );\n      })}\n    </div>\n  );\n}\n"
    }
  ]
}