{
  "schemaVersion": 1,
  "target": "react",
  "name": "conversation-list",
  "version": "0.1.0",
  "category": "ai-elements",
  "title": "Conversation List",
  "description": "The sidebar list of past chats, grouped into Pinned, Today, Yesterday, Previous 7 days, and Older, with search, pinning, inline rename, delete with undo, and a mark for chats an agent is still working on.",
  "tags": [
    "ai",
    "chat",
    "sidebar",
    "history",
    "conversations",
    "navigation"
  ],
  "requires": {
    "projectTypes": [
      "next",
      "vite-react"
    ],
    "styling": "tailwind-v4"
  },
  "npmDependencies": {
    "@base-ui/react": "^1.9.0",
    "motion": "^14.14.0"
  },
  "registryDependencies": [
    {
      "name": "agent-state",
      "version": "0.1.0"
    },
    {
      "name": "dropdown-menu",
      "version": "0.2.1"
    }
  ],
  "docsPath": "/components/conversation-list",
  "props": [
    {
      "name": "conversations",
      "type": "{ id, title, updatedAt, pinned?, status?, activity?, href? }[]",
      "description": "The chats. updatedAt decides the group; status is running, waiting, or failed."
    },
    {
      "name": "selectedId",
      "type": "string | null",
      "description": "The open chat, marked with aria-current."
    },
    {
      "name": "onSelect",
      "type": "(id) => void",
      "description": "Called when a row is chosen."
    },
    {
      "name": "onPinChange",
      "type": "(id, pinned) => void",
      "description": "Shows Pin and Unpin. Update pinned in your data and the row glides to its group."
    },
    {
      "name": "onRename",
      "type": "(id, title) => void",
      "description": "Shows Rename, also on F2 or double click, as an inline field."
    },
    {
      "name": "onDelete",
      "type": "(id) => void",
      "description": "Shows Delete, also on Delete or Backspace. Called once the undo window passes."
    },
    {
      "name": "undoMs",
      "type": "number",
      "default": "5000",
      "description": "How long Undo stays available."
    },
    {
      "name": "searchable",
      "type": "boolean",
      "default": "true",
      "description": "Shows the search field."
    },
    {
      "name": "now",
      "type": "Date",
      "description": "Reference time for the groups. Pass it when rendering on the server."
    },
    {
      "name": "label",
      "type": "string",
      "default": "\"Chats\"",
      "description": "Accessible name of the navigation landmark."
    },
    {
      "name": "empty",
      "type": "ReactNode",
      "description": "Shown when there are no chats."
    }
  ],
  "accessibility": [
    "A navigation landmark with one labeled section per group. Rows are buttons (or links with href) with a single roving tab stop; the open chat has aria-current=\"page\".",
    "Up and Down move between rows (Up from the first row returns to search, Down from search enters the list), Home and End jump, F2 renames, and Delete or Backspace deletes.",
    "Each row's More actions menu is a Base UI Menu reachable with Tab from the focused row. Rename is an inline field: Enter saves, Escape cancels, and focus returns to the row.",
    "After a delete, focus moves to the next row and a status region offers Undo; pins, deletes, and restores are announced.",
    "Running, waiting for approval, and failed are spoken as part of the row name; the agent mark and glyphs are decorative.",
    "With reduced motion rows move to their new group without gliding, the agent mark holds a still frame, and the undo timer line stays full."
  ],
  "states": [
    "idle",
    "running",
    "waiting",
    "failed",
    "pinned",
    "renaming",
    "deleted with undo",
    "no results"
  ],
  "files": [
    {
      "path": "agent/conversation-list.tsx",
      "content": "\"use client\";\n\nimport { AnimatePresence, LayoutGroup, MotionConfig, motion, type Transition } from \"motion/react\";\nimport { type ComponentProps, type KeyboardEvent, type ReactNode, useEffect, useId, useMemo, useRef, useState } from \"react\";\nimport { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from \"../ui/dropdown-menu\";\nimport { type AgentActivity, AgentMark } from \"./agent-state\";\n\nfunction cx(...classes: (string | false | null | undefined)[]) {\n  return classes.filter(Boolean).join(\" \");\n}\n\nconst ease = \"ease-[cubic-bezier(0.23,1,0.32,1)]\";\nconst move: Transition = { type: \"spring\", bounce: 0, duration: 0.35 };\n\n/*\n * Conversation list: the sidebar of past chats.\n *\n * Rows are grouped by Pinned, Today, Yesterday, Previous 7 days, and Older. Pinning a chat\n * glides its row into the Pinned group (Motion shared layout, transform only); deleting folds\n * the row out and leaves an undo bar whose hairline runs down the time left. A chat an agent is\n * still working on carries the Agent State mark, a slow loop that pauses offscreen. With reduced\n * motion rows jump to their place and the mark holds still.\n */\n\nexport type ConversationStatus = \"running\" | \"waiting\" | \"failed\";\nexport type Timestamp = Date | string | number;\n\nexport interface Conversation {\n  id: string;\n  title: string;\n  /** Last activity; decides the group. */\n  updatedAt: Timestamp;\n  pinned?: boolean;\n  /** running shows the animated mark; waiting (for approval) and failed show their glyphs. */\n  status?: ConversationStatus;\n  /** Which Agent State mark runs while `status` is running. Defaults to thinking. */\n  activity?: AgentActivity;\n  /** Renders the row as a link instead of a button. */\n  href?: string;\n}\n\nexport interface ConversationListProps extends Omit<ComponentProps<\"nav\">, \"onSelect\"> {\n  conversations: Conversation[];\n  /** The open chat, marked with aria-current. */\n  selectedId?: string | null;\n  /** Called when a row is chosen with a click, Enter, or Space. */\n  onSelect?: (id: string) => void;\n  /** Shows Pin and Unpin in each row's menu. Update `pinned` in your data. */\n  onPinChange?: (id: string, pinned: boolean) => void;\n  /** Shows Rename (menu, F2, or double click). Update the title in your data. */\n  onRename?: (id: string, title: string) => void;\n  /** Shows Delete (menu, Delete, or Backspace). Called once the undo window has passed. */\n  onDelete?: (id: string) => void;\n  /** How long Undo stays available after a delete. */\n  undoMs?: number;\n  /** Shows the search field. */\n  searchable?: boolean;\n  /** Reference time for the date groups. Pass it when rendering on the server to avoid a mismatch. */\n  now?: Date;\n  /** Accessible name of the navigation landmark. */\n  label?: string;\n  /** Shown when there are no chats at all. */\n  empty?: ReactNode;\n}\n\ntype GroupName = \"Pinned\" | \"Today\" | \"Yesterday\" | \"Previous 7 days\" | \"Older\";\nconst order: GroupName[] = [\"Pinned\", \"Today\", \"Yesterday\", \"Previous 7 days\", \"Older\"];\n\nfunction toDate(value: Timestamp): Date {\n  return value instanceof Date ? value : new Date(value);\n}\n\nfunction groupOf(conversation: Conversation, now: Date): GroupName {\n  if (conversation.pinned) return \"Pinned\";\n  const day = new Date(now.getFullYear(), now.getMonth(), now.getDate()).getTime();\n  const at = toDate(conversation.updatedAt).getTime();\n  if (at >= day) return \"Today\";\n  if (at >= day - 86_400_000) return \"Yesterday\";\n  if (at >= day - 7 * 86_400_000) return \"Previous 7 days\";\n  return \"Older\";\n}\n\n/** A sidebar list of past chats, grouped by date, with search, pin, inline rename, delete with undo, and a running indicator. */\nexport function ConversationList({\n  conversations,\n  selectedId,\n  onSelect,\n  onPinChange,\n  onRename,\n  onDelete,\n  undoMs = 5000,\n  searchable = true,\n  now: nowProp,\n  label = \"Chats\",\n  empty,\n  className,\n  ...props\n}: ConversationListProps) {\n  const [query, setQuery] = useState(\"\");\n  const [pending, setPending] = useState<Conversation[]>([]);\n  const [renaming, setRenaming] = useState<string | null>(null);\n  const [focused, setFocused] = useState<string | null>(null);\n  const [announcement, setAnnouncement] = useState(\"\");\n  const [now, setNow] = useState<Date | null>(nowProp ?? null);\n  const rowRefs = useRef(new Map<string, HTMLElement>());\n  const searchRef = useRef<HTMLInputElement>(null);\n  const timer = useRef<ReturnType<typeof setTimeout>>(undefined);\n  const pendingRef = useRef(pending);\n  const onDeleteRef = useRef(onDelete);\n  useEffect(() => {\n    pendingRef.current = pending;\n    onDeleteRef.current = onDelete;\n  });\n  const searchId = useId();\n\n  // Without `now`, group against the client clock after mount, so server and client agree.\n  useEffect(() => {\n    if (!nowProp) setNow(new Date());\n  }, [nowProp]);\n  const reference = nowProp ?? now ?? new Date(0);\n\n  // Leaving the page or unmounting commits whatever is still waiting for undo.\n  useEffect(\n    () => () => {\n      clearTimeout(timer.current);\n      for (const item of pendingRef.current) onDeleteRef.current?.(item.id);\n    },\n    [],\n  );\n\n  const hidden = useMemo(() => new Set(pending.map((item) => item.id)), [pending]);\n  const q = query.trim().toLowerCase();\n  const visible = conversations.filter((item) => !hidden.has(item.id) && (!q || item.title.toLowerCase().includes(q)));\n  const groups = order\n    .map((name) => ({\n      name,\n      items: visible\n        .filter((item) => groupOf(item, reference) === name)\n        .sort((a, b) => toDate(b.updatedAt).getTime() - toDate(a.updatedAt).getTime()),\n    }))\n    .filter((group) => group.items.length > 0);\n  const flat = groups.flatMap((group) => group.items);\n  const tabStop = flat.find((item) => item.id === focused)?.id ?? flat.find((item) => item.id === selectedId)?.id ?? flat[0]?.id;\n\n  function focusRow(id: string | undefined) {\n    if (!id) return;\n    setFocused(id);\n    rowRefs.current.get(id)?.focus();\n  }\n\n  function commitDeletes() {\n    clearTimeout(timer.current);\n    const items = pendingRef.current;\n    pendingRef.current = [];\n    setPending([]);\n    for (const item of items) onDeleteRef.current?.(item.id);\n  }\n\n  function remove(item: Conversation) {\n    const index = flat.findIndex((other) => other.id === item.id);\n    const next = flat[index + 1] ?? flat[index - 1];\n    pendingRef.current = [...pendingRef.current, item];\n    setPending(pendingRef.current);\n    setAnnouncement(`Deleted ${item.title}. Undo is available.`);\n    clearTimeout(timer.current);\n    timer.current = setTimeout(commitDeletes, undoMs);\n    if (next && rowRefs.current.get(item.id) === document.activeElement) requestAnimationFrame(() => focusRow(next.id));\n  }\n\n  function undo() {\n    clearTimeout(timer.current);\n    const restored = pendingRef.current;\n    pendingRef.current = [];\n    setPending([]);\n    setAnnouncement(restored.length === 1 ? `Restored ${restored[0]!.title}` : `Restored ${restored.length} chats`);\n    const last = restored[restored.length - 1];\n    if (last) requestAnimationFrame(() => focusRow(last.id));\n  }\n\n  function rename(id: string, title: string) {\n    setRenaming(null);\n    const current = conversations.find((item) => item.id === id);\n    const next = title.trim();\n    if (current && next && next !== current.title) onRename?.(id, next);\n    requestAnimationFrame(() => focusRow(id));\n  }\n\n  function onRowKeyDown(event: KeyboardEvent<HTMLElement>, item: Conversation, index: number) {\n    if (event.metaKey || event.ctrlKey || event.altKey) return;\n    switch (event.key) {\n      case \"ArrowDown\":\n        focusRow(flat[index + 1]?.id);\n        break;\n      case \"ArrowUp\":\n        if (index === 0 && searchable) searchRef.current?.focus();\n        else focusRow(flat[index - 1]?.id);\n        break;\n      case \"Home\":\n        focusRow(flat[0]?.id);\n        break;\n      case \"End\":\n        focusRow(flat[flat.length - 1]?.id);\n        break;\n      case \"F2\":\n        if (!onRename) return;\n        setRenaming(item.id);\n        break;\n      case \"Delete\":\n      case \"Backspace\":\n        if (!onDelete) return;\n        remove(item);\n        break;\n      default:\n        return;\n    }\n    event.preventDefault();\n  }\n\n  const hasMenu = onPinChange !== undefined || onRename !== undefined || onDelete !== undefined;\n  const searching = q.length > 0;\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <nav aria-label={label} className={cx(\"relative flex min-h-0 w-full flex-col text-left text-zinc-950 dark:text-white\", className)} {...props}>\n        {searchable ? (\n          <div className=\"relative px-1 pb-2\">\n            <label htmlFor={searchId} className=\"sr-only\">\n              Search chats\n            </label>\n            <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" className=\"pointer-events-none absolute top-[15px] left-3.5 size-4 -translate-y-1/2 text-zinc-500\">\n              <circle cx=\"7\" cy=\"7\" r=\"4.25\" />\n              <path d=\"m10.25 10.25 3 3\" />\n            </svg>\n            <input\n              ref={searchRef}\n              id={searchId}\n              type=\"search\"\n              value={query}\n              onChange={(event) => setQuery(event.target.value)}\n              onKeyDown={(event) => {\n                if (event.key === \"ArrowDown\") {\n                  event.preventDefault();\n                  focusRow(flat[0]?.id);\n                } else if (event.key === \"Escape\" && query) {\n                  event.preventDefault();\n                  setQuery(\"\");\n                }\n              }}\n              placeholder=\"Search chats\"\n              autoComplete=\"off\"\n              className={cx(\n                \"h-8 w-full rounded-lg border border-zinc-950/10 bg-white pr-2.5 pl-8 text-sm text-zinc-950 placeholder:text-zinc-500 [&::-webkit-search-cancel-button]:hidden\",\n                \"transition-[border-color] duration-150 ease-out hover:border-zinc-950/20 motion-reduce:transition-none\",\n                \"dark:border-white/10 dark:bg-black dark:text-white dark:hover:border-white/20\",\n                \"focus-visible:border-sky-500/60 focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-0 focus-visible:outline-sky-500/40\",\n              )}\n            />\n          </div>\n        ) : null}\n\n        <div className=\"min-h-0 flex-1 overflow-y-auto px-1 pb-1\">\n          {groups.length === 0 ? (\n            <p className=\"px-2 py-6 text-center text-sm text-zinc-500\">\n              {searching ? `No chats match \"${query.trim()}\"` : (empty ?? \"No chats yet\")}\n            </p>\n          ) : (\n            <LayoutGroup>\n              {groups.map((group) => {\n                const headingId = `${searchId}-${group.name.replace(/\\s+/g, \"-\")}`;\n                return (\n                  <motion.section key={group.name} layout={searching ? false : \"position\"} transition={move} aria-labelledby={headingId} className=\"mt-3 first:mt-0\">\n                    <motion.h3 layout={searching ? false : \"position\"} transition={move} id={headingId} className=\"px-2 pt-1 pb-1 text-xs font-medium text-zinc-500\">\n                      {group.name}\n                    </motion.h3>\n                    <ul className=\"flex flex-col gap-px\">\n                      <AnimatePresence initial={false} mode=\"popLayout\">\n                        {group.items.map((item) => {\n                          const index = flat.indexOf(item);\n                          return (\n                            <motion.li\n                              key={item.id}\n                              layoutId={searching ? undefined : `conversation-${searchId}-${item.id}`}\n                              layout={searching ? false : \"position\"}\n                              transition={move}\n                              initial={{ opacity: 0 }}\n                              animate={{ opacity: 1 }}\n                              exit={{ opacity: 0, scale: 0.98, transition: { duration: 0.15, ease: \"easeOut\" } }}\n                            >\n                              <Row\n                                item={item}\n                                query={q}\n                                selected={item.id === selectedId}\n                                tabStop={item.id === tabStop}\n                                renaming={renaming === item.id}\n                                hasMenu={hasMenu}\n                                canPin={onPinChange !== undefined}\n                                canRename={onRename !== undefined}\n                                canDelete={onDelete !== undefined}\n                                rowRef={(el) => {\n                                  if (el) rowRefs.current.set(item.id, el);\n                                  else rowRefs.current.delete(item.id);\n                                }}\n                                onFocus={() => setFocused(item.id)}\n                                onKeyDown={(event) => onRowKeyDown(event, item, index)}\n                                onSelect={() => onSelect?.(item.id)}\n                                onPin={() => {\n                                  onPinChange?.(item.id, !item.pinned);\n                                  setAnnouncement(item.pinned ? `Unpinned ${item.title}` : `Pinned ${item.title}`);\n                                }}\n                                onStartRename={() => setRenaming(item.id)}\n                                onRename={(title) => rename(item.id, title)}\n                                onCancelRename={() => {\n                                  setRenaming(null);\n                                  requestAnimationFrame(() => focusRow(item.id));\n                                }}\n                                onDelete={() => remove(item)}\n                              />\n                            </motion.li>\n                          );\n                        })}\n                      </AnimatePresence>\n                    </ul>\n                  </motion.section>\n                );\n              })}\n            </LayoutGroup>\n          )}\n        </div>\n\n        {pending.length > 0 ? (\n          <div\n            role=\"status\"\n            className={cx(\n              \"relative mx-1 mt-1 flex h-10 shrink-0 items-center gap-2 overflow-hidden rounded-lg border border-zinc-950/10 bg-white pr-1 pl-3 text-sm shadow-[0_8px_24px_-12px_rgb(0_0_0/0.25)]\",\n              \"dark:border-white/15 dark:bg-black dark:shadow-[0_12px_32px_-12px_rgb(0_0_0/1),inset_0_1px_0_rgb(255_255_255/0.08)]\",\n              \"transition-[opacity,translate] duration-[260ms] motion-reduce:transition-none\",\n              ease,\n              \"starting:translate-y-2 starting:opacity-0\",\n            )}\n          >\n            <span className=\"min-w-0 flex-1 truncate text-zinc-600 dark:text-zinc-400\">\n              {pending.length === 1 ? (\n                <>\n                  Deleted <span className=\"text-zinc-950 dark:text-white\">{pending[0]!.title}</span>\n                </>\n              ) : (\n                `Deleted ${pending.length} chats`\n              )}\n            </span>\n            <button\n              type=\"button\"\n              onClick={undo}\n              className={cx(\n                \"inline-flex h-8 shrink-0 cursor-pointer items-center rounded-md px-2.5 text-sm font-medium text-zinc-950 select-none dark:text-white\",\n                \"transition-[background-color,scale] duration-150 ease-out hover:bg-zinc-950/[0.05] motion-safe:active:scale-[0.97] motion-reduce:transition-none dark:hover:bg-white/[0.08]\",\n                \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-2 focus-visible:outline-sky-500\",\n              )}\n            >\n              Undo\n            </button>\n            {/* Time left to undo; restarts with each delete. Still under reduced motion. */}\n            <span\n              key={pending.length}\n              aria-hidden=\"true\"\n              style={{ transitionDuration: `${undoMs}ms` }}\n              className={cx(\n                \"absolute inset-x-0 bottom-0 h-px origin-left bg-zinc-950/30 dark:bg-white/35\",\n                \"scale-x-0 transition-[scale] ease-linear starting:scale-x-100 motion-reduce:scale-x-100 motion-reduce:transition-none\",\n              )}\n            />\n          </div>\n        ) : null}\n        <span className=\"sr-only\" aria-live=\"polite\">\n          {announcement}\n        </span>\n      </nav>\n    </MotionConfig>\n  );\n}\n\n// ---------------------------------------------------------------------------\n// Row\n\ninterface RowProps {\n  item: Conversation;\n  query: string;\n  selected: boolean;\n  tabStop: boolean;\n  renaming: boolean;\n  hasMenu: boolean;\n  canPin: boolean;\n  canRename: boolean;\n  canDelete: boolean;\n  rowRef: (el: HTMLElement | null) => void;\n  onFocus: () => void;\n  onKeyDown: (event: KeyboardEvent<HTMLElement>) => void;\n  onSelect: () => void;\n  onPin: () => void;\n  onStartRename: () => void;\n  onRename: (title: string) => void;\n  onCancelRename: () => void;\n  onDelete: () => void;\n}\n\nfunction Row({\n  item,\n  query,\n  selected,\n  tabStop,\n  renaming,\n  hasMenu,\n  canPin,\n  canRename,\n  canDelete,\n  rowRef,\n  onFocus,\n  onKeyDown,\n  onSelect,\n  onPin,\n  onStartRename,\n  onRename,\n  onCancelRename,\n  onDelete,\n}: RowProps) {\n  const [menuOpen, setMenuOpen] = useState(false);\n  const rowClass = cx(\n    \"flex h-9 min-w-0 flex-1 cursor-pointer items-center gap-2 rounded-lg pr-1 pl-2 text-left text-sm select-none\",\n    selected ? \"text-zinc-950 dark:text-white\" : \"text-zinc-700 dark:text-zinc-300\",\n    \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-sky-500\",\n  );\n  const content = (\n    <>\n      <span className=\"min-w-0 flex-1 truncate\">\n        <Highlight text={item.title} query={query} />\n      </span>\n      <StatusMark item={item} />\n    </>\n  );\n  const common = {\n    ref: rowRef,\n    tabIndex: tabStop ? 0 : -1,\n    \"aria-current\": selected ? (\"page\" as const) : undefined,\n    onFocus,\n    onKeyDown,\n    onDoubleClick: canRename ? onStartRename : undefined,\n    className: rowClass,\n  };\n\n  return (\n    <div\n      data-selected={selected || undefined}\n      className={cx(\n        \"group/row relative flex items-center rounded-lg\",\n        \"transition-colors duration-150 ease-out motion-reduce:transition-none\",\n        selected ? \"bg-zinc-950/[0.06] dark:bg-white/[0.09]\" : \"hover:bg-zinc-950/[0.04] dark:hover:bg-white/[0.06]\",\n        menuOpen && !selected && \"bg-zinc-950/[0.04] dark:bg-white/[0.06]\",\n      )}\n    >\n      {renaming ? (\n        <RenameField title={item.title} onCommit={onRename} onCancel={onCancelRename} />\n      ) : item.href ? (\n        <a href={item.href} onClick={onSelect} {...common}>\n          {content}\n        </a>\n      ) : (\n        <button\n          type=\"button\"\n          onClick={onSelect}\n          {...common}\n        >\n          {content}\n        </button>\n      )}\n      {hasMenu && !renaming ? (\n        <DropdownMenu open={menuOpen} onOpenChange={setMenuOpen}>\n          <DropdownMenuTrigger\n            tabIndex={tabStop ? 0 : -1}\n            aria-label={`More actions for ${item.title}`}\n            className={cx(\n              \"mr-1 inline-flex size-7 shrink-0 cursor-pointer items-center justify-center rounded-md text-zinc-500\",\n              \"opacity-0 transition-[opacity,background-color,color] duration-150 ease-out motion-reduce:transition-none\",\n              \"group-hover/row:opacity-100 group-focus-within/row:opacity-100 data-[popup-open]:opacity-100 [@media(hover:none)]:opacity-100\",\n              \"hover:bg-zinc-950/[0.06] hover:text-zinc-950 dark:hover:bg-white/[0.09] dark:hover:text-white\",\n              \"focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-0 focus-visible:outline-sky-500\",\n            )}\n          >\n            <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"currentColor\" className=\"size-4\">\n              <circle cx=\"3.75\" cy=\"8\" r=\"1.1\" />\n              <circle cx=\"8\" cy=\"8\" r=\"1.1\" />\n              <circle cx=\"12.25\" cy=\"8\" r=\"1.1\" />\n            </svg>\n          </DropdownMenuTrigger>\n          <DropdownMenuContent align=\"end\" className=\"min-w-44\">\n            {canPin ? (\n              <DropdownMenuItem onClick={onPin}>\n                <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                  {item.pinned ? (\n                    <path d=\"M2.75 2.75l10.5 10.5M8 11.25v3M5.75 3.25h4.5M6.25 3.25v3.5L4.25 9.25v1.5h6.5\" />\n                  ) : (\n                    <path d=\"M8 11.25v3M5.75 1.75h4.5M6.25 1.75v4.5L4.25 8.75v2.5h7.5v-2.5l-2-2.5v-4.5\" />\n                  )}\n                </svg>\n                {item.pinned ? \"Unpin\" : \"Pin\"}\n              </DropdownMenuItem>\n            ) : null}\n            {canRename ? (\n              <DropdownMenuItem onClick={onStartRename}>\n                <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                  <path d=\"M10.25 3.25 12.75 5.75M3.25 12.75l.6-2.75 7.4-7.4a1.4 1.4 0 0 1 2 2l-7.4 7.4z\" />\n                </svg>\n                Rename\n              </DropdownMenuItem>\n            ) : null}\n            {canDelete ? (\n              <>\n                {canPin || canRename ? <DropdownMenuSeparator /> : null}\n                <DropdownMenuItem destructive onClick={onDelete}>\n                  <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n                    <path d=\"M3 4.5h10M6.5 4.5V3.25c0-.28.22-.5.5-.5h2c.28 0 .5.22.5.5V4.5M4.5 4.5l.6 8.1c.04.52.47.9.99.9h3.82c.52 0 .95-.38.99-.9l.6-8.1\" />\n                  </svg>\n                  Delete\n                </DropdownMenuItem>\n              </>\n            ) : null}\n          </DropdownMenuContent>\n        </DropdownMenu>\n      ) : null}\n    </div>\n  );\n}\n\nfunction StatusMark({ item }: { item: Conversation }) {\n  if (item.status === \"running\") {\n    return (\n      <span className=\"flex shrink-0 items-center\">\n        <AgentMark activity={item.activity ?? \"thinking\"} size={14} aria-hidden=\"true\" className=\"text-zinc-700 dark:text-zinc-300\" />\n        <span className=\"sr-only\">, agent working</span>\n      </span>\n    );\n  }\n  if (item.status === \"waiting\" || item.status === \"failed\") {\n    const waiting = item.status === \"waiting\";\n    return (\n      <span className={cx(\"flex shrink-0 items-center\", waiting ? \"text-amber-600 dark:text-amber-400\" : \"text-red-600 dark:text-red-400\")}>\n        <svg\n          aria-hidden=\"true\"\n          viewBox=\"0 0 16 16\"\n          fill=\"none\"\n          stroke=\"currentColor\"\n          strokeWidth=\"1.5\"\n          strokeLinecap=\"round\"\n          className={cx(\"size-3.5 transition-[opacity,scale] duration-200 motion-reduce:transition-none\", ease, \"starting:scale-90 starting:opacity-0\")}\n        >\n          <circle cx=\"8\" cy=\"8\" r=\"6.25\" />\n          {waiting ? <path d=\"M6.5 5.75v4.5M9.5 5.75v4.5\" /> : <path d=\"m6 6 4 4M10 6l-4 4\" />}\n        </svg>\n        <span className=\"sr-only\">{waiting ? \", waiting for approval\" : \", run failed\"}</span>\n      </span>\n    );\n  }\n  return null;\n}\n\nfunction RenameField({ title, onCommit, onCancel }: { title: string; onCommit: (title: string) => void; onCancel: () => void }) {\n  const [value, setValue] = useState(title);\n  const ref = useRef<HTMLInputElement>(null);\n  const done = useRef(false);\n  useEffect(() => {\n    ref.current?.focus();\n    ref.current?.select();\n  }, []);\n  return (\n    <input\n      ref={ref}\n      aria-label=\"Chat title\"\n      value={value}\n      onChange={(event) => setValue(event.target.value)}\n      onKeyDown={(event) => {\n        if (event.key === \"Enter\") {\n          event.preventDefault();\n          done.current = true;\n          onCommit(value);\n        } else if (event.key === \"Escape\") {\n          event.preventDefault();\n          done.current = true;\n          onCancel();\n        }\n      }}\n      onBlur={() => {\n        if (!done.current) onCommit(value);\n      }}\n      className={cx(\n        \"mx-1 h-8 min-w-0 flex-1 rounded-md border border-sky-500/60 bg-white px-1.5 text-sm text-zinc-950 outline-2 outline-sky-500/30\",\n        \"dark:bg-black dark:text-white\",\n      )}\n    />\n  );\n}\n\nfunction Highlight({ text, query }: { text: string; query: string }) {\n  if (!query) return <>{text}</>;\n  const at = text.toLowerCase().indexOf(query);\n  if (at < 0) return <>{text}</>;\n  return (\n    <>\n      {text.slice(0, at)}\n      <mark className=\"rounded-[3px] bg-sky-500/20 text-inherit dark:bg-sky-400/25\">{text.slice(at, at + query.length)}</mark>\n      {text.slice(at + query.length)}\n    </>\n  );\n}\n"
    }
  ],
  "example": {
    "content": "\"use client\";\n\nimport { useState } from \"react\";\nimport { type Conversation, ConversationList } from \"@/components/shaken/agent/conversation-list\";\n\n// A fixed clock so the groups render the same on the server and in the browser.\nconst now = new Date(\"2026-11-14T16:30:00\");\nconst hoursAgo = (hours: number) => new Date(now.getTime() - hours * 3_600_000);\n\nconst initial: Conversation[] = [\n  { id: \"c1\", title: \"Northwind invoice off by a cent\", updatedAt: hoursAgo(0.2), status: \"running\", activity: \"working\" },\n  { id: \"c2\", title: \"Migrate billing webhooks to v2\", updatedAt: hoursAgo(1.5), status: \"waiting\" },\n  { id: \"c3\", title: \"Draft the Q4 pricing FAQ\", updatedAt: hoursAgo(3), pinned: true },\n  { id: \"c4\", title: \"Why is the staging deploy slow\", updatedAt: hoursAgo(5), status: \"failed\" },\n  { id: \"c5\", title: \"Summarize churn interviews\", updatedAt: hoursAgo(20) },\n  { id: \"c6\", title: \"Rate limit headers for the public API\", updatedAt: hoursAgo(26) },\n  { id: \"c7\", title: \"Postgres index for invoice search\", updatedAt: hoursAgo(50) },\n  { id: \"c8\", title: \"Onboarding email sequence, second pass\", updatedAt: hoursAgo(96) },\n  { id: \"c9\", title: \"Compare Stripe Tax and Avalara\", updatedAt: hoursAgo(240) },\n  { id: \"c10\", title: \"Holiday on-call rotation\", updatedAt: hoursAgo(600) },\n];\n\nexport default function ConversationListExample() {\n  const [conversations, setConversations] = useState(initial);\n  const [selectedId, setSelectedId] = useState(\"c1\");\n  const update = (id: string, patch: Partial<Conversation>) =>\n    setConversations((current) => current.map((item) => (item.id === id ? { ...item, ...patch } : item)));\n\n  return (\n    <div className=\"flex h-[30rem] w-full max-w-72 flex-col rounded-xl border border-zinc-950/10 bg-white p-2 shadow-[0_1px_2px_rgb(0_0_0/0.04)] dark:border-white/10 dark:bg-black dark:shadow-[inset_0_1px_0_rgb(255_255_255/0.06)]\">\n      <ConversationList\n        className=\"flex-1\"\n        now={now}\n        conversations={conversations}\n        selectedId={selectedId}\n        onSelect={setSelectedId}\n        onPinChange={(id, pinned) => update(id, { pinned })}\n        onRename={(id, title) => update(id, { title })}\n        onDelete={(id) => setConversations((current) => current.filter((item) => item.id !== id))}\n      />\n    </div>\n  );\n}\n"
  }
}
