{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "message-queue-demo",
  "title": "Message Queue Demo",
  "description": "A worked example of Message Queue: Keeps follow-ups typed while the agent is busy. They stack above the composer, can be edited, reordered or removed, and go out one at a time when the agent is free.",
  "registryDependencies": [
    "https://ui.tinkererslabs.com/r/message-queue.json"
  ],
  "files": [
    {
      "path": "components/demos/message-queue-demo.tsx",
      "content": "\"use client\"\n\nimport * as React from \"react\"\n\nimport {\n  MessageQueue,\n  type QueuedMessage,\n} from \"@/registry/default/message-queue/message-queue\"\nimport { PromptInput } from \"@/registry/default/prompt-input/prompt-input\"\n\nconst initialQueue: QueuedMessage[] = [\n  { id: \"q1\", text: \"Then run the migration against the staging database.\" },\n  { id: \"q2\", text: \"Keep the old column until the backfill finishes.\" },\n]\n\nexport function MessageQueueDemo() {\n  const [busy, setBusy] = React.useState(true)\n  const [queue, setQueue] = React.useState(initialQueue)\n  const [sent, setSent] = React.useState<string[]>([\n    \"Add a nullable email column to the users table.\",\n  ])\n  const nextId = React.useRef(3)\n\n  React.useEffect(() => {\n    if (!busy) return\n    const timer = window.setTimeout(() => setBusy(false), 4000)\n    return () => window.clearTimeout(timer)\n  }, [busy])\n\n  const send = (text: string) => {\n    setSent((current) => [...current, text])\n    setBusy(true)\n  }\n\n  return (\n    <div className=\"grid w-full max-w-xl gap-3\">\n      <ol aria-label=\"Sent messages\" className=\"grid gap-1.5\">\n        {sent.slice(-3).map((text, index) => (\n          <li\n            className=\"bg-muted text-foreground justify-self-end rounded-[var(--radius)] px-3 py-2 text-sm\"\n            key={`${index}-${text}`}\n          >\n            {text}\n          </li>\n        ))}\n      </ol>\n\n      <p className=\"text-muted-foreground text-xs\" role=\"status\">\n        {busy ? \"The agent is working.\" : \"The agent is idle.\"}\n      </p>\n\n      <MessageQueue\n        busy={busy}\n        items={queue}\n        onItemsChange={setQueue}\n        onRelease={(item) => send(item.text)}\n      />\n\n      <PromptInput\n        placeholder=\"Type a follow-up\"\n        status={busy ? \"streaming\" : \"ready\"}\n        onStop={() => setBusy(false)}\n        onSubmit={(text) => {\n          if (busy) {\n            setQueue((current) => [\n              ...current,\n              { id: `q${nextId.current++}`, text },\n            ])\n          } else {\n            send(text)\n          }\n        }}\n      />\n\n      <p className=\"text-muted-foreground text-center text-xs\">\n        Enter adds to the queue while the agent works. Stopping it sends the\n        next one.\n      </p>\n    </div>\n  )\n}\n",
      "type": "registry:example"
    }
  ],
  "type": "registry:example"
}