{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "background-runs",
  "title": "Background Runs",
  "description": "Ongoing and completed agent jobs collected in one actionable inbox.",
  "dependencies": [
    "@solar-icons/react@^2.2.0",
    "cn@^0.3.0",
    "motion@^13.4.0"
  ],
  "registryDependencies": [
    "button",
    "https://pastaui.com/r/pastaui-styles.json"
  ],
  "files": [
    {
      "path": "src/components/ai/background-runs.tsx",
      "content": "import { CheckCircleIcon as CheckCircle2Icon } from '@solar-icons/react/bold/check-circle'\nimport { DangerCircleIcon as CircleAlertIcon } from '@solar-icons/react/linear/danger-circle'\nimport { ClockCircleIcon as Clock3Icon } from '@solar-icons/react/linear/clock-circle'\nimport { LayersMinimalisticIcon as RunsIcon } from '@solar-icons/react/linear/layers-minimalistic'\nimport { LoaderIcon as LoaderCircleIcon } from '@solar-icons/react/linear/loader'\nimport { CloseIcon as XIcon } from '@solar-icons/react/linear/close'\nimport { AnimatePresence, motion } from 'motion/react'\nimport * as React from 'react'\n\nimport { Button } from '@/components/ui/button'\nimport { cn } from 'cn'\n\ninterface BackgroundRun {\n  detail?: string\n  id: string\n  label: string\n  progress?: number\n  status: 'complete' | 'failed' | 'queued' | 'running'\n  updatedAt?: string\n}\n\ninterface BackgroundRunsProps extends React.ComponentProps<'section'> {\n  items: BackgroundRun[]\n  onCancel?: (id: string) => void\n  onOpen?: (id: string) => void\n}\n\nconst titleTone: Record<BackgroundRun['status'], string> = {\n  complete: 'text-muted-foreground',\n  failed: 'text-muted-foreground',\n  queued: 'text-muted-foreground/70',\n  running: 'text-foreground',\n}\n\nfunction BackgroundRuns({ className, items, onCancel, onOpen, ...props }: BackgroundRunsProps) {\n  const [confirmingId, setConfirmingId] = React.useState<string | null>(null)\n  const running = items.filter((item) => item.status === 'running').length\n  const queued = items.filter((item) => item.status === 'queued').length\n  const summary =\n    [running && `${running} running`, queued && `${queued} queued`].filter(Boolean).join(' · ') ||\n    'All done'\n\n  React.useEffect(() => {\n    if (!confirmingId) return\n    const timer = window.setTimeout(() => setConfirmingId(null), 3000)\n    return () => window.clearTimeout(timer)\n  }, [confirmingId])\n\n  function cancel(item: BackgroundRun) {\n    if (item.status === 'running' && confirmingId !== item.id) {\n      setConfirmingId(item.id)\n      return\n    }\n    setConfirmingId(null)\n    onCancel?.(item.id)\n  }\n\n  return (\n    <section\n      data-slot=\"background-runs\"\n      className={cn(\n        'overflow-hidden rounded-[16px] bg-card font-sans text-sm font-[450] tracking-[-0.05px] text-muted-foreground shadow-card',\n        className,\n      )}\n      {...props}\n    >\n      <header className=\"flex items-center gap-2 px-4 py-3\">\n        <RunsIcon className=\"size-4 text-muted-foreground\" />\n        <h3 className=\"text-sm leading-5 font-medium text-muted-foreground\">Background runs</h3>\n        <span className=\"ml-auto rounded-full bg-foreground/6 px-2 py-0.5 text-xs leading-5 text-muted-foreground tabular-nums\">\n          {summary}\n        </span>\n      </header>\n      <ul className=\"space-y-1 border-t border-foreground/8 p-2\">\n        <AnimatePresence initial={false}>\n          {items.map((item) => {\n            const cancellable = item.status === 'queued' || item.status === 'running'\n            const confirming = confirmingId === item.id\n\n            return (\n              <motion.li\n                animate={{ opacity: 1, y: 0 }}\n                className=\"group relative rounded-[10px] p-2.5 transition-colors hover:bg-foreground/4\"\n                exit={{ opacity: 0, y: -4 }}\n                initial={{ opacity: 0, y: 4 }}\n                key={item.id}\n                layout=\"position\"\n                transition={{ duration: 0.3, ease: [0.23, 1, 0.32, 1] }}\n              >\n                <div className=\"flex items-start gap-3\">\n                  <span className=\"flex h-6 shrink-0 items-center\">\n                    <RunStatus status={item.status} />\n                  </span>\n                  <button\n                    className={cn(\n                      'min-w-0 flex-1 rounded-sm text-left outline-none focus-visible:ring-2 focus-visible:ring-ring',\n                      cancellable && 'pointer-coarse:pr-8',\n                    )}\n                    onClick={() => onOpen?.(item.id)}\n                    type=\"button\"\n                  >\n                    <span className=\"flex items-baseline gap-3\">\n                      <span\n                        className={cn(\n                          'min-w-0 flex-1 truncate text-[15px] leading-6 font-medium',\n                          titleTone[item.status],\n                        )}\n                      >\n                        {item.label}\n                      </span>\n                      {item.updatedAt && (\n                        <time\n                          className={cn(\n                            'shrink-0 text-xs text-muted-foreground/70 tabular-nums',\n                            cancellable &&\n                              'transition-opacity duration-150 ease-out group-focus-within:opacity-0 group-hover:opacity-0 pointer-coarse:opacity-100',\n                            confirming && 'opacity-0',\n                          )}\n                        >\n                          {item.updatedAt}\n                        </time>\n                      )}\n                    </span>\n                    {item.detail && (\n                      <span className=\"mt-0.5 block truncate text-[13px] leading-5 text-muted-foreground/70\">\n                        {item.detail}\n                      </span>\n                    )}\n                  </button>\n                  <span className=\"absolute top-2.5 right-2.5 flex h-6 items-center\">\n                    {cancellable &&\n                      (confirming ? (\n                        <Button\n                          aria-label={`Stop ${item.label}`}\n                          className=\"h-6 rounded-full bg-destructive/10 px-2 text-xs text-destructive hover:bg-destructive/20 hover:text-destructive\"\n                          onClick={() => cancel(item)}\n                          size=\"xs\"\n                          type=\"button\"\n                          variant=\"ghost\"\n                        >\n                          Stop\n                        </Button>\n                      ) : (\n                        <Button\n                          aria-label={`Cancel ${item.label}`}\n                          className=\"opacity-0 transition-[opacity,background-color] duration-150 ease-out group-focus-within:opacity-100 group-hover:opacity-100 pointer-coarse:opacity-100\"\n                          onClick={() => cancel(item)}\n                          size=\"icon-xs\"\n                          type=\"button\"\n                          variant=\"ghost\"\n                        >\n                          <XIcon />\n                        </Button>\n                      ))}\n                  </span>\n                </div>\n                {item.status === 'running' && item.progress !== undefined && (\n                  <div className=\"mt-2.5 ml-7 h-1 overflow-hidden rounded-full bg-foreground/8\">\n                    <div\n                      className=\"h-full origin-left rounded-full bg-blue-500 transition-[scale] duration-300 ease-linear dark:bg-blue-400\"\n                      style={{ scale: `${item.progress / 100} 1` }}\n                    />\n                  </div>\n                )}\n              </motion.li>\n            )\n          })}\n        </AnimatePresence>\n      </ul>\n    </section>\n  )\n}\n\nconst statusEnterClass =\n  'transition-[opacity,scale] duration-200 ease-[cubic-bezier(0.23,1,0.32,1)] starting:scale-90 starting:opacity-0 motion-reduce:starting:scale-100'\n\nfunction RunStatus({ status }: Pick<BackgroundRun, 'status'>) {\n  if (status === 'complete')\n    return (\n      <CheckCircle2Icon\n        aria-label=\"Complete\"\n        className={cn('size-4 text-emerald-600', statusEnterClass)}\n      />\n    )\n  if (status === 'failed')\n    return (\n      <CircleAlertIcon\n        aria-label=\"Failed\"\n        className={cn('size-4 text-destructive', statusEnterClass)}\n      />\n    )\n  if (status === 'running')\n    return (\n      <LoaderCircleIcon\n        aria-label=\"Running\"\n        className=\"size-4 animate-spin text-blue-500 motion-reduce:animate-none dark:text-blue-400\"\n      />\n    )\n  return <Clock3Icon aria-label=\"Queued\" className=\"size-4 text-muted-foreground/70\" />\n}\n\nexport { BackgroundRuns }\nexport type { BackgroundRun, BackgroundRunsProps }\n",
      "type": "registry:component",
      "target": "@components/ai/background-runs.tsx"
    }
  ],
  "type": "registry:component"
}