{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "stop-generating-demo",
  "title": "Stop Generating Demo",
  "description": "A worked example of Stop Generating: The control that interrupts a running answer, with the time it has been going and Escape wired up.",
  "dependencies": [
    "lucide-react@^1.31.0"
  ],
  "registryDependencies": [
    "https://ui.tinkererslabs.com/r/stop-generating.json"
  ],
  "files": [
    {
      "path": "components/demos/stop-generating-demo.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport { RestartButton } from \"@/components/demos/restart-button\"\nimport { StopGenerating } from \"@/registry/default/stop-generating/stop-generating\"\n\nconst answer =\n  \"Rate limiting belongs in middleware so every route inherits it. Keep the counter in Redis with a sliding window, and return 429 once the window is full.\"\n\nexport function StopGeneratingDemo() {\n  const [run, setRun] = React.useState(() => ({ id: 0, startedAt: Date.now() }))\n  const [shown, setShown] = React.useState(0)\n  const [stopped, setStopped] = React.useState(false)\n\n  const words = answer.split(\" \")\n  const done = shown >= words.length\n  const running = !done && !stopped\n\n  React.useEffect(() => {\n    if (!running) return\n\n    const timer = setTimeout(() => setShown((count) => count + 1), 130)\n    return () => clearTimeout(timer)\n  }, [running, shown, run.id])\n\n  return (\n    <div className=\"grid w-full max-w-xl gap-4\">\n      <p className=\"text-foreground min-h-16 text-sm leading-relaxed\">\n        {words.slice(0, shown).join(\" \")}\n        {stopped && !done ? (\n          <span className=\"text-muted-foreground\"> … stopped</span>\n        ) : null}\n      </p>\n\n      <div className=\"flex items-center gap-3\">\n        <StopGenerating\n          running={running}\n          startedAt={run.startedAt}\n          onStop={() => setStopped(true)}\n        />\n\n        {running ? null : (\n          <RestartButton\n            onClick={() => {\n              setShown(0)\n              setStopped(false)\n              setRun((current) => ({\n                id: current.id + 1,\n                startedAt: Date.now(),\n              }))\n            }}\n          />\n        )}\n      </div>\n    </div>\n  )\n}\n",
      "type": "registry:example"
    },
    {
      "path": "components/demos/restart-button.tsx",
      "content": "\"use client\"\n\nimport { RotateCcw } from \"lucide-react\"\n\nexport function RestartButton({ onClick }: { onClick: () => void }) {\n  return (\n    <button className=\"restore-button\" type=\"button\" onClick={onClick}>\n      <RotateCcw aria-hidden=\"true\" size={15} /> Replay\n    </button>\n  )\n}\n",
      "type": "registry:example"
    }
  ],
  "type": "registry:example"
}