{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "agent-timeline",
  "title": "Agent timeline",
  "description": "Vertical log of what an AI agent did, one row per step: an icon for the kind of step (think, search, read, tool, write), the title, a detail line, live running state and a done summary.",
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "registry/components/agent-timeline.tsx",
      "content": "\"use client\";\n\nimport { useEffect, useRef, useState } from \"react\";\nimport {\n  Brain,\n  Check,\n  FileText,\n  Loader2,\n  MessageSquare,\n  PenLine,\n  Search,\n  TriangleAlert,\n  Wrench,\n  type LucideIcon,\n} from \"lucide-react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { cn } from \"@/lib/utils\";\n\nexport type TimelineEventKind = \"think\" | \"search\" | \"read\" | \"tool\" | \"write\" | \"message\" | \"error\";\nexport type TimelineEventStatus = \"running\" | \"done\" | \"error\";\n\n/** One thing the agent did. */\nexport type TimelineEvent = {\n  kind: TimelineEventKind;\n  title: React.ReactNode;\n  /** A short muted line under the title: the query, the file, the arguments. */\n  detail?: React.ReactNode;\n  /** Right-aligned note: a duration, a count. */\n  meta?: string;\n  status?: TimelineEventStatus;\n};\n\nexport type AgentTimelineProps = {\n  /** Header label. */\n  title?: React.ReactNode;\n  events?: TimelineEvent[];\n  /** Footer line once every event is done, e.g. \"Done in 7s\". Leave unset to hide it. */\n  summary?: React.ReactNode;\n  /** Play a scripted run on a loop while on screen, for demos. */\n  autoPlay?: boolean;\n  className?: string;\n};\n\nconst ICONS: Record<TimelineEventKind, LucideIcon> = {\n  think: Brain,\n  search: Search,\n  read: FileText,\n  tool: Wrench,\n  write: PenLine,\n  message: MessageSquare,\n  error: TriangleAlert,\n};\n\nconst DEMO: TimelineEvent[] = [\n  { kind: \"think\", title: \"Planned the reply\", detail: \"Find the thread, check the file, draft\", meta: \"2s\" },\n  { kind: \"search\", title: \"Searched email\", detail: \"from:mara subject:launch\", meta: \"4 results\" },\n  { kind: \"read\", title: \"Read launch-plan.pdf\", detail: \"12 pages · updated Tuesday\", meta: \"1.1s\" },\n  { kind: \"tool\", title: \"Called calendar.find_slot\", detail: \"Thu or Fri, 30 min\", meta: \"0.6s\" },\n  { kind: \"write\", title: \"Drafted the reply\", detail: \"Re: Q4 launch timeline\", meta: \"142 words\" },\n];\n\n// Demo loop, in ms: each event arrives, runs, then settles.\nconst START = 400;\nconst STEP = 1300;\nconst RUN = 950;\nconst HOLD = 3200;\nconst TICK = 50;\n\n/** A vertical log of what an agent did, one row per step, with live status. */\nexport function AgentTimeline({ title = \"Agent activity\", events, summary, autoPlay = false, className }: AgentTimelineProps) {\n  const ref = useRef<HTMLDivElement>(null);\n  const reduce = useReducedMotion();\n  const [visible, setVisible] = useState(false);\n  const [tick, setTick] = useState(0);\n\n  const source = events ?? DEMO;\n  const END = START + source.length * STEP;\n  const LOOP = END + HOLD;\n\n  useEffect(() => {\n    const el = ref.current;\n    if (!el || !autoPlay) return;\n    const io = new IntersectionObserver(([entry]) => setVisible(entry.isIntersecting));\n    io.observe(el);\n    return () => io.disconnect();\n  }, [autoPlay]);\n\n  useEffect(() => {\n    if (!autoPlay || !visible || reduce) return;\n    const id = setInterval(() => setTick((t) => (t + TICK) % LOOP), TICK);\n    return () => clearInterval(id);\n  }, [autoPlay, visible, reduce, LOOP]);\n\n  let shown: TimelineEvent[] = source;\n  let footer = summary;\n  if (autoPlay) {\n    const t = reduce ? LOOP - 1 : tick;\n    shown = source\n      .map((e, i) => {\n        const local = t - START - i * STEP;\n        if (local < 0) return null;\n        return { ...e, status: local < RUN ? \"running\" : \"done\" } as TimelineEvent;\n      })\n      .filter((e): e is TimelineEvent => e !== null);\n    footer = summary ?? (t >= END - STEP + RUN ? `Done in ${Math.round((END - STEP + RUN) / 1000)}s` : undefined);\n  }\n\n  const running = shown.some((e) => e.status === \"running\");\n  const failed = shown.some((e) => e.status === \"error\" || e.kind === \"error\");\n\n  return (\n    <div ref={ref} className={cn(\"w-full max-w-md rounded-xl bg-muted p-1.5 text-foreground\", className)}>\n      <div className=\"rounded-lg border bg-card shadow-xs\">\n        <div className=\"flex items-center gap-2 border-b px-3.5 py-2.5 text-sm\">\n          <span className=\"font-medium\">{title}</span>\n          <span className=\"text-xs text-muted-foreground tabular-nums\">\n            {shown.length} {shown.length === 1 ? \"step\" : \"steps\"}\n          </span>\n          <span className=\"ml-auto flex items-center gap-1.5 text-xs text-muted-foreground\">\n            <span\n              className={cn(\n                \"size-1.5 rounded-full\",\n                running ? \"bg-foreground\" : failed ? \"bg-destructive\" : \"bg-muted-foreground/40\",\n                running && !reduce && \"animate-pulse\",\n              )}\n              aria-hidden\n            />\n            {running ? \"Working\" : failed ? \"Stopped\" : shown.length ? \"Done\" : \"Idle\"}\n          </span>\n        </div>\n\n        <ol className=\"px-3.5 pt-3 pb-1\" aria-live=\"polite\">\n          <AnimatePresence initial={false}>\n            {shown.map((e, i) => (\n              <motion.li\n                key={i}\n                layout={reduce ? false : \"position\"}\n                initial={reduce ? false : { opacity: 0, y: 8, filter: \"blur(3px)\" }}\n                animate={{ opacity: 1, y: 0, filter: \"blur(0px)\" }}\n                exit={reduce ? undefined : { opacity: 0 }}\n                transition={{ duration: 0.35, ease: [0.22, 1, 0.36, 1] }}\n                className=\"relative flex gap-3 pb-3\"\n              >\n                {i < shown.length - 1 && <span className=\"absolute top-7 bottom-0 left-[13px] w-px bg-border\" aria-hidden />}\n                <EventIcon event={e} still={!!reduce} />\n                <div className=\"min-w-0 flex-1 pt-1\">\n                  <div className=\"flex items-baseline gap-2\">\n                    <span className={cn(\"min-w-0 flex-1 truncate text-sm font-medium\", e.status === \"running\" && \"agent-timeline-shimmer\")}>\n                      {e.title}\n                    </span>\n                    {e.meta && e.status !== \"running\" && (\n                      <span className=\"shrink-0 font-mono text-[11px] text-muted-foreground tabular-nums\">{e.meta}</span>\n                    )}\n                  </div>\n                  {e.detail && <p className=\"mt-0.5 truncate text-xs text-muted-foreground\">{e.detail}</p>}\n                </div>\n              </motion.li>\n            ))}\n          </AnimatePresence>\n        </ol>\n\n        <AnimatePresence initial={false}>\n          {footer && (\n            <motion.div\n              initial={reduce ? false : { opacity: 0, height: 0 }}\n              animate={{ opacity: 1, height: \"auto\" }}\n              exit={reduce ? undefined : { opacity: 0, height: 0 }}\n              transition={{ duration: 0.3, ease: [0.22, 1, 0.36, 1] }}\n              className=\"overflow-hidden\"\n            >\n              <div className=\"flex items-center gap-2 border-t px-3.5 py-2.5 text-xs font-medium\">\n                <span className=\"grid size-4 place-items-center rounded-full bg-foreground text-background\" aria-hidden>\n                  <Check className=\"size-2.5\" strokeWidth={3} />\n                </span>\n                {footer}\n              </div>\n            </motion.div>\n          )}\n        </AnimatePresence>\n      </div>\n      <style>{`\n        .agent-timeline-shimmer {\n          color: transparent;\n          background: linear-gradient(90deg, var(--muted-foreground) 40%, var(--foreground) 50%, var(--muted-foreground) 60%) 0 0 / 250% 100%;\n          background-clip: text;\n          -webkit-background-clip: text;\n          animation: agent-timeline-shimmer 2s ease-in-out infinite;\n        }\n        @keyframes agent-timeline-shimmer {\n          from { background-position: 100% 0; }\n          to { background-position: 0% 0; }\n        }\n        @media (prefers-reduced-motion: reduce) {\n          .agent-timeline-shimmer { animation: none; color: var(--muted-foreground); }\n        }\n      `}</style>\n    </div>\n  );\n}\n\nfunction EventIcon({ event, still }: { event: TimelineEvent; still: boolean }) {\n  const failed = event.status === \"error\" || event.kind === \"error\";\n  const Icon = failed ? TriangleAlert : ICONS[event.kind];\n  return (\n    <span\n      className={cn(\n        \"relative z-10 grid size-7 shrink-0 place-items-center rounded-full border bg-background\",\n        failed ? \"border-destructive/40 text-destructive\" : event.status === \"running\" ? \"text-foreground\" : \"text-muted-foreground\",\n      )}\n      aria-hidden\n    >\n      {event.status === \"running\" && !still ? <Loader2 className=\"size-3.5 animate-spin\" /> : <Icon className=\"size-3.5\" />}\n    </span>\n  );\n}\n\nexport default function AgentTimelineDemo() {\n  return <AgentTimeline autoPlay />;\n}\n",
      "type": "registry:component",
      "target": "components/nextui/agent-timeline.tsx"
    }
  ],
  "meta": {
    "kind": "component",
    "category": "ai",
    "previewHeight": 440,
    "new": true,
    "free": true,
    "openSource": true,
    "added": "2026-10-31"
  },
  "categories": [
    "ai"
  ],
  "type": "registry:component"
}