{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "agent-run-lanes",
  "type": "registry:component",
  "title": "Agent Run Lanes",
  "description": "A replay of a multi-agent run with one swim lane per agent, task bars that fill as a playhead sweeps the time axis and curved handoff links that draw in when work passes between agents. Drag the track or use the arrow keys to scrub, and a status line narrates the latest event.",
  "author": "Hyperblur <hello@hyperblur.dev>",
  "dependencies": [],
  "registryDependencies": [],
  "categories": [
    "agent-kit",
    "agents",
    "multi-agent",
    "timeline",
    "swim lanes",
    "replay",
    "orchestration"
  ],
  "docs": "https://hyperblur.dev/effects/agent-run-lanes",
  "files": [
    {
      "path": "registry/hyperblur/agent-run-lanes.tsx",
      "type": "registry:component",
      "target": "components/hyperblur/agent-run-lanes.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\n\nexport interface RunLaneAgent {\n  id: string;\n  name: string;\n  role?: string;\n  color: string;\n}\n\nexport interface RunLaneTask {\n  id: string;\n  agent: string;\n  label: string;\n  start: number;\n  end: number;\n  status?: \"ok\" | \"error\";\n}\n\nexport interface RunLaneHandoff {\n  from: string;\n  to: string;\n  label: string;\n}\n\nexport interface AgentRunLanesProps extends Omit<React.HTMLAttributes<HTMLDivElement>, \"title\"> {\n  agents?: RunLaneAgent[];\n  tasks?: RunLaneTask[];\n  handoffs?: RunLaneHandoff[];\n  duration?: number;\n  title?: string;\n  time?: number;\n  defaultTime?: number;\n  onTimeChange?: (time: number) => void;\n  autoPlay?: boolean;\n  loop?: boolean;\n  speed?: number;\n  accent?: string;\n}\n\nconst sampleAgents: RunLaneAgent[] = [\n  { id: \"plan\", name: \"Planner\", role: \"orchestrator\", color: \"#9a7bff\" },\n  { id: \"research\", name: \"Researcher\", role: \"web + docs\", color: \"#3cc6e0\" },\n  { id: \"code\", name: \"Coder\", role: \"repo write\", color: \"#4c8dff\" },\n  { id: \"review\", name: \"Reviewer\", role: \"tests + lint\", color: \"#34c78a\" },\n];\n\nconst sampleTasks: RunLaneTask[] = [\n  { id: \"t1\", agent: \"plan\", label: \"Break down brief\", start: 0, end: 9 },\n  { id: \"t2\", agent: \"research\", label: \"Scan 6 pricing pages\", start: 10, end: 34 },\n  { id: \"t3\", agent: \"code\", label: \"Scaffold route\", start: 10, end: 26 },\n  { id: \"t4\", agent: \"plan\", label: \"Merge findings\", start: 35, end: 41 },\n  { id: \"t5\", agent: \"code\", label: \"Build tier table\", start: 42, end: 70 },\n  { id: \"t6\", agent: \"review\", label: \"Run 48 tests\", start: 58, end: 66, status: \"error\" },\n  { id: \"t7\", agent: \"code\", label: \"Fix rounding\", start: 71, end: 78 },\n  { id: \"t8\", agent: \"review\", label: \"Re-run + lint\", start: 79, end: 88 },\n];\n\nconst sampleHandoffs: RunLaneHandoff[] = [\n  { from: \"t1\", to: \"t2\", label: \"brief\" },\n  { from: \"t1\", to: \"t3\", label: \"spec\" },\n  { from: \"t2\", to: \"t4\", label: \"6 sources\" },\n  { from: \"t4\", to: \"t5\", label: \"tier plan\" },\n  { from: \"t6\", to: \"t7\", label: \"1 failing test\" },\n  { from: \"t7\", to: \"t8\", label: \"patch\" },\n];\n\nconst clock = (s: number) => `${Math.floor(s / 60).toString().padStart(2, \"0\")}:${Math.floor(s % 60).toString().padStart(2, \"0\")}`;\n\nconst css = `\n.hb-wj5 {\n  --hb-wj5-a: #2f7bff;\n  --hb-wj5-lh: 26px;\n  box-sizing: border-box;\n  container-type: inline-size;\n  width: 100%;\n  padding: 10px 12px 10px;\n  font-family: inherit;\n  font-size: 11.5px;\n  color: #ededed;\n  background: linear-gradient(180deg, #131313, #0e0e0e);\n  border: 1px solid #262626;\n  border-radius: 14px;\n  box-shadow: 0 1px 0 rgba(255,255,255,0.04) inset, 0 24px 50px -30px rgba(0,0,0,0.9);\n}\n.hb-wj5 *, .hb-wj5 *::before, .hb-wj5 *::after { box-sizing: border-box; font-family: inherit; }\n.hb-wj5-top { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }\n.hb-wj5-play { display: grid; place-items: center; flex: none; width: 24px; height: 24px; padding: 0; color: #0a0a0a; background: #ededed; border: 0; border-radius: 50%; cursor: pointer; transition: transform .15s ease, background-color .15s ease; }\n.hb-wj5-play:hover { background: #fff; }\n.hb-wj5-play:active { transform: scale(.92); }\n.hb-wj5-play svg { width: 10px; height: 10px; }\n.hb-wj5-title { flex: 1; min-width: 0; margin: 0; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }\n.hb-wj5-clock { flex: none; font-family: var(--font-mono), ui-monospace, monospace; font-size: 10.5px; color: #8f8f8f; font-variant-numeric: tabular-nums; }\n.hb-wj5-clock b { color: #ededed; font-weight: 500; }\n.hb-wj5-grid { display: grid; grid-template-columns: 88px minmax(0, 1fr); column-gap: 8px; }\n.hb-wj5-who { display: flex; align-items: center; gap: 6px; height: var(--hb-wj5-lh); min-width: 0; }\n.hb-wj5-av { position: relative; display: grid; place-items: center; flex: none; width: 18px; height: 18px; font-size: 9px; font-weight: 700; color: #0a0a0a; background: var(--c); border-radius: 6px; }\n.hb-wj5-av[data-live=\"true\"]::after { content: \"\"; position: absolute; inset: -3px; border: 1.5px solid var(--c); border-radius: 8px; animation: hb-wj5-ping 1.4s ease-out infinite; }\n.hb-wj5-nm { min-width: 0; line-height: 1.1; }\n.hb-wj5-nm b { display: block; font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-wj5-nm span { display: block; font-size: 9.5px; color: #6f6f6f; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }\n.hb-wj5-track { position: relative; touch-action: none; cursor: ew-resize; }\n.hb-wj5-lane { position: relative; height: var(--hb-wj5-lh); border-top: 1px dashed #1f1f1f; }\n.hb-wj5-lane:first-child { border-top-color: transparent; }\n.hb-wj5-bar { position: absolute; top: 4px; bottom: 4px; display: flex; align-items: center; padding: 0 6px; overflow: hidden; font-size: 10px; font-weight: 500; color: #8f8f8f; white-space: nowrap; border: 1px dashed #333; border-radius: 6px; transition: color .2s ease, border-color .2s ease; }\n.hb-wj5-bar span { position: relative; z-index: 1; overflow: hidden; text-overflow: ellipsis; }\n.hb-wj5-fill { position: absolute; inset: 0; background: linear-gradient(180deg, color-mix(in srgb, var(--c) 40%, #151515), color-mix(in srgb, var(--c) 26%, #121212)); transform-origin: left center; }\n.hb-wj5-bar[data-state=\"run\"], .hb-wj5-bar[data-state=\"done\"] { color: #fff; border-style: solid; border-color: color-mix(in srgb, var(--c) 45%, transparent); }\n.hb-wj5-bar[data-state=\"run\"] .hb-wj5-fill::after { content: \"\"; position: absolute; top: 0; bottom: 0; right: 0; width: 18px; background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--c) 80%, #fff)); opacity: .55; }\n.hb-wj5-bar[data-state=\"done\"][data-error=\"true\"] { border-color: rgba(255,90,79,.6); }\n.hb-wj5-bar[data-state=\"done\"][data-error=\"true\"] .hb-wj5-fill { background: linear-gradient(180deg, rgba(255,90,79,.38), rgba(255,90,79,.22)); }\n.hb-wj5-links { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }\n.hb-wj5-links path { fill: none; stroke: #5a5a5a; stroke-width: 1.2; stroke-dasharray: 1 1; stroke-dashoffset: 1; transition: stroke-dashoffset .5s cubic-bezier(.4,0,.2,1), stroke .3s ease; }\n.hb-wj5-links path[data-on=\"true\"] { stroke-dashoffset: 0; stroke: color-mix(in srgb, var(--hb-wj5-a) 70%, #fff); }\n.hb-wj5-head { position: absolute; top: -4px; bottom: 0; width: 0; pointer-events: none; z-index: 3; }\n.hb-wj5-head::before { content: \"\"; position: absolute; top: 0; bottom: 0; left: -0.5px; width: 1px; background: #fff; box-shadow: 0 0 8px rgba(255,255,255,.6); }\n.hb-wj5-head::after { content: \"\"; position: absolute; top: -3px; left: -4px; width: 8px; height: 8px; background: #fff; clip-path: polygon(0 0, 100% 0, 50% 100%); }\n.hb-wj5-axis { position: relative; height: 14px; margin-top: 2px; font-family: var(--font-mono), ui-monospace, monospace; font-size: 9px; color: #5a5a5a; }\n.hb-wj5-axis span { position: absolute; top: 2px; transform: translateX(-50%); font-variant-numeric: tabular-nums; }\n.hb-wj5-axis span:first-child { transform: none; }\n.hb-wj5-axis span:last-child { transform: translateX(-100%); }\n.hb-wj5-log { display: flex; align-items: center; gap: 6px; height: 20px; margin-top: 4px; padding: 0 8px; overflow: hidden; font-size: 10.5px; color: #a1a1a1; background: #151515; border: 1px solid #222; border-radius: 7px; }\n.hb-wj5-log i { flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--c, #555); font-style: normal; }\n.hb-wj5-log span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: hb-wj5-in .3s cubic-bezier(.2,.8,.2,1) both; }\n.hb-wj5-log b { color: #ededed; font-weight: 600; }\n.hb-wj5-track:focus-visible, .hb-wj5-play:focus-visible { outline: 2px solid var(--hb-wj5-a); outline-offset: 2px; border-radius: 4px; }\n@keyframes hb-wj5-ping { from { opacity: .9; transform: scale(.9); } to { opacity: 0; transform: scale(1.35); } }\n@keyframes hb-wj5-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }\n@container (max-width: 360px) {\n  .hb-wj5-grid { grid-template-columns: 18px minmax(0, 1fr); }\n  .hb-wj5-nm { display: none; }\n}\n@media (prefers-reduced-motion: reduce) {\n  .hb-wj5-av[data-live=\"true\"]::after, .hb-wj5-log span { animation: none; }\n  .hb-wj5-links path, .hb-wj5-bar { transition: none; }\n}\n`;\n\nexport function AgentRunLanes({\n  agents = sampleAgents,\n  tasks = sampleTasks,\n  handoffs = sampleHandoffs,\n  duration,\n  title = \"Run 2291 · Ship the pricing page\",\n  time,\n  defaultTime = 0,\n  onTimeChange,\n  autoPlay = true,\n  loop = true,\n  speed = 1,\n  accent = \"#2f7bff\",\n  className,\n  style,\n  ...rest\n}: AgentRunLanesProps) {\n  const total = duration ?? Math.max(1, ...tasks.map((t) => t.end)) + 2;\n  const [inner, setInner] = React.useState(defaultTime);\n  const [playing, setPlaying] = React.useState(autoPlay);\n  const now = Math.min(total, Math.max(0, time ?? inner));\n  const nowRef = React.useRef(now);\n  const trackRef = React.useRef<HTMLDivElement>(null);\n  const scrub = React.useRef(false);\n  const cb = React.useRef(onTimeChange);\n  React.useEffect(() => {\n    nowRef.current = now;\n    cb.current = onTimeChange;\n  });\n\n  const setTime = React.useCallback(\n    (t: number) => {\n      const v = Math.min(total, Math.max(0, t));\n      if (time === undefined) setInner(v);\n      cb.current?.(v);\n    },\n    [time, total],\n  );\n\n  React.useEffect(() => {\n    if (!playing) return;\n    let raf = 0;\n    if (window.matchMedia(\"(prefers-reduced-motion: reduce)\").matches) {\n      raf = requestAnimationFrame(() => {\n        setTime(total);\n        setPlaying(false);\n      });\n      return () => cancelAnimationFrame(raf);\n    }\n    let last = performance.now();\n    let hold = 0;\n    const tick = (ts: number) => {\n      const dt = Math.min(0.1, (ts - last) / 1000);\n      last = ts;\n      if (!scrub.current) {\n        const cur = nowRef.current;\n        if (cur >= total) {\n          hold += dt;\n          if (!loop) {\n            setPlaying(false);\n            return;\n          }\n          if (hold > 1.6) {\n            hold = 0;\n            setTime(0);\n          }\n        } else setTime(cur + dt * speed * 6);\n      }\n      raf = requestAnimationFrame(tick);\n    };\n    raf = requestAnimationFrame(tick);\n    return () => cancelAnimationFrame(raf);\n  }, [playing, loop, speed, total, setTime]);\n\n  const laneOf = (id: string) => agents.findIndex((a) => a.id === id);\n  const pct = (s: number) => (s / total) * 100;\n  const byId = new Map(tasks.map((t) => [t.id, t]));\n\n  const fromX = (clientX: number) => {\n    const r = trackRef.current?.getBoundingClientRect();\n    if (!r) return;\n    setTime(((clientX - r.left) / r.width) * total);\n  };\n\n  const events: { at: number; color: string; text: React.ReactNode; key: string }[] = [];\n  tasks.forEach((t) => {\n    const a = agents[laneOf(t.agent)];\n    if (!a) return;\n    events.push({ at: t.start, color: a.color, key: `s${t.id}`, text: <><b>{a.name}</b> started {t.label.toLowerCase()}</> });\n    if (t.status === \"error\") events.push({ at: t.end, color: \"#ff5a4f\", key: `e${t.id}`, text: <><b>{a.name}</b> flagged a failure in {t.label.toLowerCase()}</> });\n  });\n  handoffs.forEach((h) => {\n    const f = byId.get(h.from);\n    const to = byId.get(h.to);\n    if (!f || !to) return;\n    const fa = agents[laneOf(f.agent)];\n    const ta = agents[laneOf(to.agent)];\n    if (fa && ta) events.push({ at: f.end + 0.01, color: fa.color, key: `h${h.from}${h.to}`, text: <><b>{fa.name}</b> → <b>{ta.name}</b>: {h.label}</> });\n  });\n  events.sort((a, b) => a.at - b.at);\n  const lastEvent = [...events].reverse().find((e) => e.at <= now);\n  const finished = now >= Math.max(...tasks.map((t) => t.end));\n  const ticks = [0, 0.25, 0.5, 0.75, 1].map((f) => Math.round(f * total));\n  const lanes = agents.length;\n\n  return (\n    <div className={[\"hb-wj5\", className].filter(Boolean).join(\" \")} style={{ \"--hb-wj5-a\": accent, ...style } as React.CSSProperties} {...rest}>\n      <style href=\"hb-agent-run-lanes\" precedence=\"default\">{css}</style>\n      <div className=\"hb-wj5-top\">\n        <button\n          type=\"button\"\n          className=\"hb-wj5-play\"\n          aria-label={playing ? \"Pause replay\" : \"Play replay\"}\n          onClick={() => {\n            if (!playing && now >= total) setTime(0);\n            setPlaying((p) => !p);\n          }}\n        >\n          {playing ? <svg viewBox=\"0 0 10 10\" aria-hidden=\"true\"><path d=\"M2 1.5h2v7H2zM6 1.5h2v7H6z\" fill=\"currentColor\" /></svg> : <svg viewBox=\"0 0 10 10\" aria-hidden=\"true\"><path d=\"M2.5 1.2v7.6L8.8 5Z\" fill=\"currentColor\" /></svg>}\n        </button>\n        <p className=\"hb-wj5-title\">{title}</p>\n        <span className=\"hb-wj5-clock\"><b>{clock(now)}</b> / {clock(total)}</span>\n      </div>\n      <div className=\"hb-wj5-grid\">\n        <div>\n          {agents.map((a) => {\n            const live = tasks.some((t) => t.agent === a.id && now >= t.start && now < t.end);\n            return (\n              <div key={a.id} className=\"hb-wj5-who\" style={{ \"--c\": a.color } as React.CSSProperties}>\n                <span className=\"hb-wj5-av\" data-live={live} aria-hidden=\"true\">{a.name[0]}</span>\n                <span className=\"hb-wj5-nm\"><b>{a.name}</b>{a.role && <span>{a.role}</span>}</span>\n              </div>\n            );\n          })}\n        </div>\n        <div>\n          <div\n            ref={trackRef}\n            className=\"hb-wj5-track\"\n            role=\"slider\"\n            tabIndex={0}\n            aria-label=\"Replay position\"\n            aria-valuemin={0}\n            aria-valuemax={Math.round(total)}\n            aria-valuenow={Math.round(now)}\n            aria-valuetext={`${clock(now)} of ${clock(total)}`}\n            onPointerDown={(e) => {\n              e.currentTarget.setPointerCapture(e.pointerId);\n              scrub.current = true;\n              fromX(e.clientX);\n            }}\n            onPointerMove={(e) => {\n              if (scrub.current) fromX(e.clientX);\n            }}\n            onPointerUp={() => { scrub.current = false; }}\n            onPointerCancel={() => { scrub.current = false; }}\n            onKeyDown={(e) => {\n              const step = e.shiftKey ? 10 : 2;\n              if (e.key === \"ArrowRight\") setTime(now + step);\n              else if (e.key === \"ArrowLeft\") setTime(now - step);\n              else if (e.key === \"Home\") setTime(0);\n              else if (e.key === \"End\") setTime(total);\n              else if (e.key === \" \") setPlaying((p) => !p);\n              else return;\n              e.preventDefault();\n            }}\n          >\n            {agents.map((a) => (\n              <div key={a.id} className=\"hb-wj5-lane\">\n                {tasks\n                  .filter((t) => t.agent === a.id)\n                  .map((t) => {\n                    const p = Math.min(1, Math.max(0, (now - t.start) / (t.end - t.start)));\n                    const state = p <= 0 ? \"wait\" : p < 1 ? \"run\" : \"done\";\n                    return (\n                      <div key={t.id} className=\"hb-wj5-bar\" data-state={state} data-error={t.status === \"error\"} title={`${a.name}: ${t.label} (${t.end - t.start}s)`} style={{ \"--c\": a.color, left: `${pct(t.start).toFixed(2)}%`, width: `${pct(t.end - t.start).toFixed(2)}%` } as React.CSSProperties}>\n                        <i className=\"hb-wj5-fill\" style={{ transform: `scaleX(${p.toFixed(3)})` }} />\n                        <span>{t.label}</span>\n                      </div>\n                    );\n                  })}\n              </div>\n            ))}\n            <svg className=\"hb-wj5-links\" viewBox={`0 0 100 ${lanes * 10}`} preserveAspectRatio=\"none\" aria-hidden=\"true\">\n              {handoffs.map((h) => {\n                const f = byId.get(h.from);\n                const to = byId.get(h.to);\n                if (!f || !to) return null;\n                const x1 = pct(f.end);\n                const x2 = pct(to.start);\n                const y1 = laneOf(f.agent) * 10 + 5;\n                const y2 = laneOf(to.agent) * 10 + 5;\n                const mx = (x1 + x2) / 2;\n                return <path key={`${h.from}-${h.to}`} pathLength={1} vectorEffect=\"non-scaling-stroke\" data-on={now >= f.end} d={`M${x1.toFixed(2)} ${y1} C${mx.toFixed(2)} ${y1}, ${mx.toFixed(2)} ${y2}, ${x2.toFixed(2)} ${y2}`} />;\n              })}\n            </svg>\n            <div className=\"hb-wj5-head\" style={{ left: `${pct(now).toFixed(3)}%` }} />\n          </div>\n          <div className=\"hb-wj5-axis\" aria-hidden=\"true\">\n            {ticks.map((t, i) => (\n              <span key={i} style={{ left: `${pct(t).toFixed(2)}%` }}>{clock(t)}</span>\n            ))}\n          </div>\n        </div>\n      </div>\n      <div className=\"hb-wj5-log\" role=\"status\" style={{ \"--c\": finished ? \"#34c78a\" : lastEvent?.color } as React.CSSProperties}>\n        <i />\n        {finished ? <span key=\"done\"><b>Run complete</b> · {tasks.length} tasks, {handoffs.length} handoffs, {tasks.filter((t) => t.status === \"error\").length} retries</span> : lastEvent ? <span key={lastEvent.key}>{lastEvent.text}</span> : <span key=\"idle\">Waiting to start</span>}\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}