{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "retro-tool-call",
  "title": "RetroToolCall",
  "description": "A Mac OS 9 row for an AI tool call: status icon, tool name, and a disclosure triangle revealing input and output.",
  "dependencies": [
    "@ui-sdk/core@0.1.0-beta.1",
    "@ui-sdk/react@0.1.0-beta.1"
  ],
  "registryDependencies": [
    "https://nostalgia-ui.com/r/nostalgia-theme.json",
    "https://nostalgia-ui.com/r/retro-ai.json",
    "https://nostalgia-ui.com/r/retro-progress.json"
  ],
  "files": [
    {
      "path": "registry/new-york/ui/retro-tool-call.tsx",
      "content": "\"use client\"\n\n/*\n * RetroToolCall: one AI tool call as a single Platinum row, on UI SDK\n * Collapsible.\n *\n *   [▸] [⌚] Search Files                                 Running…\n *       ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒  (barber pole)\n *\n * Expanding the row morphs its height open to show the call's Input and\n * Output as pretty-printed JSON in inset wells (or the error text).\n *\n * Crafted moment: the status flip. When a call settles, its watch turns\n * edge-on and comes back as the check (or stop sign), in two hard frames,\n * the same way the disclosure triangle turns. It plays in both flairs, as\n * OS 9 itself would have; reduced motion swaps the glyph at once.\n *\n * Also exported: RetroToolCallGroup (consecutive calls sharing borders),\n * RetroToolChips (compact inline bevel chips for dense layouts),\n * RetroToolStatusIcon (the glyphs) and the toolStatus / toolTitle helpers.\n */\n\nimport * as React from \"react\"\nimport {\n  Collapsible as CollapsiblePrimitive,\n  CollapsiblePanel as CollapsiblePanelPrimitive,\n  CollapsibleTrigger as CollapsibleTriggerPrimitive,\n} from \"@ui-sdk/react/collapsible\"\n\nimport { cn } from \"@/lib/utils\"\nimport { toolNameOf, type RetroToolPart } from \"@/registry/new-york/lib/retro-ai\"\nimport { RetroProgress } from \"@/registry/new-york/ui/retro-progress\"\n\n/* ------------------------------------------------------------------ */\n/*  Status                                                             */\n/* ------------------------------------------------------------------ */\n\n/** What a tool call looks like to the person reading the transcript. */\ntype RetroToolStatus = \"running\" | \"waiting\" | \"done\" | \"error\" | \"denied\"\n\nfunction toolStatus(part: RetroToolPart): RetroToolStatus {\n  switch (part.state) {\n    case \"approval-requested\":\n      return \"waiting\"\n    case \"approval-responded\":\n      return part.approval?.approved === false ? \"denied\" : \"running\"\n    case \"output-available\":\n      return \"done\"\n    case \"output-error\":\n      return \"error\"\n    case \"output-denied\":\n      return \"denied\"\n    default:\n      return \"running\"\n  }\n}\n\nconst STATUS_WORDS: Record<RetroToolStatus, string> = {\n  running: \"Running…\",\n  waiting: \"Waiting for you\",\n  done: \"Done\",\n  error: \"Failed\",\n  denied: \"Denied\",\n}\n\n/** `searchFiles` / `search_files` / `search-files` → `Search Files`. */\nfunction prettifyToolName(name: string) {\n  return name\n    .replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n    .replace(/([A-Z]+)([A-Z][a-z])/g, \"$1 $2\")\n    .replace(/[_\\-.]+/g, \" \")\n    .trim()\n    .replace(/\\s+/g, \" \")\n    .replace(/\\b\\w/g, (c) => c.toUpperCase())\n}\n\n/** The human title for a tool call: its tool name, prettified. */\nfunction toolTitle(part: RetroToolPart) {\n  return prettifyToolName(toolNameOf(part))\n}\n\n/* ------------------------------------------------------------------ */\n/*  Glyphs: 16px, 1px pixel strokes                                    */\n/* ------------------------------------------------------------------ */\n\nconst GLYPH_CSS = `\n@keyframes os9-tool-tick { to { transform: rotate(360deg); } }\n.os9-tool-hand { transform-box: view-box; transform-origin: 8px 8px; animation: os9-tool-tick 1.6s steps(8, end) infinite; }\n@keyframes os9-tool-flip-out { 0% { transform: scaleX(0.35); } 50%, 100% { opacity: 0; } }\n@keyframes os9-tool-flip-in { 0% { opacity: 0; } 50% { opacity: 1; transform: scaleX(0.35); } 100% { opacity: 1; transform: none; } }\n.os9-tool-flip-out { animation: os9-tool-flip-out 120ms step-end both; }\n.os9-tool-flip-in { animation: os9-tool-flip-in 120ms step-end both; }\n@keyframes os9-tool-rise { from { opacity: 0; transform: translateY(4px); } }\n.os9-tool-enter { animation: os9-tool-rise 160ms cubic-bezier(0.23, 1, 0.32, 1) both; }\n[data-flair=\"classic\"] .os9-tool-enter { animation: none; }\n@media (prefers-reduced-motion: reduce) {\n  .os9-tool-hand, .os9-tool-flip-out, .os9-tool-flip-in, .os9-tool-enter { animation: none; }\n  .os9-tool-flip-out { display: none; }\n}\n`\n\nfunction GlyphStyle() {\n  return (\n    <style href=\"os9-tool-call\" precedence=\"default\">\n      {GLYPH_CSS}\n    </style>\n  )\n}\n\nfunction Svg({ children, className }: { children: React.ReactNode; className?: string }) {\n  return (\n    <svg\n      width=\"16\"\n      height=\"16\"\n      viewBox=\"0 0 16 16\"\n      fill=\"none\"\n      shapeRendering=\"crispEdges\"\n      aria-hidden=\"true\"\n      className={cn(\"block shrink-0\", className)}\n    >\n      {children}\n    </svg>\n  )\n}\n\n/** The OS 9 watch: strap, round face, a hand that ticks round in eighths. */\nfunction WatchGlyph() {\n  return (\n    <Svg>\n      <path d=\"M5 0h6v3H5zM5 13h6v3H5z\" fill=\"var(--os9-black)\" />\n      <path d=\"M5 2h6v1h1v1h1v1h1v6h-1v1h-1v1h-1v1H5v-1H4v-1H3v-1H2V5h1V4h1V3h1z\" fill=\"var(--os9-black)\" />\n      <path d=\"M5 3h6v1h1v1h1v6h-1v1h-1v1H5v-1H4v-1H3V5h1V4h1z\" fill=\"var(--os9-white)\" />\n      <path d=\"M14 7h1v2h-1z\" fill=\"var(--os9-black)\" />\n      <path d=\"M8 8h3v1H8z\" fill=\"var(--os9-black)\" />\n      <g className=\"os9-tool-hand\">\n        <path d=\"M8 4h1v5H8z\" fill=\"var(--os9-black)\" />\n      </g>\n    </Svg>\n  )\n}\n\nfunction CheckGlyph() {\n  return (\n    <Svg>\n      <path\n        d=\"M2 8h2v1h1v1h1v1h1V9h1V8h1V7h1V6h1V5h1V4h1V3h2v2h-1v1h-1v1h-1v1h-1v1h-1v1h-1v1H9v1H8v1H6v-1H5v-1H4v-1H3v-1H2z\"\n        fill=\"var(--os9-black)\"\n      />\n    </Svg>\n  )\n}\n\n/** Caution: the yellow triangle with a black outline. */\nfunction CautionGlyph() {\n  return (\n    <Svg>\n      <path\n        d=\"M7 1h2v2h1v2h1v2h1v2h1v2h1v2h1v2H1v-2h1v-2h1V9h1V7h1V5h1V3h1z\"\n        fill=\"var(--os9-black)\"\n      />\n      <path d=\"M7 3h2v2h1v2h1v2h1v2h1v3H3v-3h1V9h1V7h1V5h1z\" fill=\"#ffcc00\" />\n      <path d=\"M7 6h2v4H7zM7 11h2v2H7z\" fill=\"var(--os9-black)\" />\n    </Svg>\n  )\n}\n\n/** Stop: the red octagon with a raised white hand. */\nfunction StopGlyph() {\n  return (\n    <Svg>\n      <path d=\"M5 0h6v1h1v1h1v1h1v1h1v1h1v6h-1v1h-1v1h-1v1h-1v1h-1v1H5v-1H4v-1H3v-1H2v-1H1v-1H0V5h1V4h1V3h1V2h1V1h1z\" fill=\"var(--os9-black)\" />\n      <path d=\"M5 1h6v1h1v1h1v1h1v1h1v6h-1v1h-1v1h-1v1h-1v1H5v-1H4v-1H3v-1H2v-1H1V5h1V4h1V3h1V2h1z\" fill=\"#cc0000\" />\n      <path d=\"M5 4h1v3h1V3h1v4h1V4h1v4h1V7h1v3h-1v1h-1v1H6v-1H5z\" fill=\"var(--os9-white)\" />\n    </Svg>\n  )\n}\n\n/** Denied: a circle struck through. */\nfunction DeniedGlyph() {\n  return (\n    <Svg>\n      <path\n        d=\"M5 1h6v1h2v2h1v2h1v4h-1v2h-1v2h-2v1H5v-1H3v-2H2v-2H1V6h1V4h1V2h2zM5 3v1H4v2H3v4h1v1h1v-1h1V9h1V8h1V7h1V6h1V5h1V4h1V3h-1V2H6v1zM11 5v1h-1v1H9v1H8v1H7v1H6v1H5v1h1v1h4v-1h2v-2h1V6h-1V5z\"\n        fill=\"var(--os9-black)\"\n        fillRule=\"evenodd\"\n      />\n    </Svg>\n  )\n}\n\nconst GLYPHS: Record<RetroToolStatus, () => React.ReactElement> = {\n  running: WatchGlyph,\n  waiting: CautionGlyph,\n  done: CheckGlyph,\n  error: StopGlyph,\n  denied: DeniedGlyph,\n}\n\ninterface RetroToolStatusIconProps {\n  status: RetroToolStatus\n  className?: string\n}\n\n/**\n * The 16px status glyph. When `status` changes after mount, the old glyph\n * turns edge-on and the new one comes back in two frames (both flairs).\n */\nfunction RetroToolStatusIcon({ status, className }: RetroToolStatusIconProps) {\n  const [shown, setShown] = React.useState(status)\n  const [leaving, setLeaving] = React.useState<RetroToolStatus | null>(null)\n\n  /* adjust state while rendering: remember the glyph we're flipping away from */\n  if (status !== shown) {\n    setLeaving(shown)\n    setShown(status)\n  }\n\n  React.useEffect(() => {\n    if (!leaving) return\n    const t = window.setTimeout(() => setLeaving(null), 140)\n    return () => window.clearTimeout(t)\n  }, [leaving, shown])\n\n  const Glyph = GLYPHS[shown]\n  const Old = leaving ? GLYPHS[leaving] : null\n  return (\n    <span className={cn(\"relative inline-grid size-4 shrink-0 place-items-center\", className)} aria-hidden=\"true\">\n      <GlyphStyle />\n      {Old && (\n        <span key={`out-${leaving}-${shown}`} className=\"os9-tool-flip-out col-start-1 row-start-1\">\n          <Old />\n        </span>\n      )}\n      <span key={`in-${shown}`} className={cn(\"col-start-1 row-start-1\", Old && \"os9-tool-flip-in\")}>\n        <Glyph />\n      </span>\n    </span>\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  Shared bits                                                        */\n/* ------------------------------------------------------------------ */\n\nfunction formatValue(value: unknown): string {\n  if (value === undefined) return \"\"\n  if (typeof value === \"string\") return value\n  try {\n    return JSON.stringify(value, null, 2) ?? String(value)\n  } catch {\n    return String(value)\n  }\n}\n\n/** A labelled inset well holding Monaco text. */\nfunction Well({ label, children, tone }: { label: string; children: React.ReactNode; tone?: \"error\" | \"muted\" }) {\n  return (\n    <div className=\"flex flex-col gap-1\">\n      <span className=\"font-[family-name:var(--os9-font-heading)] text-[11px] tracking-[0.42px] leading-none text-os9-gray-800\">\n        {label}\n      </span>\n      <pre\n        className={cn(\n          \"os9-inset m-0 max-h-[180px] overflow-auto px-2 py-1.5\",\n          \"font-[family-name:var(--os9-font-mono)] text-[10px] leading-[1.5] whitespace-pre-wrap break-words\",\n          tone === \"muted\" ? \"text-os9-gray-700\" : \"text-os9-black\"\n        )}\n      >\n        {children}\n      </pre>\n    </div>\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  RetroToolCall                                                      */\n/* ------------------------------------------------------------------ */\n\ntype RetroToolCallProps = Omit<\n  React.ComponentProps<typeof CollapsiblePrimitive>,\n  \"className\" | \"children\" | \"render\" | \"part\" | \"title\"\n> & {\n  /** The tool call, as the AI SDK streams it. */\n  part: RetroToolPart\n  /** Overrides the default title (the tool name, prettified). */\n  title?: React.ReactNode\n  /** An optional 16px icon shown before the title, e.g. a pixel folder for a file tool. */\n  icon?: React.ReactNode\n  className?: string\n}\n\nfunction RetroToolCall({ part, title, icon, className, ...props }: RetroToolCallProps) {\n  const status = toolStatus(part)\n  const running = status === \"running\"\n  const name = toolNameOf(part)\n  const hasInput = part.input !== undefined\n  const hasOutput = part.output !== undefined\n\n  return (\n    <CollapsiblePrimitive\n      data-retro-tool-call=\"\"\n      data-status={status}\n      className={cn(\n        \"os9-tool-enter w-full border border-os9-black bg-os9-gray-200 text-os9-black\",\n        \"shadow-[inset_1px_1px_0_var(--os9-white),inset_-1px_-1px_0_var(--os9-gray-500)]\",\n        className\n      )}\n      {...props}\n    >\n      <GlyphStyle />\n      <CollapsibleTriggerPrimitive\n        className={cn(\n          \"group/tool flex h-[24px] w-full min-w-0 cursor-pointer select-none items-center gap-[6px] px-[6px] text-left\",\n          \"hover:bg-os9-lavender/50 focus-visible:os9-focus-ring outline-none\"\n        )}\n      >\n        {/* Disclosure triangle: 0° → 45° → 90° in two frames */}\n        <svg\n          width=\"8\"\n          height=\"8\"\n          viewBox=\"0 0 8 8\"\n          fill=\"none\"\n          aria-hidden=\"true\"\n          shapeRendering=\"crispEdges\"\n          className={cn(\n            \"shrink-0 transition-transform duration-[110ms] [transition-timing-function:steps(2,end)]\",\n            \"motion-reduce:transition-none group-data-open/tool:rotate-90\"\n          )}\n        >\n          <path d=\"M2 1L6 4L2 7Z\" fill=\"var(--os9-black)\" />\n        </svg>\n        <RetroToolStatusIcon status={status} />\n        {icon && <span className=\"flex size-4 shrink-0 items-center justify-center [&_svg]:size-4\">{icon}</span>}\n        <span className=\"min-w-0 flex-1 truncate font-[family-name:var(--os9-font-heading)] text-[12px] tracking-[0.42px] leading-none\">\n          {title ?? toolTitle(part)}\n        </span>\n        <span\n          className={cn(\n            \"shrink-0 font-[family-name:var(--os9-font-sans)] text-[10px] leading-none\",\n            status === \"waiting\" ? \"font-bold text-os9-black\" : \"text-os9-gray-800\"\n          )}\n        >\n          {STATUS_WORDS[status]}\n        </span>\n      </CollapsibleTriggerPrimitive>\n\n      {/* The barber pole slides in under the row while the call runs */}\n      <div\n        className={cn(\n          \"grid transition-[grid-template-rows] duration-180 ease-[cubic-bezier(0.23,1,0.32,1)]\",\n          \"in-data-[flair=classic]:transition-none motion-reduce:transition-none\",\n          running ? \"grid-rows-[1fr]\" : \"grid-rows-[0fr]\"\n        )}\n        aria-hidden={!running}\n      >\n        <div className=\"min-h-0 overflow-hidden\">\n          <div className=\"px-[6px] pb-[5px] pl-[20px]\">\n            {running && (\n              <RetroProgress indeterminate aria-label={`${toolTitle(part)} running`} className=\"h-[7px]\" />\n            )}\n          </div>\n        </div>\n      </div>\n\n      <CollapsiblePanelPrimitive\n        className={cn(\n          \"h-(--collapsible-panel-height) overflow-hidden\",\n          \"transition-[height] duration-220 ease-[cubic-bezier(0.23,1,0.32,1)]\",\n          \"data-starting-style:h-0 data-ending-style:h-0 data-ending-style:duration-180\",\n          \"in-data-[flair=classic]:transition-none motion-reduce:transition-none\"\n        )}\n      >\n        <div className=\"flex flex-col gap-2 border-t border-os9-gray-500 px-[8px] pt-[6px] pb-[8px] pl-[20px]\">\n          <span className=\"font-[family-name:var(--os9-font-mono)] text-[10px] leading-none text-os9-gray-700\">\n            {name}\n            {part.toolCallId ? ` · ${part.toolCallId}` : \"\"}\n          </span>\n          <Well label=\"Input\" tone={hasInput ? undefined : \"muted\"}>\n            {hasInput ? formatValue(part.input) : part.state === \"input-streaming\" ? \"Receiving…\" : \"None\"}\n          </Well>\n          {status === \"error\" ? (\n            <Well label=\"Error\" tone=\"error\">\n              {part.errorText || \"The tool failed without saying why.\"}\n            </Well>\n          ) : status === \"denied\" ? (\n            <Well label=\"Output\" tone=\"muted\">\n              {part.approval?.reason\n                ? `Not run. ${part.approval.reason}`\n                : \"Not run: you didn’t allow it.\"}\n            </Well>\n          ) : (\n            <Well label=\"Output\" tone={hasOutput ? undefined : \"muted\"}>\n              {hasOutput\n                ? formatValue(part.output)\n                : status === \"waiting\"\n                  ? \"Waits for your answer.\"\n                  : \"Waiting for the result…\"}\n            </Well>\n          )}\n        </div>\n      </CollapsiblePanelPrimitive>\n    </CollapsiblePrimitive>\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  RetroToolCallGroup                                                 */\n/* ------------------------------------------------------------------ */\n\n/** Stacks consecutive tool calls so neighbours share one border. */\nfunction RetroToolCallGroup({ className, ...props }: React.ComponentProps<\"div\">) {\n  return (\n    <div\n      role=\"group\"\n      className={cn(\n        \"flex w-full flex-col\",\n        \"[&>[data-retro-tool-call]+[data-retro-tool-call]]:border-t-0\",\n        className\n      )}\n      {...props}\n    />\n  )\n}\n\n/* ------------------------------------------------------------------ */\n/*  RetroToolChips                                                     */\n/* ------------------------------------------------------------------ */\n\ninterface RetroToolChipsProps extends Omit<React.ComponentProps<\"div\">, \"onSelect\"> {\n  parts: RetroToolPart[]\n  /** Makes each chip a button, e.g. to scroll to or expand the full call. */\n  onSelect?: (part: RetroToolPart) => void\n}\n\nconst chipClass = cn(\n  \"os9-tool-enter inline-flex h-[20px] max-w-full items-center gap-1 pl-[3px] pr-[6px]\",\n  \"border border-os9-black bg-os9-gray-300 text-os9-black\",\n  \"shadow-[inset_1px_1px_0_var(--os9-white),inset_-1px_-1px_0_var(--os9-gray-700)]\",\n  \"font-[family-name:var(--os9-font-mono)] text-[10px] leading-none\"\n)\n\n/** Compact inline bevel chips: status glyph + tool name, for dense layouts. */\nfunction RetroToolChips({ parts, onSelect, className, ...props }: RetroToolChipsProps) {\n  return (\n    <div role=\"list\" className={cn(\"flex flex-wrap items-center gap-1\", className)} {...props}>\n      {parts.map((part) => {\n        const status = toolStatus(part)\n        const label = `${toolTitle(part)}: ${STATUS_WORDS[status]}`\n        const inner = (\n          <>\n            <RetroToolStatusIcon status={status} />\n            <span className=\"truncate\">{toolNameOf(part)}</span>\n          </>\n        )\n        return (\n          <span role=\"listitem\" key={part.toolCallId} className=\"inline-flex max-w-full\">\n            {onSelect ? (\n              <button\n                type=\"button\"\n                title={label}\n                aria-label={label}\n                onClick={() => onSelect(part)}\n                className={cn(\n                  chipClass,\n                  \"cursor-pointer select-none focus-visible:os9-focus-ring outline-none\",\n                  \"active:bg-os9-gray-800 active:text-os9-white\",\n                  \"active:shadow-[inset_1px_1px_0_var(--os9-gray-700),inset_-1px_-1px_0_var(--os9-white)]\"\n                )}\n              >\n                {inner}\n              </button>\n            ) : (\n              <span title={label} aria-label={label} role=\"img\" className={chipClass}>\n                {inner}\n              </span>\n            )}\n          </span>\n        )\n      })}\n    </div>\n  )\n}\n\nexport {\n  RetroToolCall,\n  RetroToolCallGroup,\n  RetroToolChips,\n  RetroToolStatusIcon,\n  toolStatus,\n  toolTitle,\n  prettifyToolName,\n}\nexport type { RetroToolCallProps, RetroToolChipsProps, RetroToolStatus, RetroToolStatusIconProps }\n",
      "type": "registry:ui"
    }
  ],
  "type": "registry:ui"
}