{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "split-shell",
  "type": "registry:block",
  "title": "Split Shell",
  "description": "A frame for working with an agent: tasks on the left, its thread in the middle, and a work panel you can drag or nudge with arrow keys to watch its tool calls tick by, the page it's reading and the sources it will cite.",
  "categories": [
    "screen",
    "Shells"
  ],
  "dependencies": [
    "motion",
    "lucide-react"
  ],
  "registryDependencies": [
    "utils",
    "https://coss.com/ui/r/avatar.json",
    "https://coss.com/ui/r/badge.json",
    "https://coss.com/ui/r/button.json",
    "https://coss.com/ui/r/checkbox.json",
    "https://coss.com/ui/r/kbd.json",
    "https://coss.com/ui/r/tabs.json",
    "https://coss.com/ui/r/tooltip.json"
  ],
  "files": [
    {
      "path": "registry/devl/split-shell.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport { AnimatePresence, LayoutGroup, MotionConfig, motion, useReducedMotion } from \"motion/react\";\nimport {\n  ArrowLeftIcon,\n  ArrowRightIcon,\n  ArrowUpIcon,\n  BookOpenIcon,\n  BotIcon,\n  CheckIcon,\n  ChevronRightIcon,\n  ChevronsUpDownIcon,\n  FileTextIcon,\n  GlobeIcon,\n  InboxIcon,\n  LibraryIcon,\n  LoaderCircleIcon,\n  LockIcon,\n  type LucideIcon,\n  MenuIcon,\n  PanelRightIcon,\n  PaperclipIcon,\n  PlusIcon,\n  RotateCwIcon,\n  SearchIcon,\n  SquareTerminalIcon,\n  WrenchIcon,\n  XIcon,\n} from \"lucide-react\";\nimport {\n  type KeyboardEvent,\n  type PointerEvent,\n  type ReactNode,\n  useCallback,\n  useEffect,\n  useId,\n  useRef,\n  useState,\n} from \"react\";\nimport { Avatar, AvatarFallback } from \"@/components/ui/avatar\";\nimport { Badge } from \"@/components/ui/badge\";\nimport { Button } from \"@/components/ui/button\";\nimport { Checkbox } from \"@/components/ui/checkbox\";\nimport { Kbd } from \"@/components/ui/kbd\";\nimport { Tabs, TabsList, TabsPanel, TabsTab } from \"@/components/ui/tabs\";\nimport { Tooltip, TooltipPopup, TooltipTrigger } from \"@/components/ui/tooltip\";\nimport { cn } from \"@/lib/utils\";\n\nexport interface WorkspaceTask {\n  id: string;\n  title: string;\n  state: \"running\" | \"done\" | \"idle\";\n  time: string;\n}\n\nexport interface WorkspaceToolCall {\n  id: string;\n  tool: string;\n  detail: string;\n  icon: LucideIcon;\n  ms: number;\n  output?: string;\n}\n\nexport interface WorkspaceSource {\n  id: string;\n  title: string;\n  domain: string;\n  cited: number;\n  tone: string;\n}\n\nexport interface SplitShellProps {\n  tasks?: WorkspaceTask[];\n  toolCalls?: WorkspaceToolCall[];\n  sources?: WorkspaceSource[];\n  defaultPanelWidth?: number;\n  minPanelWidth?: number;\n  maxPanelWidth?: number;\n  children?: ReactNode;\n  className?: string;\n}\n\nconst spring = { type: \"spring\", stiffness: 420, damping: 38 } as const;\n\nconst defaultTasks: WorkspaceTask[] = [\n  { id: \"t1\", title: \"Competitive scan: note apps\", state: \"running\", time: \"now\" },\n  { id: \"t2\", title: \"Draft Q4 pricing memo\", state: \"done\", time: \"1h\" },\n  { id: \"t3\", title: \"Summarise churn interviews\", state: \"done\", time: \"Tue\" },\n  { id: \"t4\", title: \"Onboarding email rewrite\", state: \"idle\", time: \"Mon\" },\n  { id: \"t5\", title: \"Clean up the roadmap doc\", state: \"idle\", time: \"Oct 18\" },\n];\n\nconst defaultToolCalls: WorkspaceToolCall[] = [\n  { id: \"c1\", tool: \"web.search\", detail: \"note taking app pricing 2026\", icon: SearchIcon, ms: 820, output: \"14 results · 6 kept\" },\n  { id: \"c2\", tool: \"browser.open\", detail: \"quillpad.app/pricing\", icon: GlobeIcon, ms: 1640, output: \"Read 3 plan cards, 1 FAQ\" },\n  { id: \"c3\", tool: \"browser.open\", detail: \"notably.io/plans\", icon: GlobeIcon, ms: 1310, output: \"Read 4 plan cards\" },\n  { id: \"c4\", tool: \"files.read\", detail: \"churn-interviews.md\", icon: FileTextIcon, ms: 410, output: \"38 quotes tagged 'price'\" },\n  { id: \"c5\", tool: \"python.run\", detail: \"compare_plans.py\", icon: SquareTerminalIcon, ms: 2280, output: \"Table: 3 apps × 5 columns\" },\n  { id: \"c6\", tool: \"doc.write\", detail: \"Draft summary\", icon: BookOpenIcon, ms: 1900, output: \"412 words\" },\n];\n\nconst defaultSources: WorkspaceSource[] = [\n  { id: \"s1\", title: \"Quillpad · Plans and pricing\", domain: \"quillpad.app\", cited: 4, tone: \"bg-orange-500/14 text-orange-800 dark:text-orange-400\" },\n  { id: \"s2\", title: \"Notably plans for teams\", domain: \"notably.io\", cited: 3, tone: \"bg-teal-500/14 text-teal-800 dark:text-teal-400\" },\n  { id: \"s3\", title: \"Driftnote changelog: October\", domain: \"driftnote.co\", cited: 2, tone: \"bg-info/14 text-info-foreground\" },\n  { id: \"s4\", title: \"churn-interviews.md\", domain: \"Orbit files\", cited: 5, tone: \"bg-violet-500/18 text-violet-700 dark:text-violet-400\" },\n  { id: \"s5\", title: \"The state of note apps, 2026\", domain: \"fieldnotes.blog\", cited: 1, tone: \"bg-rose-500/14 text-rose-700 dark:text-rose-400\" },\n];\n\nfunction Sidebar({ tasks, onClose }: { tasks: WorkspaceTask[]; onClose?: () => void }) {\n  const [active, setActive] = useState(tasks[0]?.id);\n  const group = useId();\n  return (\n    <LayoutGroup id={group}>\n      <div className=\"flex h-full min-h-0 flex-col\">\n        <div className=\"flex h-13 items-center gap-2 px-3\">\n          <span className=\"flex size-7 items-center justify-center rounded-lg bg-primary text-primary-foreground\">\n            <BotIcon className=\"size-4\" />\n          </span>\n          <span className=\"font-semibold\">Orbit</span>\n          <span className=\"text-muted-foreground text-xs\">Workspace</span>\n          {onClose && (\n            <Button aria-label=\"Close navigation\" className=\"ms-auto\" onClick={onClose} size=\"icon-sm\" variant=\"ghost\">\n              <XIcon />\n            </Button>\n          )}\n        </div>\n        <div className=\"px-3 pb-2\">\n          <Button className=\"w-full justify-start\" variant=\"outline\">\n            <PlusIcon />\n            New task\n          </Button>\n        </div>\n        <nav aria-label=\"Workspace\" className=\"flex flex-col gap-0.5 px-2 pb-2\">\n          {[\n            { label: \"Search\", icon: SearchIcon, meta: <Kbd>⌘K</Kbd> },\n            { label: \"Inbox\", icon: InboxIcon, meta: <span className=\"rounded-full bg-info/14 px-1.5 font-medium text-[11px] text-info-foreground tabular-nums\">2</span> },\n            { label: \"Library\", icon: LibraryIcon },\n          ].map((n) => (\n            <button\n              className=\"flex h-8 cursor-pointer items-center gap-2.5 rounded-lg px-3 text-left text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n              key={n.label}\n              type=\"button\"\n            >\n              <n.icon className=\"size-4 shrink-0\" />\n              <span className=\"flex-1\">{n.label}</span>\n              {n.meta}\n            </button>\n          ))}\n        </nav>\n        <div className=\"flex items-center justify-between px-5 pt-3 pb-1.5 text-muted-foreground text-xs\">\n          <span className=\"font-medium\">Tasks</span>\n          <span className=\"tabular-nums\">{tasks.length}</span>\n        </div>\n        <ul className=\"flex min-h-0 flex-1 flex-col gap-0.5 overflow-y-auto px-2\">\n          {tasks.map((t) => {\n            const on = active === t.id;\n            return (\n              <li key={t.id}>\n                <button\n                  aria-current={on ? \"page\" : undefined}\n                  className={cn(\n                    \"relative flex h-9 w-full cursor-pointer items-center gap-2.5 rounded-lg px-3 text-left outline-none transition-transform focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.98]\",\n                    on ? \"text-foreground\" : \"text-muted-foreground hover:bg-accent hover:text-foreground\",\n                  )}\n                  onClick={() => setActive(t.id)}\n                  type=\"button\"\n                >\n                  {on && (\n                    <motion.span\n                      className=\"absolute inset-0 rounded-lg bg-background shadow-xs/5 ring-1 ring-border dark:bg-accent dark:ring-0\"\n                      layoutId=\"ws-task\"\n                      transition={spring}\n                    />\n                  )}\n                  <span className=\"relative flex size-4 shrink-0 items-center justify-center\">\n                    {t.state === \"running\" ? (\n                      <LoaderCircleIcon className=\"size-3.5 animate-spin text-info motion-reduce:animate-none\" />\n                    ) : t.state === \"done\" ? (\n                      <CheckIcon className=\"size-3.5 text-success\" />\n                    ) : (\n                      <span className=\"size-1.5 rounded-full bg-muted-foreground/40\" />\n                    )}\n                  </span>\n                  <span className=\"relative min-w-0 flex-1 truncate\">{t.title}</span>\n                  <span className=\"relative text-muted-foreground text-xs tabular-nums\">{t.time}</span>\n                </button>\n              </li>\n            );\n          })}\n        </ul>\n        <div className=\"flex items-center gap-2.5 p-3\">\n          <Avatar className=\"size-7\">\n            <AvatarFallback className=\"bg-orange-500/16 text-[11px] text-orange-800 dark:text-orange-400\">DA</AvatarFallback>\n          </Avatar>\n          <div className=\"min-w-0 flex-1 leading-tight\">\n            <div className=\"truncate font-medium\">Dara Achebe</div>\n            <div className=\"truncate text-muted-foreground text-xs\">Northwind Labs</div>\n          </div>\n          <ChevronsUpDownIcon className=\"size-4 text-muted-foreground\" />\n        </div>\n      </div>\n    </LayoutGroup>\n  );\n}\n\nconst compare = [\n  { app: \"Quillpad\", price: \"$8\", seats: \"Unlimited\", ai: \"Add-on $5\", offline: true },\n  { app: \"Notably\", price: \"$10\", seats: \"Up to 50\", ai: \"Included\", offline: false },\n  { app: \"Driftnote\", price: \"$6\", seats: \"Up to 20\", ai: \"None\", offline: true },\n];\n\nconst quotes = [\n  { text: \"We paid for Notably's AI on every seat and maybe three people used it.\", who: \"Ops lead, 30-person agency\" },\n  { text: \"Half our week is on client sites with bad wifi. Offline was the deal breaker.\", who: \"Producer, events studio\" },\n];\n\nconst enter = { initial: { opacity: 0, y: 4 }, animate: { opacity: 1, y: 0 }, transition: { duration: 0.22, ease: [0.23, 1, 0.32, 1] } } as const;\n\nfunction Cite({ n, label }: { n: number; label: string }) {\n  return (\n    <Tooltip>\n      <TooltipTrigger\n        render={\n          <button\n            aria-label={`Source ${n}: ${label}`}\n            className=\"relative ms-0.5 inline-flex size-4 -translate-y-px cursor-pointer items-center justify-center rounded bg-muted align-middle font-medium text-[10px] text-muted-foreground tabular-nums outline-none before:absolute before:-inset-2 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n            type=\"button\"\n          />\n        }\n      >\n        {n}\n      </TooltipTrigger>\n      <TooltipPopup>{label}</TooltipPopup>\n    </Tooltip>\n  );\n}\n\nfunction SkeletonLines({ rows, label }: { rows: number; label: string }) {\n  return (\n    <div aria-label={label} className=\"flex flex-col gap-2 rounded-xl border border-dashed p-3\" role=\"status\">\n      <span className=\"flex items-center gap-1.5 text-muted-foreground text-xs\">\n        <LoaderCircleIcon className=\"size-3 animate-spin motion-reduce:animate-none\" />\n        {label}\n      </span>\n      {Array.from({ length: rows }, (_, i) => (\n        <span className=\"h-2 animate-pulse rounded-full bg-muted motion-reduce:animate-none\" key={i} style={{ width: `${92 - i * 17}%` }} />\n      ))}\n    </div>\n  );\n}\n\nfunction SampleThread({ running, step, total }: { running: boolean; step: number; total: number }) {\n  const [draft, setDraft] = useState(\"\");\n  const composer = useId();\n  const scroller = useRef<HTMLDivElement>(null);\n  const reduce = useReducedMotion();\n  const haveTable = step >= 3;\n  useEffect(() => {\n    const el = scroller.current;\n    if (!el || step === 0) return;\n    const t = setTimeout(() => {\n      const nearBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 240;\n      if (nearBottom) el.scrollTo({ top: el.scrollHeight, behavior: reduce ? \"auto\" : \"smooth\" });\n    }, 60);\n    return () => clearTimeout(t);\n  }, [step, reduce]);\n  const haveQuotes = step >= 4;\n  return (\n    <div className=\"flex h-full min-h-0 flex-col\">\n      <div className=\"min-h-0 flex-1 overflow-y-auto\" ref={scroller}>\n        <div className=\"mx-auto flex max-w-2xl flex-col gap-6 px-4 py-6 @3xl:px-6\">\n          <div className=\"ms-auto max-w-[85%] text-pretty rounded-2xl rounded-br-md bg-muted px-4 py-2.5\">\n            Scan the three note apps we lose deals to. Pricing, seat limits, AI and offline. Use the churn interviews for\n            why people leave.\n          </div>\n          <div className=\"flex gap-3\">\n            <span className=\"mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-full bg-foreground text-background\">\n              <BotIcon className=\"size-3.5\" />\n            </span>\n            <div className=\"flex min-w-0 flex-1 flex-col gap-4\">\n              <div className=\"flex h-5 items-center gap-2 text-muted-foreground text-xs\">\n                {running ? (\n                  <LoaderCircleIcon className=\"size-3.5 animate-spin text-info motion-reduce:animate-none\" />\n                ) : (\n                  <CheckIcon className=\"size-3.5 text-success\" />\n                )}\n                <span className=\"tabular-nums\">\n                  {running ? `Working · step ${Math.min(step + 1, total)} of ${total}` : `Finished · ${total} steps · 9.4s`}\n                </span>\n              </div>\n              <p className=\"text-pretty leading-relaxed\">\n                Notably costs the most per seat but bundles{\" \"}\n                <span className=\"whitespace-nowrap\">\n                  AI\n                  <Cite label=\"notably.io/plans\" n={2} />,\n                </span>{\" \"}\n                and paying for AI nobody used is the top reason teams left. Quillpad is the closest match on seats and still\n                works{\" \"}\n                <span className=\"whitespace-nowrap\">\n                  offline\n                  <Cite label=\"quillpad.app/pricing\" n={1} />.\n                </span>\n              </p>\n\n              {haveTable ? (\n                <motion.div {...enter}>\n                  <div className=\"hidden overflow-hidden rounded-xl border @3xl:block\">\n                    <table className=\"w-full text-left\">\n                      <thead className=\"bg-muted/60 text-muted-foreground text-xs\">\n                        <tr>\n                          <th className=\"px-3 py-2 font-medium\">App</th>\n                          <th className=\"px-3 py-2 text-right font-medium\">Per seat</th>\n                          <th className=\"px-3 py-2 font-medium\">Seats</th>\n                          <th className=\"px-3 py-2 font-medium\">AI</th>\n                          <th className=\"px-3 py-2 text-center font-medium\">Offline</th>\n                        </tr>\n                      </thead>\n                      <tbody>\n                        {compare.map((r) => (\n                          <tr className=\"border-t\" key={r.app}>\n                            <td className=\"px-3 py-2 font-medium\">{r.app}</td>\n                            <td className=\"px-3 py-2 text-right tabular-nums\">{r.price}</td>\n                            <td className=\"px-3 py-2 text-muted-foreground\">{r.seats}</td>\n                            <td className=\"px-3 py-2 text-muted-foreground\">{r.ai}</td>\n                            <td className=\"px-3 py-2\">\n                              {r.offline ? (\n                                <CheckIcon aria-label=\"Yes\" className=\"mx-auto size-4 text-success\" />\n                              ) : (\n                                <span aria-label=\"No\" className=\"block text-center text-muted-foreground\">—</span>\n                              )}\n                            </td>\n                          </tr>\n                        ))}\n                      </tbody>\n                    </table>\n                  </div>\n                  <ul className=\"flex flex-col divide-y rounded-xl border @3xl:hidden\">\n                    {compare.map((r) => (\n                      <li className=\"flex flex-col gap-0.5 px-3 py-2.5\" key={r.app}>\n                        <span className=\"flex items-baseline justify-between\">\n                          <span className=\"font-medium\">{r.app}</span>\n                          <span className=\"tabular-nums\">\n                            {r.price}\n                            <span className=\"text-muted-foreground text-xs\"> / seat</span>\n                          </span>\n                        </span>\n                        <span className=\"text-muted-foreground text-xs\">\n                          {r.seats} seats · AI {r.ai.toLowerCase()} · {r.offline ? \"works offline\" : \"online only\"}\n                        </span>\n                      </li>\n                    ))}\n                  </ul>\n                </motion.div>\n              ) : (\n                <SkeletonLines label=\"Comparing plans\" rows={3} />\n              )}\n\n              <div className=\"flex flex-col gap-2\">\n                <h3 className=\"font-medium text-xs\">Why teams left</h3>\n                {haveQuotes ? (\n                  <motion.ul className=\"flex flex-col gap-2\" {...enter}>\n                    {quotes.map((q) => (\n                      <li className=\"flex gap-3 rounded-xl bg-muted/60 px-3 py-2.5\" key={q.who}>\n                        <span aria-hidden className=\"w-0.5 shrink-0 rounded-full bg-violet-500/48\" />\n                        <span className=\"flex min-w-0 flex-col gap-1\">\n                          <span className=\"text-pretty leading-relaxed\">“{q.text}”</span>\n                          <span className=\"text-muted-foreground text-xs\">\n                            {q.who}{\" \"}\n                            <Cite label=\"churn-interviews.md\" n={4} />\n                          </span>\n                        </span>\n                      </li>\n                    ))}\n                  </motion.ul>\n                ) : (\n                  <SkeletonLines label=\"Reading churn-interviews.md\" rows={2} />\n                )}\n              </div>\n\n              <AnimatePresence initial={false}>\n                {!running && (\n                  <motion.div className=\"flex flex-col gap-3\" {...enter} exit={{ opacity: 0 }}>\n                    <p className=\"text-pretty leading-relaxed\">\n                      I saved the write-up to Research. Want a one-slide version for Thursday&apos;s pricing review?\n                    </p>\n                    <div className=\"flex max-w-sm items-center gap-3 rounded-xl border bg-card p-2.5 shadow-xs/5\">\n                      <span className=\"flex size-9 shrink-0 items-center justify-center rounded-lg bg-info/12 text-info-foreground\">\n                        <FileTextIcon className=\"size-4\" />\n                      </span>\n                      <span className=\"flex min-w-0 flex-1 flex-col leading-tight\">\n                        <span className=\"truncate font-medium\">Note apps: competitive scan</span>\n                        <span className=\"text-muted-foreground text-xs tabular-nums\">Doc · 412 words · 5 sources</span>\n                      </span>\n                      <Button size=\"sm\" variant=\"outline\">\n                        Open\n                      </Button>\n                    </div>\n                  </motion.div>\n                )}\n              </AnimatePresence>\n            </div>\n          </div>\n        </div>\n      </div>\n      <div className=\"px-4 pb-4 @3xl:px-6\">\n        <form\n          className=\"mx-auto flex max-w-2xl items-end gap-2 rounded-2xl border bg-card p-2 shadow-xs/5 transition-shadow focus-within:border-ring/64 focus-within:ring-[3px] focus-within:ring-ring/16\"\n          onSubmit={(e) => {\n            e.preventDefault();\n            setDraft(\"\");\n          }}\n        >\n          <Button aria-label=\"Attach\" size=\"icon-sm\" type=\"button\" variant=\"ghost\">\n            <PaperclipIcon />\n          </Button>\n          <label className=\"sr-only\" htmlFor={composer}>\n            Message\n          </label>\n          <textarea\n            className=\"field-sizing-content max-h-32 min-h-8 flex-1 resize-none bg-transparent py-1.5 text-sm outline-none placeholder:text-muted-foreground/72\"\n            id={composer}\n            onChange={(e) => setDraft(e.target.value)}\n            placeholder={running ? \"Steer the task while it works…\" : \"Ask a follow-up…\"}\n            rows={1}\n            value={draft}\n          />\n          <Button\n            aria-label=\"Send\"\n            className=\"rounded-full transition-transform active:scale-[0.97]\"\n            disabled={!draft.trim()}\n            size=\"icon-sm\"\n            type=\"submit\"\n          >\n            <ArrowUpIcon />\n          </Button>\n        </form>\n      </div>\n    </div>\n  );\n}\n\nfunction ToolsTab({ calls, step }: { calls: WorkspaceToolCall[]; step: number }) {\n  const [open, setOpen] = useState<string | null>(null);\n  const done = Math.min(step, calls.length);\n  const elapsed = calls.slice(0, done).reduce((sum, c) => sum + c.ms, 0);\n  return (\n    <div className=\"flex flex-col gap-3 p-3\">\n      <div className=\"flex items-center gap-3 rounded-xl border bg-card px-3 py-2.5\">\n        <div className=\"flex min-w-0 flex-1 flex-col gap-1.5\">\n          <div className=\"flex items-center justify-between text-xs\">\n            <span className=\"font-medium\">\n              {done === calls.length ? \"All steps done\" : `Step ${done + 1} of ${calls.length}`}\n            </span>\n            <span className=\"text-muted-foreground tabular-nums\">{(elapsed / 1000).toFixed(1)}s tool time</span>\n          </div>\n          <div className=\"flex gap-1\">\n            {calls.map((c, i) => (\n              <span className=\"relative h-1 flex-1 overflow-hidden rounded-full bg-muted\" key={c.id}>\n                <motion.span\n                  animate={{ scaleX: i < done ? 1 : i === done ? 0.85 : 0 }}\n                  className={cn(\"absolute inset-0 origin-left rounded-full\", i < done ? \"bg-foreground/72\" : \"bg-info\")}\n                  initial={false}\n                  key={i < done ? \"done\" : i === done ? \"run\" : \"queued\"}\n                  transition={\n                    i === done ? { duration: (c.ms + 1400) / 1000, ease: [0.23, 1, 0.32, 1] } : { duration: 0.2, ease: \"easeOut\" }\n                  }\n                />\n              </span>\n            ))}\n          </div>\n        </div>\n      </div>\n      <ol className=\"relative flex flex-col\">\n        <span aria-hidden className=\"absolute top-5 bottom-5 left-[19px] w-px bg-border\" />\n        {calls.map((c, i) => {\n          const state = i < done ? \"done\" : i === done ? \"running\" : \"queued\";\n          const expanded = open === c.id && state === \"done\";\n          return (\n            <li className=\"relative\" key={c.id}>\n              <button\n                aria-expanded={state === \"done\" ? expanded : undefined}\n                className={cn(\n                  \"flex w-full items-start gap-3 rounded-lg px-2 py-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring\",\n                  state === \"done\" ? \"cursor-pointer hover:bg-accent\" : \"cursor-default\",\n                )}\n                disabled={state !== \"done\"}\n                onClick={() => setOpen(expanded ? null : c.id)}\n                type=\"button\"\n              >\n                <span\n                  className={cn(\n                    \"relative z-10 flex size-6 shrink-0 items-center justify-center rounded-full border bg-background transition-colors\",\n                    state === \"running\" && \"border-info/48 text-info\",\n                    state === \"queued\" && \"border-dashed text-muted-foreground/48\",\n                  )}\n                >\n                  {state === \"running\" ? (\n                    <LoaderCircleIcon className=\"size-3.5 animate-spin motion-reduce:animate-none\" />\n                  ) : (\n                    <c.icon className={cn(\"size-3.5\", state === \"done\" && \"text-muted-foreground\")} />\n                  )}\n                </span>\n                <span className={cn(\"flex min-w-0 flex-1 flex-col gap-0.5 transition-opacity\", state === \"queued\" && \"opacity-48\")}>\n                  <span className=\"flex items-center gap-2\">\n                    <span className=\"font-medium font-mono text-xs\">{c.tool}</span>\n                    <span className=\"ms-auto text-muted-foreground text-xs tabular-nums\">\n                      {state === \"running\" ? (\n                        <span className=\"text-info-foreground\">running</span>\n                      ) : state === \"done\" ? (\n                        `${(c.ms / 1000).toFixed(1)}s`\n                      ) : (\n                        \"queued\"\n                      )}\n                    </span>\n                  </span>\n                  <span className=\"truncate text-muted-foreground text-xs\">{c.detail}</span>\n                </span>\n                <ChevronRightIcon\n                  className={cn(\n                    \"mt-1 size-3.5 shrink-0 text-muted-foreground transition-[rotate,opacity]\",\n                    expanded && \"rotate-90\",\n                    state !== \"done\" && \"opacity-0\",\n                  )}\n                />\n              </button>\n              <AnimatePresence initial={false}>\n                {expanded && (\n                  <motion.div\n                    animate={{ height: \"auto\", opacity: 1 }}\n                    className=\"overflow-hidden\"\n                    exit={{ height: 0, opacity: 0 }}\n                    initial={{ height: 0, opacity: 0 }}\n                    transition={spring}\n                  >\n                    <div className=\"mb-2 ms-11 me-2 rounded-lg bg-muted px-3 py-2 font-mono text-muted-foreground text-xs\">\n                      → {c.output ?? \"ok\"}\n                    </div>\n                  </motion.div>\n                )}\n              </AnimatePresence>\n            </li>\n          );\n        })}\n      </ol>\n    </div>\n  );\n}\n\nfunction BrowserTab({ reading }: { reading: boolean }) {\n  const reduce = useReducedMotion();\n  const plans = [\n    { name: \"Personal\", price: \"$0\", note: \"1 seat\" },\n    { name: \"Team\", price: \"$8\", note: \"per seat / mo\" },\n    { name: \"Business\", price: \"$14\", note: \"per seat / mo\" },\n  ];\n  return (\n    <div className=\"flex h-full flex-col p-3\">\n      <div className=\"flex items-center gap-1 pb-2\">\n        <Button aria-label=\"Back\" size=\"icon-xs\" variant=\"ghost\">\n          <ArrowLeftIcon />\n        </Button>\n        <Button aria-label=\"Forward\" disabled size=\"icon-xs\" variant=\"ghost\">\n          <ArrowRightIcon />\n        </Button>\n        <Button aria-label=\"Reload\" size=\"icon-xs\" variant=\"ghost\">\n          <RotateCwIcon />\n        </Button>\n        <div className=\"ms-1 flex h-7 min-w-0 flex-1 items-center gap-1.5 rounded-full bg-muted px-3 text-xs\">\n          <LockIcon className=\"size-3 shrink-0 text-muted-foreground\" />\n          <span className=\"truncate\">\n            quillpad.app<span className=\"text-muted-foreground\">/pricing</span>\n          </span>\n        </div>\n      </div>\n      <div className=\"relative min-h-0 flex-1 overflow-y-auto rounded-xl border bg-background [scrollbar-width:thin]\">\n        <div className=\"flex items-center gap-2 border-b px-4 py-2.5\">\n          <span className=\"size-3.5 rounded bg-orange-500\" />\n          <span className=\"font-semibold text-xs\">Quillpad</span>\n          <span className=\"ms-auto flex gap-3 text-[10px] text-muted-foreground\">\n            <span>Product</span>\n            <span className=\"text-foreground\">Pricing</span>\n            <span>Blog</span>\n          </span>\n        </div>\n        <div className=\"px-4 pt-5 pb-4 text-center\">\n          <div className=\"font-heading font-semibold text-base\">Simple plans for every notebook</div>\n          <div className=\"mt-1 text-[11px] text-muted-foreground\">Billed yearly. Cancel any time.</div>\n        </div>\n        <div className=\"relative mx-4 grid grid-cols-3 gap-2\">\n          {plans.map((p, i) => (\n            <div className={cn(\"rounded-lg border p-2.5\", i === 1 && \"border-orange-500/40 bg-orange-500/5\")} key={p.name}>\n              <div className=\"font-medium text-[11px]\">{p.name}</div>\n              <div className=\"mt-1 font-semibold text-base tabular-nums\">{p.price}</div>\n              <div className=\"text-[10px] text-muted-foreground\">{p.note}</div>\n              <div className=\"mt-2 flex flex-col gap-1\">\n                {[0, 1, 2].map((k) => (\n                  <span className=\"h-1 rounded-full bg-muted\" key={k} style={{ width: `${86 - k * 18}%` }} />\n                ))}\n              </div>\n            </div>\n          ))}\n          {reading && (\n            <motion.span\n              animate={reduce ? undefined : { opacity: [0.5, 1, 0.5] }}\n              className=\"pointer-events-none absolute -inset-1.5 rounded-xl border-2 border-info\"\n              transition={{ duration: 1.8, repeat: Infinity, ease: \"easeInOut\" }}\n            >\n              <span className=\"absolute -top-2.5 left-2 rounded-full bg-info px-2 py-0.5 font-medium text-[10px] text-white\">\n                Reading plan table\n              </span>\n            </motion.span>\n          )}\n        </div>\n        <div className=\"mx-4 mt-5 rounded-lg border\">\n          {[\n            [\"Offline notebooks\", true, true, true],\n            [\"Shared spaces\", false, true, true],\n            [\"AI writing\", false, \"Add-on\", \"Add-on\"],\n            [\"SSO & audit log\", false, false, true],\n          ].map(([label, ...cells], r) => (\n            <div className={cn(\"grid grid-cols-[1.4fr_1fr_1fr_1fr] items-center px-2.5 py-1.5 text-[10px]\", r > 0 && \"border-t\")} key={String(label)}>\n              <span className=\"text-muted-foreground\">{label}</span>\n              {cells.map((c, k) => (\n                <span className=\"text-center\" key={k}>\n                  {c === true ? (\n                    <CheckIcon className=\"mx-auto size-3 text-success\" />\n                  ) : c === false ? (\n                    <span className=\"text-muted-foreground/60\">—</span>\n                  ) : (\n                    c\n                  )}\n                </span>\n              ))}\n            </div>\n          ))}\n        </div>\n        <div className=\"mx-4 mt-5 mb-4 flex flex-col gap-2\">\n          <div className=\"font-medium text-[11px]\">Questions</div>\n          {[\"Can I switch plans later?\", \"Do you offer student pricing?\", \"What happens to my notes if I cancel?\"].map((q) => (\n            <div className=\"flex items-center justify-between rounded-md bg-muted/60 px-2.5 py-1.5 text-[10px]\" key={q}>\n              {q}\n              <PlusIcon className=\"size-3 text-muted-foreground\" />\n            </div>\n          ))}\n        </div>\n      </div>\n    </div>\n  );\n}\n\nfunction SourcesTab({ sources }: { sources: WorkspaceSource[] }) {\n  const [included, setIncluded] = useState(() => sources.map((s) => s.id));\n  return (\n    <div className=\"flex flex-col gap-1 p-3\">\n      <p className=\"px-2 pb-1 text-muted-foreground text-xs\">\n        <span className=\"tabular-nums\">{included.length}</span> of {sources.length} used in the answer\n      </p>\n      {sources.map((s, i) => {\n        const on = included.includes(s.id);\n        const id = `src-${s.id}`;\n        return (\n          <label\n            className={cn(\n              \"flex cursor-pointer items-center gap-3 rounded-lg px-2 py-2 transition-opacity hover:bg-accent\",\n              !on && \"opacity-56\",\n            )}\n            htmlFor={id}\n            key={s.id}\n          >\n            <span className={cn(\"flex size-7 shrink-0 items-center justify-center rounded-md font-semibold text-xs tabular-nums\", s.tone)}>\n              {i + 1}\n            </span>\n            <span className=\"flex min-w-0 flex-1 flex-col\">\n              <span className=\"truncate font-medium\">{s.title}</span>\n              <span className=\"truncate text-muted-foreground text-xs\">\n                {s.domain} · cited {s.cited}×\n              </span>\n            </span>\n            <Checkbox\n              checked={on}\n              id={id}\n              onCheckedChange={(v) => setIncluded((x) => (v ? [...x, s.id] : x.filter((y) => y !== s.id)))}\n            />\n          </label>\n        );\n      })}\n      <button\n        className=\"mt-1 flex h-10 cursor-pointer items-center gap-3 rounded-lg border border-dashed px-2 text-muted-foreground outline-none transition-transform hover:border-foreground/24 hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.98]\"\n        type=\"button\"\n      >\n        <span className=\"flex size-7 items-center justify-center\">\n          <PlusIcon className=\"size-4\" />\n        </span>\n        Add a link or file\n      </button>\n    </div>\n  );\n}\n\nfunction WorkPanel({\n  calls,\n  sources,\n  step,\n  onClose,\n}: {\n  calls: WorkspaceToolCall[];\n  sources: WorkspaceSource[];\n  step: number;\n  onClose: () => void;\n}) {\n  const running = step < calls.length;\n  const reading = running && calls[step]?.tool.startsWith(\"browser\");\n  const [tab, setTab] = useState(\"tools\");\n  return (\n    <Tabs className=\"h-full min-h-0 gap-0\" onValueChange={(v) => setTab(v as string)} value={tab}>\n      <div className=\"flex h-13 shrink-0 items-center gap-2 border-b px-3\">\n        <TabsList className=\"min-w-0 overflow-x-auto text-muted-foreground [scrollbar-width:none]\" size=\"sm\">\n          <TabsTab value=\"tools\">\n            <WrenchIcon />\n            Tools\n            <span className=\"text-muted-foreground text-xs tabular-nums\">{calls.length}</span>\n          </TabsTab>\n          <TabsTab value=\"browser\">\n            <GlobeIcon />\n            Browser\n            {reading && <span className=\"size-1.5 rounded-full bg-info\" />}\n          </TabsTab>\n          <TabsTab value=\"sources\">\n            <BookOpenIcon />\n            Sources\n          </TabsTab>\n        </TabsList>\n        <Button aria-label=\"Close work panel\" className=\"ms-auto\" onClick={onClose} size=\"icon-sm\" variant=\"ghost\">\n          <XIcon />\n        </Button>\n      </div>\n      <TabsPanel className=\"min-h-0 overflow-y-auto\" value=\"tools\">\n        <ToolsTab calls={calls} step={step} />\n      </TabsPanel>\n      <TabsPanel className=\"min-h-0\" value=\"browser\">\n        <BrowserTab reading={Boolean(reading)} />\n      </TabsPanel>\n      <TabsPanel className=\"min-h-0 overflow-y-auto\" value=\"sources\">\n        <SourcesTab sources={sources} />\n      </TabsPanel>\n    </Tabs>\n  );\n}\n\nexport function SplitShell({\n  tasks = defaultTasks,\n  toolCalls = defaultToolCalls,\n  sources = defaultSources,\n  defaultPanelWidth = 380,\n  minPanelWidth = 300,\n  maxPanelWidth = 600,\n  children,\n  className,\n}: SplitShellProps) {\n  const rootRef = useRef<HTMLDivElement>(null);\n  const drawerRef = useRef<HTMLDivElement>(null);\n  const [rootWidth, setRootWidth] = useState(1280);\n  const [panelOpen, setPanelOpen] = useState(true);\n  const [overlayOpen, setOverlayOpen] = useState(false);\n  const [drawer, setDrawer] = useState(false);\n  const [width, setWidth] = useState(defaultPanelWidth);\n  const [dragging, setDragging] = useState(false);\n  const [step, setStep] = useState(3);\n  const panelId = useId();\n  const drag = useRef<{ x: number; w: number } | null>(null);\n  const reduce = useReducedMotion();\n\n  useEffect(() => {\n    const el = rootRef.current;\n    if (!el) return;\n    const ro = new ResizeObserver(([entry]) => setRootWidth(entry.contentRect.width));\n    ro.observe(el);\n    return () => ro.disconnect();\n  }, []);\n\n  useEffect(() => {\n    if (drawer) drawerRef.current?.focus();\n  }, [drawer]);\n\n  useEffect(() => {\n    if (step >= toolCalls.length) return;\n    const t = setTimeout(() => setStep((s) => s + 1), reduce ? 400 : (toolCalls[step]?.ms ?? 1500) + 1400);\n    return () => clearTimeout(t);\n  }, [step, toolCalls, reduce]);\n\n  const docked = rootWidth >= 1024;\n  const sidebarWidth = rootWidth >= 768 ? 240 : 0;\n  const maxW = Math.max(minPanelWidth, Math.min(maxPanelWidth, rootWidth - sidebarWidth - 400));\n  const w = Math.min(Math.max(width, minPanelWidth), maxW);\n  const showPanel = docked ? panelOpen : overlayOpen;\n\n  const clamp = useCallback((v: number) => Math.min(Math.max(v, minPanelWidth), maxW), [minPanelWidth, maxW]);\n\n  const onPointerDown = (e: PointerEvent<HTMLDivElement>) => {\n    e.currentTarget.setPointerCapture(e.pointerId);\n    drag.current = { x: e.clientX, w };\n    setDragging(true);\n  };\n  const onPointerMove = (e: PointerEvent<HTMLDivElement>) => {\n    if (!drag.current) return;\n    setWidth(clamp(drag.current.w + (drag.current.x - e.clientX)));\n  };\n  const onPointerUp = () => {\n    drag.current = null;\n    setDragging(false);\n  };\n  const onHandleKey = (e: KeyboardEvent<HTMLDivElement>) => {\n    const delta = e.shiftKey ? 64 : 16;\n    if (e.key === \"ArrowLeft\") setWidth(clamp(w + delta));\n    else if (e.key === \"ArrowRight\") setWidth(clamp(w - delta));\n    else if (e.key === \"Home\") setWidth(maxW);\n    else if (e.key === \"End\") setWidth(minPanelWidth);\n    else if (e.key === \"Enter\") setWidth(defaultPanelWidth);\n    else return;\n    e.preventDefault();\n  };\n\n  const running = step < toolCalls.length;\n  const liveId = tasks.find((t) => t.state === \"running\")?.id;\n  const liveTasks = tasks.map((t) => (t.id === liveId ? { ...t, state: running ? (\"running\" as const) : (\"done\" as const) } : t));\n  const togglePanel = () => (docked ? setPanelOpen((o) => !o) : setOverlayOpen((o) => !o));\n\n  return (\n    <MotionConfig reducedMotion=\"user\">\n      <div\n        className={cn(\n          \"@container relative isolate flex h-[760px] w-full overflow-hidden bg-sidebar text-foreground text-sm\",\n          dragging && \"cursor-col-resize select-none\",\n          className,\n        )}\n        onKeyDown={(e) => {\n          if (e.key !== \"Escape\") return;\n          if (drawer) setDrawer(false);\n          else if (overlayOpen) setOverlayOpen(false);\n        }}\n        ref={rootRef}\n      >\n        <aside aria-label=\"Sidebar\" className=\"hidden w-60 shrink-0 @3xl:block\">\n          <Sidebar tasks={liveTasks} />\n        </aside>\n\n        <AnimatePresence>\n          {drawer && (\n            <>\n              <motion.div\n                animate={{ opacity: 1 }}\n                aria-hidden\n                className=\"absolute inset-0 z-40 bg-black/32 @3xl:hidden\"\n                exit={{ opacity: 0 }}\n                initial={{ opacity: 0 }}\n                onClick={() => setDrawer(false)}\n              />\n              <motion.div\n                animate={{ x: 0 }}\n                aria-label=\"Navigation\"\n                aria-modal=\"true\"\n                className=\"absolute inset-y-0 left-0 z-50 w-72 max-w-[85%] border-e bg-sidebar outline-none @3xl:hidden\"\n                exit={{ x: \"-100%\" }}\n                initial={{ x: \"-100%\" }}\n                ref={drawerRef}\n                role=\"dialog\"\n                tabIndex={-1}\n                transition={spring}\n              >\n                <Sidebar onClose={() => setDrawer(false)} tasks={liveTasks} />\n              </motion.div>\n            </>\n          )}\n        </AnimatePresence>\n\n        <div className=\"flex min-w-0 flex-1 @3xl:py-2 @3xl:pe-2\">\n          <main className=\"flex min-w-0 flex-1 flex-col overflow-hidden bg-background @3xl:rounded-2xl @3xl:border @3xl:shadow-xs/5\">\n            <header className=\"flex h-13 shrink-0 items-center gap-2 border-b px-3 @3xl:px-4\">\n              <Button\n                aria-label=\"Open navigation\"\n                className=\"@3xl:hidden\"\n                onClick={() => setDrawer(true)}\n                size=\"icon-sm\"\n                variant=\"ghost\"\n              >\n                <MenuIcon />\n              </Button>\n              <nav aria-label=\"Breadcrumb\" className=\"flex min-w-0 flex-1 items-center gap-1.5\">\n                <span className=\"hidden text-muted-foreground @md:inline\">Research</span>\n                <ChevronRightIcon aria-hidden className=\"hidden size-3.5 text-muted-foreground/60 @md:inline\" />\n                <span aria-current=\"page\" className=\"truncate font-medium\">\n                  Competitive scan: note apps\n                </span>\n              </nav>\n              <Badge className=\"hidden gap-1.5 @lg:inline-flex\" variant={running ? \"info\" : \"success\"}>\n                {running ? (\n                  <LoaderCircleIcon className=\"size-3 animate-spin motion-reduce:animate-none\" />\n                ) : (\n                  <CheckIcon className=\"size-3\" />\n                )}\n                {running ? \"Running\" : \"Done\"}\n              </Badge>\n              {!running && (\n                <Button className=\"hidden @2xl:inline-flex\" onClick={() => setStep(0)} size=\"sm\" variant=\"ghost\">\n                  <RotateCwIcon />\n                  Re-run\n                </Button>\n              )}\n              <Tooltip>\n                <TooltipTrigger\n                  render={\n                    <Button\n                      aria-expanded={showPanel}\n                      aria-label={showPanel ? \"Hide work panel\" : \"Show work panel\"}\n                      onClick={togglePanel}\n                      size=\"icon-sm\"\n                      variant={showPanel ? \"secondary\" : \"ghost\"}\n                    />\n                  }\n                >\n                  <PanelRightIcon />\n                </TooltipTrigger>\n                <TooltipPopup>{showPanel ? \"Hide work panel\" : \"Show work panel\"}</TooltipPopup>\n              </Tooltip>\n            </header>\n            <div className=\"min-h-0 flex-1\">\n              {children ?? <SampleThread running={running} step={step} total={toolCalls.length} />}\n            </div>\n          </main>\n\n          {docked && (\n            <AnimatePresence initial={false}>\n              {panelOpen && (\n                <motion.div\n                  animate={{ width: w + 8, opacity: 1 }}\n                  className=\"flex shrink-0 overflow-hidden\"\n                  exit={{ width: 0, opacity: 0 }}\n                  initial={{ width: 0, opacity: 0 }}\n                  transition={dragging ? { duration: 0 } : spring}\n                >\n                  <div\n                    aria-controls={panelId}\n                    aria-label=\"Resize work panel\"\n                    aria-orientation=\"vertical\"\n                    aria-valuemax={maxW}\n                    aria-valuemin={minPanelWidth}\n                    aria-valuenow={Math.round(w)}\n                    className=\"group/handle relative flex w-2 shrink-0 cursor-col-resize touch-none items-center justify-center outline-none before:absolute before:inset-y-0 before:-inset-x-2\"\n                    onDoubleClick={() => setWidth(defaultPanelWidth)}\n                    onKeyDown={onHandleKey}\n                    onPointerCancel={onPointerUp}\n                    onPointerDown={onPointerDown}\n                    onPointerMove={onPointerMove}\n                    onPointerUp={onPointerUp}\n                    role=\"separator\"\n                    tabIndex={0}\n                  >\n                    <motion.span\n                      animate={{ height: dragging ? 56 : 32 }}\n                      className={cn(\n                        \"w-1 rounded-full bg-muted-foreground/24 transition-colors group-hover/handle:bg-muted-foreground/48 group-focus-visible/handle:bg-ring\",\n                        dragging && \"bg-info!\",\n                      )}\n                      transition={spring}\n                    />\n                  </div>\n                  <section\n                    aria-label=\"Work panel\"\n                    className=\"relative flex min-w-0 flex-1 flex-col overflow-hidden rounded-2xl border bg-background shadow-xs/5\"\n                    id={panelId}\n                    style={{ width: w }}\n                  >\n                    <WorkPanel calls={toolCalls} onClose={() => setPanelOpen(false)} sources={sources} step={step} />\n                    <AnimatePresence>\n                      {dragging && (\n                        <motion.span\n                          animate={{ opacity: 1, y: 0 }}\n                          className=\"pointer-events-none absolute bottom-4 left-1/2 -translate-x-1/2 rounded-full bg-foreground px-2 py-0.5 font-mono text-[11px] text-background tabular-nums\"\n                          exit={{ opacity: 0, y: 4 }}\n                          initial={{ opacity: 0, y: 4 }}\n                        >\n                          {Math.round(w)}px\n                        </motion.span>\n                      )}\n                    </AnimatePresence>\n                  </section>\n                </motion.div>\n              )}\n            </AnimatePresence>\n          )}\n        </div>\n\n        {!docked && (\n          <AnimatePresence>\n            {overlayOpen && (\n              <>\n                <motion.div\n                  animate={{ opacity: 1 }}\n                  aria-hidden\n                  className=\"absolute inset-0 z-30 bg-black/24\"\n                  exit={{ opacity: 0 }}\n                  initial={{ opacity: 0 }}\n                  onClick={() => setOverlayOpen(false)}\n                />\n                <motion.section\n                  animate={{ x: 0 }}\n                  aria-label=\"Work panel\"\n                  className=\"absolute inset-y-2 right-2 z-30 flex w-[min(400px,calc(100%-1rem))] flex-col overflow-hidden rounded-2xl border bg-background shadow-lg/10\"\n                  exit={{ x: \"110%\" }}\n                  initial={{ x: \"110%\" }}\n                  transition={spring}\n                >\n                  <WorkPanel calls={toolCalls} onClose={() => setOverlayOpen(false)} sources={sources} step={step} />\n                </motion.section>\n              </>\n            )}\n          </AnimatePresence>\n        )}\n      </div>\n    </MotionConfig>\n  );\n}\n"
    }
  ]
}