agent-relay-server 0.62.0 → 0.62.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/docs/openapi.json +1 -1
  2. package/package.json +2 -2
  3. package/public/assets/{MessageBubble-BP0Ym3xb.js → MessageBubble-DRrxfjyT.js} +2 -2
  4. package/public/assets/{MessageBubble-BP0Ym3xb.js.map → MessageBubble-DRrxfjyT.js.map} +1 -1
  5. package/public/assets/{PlanGraphPanel-DKc3gdou.js → PlanGraphPanel-Dp2eYazz.js} +2 -2
  6. package/public/assets/{PlanGraphPanel-DKc3gdou.js.map → PlanGraphPanel-Dp2eYazz.js.map} +1 -1
  7. package/public/assets/{activity-CRLG6ICe.js → activity--t0U2yzq.js} +2 -2
  8. package/public/assets/{activity-CRLG6ICe.js.map → activity--t0U2yzq.js.map} +1 -1
  9. package/public/assets/{agent-profiles-DItyEkXP.js → agent-profiles-BMtJYzxn.js} +2 -2
  10. package/public/assets/{agent-profiles-DItyEkXP.js.map → agent-profiles-BMtJYzxn.js.map} +1 -1
  11. package/public/assets/{agents-5mKiZ1rz.js → agents-Ck9AePlc.js} +2 -2
  12. package/public/assets/{agents-5mKiZ1rz.js.map → agents-Ck9AePlc.js.map} +1 -1
  13. package/public/assets/{analytics-J5pPcS-v.js → analytics-CzfK387L.js} +2 -2
  14. package/public/assets/{analytics-J5pPcS-v.js.map → analytics-CzfK387L.js.map} +1 -1
  15. package/public/assets/automation-Cgw8vtE8.js +2 -0
  16. package/public/assets/automation-Cgw8vtE8.js.map +1 -0
  17. package/public/assets/{branch-state-badge-BZMoxs65.js → branch-state-badge-DnEEPtOP.js} +2 -2
  18. package/public/assets/{branch-state-badge-BZMoxs65.js.map → branch-state-badge-DnEEPtOP.js.map} +1 -1
  19. package/public/assets/{channels-B2PeqiRT.js → channels-Dc3L2MQs.js} +2 -2
  20. package/public/assets/{channels-B2PeqiRT.js.map → channels-Dc3L2MQs.js.map} +1 -1
  21. package/public/assets/{chat-CLRJVagA.js → chat-Fc6iJ7sa.js} +2 -2
  22. package/public/assets/{chat-CLRJVagA.js.map → chat-Fc6iJ7sa.js.map} +1 -1
  23. package/public/assets/{connectors-Bzvkxsgo.js → connectors-Dc2ttGWs.js} +2 -2
  24. package/public/assets/{connectors-Bzvkxsgo.js.map → connectors-Dc2ttGWs.js.map} +1 -1
  25. package/public/assets/display-DzNvOu1j.js.map +1 -1
  26. package/public/assets/{formatted-body-impl-QqHxdMGP.js → formatted-body-impl-Bg-gx7rG.js} +2 -2
  27. package/public/assets/{formatted-body-impl-QqHxdMGP.js.map → formatted-body-impl-Bg-gx7rG.js.map} +1 -1
  28. package/public/assets/index-BeDncjN4.js +22 -0
  29. package/public/assets/index-BeDncjN4.js.map +1 -0
  30. package/public/assets/{insights-D-EyDfoZ.js → insights-c08aW-7n.js} +2 -2
  31. package/public/assets/{insights-D-EyDfoZ.js.map → insights-c08aW-7n.js.map} +1 -1
  32. package/public/assets/{integrations-D1kc-yNi.js → integrations-BwpgcqnF.js} +2 -2
  33. package/public/assets/{integrations-D1kc-yNi.js.map → integrations-BwpgcqnF.js.map} +1 -1
  34. package/public/assets/{maintenance-COqID7aq.js → maintenance-CTKP0kWB.js} +2 -2
  35. package/public/assets/{maintenance-COqID7aq.js.map → maintenance-CTKP0kWB.js.map} +1 -1
  36. package/public/assets/{managed-agents-b4B8qewQ.js → managed-agents-BofCxo8d.js} +2 -2
  37. package/public/assets/{managed-agents-b4B8qewQ.js.map → managed-agents-BofCxo8d.js.map} +1 -1
  38. package/public/assets/{markdown-preview-impl-D7o8jS07.js → markdown-preview-impl-CQ-6BIb8.js} +2 -2
  39. package/public/assets/{markdown-preview-impl-D7o8jS07.js.map → markdown-preview-impl-CQ-6BIb8.js.map} +1 -1
  40. package/public/assets/{memory-Q0qF7_i3.js → memory-DvfXjMoi.js} +2 -2
  41. package/public/assets/{memory-Q0qF7_i3.js.map → memory-DvfXjMoi.js.map} +1 -1
  42. package/public/assets/{messages-m4EpkK6s.js → messages-C9VsPzZ_.js} +2 -2
  43. package/public/assets/{messages-m4EpkK6s.js.map → messages-C9VsPzZ_.js.map} +1 -1
  44. package/public/assets/orchestrators-MffVueeE.js +2 -0
  45. package/public/assets/{orchestrators-CnAtGfUN.js.map → orchestrators-MffVueeE.js.map} +1 -1
  46. package/public/assets/{overview-D7CF88ik.js → overview-BSVajefM.js} +2 -2
  47. package/public/assets/{overview-D7CF88ik.js.map → overview-BSVajefM.js.map} +1 -1
  48. package/public/assets/{pairs-Q6PlFJtH.js → pairs-B5711-Cs.js} +2 -2
  49. package/public/assets/{pairs-Q6PlFJtH.js.map → pairs-B5711-Cs.js.map} +1 -1
  50. package/public/assets/{security-BeV-6SdA.js → security-DkUwK9Vj.js} +2 -2
  51. package/public/assets/{security-BeV-6SdA.js.map → security-DkUwK9Vj.js.map} +1 -1
  52. package/public/assets/{select-Dchc0_Jg.js → select-DrM2RRiT.js} +2 -2
  53. package/public/assets/{select-Dchc0_Jg.js.map → select-DrM2RRiT.js.map} +1 -1
  54. package/public/assets/{settings-hPwL-31u.js → settings-DdKCb-vy.js} +3 -3
  55. package/public/assets/{settings-hPwL-31u.js.map → settings-DdKCb-vy.js.map} +1 -1
  56. package/public/assets/{store-Buwkqv_7.js → store-iTiheuTD.js} +4 -4
  57. package/public/assets/store-iTiheuTD.js.map +1 -0
  58. package/public/assets/{tasks-DKUMPEgk.js → tasks-e1y1PFfO.js} +2 -2
  59. package/public/assets/{tasks-DKUMPEgk.js.map → tasks-e1y1PFfO.js.map} +1 -1
  60. package/public/assets/{teams-T5fFsdOX.js → teams-BUcxoGC_.js} +2 -2
  61. package/public/assets/{teams-T5fFsdOX.js.map → teams-BUcxoGC_.js.map} +1 -1
  62. package/public/assets/{terminal-viewer-impl-Bk0u_Mav.js → terminal-viewer-impl-CmZjQOB2.js} +2 -2
  63. package/public/assets/{terminal-viewer-impl-Bk0u_Mav.js.map → terminal-viewer-impl-CmZjQOB2.js.map} +1 -1
  64. package/public/assets/{work-queue-D26jok09.js → work-queue-CXBQx43n.js} +2 -2
  65. package/public/assets/{work-queue-D26jok09.js.map → work-queue-CXBQx43n.js.map} +1 -1
  66. package/public/assets/{workspaces-BMj6zx23.js → workspaces-D2EfZh9a.js} +2 -2
  67. package/public/assets/{workspaces-BMj6zx23.js.map → workspaces-D2EfZh9a.js.map} +1 -1
  68. package/public/index.html +2 -2
  69. package/src/branch-landed.ts +7 -1
  70. package/src/bus.ts +3 -1
  71. package/src/db/agents.ts +14 -5
  72. package/src/db/migrations.ts +6 -0
  73. package/src/db/schema.ts +3 -1
  74. package/src/routes/commands.ts +3 -0
  75. package/src/routes/orchestrator-bootstrap.ts +2 -1
  76. package/src/routes/tokens.ts +1 -1
  77. package/src/runtime-tokens.ts +15 -11
  78. package/src/security.ts +43 -3
  79. package/src/services/issue-lifecycle.ts +100 -22
  80. package/src/token-db.ts +24 -4
  81. package/public/assets/automation-BG2HWK5N.js +0 -2
  82. package/public/assets/automation-BG2HWK5N.js.map +0 -1
  83. package/public/assets/index-CCp1V35c.js +0 -22
  84. package/public/assets/index-CCp1V35c.js.map +0 -1
  85. package/public/assets/orchestrators-CnAtGfUN.js +0 -2
  86. package/public/assets/store-Buwkqv_7.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{Ln as e,ct as t,hn as n,i as r,in as i}from"./lucide-react-DWYjU-AF.js";import{s as a,t as o}from"./store-Buwkqv_7.js";import{U as s,d as c,ut as l}from"./display-DzNvOu1j.js";import{t as u}from"./badge-CZhIdlTJ.js";import{t as d}from"./button-2taQeNHW.js";import{G as f,s as p,z as m}from"./index-CCp1V35c.js";import{r as h,t as g}from"./card-DzIsAI41.js";var _=e(),v={open:`bg-blue-500/10 text-blue-400 border-blue-500/20`,blocked:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,claimed:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`,in_progress:`bg-purple-500/10 text-purple-400 border-purple-500/20`};function y(){let e=a(),n=o(e=>e.agentsById),r=o(e=>e.compose),i=o(e=>e.set),s=o(e=>e.doClaimTask),l=o(e=>e.doClaim),d=o(e=>e.openTaskEvents),h=o(e=>e.showError),g=o(e=>e.openConfirm),v=o(e=>e.doDeleteMessage),y=o(e=>e.doUpdateTaskStatus),x=m(),S=f(),C=S.filter(e=>e.claimable).length;function w(e){if(!r.from){h(`Validation`,`Select a "Claim as" agent first.`);return}e.sourceType===`task`&&e.task?s(e.task.id):e.sourceType===`message`&&e.message&&l(e.message.id)}function T(e){g(`Cancel Item`,`Cancel "${e.title||(e.sourceType===`task`?`Task #${e.id}`:`Message #${e.id}`)}"? This cannot be undone.`,()=>{e.sourceType===`task`&&e.task?y(e.task,`canceled`):e.sourceType===`message`&&e.message&&v(e.message.id)})}function E(e){e.task&&d(e.task)}return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(t,{className:`w-5 h-5 text-muted-foreground`}),(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Work Queue`}),C>0&&(0,_.jsxs)(u,{className:`bg-orange-500/20 text-orange-400 border-orange-500/30 border`,children:[C,` claimable`]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`label`,{className:`text-xs text-muted-foreground shrink-0`,children:`Claim as`}),(0,_.jsxs)(`select`,{className:`rounded-md border border-input bg-background px-3 py-1.5 text-sm`,value:r.from,onChange:e=>i({compose:{...r,from:e.target.value}}),children:[(0,_.jsx)(`option`,{value:``,children:`Select agent...`}),x.map(e=>(0,_.jsx)(`option`,{value:e.id,children:c(e)},e.id))]})]})]}),(0,_.jsx)(p,{className:`h-[calc(100dvh-11rem)]`,children:(0,_.jsxs)(`div`,{className:`space-y-2 pr-2`,children:[S.length===0&&(0,_.jsx)(`div`,{className:`text-center text-muted-foreground py-16 text-sm`,children:`Work queue is empty`}),S.map(t=>(0,_.jsx)(b,{item:t,now:e,agentName:e=>n[e]?c(n[e]):e.slice(-10),onClaim:()=>w(t),onCancel:()=>T(t),onEvents:t.task?()=>E(t):void 0},t.id))]})})]})}function b({item:e,now:t,agentName:a,onClaim:o,onCancel:c,onEvents:f}){let p=l[e.severity]||l.info,m=v[e.status]||`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`;return(0,_.jsx)(g,{className:e.claimable?`ring-1 ring-orange-500/30`:``,children:(0,_.jsx)(h,{className:`p-3`,children:(0,_.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap mb-1`,children:[(0,_.jsx)(`span`,{className:`font-medium text-sm truncate`,children:e.title}),(0,_.jsx)(u,{variant:`outline`,className:`text-xs px-1.5 py-0 border ${p}`,children:e.severity}),(0,_.jsx)(u,{variant:`outline`,className:`text-xs px-1.5 py-0 border ${m}`,children:e.status}),e.sourceType===`message`&&(0,_.jsx)(u,{variant:`outline`,className:`text-xs px-1.5 py-0 border border-zinc-500/20 text-zinc-400`,children:`msg`})]}),e.body&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-2 mb-2`,children:e.body}),(0,_.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[e.owner&&(0,_.jsxs)(`span`,{title:`Owner`,children:[(0,_.jsx)(i,{className:`w-3 h-3 inline mr-1`}),a(e.owner)]}),e.source&&(0,_.jsx)(`span`,{className:`font-mono`,children:e.source}),(0,_.jsxs)(`span`,{title:String(e.updatedAt),children:[(0,_.jsx)(n,{className:`w-3 h-3 inline mr-1`}),s(t,e.updatedAt)]})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-1 shrink-0`,children:[e.claimable&&(0,_.jsxs)(d,{size:`sm`,className:`h-7 text-xs bg-orange-600 hover:bg-orange-700 text-white`,onClick:o,children:[(0,_.jsx)(i,{className:`w-3.5 h-3.5 mr-1`}),` Claim`]}),f&&(0,_.jsx)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:f,children:`Events`}),(0,_.jsxs)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs text-red-400 hover:text-red-300 hover:bg-red-500/10 border-red-500/20`,onClick:c,children:[(0,_.jsx)(r,{className:`w-3.5 h-3.5 mr-1`}),` Cancel`]})]})]})})})}export{y as WorkQueueView};
2
- //# sourceMappingURL=work-queue-D26jok09.js.map
1
+ import{Ln as e,ct as t,hn as n,i as r,in as i}from"./lucide-react-DWYjU-AF.js";import{c as a,t as o}from"./store-iTiheuTD.js";import{U as s,d as c,ut as l}from"./display-DzNvOu1j.js";import{t as u}from"./badge-CZhIdlTJ.js";import{t as d}from"./button-2taQeNHW.js";import{G as f,s as p,z as m}from"./index-BeDncjN4.js";import{r as h,t as g}from"./card-DzIsAI41.js";var _=e(),v={open:`bg-blue-500/10 text-blue-400 border-blue-500/20`,blocked:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,claimed:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`,in_progress:`bg-purple-500/10 text-purple-400 border-purple-500/20`};function y(){let e=a(),n=o(e=>e.agentsById),r=o(e=>e.compose),i=o(e=>e.set),s=o(e=>e.doClaimTask),l=o(e=>e.doClaim),d=o(e=>e.openTaskEvents),h=o(e=>e.showError),g=o(e=>e.openConfirm),v=o(e=>e.doDeleteMessage),y=o(e=>e.doUpdateTaskStatus),x=m(),S=f(),C=S.filter(e=>e.claimable).length;function w(e){if(!r.from){h(`Validation`,`Select a "Claim as" agent first.`);return}e.sourceType===`task`&&e.task?s(e.task.id):e.sourceType===`message`&&e.message&&l(e.message.id)}function T(e){g(`Cancel Item`,`Cancel "${e.title||(e.sourceType===`task`?`Task #${e.id}`:`Message #${e.id}`)}"? This cannot be undone.`,()=>{e.sourceType===`task`&&e.task?y(e.task,`canceled`):e.sourceType===`message`&&e.message&&v(e.message.id)})}function E(e){e.task&&d(e.task)}return(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between flex-wrap gap-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(t,{className:`w-5 h-5 text-muted-foreground`}),(0,_.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Work Queue`}),C>0&&(0,_.jsxs)(u,{className:`bg-orange-500/20 text-orange-400 border-orange-500/30 border`,children:[C,` claimable`]})]}),(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(`label`,{className:`text-xs text-muted-foreground shrink-0`,children:`Claim as`}),(0,_.jsxs)(`select`,{className:`rounded-md border border-input bg-background px-3 py-1.5 text-sm`,value:r.from,onChange:e=>i({compose:{...r,from:e.target.value}}),children:[(0,_.jsx)(`option`,{value:``,children:`Select agent...`}),x.map(e=>(0,_.jsx)(`option`,{value:e.id,children:c(e)},e.id))]})]})]}),(0,_.jsx)(p,{className:`h-[calc(100dvh-11rem)]`,children:(0,_.jsxs)(`div`,{className:`space-y-2 pr-2`,children:[S.length===0&&(0,_.jsx)(`div`,{className:`text-center text-muted-foreground py-16 text-sm`,children:`Work queue is empty`}),S.map(t=>(0,_.jsx)(b,{item:t,now:e,agentName:e=>n[e]?c(n[e]):e.slice(-10),onClaim:()=>w(t),onCancel:()=>T(t),onEvents:t.task?()=>E(t):void 0},t.id))]})})]})}function b({item:e,now:t,agentName:a,onClaim:o,onCancel:c,onEvents:f}){let p=l[e.severity]||l.info,m=v[e.status]||`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`;return(0,_.jsx)(g,{className:e.claimable?`ring-1 ring-orange-500/30`:``,children:(0,_.jsx)(h,{className:`p-3`,children:(0,_.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,_.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap mb-1`,children:[(0,_.jsx)(`span`,{className:`font-medium text-sm truncate`,children:e.title}),(0,_.jsx)(u,{variant:`outline`,className:`text-xs px-1.5 py-0 border ${p}`,children:e.severity}),(0,_.jsx)(u,{variant:`outline`,className:`text-xs px-1.5 py-0 border ${m}`,children:e.status}),e.sourceType===`message`&&(0,_.jsx)(u,{variant:`outline`,className:`text-xs px-1.5 py-0 border border-zinc-500/20 text-zinc-400`,children:`msg`})]}),e.body&&(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground line-clamp-2 mb-2`,children:e.body}),(0,_.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[e.owner&&(0,_.jsxs)(`span`,{title:`Owner`,children:[(0,_.jsx)(i,{className:`w-3 h-3 inline mr-1`}),a(e.owner)]}),e.source&&(0,_.jsx)(`span`,{className:`font-mono`,children:e.source}),(0,_.jsxs)(`span`,{title:String(e.updatedAt),children:[(0,_.jsx)(n,{className:`w-3 h-3 inline mr-1`}),s(t,e.updatedAt)]})]})]}),(0,_.jsxs)(`div`,{className:`flex flex-col gap-1 shrink-0`,children:[e.claimable&&(0,_.jsxs)(d,{size:`sm`,className:`h-7 text-xs bg-orange-600 hover:bg-orange-700 text-white`,onClick:o,children:[(0,_.jsx)(i,{className:`w-3.5 h-3.5 mr-1`}),` Claim`]}),f&&(0,_.jsx)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs`,onClick:f,children:`Events`}),(0,_.jsxs)(d,{size:`sm`,variant:`outline`,className:`h-7 text-xs text-red-400 hover:text-red-300 hover:bg-red-500/10 border-red-500/20`,onClick:c,children:[(0,_.jsx)(r,{className:`w-3.5 h-3.5 mr-1`}),` Cancel`]})]})]})})})}export{y as WorkQueueView};
2
+ //# sourceMappingURL=work-queue-CXBQx43n.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"work-queue-D26jok09.js","names":[],"sources":["../../dashboard/src/components/views/work-queue.tsx"],"sourcesContent":["import { useRelayStore, useNow } from '@/store'\nimport { useWorkQueueItems, useComposeAgents } from '@/hooks/use-selectors'\nimport { Card, CardContent } from '@/components/ui/card'\nimport { Badge } from '@/components/ui/badge'\nimport { Button } from '@/components/ui/button'\nimport { ScrollArea } from '@/components/ui/scroll-area'\nimport { ListChecks, CheckCircle2, Calendar, X } from 'lucide-react'\nimport { displayName, timeAgo } from '@/lib/display'\nimport { SEVERITY_COLORS } from '@/lib/constants'\nimport type { WorkQueueItem } from '@/types'\n\nconst STATUS_COLORS: Record<string, string> = {\n open: 'bg-blue-500/10 text-blue-400 border-blue-500/20',\n blocked: 'bg-yellow-500/10 text-yellow-400 border-yellow-500/20',\n claimed: 'bg-emerald-500/10 text-emerald-400 border-emerald-500/20',\n in_progress: 'bg-purple-500/10 text-purple-400 border-purple-500/20',\n}\n\nexport function WorkQueueView() {\n const now = useNow()\n const agentsById = useRelayStore((s) => s.agentsById)\n const compose = useRelayStore((s) => s.compose)\n const set = useRelayStore((s) => s.set)\n const doClaimTask = useRelayStore((s) => s.doClaimTask)\n const doClaim = useRelayStore((s) => s.doClaim)\n const openTaskEvents = useRelayStore((s) => s.openTaskEvents)\n const showError = useRelayStore((s) => s.showError)\n const openConfirm = useRelayStore((s) => s.openConfirm)\n const doDeleteMessage = useRelayStore((s) => s.doDeleteMessage)\n const doUpdateTaskStatus = useRelayStore((s) => s.doUpdateTaskStatus)\n\n const composeAgents = useComposeAgents()\n const items = useWorkQueueItems()\n\n const claimableCount = items.filter((i) => i.claimable).length\n\n function handleClaim(item: WorkQueueItem) {\n if (!compose.from) { showError('Validation', 'Select a \"Claim as\" agent first.'); return }\n if (item.sourceType === 'task' && item.task) doClaimTask(item.task.id)\n else if (item.sourceType === 'message' && item.message) doClaim(item.message.id)\n }\n\n function handleCancel(item: WorkQueueItem) {\n const label = item.title || (item.sourceType === 'task' ? `Task #${item.id}` : `Message #${item.id}`)\n openConfirm('Cancel Item', `Cancel \"${label}\"? This cannot be undone.`, () => {\n if (item.sourceType === 'task' && item.task) doUpdateTaskStatus(item.task, 'canceled')\n else if (item.sourceType === 'message' && item.message) doDeleteMessage(item.message.id)\n })\n }\n\n function handleEvents(item: WorkQueueItem) {\n if (item.task) openTaskEvents(item.task)\n }\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex items-center justify-between flex-wrap gap-2\">\n <div className=\"flex items-center gap-2\">\n <ListChecks className=\"w-5 h-5 text-muted-foreground\" />\n <h2 className=\"text-lg font-semibold\">Work Queue</h2>\n {claimableCount > 0 && (\n <Badge className=\"bg-orange-500/20 text-orange-400 border-orange-500/30 border\">\n {claimableCount} claimable\n </Badge>\n )}\n </div>\n <div className=\"flex items-center gap-2\">\n <label className=\"text-xs text-muted-foreground shrink-0\">Claim as</label>\n <select\n className=\"rounded-md border border-input bg-background px-3 py-1.5 text-sm\"\n value={compose.from}\n onChange={(e) => set({ compose: { ...compose, from: e.target.value } })}\n >\n <option value=\"\">Select agent...</option>\n {composeAgents.map((a) => <option key={a.id} value={a.id}>{displayName(a)}</option>)}\n </select>\n </div>\n </div>\n\n <ScrollArea className=\"h-[calc(100dvh-11rem)]\">\n <div className=\"space-y-2 pr-2\">\n {items.length === 0 && (\n <div className=\"text-center text-muted-foreground py-16 text-sm\">Work queue is empty</div>\n )}\n {items.map((item) => (\n <WorkQueueCard\n key={item.id}\n item={item}\n now={now}\n agentName={(id) => agentsById[id] ? displayName(agentsById[id]) : id.slice(-10)}\n onClaim={() => handleClaim(item)}\n onCancel={() => handleCancel(item)}\n onEvents={item.task ? () => handleEvents(item) : undefined}\n />\n ))}\n </div>\n </ScrollArea>\n </div>\n )\n}\n\nfunction WorkQueueCard({\n item, now, agentName, onClaim, onCancel, onEvents,\n}: {\n item: WorkQueueItem\n now: number\n agentName: (id: string) => string\n onClaim: () => void\n onCancel: () => void\n onEvents?: () => void\n}) {\n const severityClass = SEVERITY_COLORS[item.severity] || SEVERITY_COLORS.info\n const statusClass = STATUS_COLORS[item.status] || 'bg-zinc-500/10 text-zinc-400 border-zinc-500/20'\n\n return (\n <Card className={item.claimable ? 'ring-1 ring-orange-500/30' : ''}>\n <CardContent className=\"p-3\">\n <div className=\"flex items-start gap-3\">\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2 flex-wrap mb-1\">\n <span className=\"font-medium text-sm truncate\">{item.title}</span>\n <Badge variant=\"outline\" className={`text-xs px-1.5 py-0 border ${severityClass}`}>{item.severity}</Badge>\n <Badge variant=\"outline\" className={`text-xs px-1.5 py-0 border ${statusClass}`}>{item.status}</Badge>\n {item.sourceType === 'message' && (\n <Badge variant=\"outline\" className=\"text-xs px-1.5 py-0 border border-zinc-500/20 text-zinc-400\">msg</Badge>\n )}\n </div>\n {item.body && (\n <p className=\"text-xs text-muted-foreground line-clamp-2 mb-2\">{item.body}</p>\n )}\n <div className=\"flex items-center gap-3 text-xs text-muted-foreground flex-wrap\">\n {item.owner && (\n <span title=\"Owner\">\n <CheckCircle2 className=\"w-3 h-3 inline mr-1\" />{agentName(item.owner)}\n </span>\n )}\n {item.source && (\n <span className=\"font-mono\">{item.source}</span>\n )}\n <span title={String(item.updatedAt)}>\n <Calendar className=\"w-3 h-3 inline mr-1\" />{timeAgo(now, item.updatedAt)}\n </span>\n </div>\n </div>\n <div className=\"flex flex-col gap-1 shrink-0\">\n {item.claimable && (\n <Button size=\"sm\" className=\"h-7 text-xs bg-orange-600 hover:bg-orange-700 text-white\" onClick={onClaim}>\n <CheckCircle2 className=\"w-3.5 h-3.5 mr-1\" /> Claim\n </Button>\n )}\n {onEvents && (\n <Button size=\"sm\" variant=\"outline\" className=\"h-7 text-xs\" onClick={onEvents}>\n Events\n </Button>\n )}\n <Button size=\"sm\" variant=\"outline\" className=\"h-7 text-xs text-red-400 hover:text-red-300 hover:bg-red-500/10 border-red-500/20\" onClick={onCancel}>\n <X className=\"w-3.5 h-3.5 mr-1\" /> Cancel\n </Button>\n </div>\n </div>\n </CardContent>\n </Card>\n )\n}\n"],"mappings":"sXAWM,EAAwC,CAC5C,KAAM,kDACN,QAAS,wDACT,QAAS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,CAAQ,KAAK,KAAK,UAAU,2DAA2D,QAAS,WAAhG,EACE,EAAA,EAAA,KAAC,EAAD,CAAc,UAAU,mBAAqB,CAAA,CAAA,SACtC,GAEV,IACC,EAAA,EAAA,KAAC,EAAD,CAAQ,KAAK,KAAK,QAAQ,UAAU,UAAU,cAAc,QAAS,WAAU,SAEtE,CAAA,EAEX,EAAA,EAAA,MAAC,EAAD,CAAQ,KAAK,KAAK,QAAQ,UAAU,UAAU,oFAAoF,QAAS,WAA3I,EACE,EAAA,EAAA,KAAC,EAAD,CAAG,UAAU,mBAAqB,CAAA,CAAA,UAC3B,GACL,GACF,GACM,CAAA,CACT,CAAA"}
1
+ {"version":3,"file":"work-queue-CXBQx43n.js","names":[],"sources":["../../dashboard/src/components/views/work-queue.tsx"],"sourcesContent":["import { useRelayStore, useNow } from '@/store'\nimport { useWorkQueueItems, useComposeAgents } from '@/hooks/use-selectors'\nimport { Card, CardContent } from '@/components/ui/card'\nimport { Badge } from '@/components/ui/badge'\nimport { Button } from '@/components/ui/button'\nimport { ScrollArea } from '@/components/ui/scroll-area'\nimport { ListChecks, CheckCircle2, Calendar, X } from 'lucide-react'\nimport { displayName, timeAgo } from '@/lib/display'\nimport { SEVERITY_COLORS } from '@/lib/constants'\nimport type { WorkQueueItem } from '@/types'\n\nconst STATUS_COLORS: Record<string, string> = {\n open: 'bg-blue-500/10 text-blue-400 border-blue-500/20',\n blocked: 'bg-yellow-500/10 text-yellow-400 border-yellow-500/20',\n claimed: 'bg-emerald-500/10 text-emerald-400 border-emerald-500/20',\n in_progress: 'bg-purple-500/10 text-purple-400 border-purple-500/20',\n}\n\nexport function WorkQueueView() {\n const now = useNow()\n const agentsById = useRelayStore((s) => s.agentsById)\n const compose = useRelayStore((s) => s.compose)\n const set = useRelayStore((s) => s.set)\n const doClaimTask = useRelayStore((s) => s.doClaimTask)\n const doClaim = useRelayStore((s) => s.doClaim)\n const openTaskEvents = useRelayStore((s) => s.openTaskEvents)\n const showError = useRelayStore((s) => s.showError)\n const openConfirm = useRelayStore((s) => s.openConfirm)\n const doDeleteMessage = useRelayStore((s) => s.doDeleteMessage)\n const doUpdateTaskStatus = useRelayStore((s) => s.doUpdateTaskStatus)\n\n const composeAgents = useComposeAgents()\n const items = useWorkQueueItems()\n\n const claimableCount = items.filter((i) => i.claimable).length\n\n function handleClaim(item: WorkQueueItem) {\n if (!compose.from) { showError('Validation', 'Select a \"Claim as\" agent first.'); return }\n if (item.sourceType === 'task' && item.task) doClaimTask(item.task.id)\n else if (item.sourceType === 'message' && item.message) doClaim(item.message.id)\n }\n\n function handleCancel(item: WorkQueueItem) {\n const label = item.title || (item.sourceType === 'task' ? `Task #${item.id}` : `Message #${item.id}`)\n openConfirm('Cancel Item', `Cancel \"${label}\"? This cannot be undone.`, () => {\n if (item.sourceType === 'task' && item.task) doUpdateTaskStatus(item.task, 'canceled')\n else if (item.sourceType === 'message' && item.message) doDeleteMessage(item.message.id)\n })\n }\n\n function handleEvents(item: WorkQueueItem) {\n if (item.task) openTaskEvents(item.task)\n }\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex items-center justify-between flex-wrap gap-2\">\n <div className=\"flex items-center gap-2\">\n <ListChecks className=\"w-5 h-5 text-muted-foreground\" />\n <h2 className=\"text-lg font-semibold\">Work Queue</h2>\n {claimableCount > 0 && (\n <Badge className=\"bg-orange-500/20 text-orange-400 border-orange-500/30 border\">\n {claimableCount} claimable\n </Badge>\n )}\n </div>\n <div className=\"flex items-center gap-2\">\n <label className=\"text-xs text-muted-foreground shrink-0\">Claim as</label>\n <select\n className=\"rounded-md border border-input bg-background px-3 py-1.5 text-sm\"\n value={compose.from}\n onChange={(e) => set({ compose: { ...compose, from: e.target.value } })}\n >\n <option value=\"\">Select agent...</option>\n {composeAgents.map((a) => <option key={a.id} value={a.id}>{displayName(a)}</option>)}\n </select>\n </div>\n </div>\n\n <ScrollArea className=\"h-[calc(100dvh-11rem)]\">\n <div className=\"space-y-2 pr-2\">\n {items.length === 0 && (\n <div className=\"text-center text-muted-foreground py-16 text-sm\">Work queue is empty</div>\n )}\n {items.map((item) => (\n <WorkQueueCard\n key={item.id}\n item={item}\n now={now}\n agentName={(id) => agentsById[id] ? displayName(agentsById[id]) : id.slice(-10)}\n onClaim={() => handleClaim(item)}\n onCancel={() => handleCancel(item)}\n onEvents={item.task ? () => handleEvents(item) : undefined}\n />\n ))}\n </div>\n </ScrollArea>\n </div>\n )\n}\n\nfunction WorkQueueCard({\n item, now, agentName, onClaim, onCancel, onEvents,\n}: {\n item: WorkQueueItem\n now: number\n agentName: (id: string) => string\n onClaim: () => void\n onCancel: () => void\n onEvents?: () => void\n}) {\n const severityClass = SEVERITY_COLORS[item.severity] || SEVERITY_COLORS.info\n const statusClass = STATUS_COLORS[item.status] || 'bg-zinc-500/10 text-zinc-400 border-zinc-500/20'\n\n return (\n <Card className={item.claimable ? 'ring-1 ring-orange-500/30' : ''}>\n <CardContent className=\"p-3\">\n <div className=\"flex items-start gap-3\">\n <div className=\"flex-1 min-w-0\">\n <div className=\"flex items-center gap-2 flex-wrap mb-1\">\n <span className=\"font-medium text-sm truncate\">{item.title}</span>\n <Badge variant=\"outline\" className={`text-xs px-1.5 py-0 border ${severityClass}`}>{item.severity}</Badge>\n <Badge variant=\"outline\" className={`text-xs px-1.5 py-0 border ${statusClass}`}>{item.status}</Badge>\n {item.sourceType === 'message' && (\n <Badge variant=\"outline\" className=\"text-xs px-1.5 py-0 border border-zinc-500/20 text-zinc-400\">msg</Badge>\n )}\n </div>\n {item.body && (\n <p className=\"text-xs text-muted-foreground line-clamp-2 mb-2\">{item.body}</p>\n )}\n <div className=\"flex items-center gap-3 text-xs text-muted-foreground flex-wrap\">\n {item.owner && (\n <span title=\"Owner\">\n <CheckCircle2 className=\"w-3 h-3 inline mr-1\" />{agentName(item.owner)}\n </span>\n )}\n {item.source && (\n <span className=\"font-mono\">{item.source}</span>\n )}\n <span title={String(item.updatedAt)}>\n <Calendar className=\"w-3 h-3 inline mr-1\" />{timeAgo(now, item.updatedAt)}\n </span>\n </div>\n </div>\n <div className=\"flex flex-col gap-1 shrink-0\">\n {item.claimable && (\n <Button size=\"sm\" className=\"h-7 text-xs bg-orange-600 hover:bg-orange-700 text-white\" onClick={onClaim}>\n <CheckCircle2 className=\"w-3.5 h-3.5 mr-1\" /> Claim\n </Button>\n )}\n {onEvents && (\n <Button size=\"sm\" variant=\"outline\" className=\"h-7 text-xs\" onClick={onEvents}>\n Events\n </Button>\n )}\n <Button size=\"sm\" variant=\"outline\" className=\"h-7 text-xs text-red-400 hover:text-red-300 hover:bg-red-500/10 border-red-500/20\" onClick={onCancel}>\n <X className=\"w-3.5 h-3.5 mr-1\" /> Cancel\n </Button>\n </div>\n </div>\n </CardContent>\n </Card>\n )\n}\n"],"mappings":"sXAWM,EAAwC,CAC5C,KAAM,kDACN,QAAS,wDACT,QAAS,2DACT,YAAa,wDACd,CAED,SAAgB,GAAgB,CAC9B,IAAM,EAAM,GAAQ,CACd,EAAa,EAAe,GAAM,EAAE,WAAW,CAC/C,EAAU,EAAe,GAAM,EAAE,QAAQ,CACzC,EAAM,EAAe,GAAM,EAAE,IAAI,CACjC,EAAc,EAAe,GAAM,EAAE,YAAY,CACjD,EAAU,EAAe,GAAM,EAAE,QAAQ,CACzC,EAAiB,EAAe,GAAM,EAAE,eAAe,CACvD,EAAY,EAAe,GAAM,EAAE,UAAU,CAC7C,EAAc,EAAe,GAAM,EAAE,YAAY,CACjD,EAAkB,EAAe,GAAM,EAAE,gBAAgB,CACzD,EAAqB,EAAe,GAAM,EAAE,mBAAmB,CAE/D,EAAgB,GAAkB,CAClC,EAAQ,GAAmB,CAE3B,EAAiB,EAAM,OAAQ,GAAM,EAAE,UAAU,CAAC,OAExD,SAAS,EAAY,EAAqB,CACxC,GAAI,CAAC,EAAQ,KAAM,CAAE,EAAU,aAAc,mCAAmC,CAAE,OAC9E,EAAK,aAAe,QAAU,EAAK,KAAM,EAAY,EAAK,KAAK,GAAG,CAC7D,EAAK,aAAe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AEhF,EAAA,EAAA,MAAC,MAAD,CAAK,UAAU,2EAAf,CACG,EAAK,QACJ,EAAA,EAAA,MAAC,OAAD,CAAM,MAAM,iBAAZ,EACE,EAAA,EAAA,KAAC,EAAD,CAAc,UAAU,sBAAwB,CAAA,CAAC,EAAU,EAAK,MAAM,CACjE,GAER,EAAK,SACJ,EAAA,EAAA,KAAC,OAAD,CAAM,UAAU,qBAAa,EAAK,OAAc,CAAA,EAElD,EAAA,EAAA,MAAC,OAAD,CAAM,MAAO,OAAO,EAAK,UAAU,UAAnC,EACE,EAAA,EAAA,KAAC,EAAD,CAAU,UAAU,sBAAwB,CAAA,CAAC,EAAQ,EAAK,EAAK,UAAU,CACpE,GACH,GACF,IACN,EAAA,EAAA,MAAC,MAAD,CAAK,UAAU,wCAAf,CACG,EAAK,YACJ,EAAA,EAAA,MAAC,EAAD,CAAQ,KAAK,KAAK,UAAU,2DAA2D,QAAS,WAAhG,EACE,EAAA,EAAA,KAAC,EAAD,CAAc,UAAU,mBAAqB,CAAA,CAAA,SACtC,GAEV,IACC,EAAA,EAAA,KAAC,EAAD,CAAQ,KAAK,KAAK,QAAQ,UAAU,UAAU,cAAc,QAAS,WAAU,SAEtE,CAAA,EAEX,EAAA,EAAA,MAAC,EAAD,CAAQ,KAAK,KAAK,QAAQ,UAAU,UAAU,oFAAoF,QAAS,WAA3I,EACE,EAAA,EAAA,KAAC,EAAD,CAAG,UAAU,mBAAqB,CAAA,CAAA,UAC3B,GACL,GACF,GACM,CAAA,CACT,CAAA"}
@@ -1,3 +1,3 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{An as t,At as n,Ct as r,Ft as i,G as a,It as o,Ln as s,N as c,Nn as l,Nt as u,Ot as d,Tn as f,Xt as p,Yn as m,cn as h,dn as g,i as _,m as v,p as y,un as b,wt as x,xt as S}from"./lucide-react-DWYjU-AF.js";import{s as C,t as w}from"./store-Buwkqv_7.js";import{J as T,U as E,d as D}from"./display-DzNvOu1j.js";import{t as O}from"./badge-CZhIdlTJ.js";import{t as k}from"./button-2taQeNHW.js";import{t as A}from"./copy-button-HEkwi6xX.js";import{a as j,o as M,r as N,t as P}from"./card-DzIsAI41.js";var F=e(m(),1),I=s(),L=new Set([`active`,`ready`,`conflict`,`review_requested`,`merge_planned`,`cleanup_requested`]),R=new Set([`active`,`ready`,`conflict`,`review_requested`,`merge_planned`]),z=new Set([`active`,`ready`,`review_requested`,`merge_planned`,`conflict`]),B={active:`bg-blue-500/10 text-blue-400 border-blue-500/20`,ready:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`,conflict:`bg-red-500/10 text-red-400 border-red-500/20`,review_requested:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,merge_planned:`bg-indigo-500/10 text-indigo-400 border-indigo-500/20`,merged:`bg-violet-500/10 text-violet-400 border-violet-500/20`,abandoned:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`,cleanup_requested:`bg-orange-500/10 text-orange-400 border-orange-500/20`,cleaned:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`},V={active:`active`,ready:`ready`,conflict:`conflict`,review_requested:`review`,merge_planned:`merge planned`,merged:`merged`,abandoned:`abandoned`,cleanup_requested:`cleanup`,cleaned:`cleaned`},H={conflict:0,ready:1,review_requested:2,merge_planned:3,active:4,cleanup_requested:5,merged:6,abandoned:7,cleaned:8},U=new Set(T);function W(e){let t=e.split(`/`).filter(Boolean);return t.length<=3?e||`-`:`/${t.slice(-3).join(`/`)}`}function G(e,t){return e?D(e):t||`-`}function K(e){return B[e]||`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`}function q(e,t){let n=(H[e.status]??99)-(H[t.status]??99);return n===0?Number(t.updatedAt||0)-Number(e.updatedAt||0):n}function J(e){let t=new Map;for(let n of e){let e=n.repoRoot||n.sourceCwd||`unknown repo`;t.set(e,[...t.get(e)||[],n])}return[...t.entries()].map(([e,t])=>({repoRoot:e,workspaces:t.sort(q)})).sort((e,t)=>{let n=e.workspaces.some(e=>L.has(e.status));return n===t.workspaces.some(e=>L.has(e.status))?e.repoRoot.localeCompare(t.repoRoot):n?-1:1})}function Y(e,t){return t===`all`?e:t===`cleaned`?e.filter(e=>U.has(e.status)):e.filter(e=>!U.has(e.status))}function X({workspace:e,expanded:t,onToggleDetails:r}){let i=w(e=>e.workspaceAction),a=w(e=>e.purgeWorkspace),s=w(e=>e.fetchWorkspaceMergePreview),c=w(e=>e.openFilesAt),l=e.status===`cleaned`||e.status===`merged`||e.status===`abandoned`,u=l||e.status===`cleanup_requested`,f=e.worktreePath||e.sourceCwd||e.repoRoot,p=w(t=>t.workspaceGitState[e.id]),m=!!p&&p.available!==!1&&p.landed===!0,y=e.mode===`isolated`&&!!e.worktreePath&&z.has(e.status)&&!m;async function x(){await s(e.id),await i(e.id,`merge`)}return(0,I.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:[(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,title:t?`Hide details`:`Show diff & timeline`,onClick:r,children:t?(0,I.jsx)(b,{className:`h-3.5 w-3.5`}):(0,I.jsx)(h,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,title:`Open workspace`,disabled:!f||e.status===`cleaned`,onClick:()=>void c({path:f}),children:(0,I.jsx)(d,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(A,{value:f,label:`Copy path`,copiedLabel:`Copied path`,size:`icon-sm`,variant:`ghost`,disabled:!f}),(0,I.jsx)(k,{size:`icon-sm`,variant:`outline`,title:`Mark ready`,disabled:u||e.status===`ready`,onClick:()=>void i(e.id,`ready`),children:(0,I.jsx)(g,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`outline`,title:`Request review`,disabled:u||e.status===`review_requested`,onClick:()=>void i(e.id,`request-review`),children:(0,I.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`outline`,title:`Mark merge planned`,disabled:u||e.status===`merge_planned`,onClick:()=>void i(e.id,`merge-plan`),children:(0,I.jsx)(n,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`default`,title:m?`Already merged into base — nothing to land`:`Merge & land work`,disabled:!y,onClick:()=>void x(),children:(0,I.jsx)(S,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`outline`,title:`Request cleanup (removes the worktree on the host)`,disabled:e.status===`cleaned`||e.status===`cleanup_requested`,onClick:()=>void i(e.id,`cleanup`),children:(0,I.jsx)(v,{className:`h-3.5 w-3.5`})}),l&&(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,title:`Purge record (clears the row, does not touch disk)`,onClick:()=>void a(e.id),children:(0,I.jsx)(_,{className:`h-3.5 w-3.5`})})]})}function Z({workspace:e,unmerged:t}){let n=w(t=>t.workspaceMergePreview[e.id]),r=w(e=>e.fetchWorkspaceMergePreview),i=t>0&&z.has(e.status);return(0,F.useEffect)(()=>{i&&n===void 0&&r(e.id)},[i,n,e.id,r]),!i||n===void 0||n.available===!1?null:n.conflict?(0,I.jsxs)(`span`,{className:`flex items-center gap-0.5 text-amber-400`,title:`Merging into ${n.baseRef||`base`} would conflict — resolve before merging`,children:[(0,I.jsx)(y,{className:`h-3 w-3`}),`conflict`]}):n.conflict===!1?(0,I.jsxs)(`span`,{className:`flex items-center gap-0.5 text-emerald-400`,title:`Clean to merge via ${n.strategy===`pr`?`PR`:`rebase + fast-forward`} into ${n.baseRef||`base`}`,children:[(0,I.jsx)(g,{className:`h-3 w-3`}),n.strategy===`pr`?`PR ready`:`clean`]}):null}function Q({workspace:e}){let n=C(),i=w(t=>t.workspaceGitState[e.id]),a=w(e=>e.fetchWorkspaceGitState),o=e.mode===`isolated`&&!!e.worktreePath&&R.has(e.status);if((0,F.useEffect)(()=>{o&&i===void 0&&a(e.id)},[o,i,e.id,a]),!o)return null;let s=(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,className:`h-5 w-5`,title:`Refresh git state`,onClick:()=>void a(e.id),children:(0,I.jsx)(c,{className:`h-3 w-3`})});if(i===void 0)return(0,I.jsx)(`div`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground`,children:`Loading git state…`});if(i.available===!1)return(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground`,title:i.reason,children:[(0,I.jsx)(`span`,{children:`git state unavailable`}),s]});if(i.missing)return(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground`,children:[`worktree gone `,s]});if(i.error)return(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-red-400`,title:i.error,children:[(0,I.jsx)(`span`,{children:`git error`}),s]});let l=i.ahead??0,d=i.landed===!0,p=d?0:i.unmergedAhead??l,m=i.behind??0,h=i.dirtyCount??0,_=p===0&&h===0&&!d,v=i.lastCommit;return(0,I.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px]`,children:[_?(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`no unmerged work`}):(0,I.jsxs)(I.Fragment,{children:[d?(0,I.jsxs)(`span`,{className:`flex items-center gap-0.5 text-emerald-400`,title:`Work already landed in ${i.baseRef||`base`} via squash/cherry-pick — safe to clean up`,children:[(0,I.jsx)(g,{className:`h-3 w-3`}),`landed`]}):(0,I.jsxs)(`span`,{className:p>0?`flex items-center text-emerald-400`:`flex items-center text-muted-foreground`,title:l===p?`${p} commit(s) ahead of base`:`${p} unmerged commit(s) (${l} ahead of base)`,children:[(0,I.jsx)(f,{className:`h-3 w-3`}),p]}),(0,I.jsxs)(`span`,{className:m>0?`flex items-center text-amber-400`:`flex items-center text-muted-foreground`,title:`${m} commit(s) behind base`,children:[(0,I.jsx)(t,{className:`h-3 w-3`}),m]}),h>0&&(0,I.jsxs)(`span`,{className:`flex items-center text-orange-400`,title:`${h} uncommitted change(s)`,children:[(0,I.jsx)(u,{className:`h-3 w-3`}),h]}),!d&&(0,I.jsx)(Z,{workspace:e,unmerged:p})]}),s]}),v&&(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground`,title:`${v.sha.slice(0,8)} — ${v.message}`,children:[(0,I.jsx)(r,{className:`h-3 w-3 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:v.message||v.sha.slice(0,8)}),v.at?(0,I.jsxs)(`span`,{className:`shrink-0 opacity-70`,children:[`· `,E(n,v.at)]}):null]})]})}function $({workspace:e}){let t=C(),n=typeof e.metadata?.mergedAt==`number`?e.metadata.mergedAt:void 0,r=[{label:`created`,at:e.createdAt},{label:`ready`,at:e.readyAt},{label:`merged`,at:n},{label:`cleaned`,at:e.cleanedAt}].filter(e=>typeof e.at==`number`&&e.at>0);return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1 font-medium text-foreground`,children:[(0,I.jsx)(p,{className:`h-3 w-3`}),`Timeline`]}),r.map((e,n)=>(0,I.jsxs)(`span`,{className:`flex items-center gap-1`,children:[n>0&&(0,I.jsx)(`span`,{className:`opacity-40`,children:`→`}),(0,I.jsx)(`span`,{className:`text-foreground`,children:e.label}),(0,I.jsx)(`span`,{title:new Date(e.at).toLocaleString(),children:E(t,e.at)})]},e.label))]})}function ee(e){return e.startsWith(`+`)&&!e.startsWith(`+++`)?`text-emerald-400`:e.startsWith(`-`)&&!e.startsWith(`---`)?`text-red-400`:e.startsWith(`@@`)?`text-cyan-400`:e.startsWith(`diff `)||e.startsWith(`index `)||e.startsWith(`+++`)||e.startsWith(`---`)?`text-muted-foreground`:``}function te({workspace:e}){let t=w(t=>t.workspaceDiff[e.id]),n=w(e=>e.fetchWorkspaceDiff),r=e.mode===`isolated`&&!!e.worktreePath;if((0,F.useEffect)(()=>{r&&t===void 0&&n(e.id)},[r,t,e.id,n]),!r)return null;if(t===void 0)return(0,I.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:`Loading diff…`});if(t.available===!1)return(0,I.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[`Diff unavailable`,t.reason?`: ${t.reason}`:``]});if(t.missing)return(0,I.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:`Worktree no longer on disk`});if(t.error)return(0,I.jsxs)(`div`,{className:`text-[11px] text-red-400`,children:[`Diff error: `,t.error]});if(!t.files.length)return(0,I.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[`No committed changes against `,t.baseRef||`base`]});let a=(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,className:`h-5 w-5`,title:`Refresh diff`,onClick:()=>void n(e.id),children:(0,I.jsx)(c,{className:`h-3 w-3`})});return(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-medium`,children:[(0,I.jsx)(i,{className:`h-3 w-3`}),(0,I.jsxs)(`span`,{children:[t.files.length,` file`,t.files.length===1?``:`s`,` vs `,t.baseRef||`base`]}),a]}),(0,I.jsx)(`ul`,{className:`space-y-0.5 text-[11px]`,children:t.files.map(e=>(0,I.jsxs)(`li`,{className:`flex items-center gap-2 font-mono`,children:[(0,I.jsx)(`span`,{className:`truncate`,title:e.path,children:e.path}),e.binary?(0,I.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`binary`}):(0,I.jsxs)(`span`,{className:`shrink-0`,children:[(0,I.jsxs)(`span`,{className:`text-emerald-400`,children:[`+`,e.additions??0]}),` `,(0,I.jsxs)(`span`,{className:`text-red-400`,children:[`−`,e.deletions??0]})]})]},e.path))}),t.patch&&(0,I.jsxs)(`pre`,{className:`max-h-80 overflow-auto rounded border border-border bg-muted/30 p-2 text-[10.5px] leading-relaxed`,children:[t.patch.split(`
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{An as t,At as n,Ct as r,Ft as i,G as a,It as o,Ln as s,N as c,Nn as l,Nt as u,Ot as d,Tn as f,Xt as p,Yn as m,cn as h,dn as g,i as _,m as v,p as y,un as b,wt as x,xt as S}from"./lucide-react-DWYjU-AF.js";import{c as C,t as w}from"./store-iTiheuTD.js";import{J as T,U as E,d as D}from"./display-DzNvOu1j.js";import{t as O}from"./badge-CZhIdlTJ.js";import{t as k}from"./button-2taQeNHW.js";import{t as A}from"./copy-button-HEkwi6xX.js";import{a as j,o as M,r as N,t as P}from"./card-DzIsAI41.js";var F=e(m(),1),I=s(),L=new Set([`active`,`ready`,`conflict`,`review_requested`,`merge_planned`,`cleanup_requested`]),R=new Set([`active`,`ready`,`conflict`,`review_requested`,`merge_planned`]),z=new Set([`active`,`ready`,`review_requested`,`merge_planned`,`conflict`]),B={active:`bg-blue-500/10 text-blue-400 border-blue-500/20`,ready:`bg-emerald-500/10 text-emerald-400 border-emerald-500/20`,conflict:`bg-red-500/10 text-red-400 border-red-500/20`,review_requested:`bg-yellow-500/10 text-yellow-400 border-yellow-500/20`,merge_planned:`bg-indigo-500/10 text-indigo-400 border-indigo-500/20`,merged:`bg-violet-500/10 text-violet-400 border-violet-500/20`,abandoned:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`,cleanup_requested:`bg-orange-500/10 text-orange-400 border-orange-500/20`,cleaned:`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`},V={active:`active`,ready:`ready`,conflict:`conflict`,review_requested:`review`,merge_planned:`merge planned`,merged:`merged`,abandoned:`abandoned`,cleanup_requested:`cleanup`,cleaned:`cleaned`},H={conflict:0,ready:1,review_requested:2,merge_planned:3,active:4,cleanup_requested:5,merged:6,abandoned:7,cleaned:8},U=new Set(T);function W(e){let t=e.split(`/`).filter(Boolean);return t.length<=3?e||`-`:`/${t.slice(-3).join(`/`)}`}function G(e,t){return e?D(e):t||`-`}function K(e){return B[e]||`bg-zinc-500/10 text-zinc-400 border-zinc-500/20`}function q(e,t){let n=(H[e.status]??99)-(H[t.status]??99);return n===0?Number(t.updatedAt||0)-Number(e.updatedAt||0):n}function J(e){let t=new Map;for(let n of e){let e=n.repoRoot||n.sourceCwd||`unknown repo`;t.set(e,[...t.get(e)||[],n])}return[...t.entries()].map(([e,t])=>({repoRoot:e,workspaces:t.sort(q)})).sort((e,t)=>{let n=e.workspaces.some(e=>L.has(e.status));return n===t.workspaces.some(e=>L.has(e.status))?e.repoRoot.localeCompare(t.repoRoot):n?-1:1})}function Y(e,t){return t===`all`?e:t===`cleaned`?e.filter(e=>U.has(e.status)):e.filter(e=>!U.has(e.status))}function X({workspace:e,expanded:t,onToggleDetails:r}){let i=w(e=>e.workspaceAction),a=w(e=>e.purgeWorkspace),s=w(e=>e.fetchWorkspaceMergePreview),c=w(e=>e.openFilesAt),l=e.status===`cleaned`||e.status===`merged`||e.status===`abandoned`,u=l||e.status===`cleanup_requested`,f=e.worktreePath||e.sourceCwd||e.repoRoot,p=w(t=>t.workspaceGitState[e.id]),m=!!p&&p.available!==!1&&p.landed===!0,y=e.mode===`isolated`&&!!e.worktreePath&&z.has(e.status)&&!m;async function x(){await s(e.id),await i(e.id,`merge`)}return(0,I.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:[(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,title:t?`Hide details`:`Show diff & timeline`,onClick:r,children:t?(0,I.jsx)(b,{className:`h-3.5 w-3.5`}):(0,I.jsx)(h,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,title:`Open workspace`,disabled:!f||e.status===`cleaned`,onClick:()=>void c({path:f}),children:(0,I.jsx)(d,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(A,{value:f,label:`Copy path`,copiedLabel:`Copied path`,size:`icon-sm`,variant:`ghost`,disabled:!f}),(0,I.jsx)(k,{size:`icon-sm`,variant:`outline`,title:`Mark ready`,disabled:u||e.status===`ready`,onClick:()=>void i(e.id,`ready`),children:(0,I.jsx)(g,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`outline`,title:`Request review`,disabled:u||e.status===`review_requested`,onClick:()=>void i(e.id,`request-review`),children:(0,I.jsx)(o,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`outline`,title:`Mark merge planned`,disabled:u||e.status===`merge_planned`,onClick:()=>void i(e.id,`merge-plan`),children:(0,I.jsx)(n,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`default`,title:m?`Already merged into base — nothing to land`:`Merge & land work`,disabled:!y,onClick:()=>void x(),children:(0,I.jsx)(S,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(k,{size:`icon-sm`,variant:`outline`,title:`Request cleanup (removes the worktree on the host)`,disabled:e.status===`cleaned`||e.status===`cleanup_requested`,onClick:()=>void i(e.id,`cleanup`),children:(0,I.jsx)(v,{className:`h-3.5 w-3.5`})}),l&&(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,title:`Purge record (clears the row, does not touch disk)`,onClick:()=>void a(e.id),children:(0,I.jsx)(_,{className:`h-3.5 w-3.5`})})]})}function Z({workspace:e,unmerged:t}){let n=w(t=>t.workspaceMergePreview[e.id]),r=w(e=>e.fetchWorkspaceMergePreview),i=t>0&&z.has(e.status);return(0,F.useEffect)(()=>{i&&n===void 0&&r(e.id)},[i,n,e.id,r]),!i||n===void 0||n.available===!1?null:n.conflict?(0,I.jsxs)(`span`,{className:`flex items-center gap-0.5 text-amber-400`,title:`Merging into ${n.baseRef||`base`} would conflict — resolve before merging`,children:[(0,I.jsx)(y,{className:`h-3 w-3`}),`conflict`]}):n.conflict===!1?(0,I.jsxs)(`span`,{className:`flex items-center gap-0.5 text-emerald-400`,title:`Clean to merge via ${n.strategy===`pr`?`PR`:`rebase + fast-forward`} into ${n.baseRef||`base`}`,children:[(0,I.jsx)(g,{className:`h-3 w-3`}),n.strategy===`pr`?`PR ready`:`clean`]}):null}function Q({workspace:e}){let n=C(),i=w(t=>t.workspaceGitState[e.id]),a=w(e=>e.fetchWorkspaceGitState),o=e.mode===`isolated`&&!!e.worktreePath&&R.has(e.status);if((0,F.useEffect)(()=>{o&&i===void 0&&a(e.id)},[o,i,e.id,a]),!o)return null;let s=(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,className:`h-5 w-5`,title:`Refresh git state`,onClick:()=>void a(e.id),children:(0,I.jsx)(c,{className:`h-3 w-3`})});if(i===void 0)return(0,I.jsx)(`div`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground`,children:`Loading git state…`});if(i.available===!1)return(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground`,title:i.reason,children:[(0,I.jsx)(`span`,{children:`git state unavailable`}),s]});if(i.missing)return(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-muted-foreground`,children:[`worktree gone `,s]});if(i.error)return(0,I.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] text-red-400`,title:i.error,children:[(0,I.jsx)(`span`,{children:`git error`}),s]});let l=i.ahead??0,d=i.landed===!0,p=d?0:i.unmergedAhead??l,m=i.behind??0,h=i.dirtyCount??0,_=p===0&&h===0&&!d,v=i.lastCommit;return(0,I.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px]`,children:[_?(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`no unmerged work`}):(0,I.jsxs)(I.Fragment,{children:[d?(0,I.jsxs)(`span`,{className:`flex items-center gap-0.5 text-emerald-400`,title:`Work already landed in ${i.baseRef||`base`} via squash/cherry-pick — safe to clean up`,children:[(0,I.jsx)(g,{className:`h-3 w-3`}),`landed`]}):(0,I.jsxs)(`span`,{className:p>0?`flex items-center text-emerald-400`:`flex items-center text-muted-foreground`,title:l===p?`${p} commit(s) ahead of base`:`${p} unmerged commit(s) (${l} ahead of base)`,children:[(0,I.jsx)(f,{className:`h-3 w-3`}),p]}),(0,I.jsxs)(`span`,{className:m>0?`flex items-center text-amber-400`:`flex items-center text-muted-foreground`,title:`${m} commit(s) behind base`,children:[(0,I.jsx)(t,{className:`h-3 w-3`}),m]}),h>0&&(0,I.jsxs)(`span`,{className:`flex items-center text-orange-400`,title:`${h} uncommitted change(s)`,children:[(0,I.jsx)(u,{className:`h-3 w-3`}),h]}),!d&&(0,I.jsx)(Z,{workspace:e,unmerged:p})]}),s]}),v&&(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground`,title:`${v.sha.slice(0,8)} — ${v.message}`,children:[(0,I.jsx)(r,{className:`h-3 w-3 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate`,children:v.message||v.sha.slice(0,8)}),v.at?(0,I.jsxs)(`span`,{className:`shrink-0 opacity-70`,children:[`· `,E(n,v.at)]}):null]})]})}function $({workspace:e}){let t=C(),n=typeof e.metadata?.mergedAt==`number`?e.metadata.mergedAt:void 0,r=[{label:`created`,at:e.createdAt},{label:`ready`,at:e.readyAt},{label:`merged`,at:n},{label:`cleaned`,at:e.cleanedAt}].filter(e=>typeof e.at==`number`&&e.at>0);return(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-1 font-medium text-foreground`,children:[(0,I.jsx)(p,{className:`h-3 w-3`}),`Timeline`]}),r.map((e,n)=>(0,I.jsxs)(`span`,{className:`flex items-center gap-1`,children:[n>0&&(0,I.jsx)(`span`,{className:`opacity-40`,children:`→`}),(0,I.jsx)(`span`,{className:`text-foreground`,children:e.label}),(0,I.jsx)(`span`,{title:new Date(e.at).toLocaleString(),children:E(t,e.at)})]},e.label))]})}function ee(e){return e.startsWith(`+`)&&!e.startsWith(`+++`)?`text-emerald-400`:e.startsWith(`-`)&&!e.startsWith(`---`)?`text-red-400`:e.startsWith(`@@`)?`text-cyan-400`:e.startsWith(`diff `)||e.startsWith(`index `)||e.startsWith(`+++`)||e.startsWith(`---`)?`text-muted-foreground`:``}function te({workspace:e}){let t=w(t=>t.workspaceDiff[e.id]),n=w(e=>e.fetchWorkspaceDiff),r=e.mode===`isolated`&&!!e.worktreePath;if((0,F.useEffect)(()=>{r&&t===void 0&&n(e.id)},[r,t,e.id,n]),!r)return null;if(t===void 0)return(0,I.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:`Loading diff…`});if(t.available===!1)return(0,I.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[`Diff unavailable`,t.reason?`: ${t.reason}`:``]});if(t.missing)return(0,I.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:`Worktree no longer on disk`});if(t.error)return(0,I.jsxs)(`div`,{className:`text-[11px] text-red-400`,children:[`Diff error: `,t.error]});if(!t.files.length)return(0,I.jsxs)(`div`,{className:`text-[11px] text-muted-foreground`,children:[`No committed changes against `,t.baseRef||`base`]});let a=(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,className:`h-5 w-5`,title:`Refresh diff`,onClick:()=>void n(e.id),children:(0,I.jsx)(c,{className:`h-3 w-3`})});return(0,I.jsxs)(`div`,{className:`space-y-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] font-medium`,children:[(0,I.jsx)(i,{className:`h-3 w-3`}),(0,I.jsxs)(`span`,{children:[t.files.length,` file`,t.files.length===1?``:`s`,` vs `,t.baseRef||`base`]}),a]}),(0,I.jsx)(`ul`,{className:`space-y-0.5 text-[11px]`,children:t.files.map(e=>(0,I.jsxs)(`li`,{className:`flex items-center gap-2 font-mono`,children:[(0,I.jsx)(`span`,{className:`truncate`,title:e.path,children:e.path}),e.binary?(0,I.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`binary`}):(0,I.jsxs)(`span`,{className:`shrink-0`,children:[(0,I.jsxs)(`span`,{className:`text-emerald-400`,children:[`+`,e.additions??0]}),` `,(0,I.jsxs)(`span`,{className:`text-red-400`,children:[`−`,e.deletions??0]})]})]},e.path))}),t.patch&&(0,I.jsxs)(`pre`,{className:`max-h-80 overflow-auto rounded border border-border bg-muted/30 p-2 text-[10.5px] leading-relaxed`,children:[t.patch.split(`
2
2
  `).map((e,t)=>(0,I.jsx)(`div`,{className:ee(e),children:e||` `},t)),t.truncated&&(0,I.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:`… patch truncated`})]})]})}function ne({workspace:e}){return(0,I.jsxs)(`div`,{className:`space-y-3 border-t border-dashed border-border bg-muted/20 px-3 py-3`,children:[(0,I.jsx)($,{workspace:e}),(0,I.jsx)(te,{workspace:e})]})}function re(){let e=w(e=>e.workspaceOrphans),t=w(e=>e.fetchWorkspaceOrphans),n=w(e=>e.reclaimWorkspaceOrphan);return(0,F.useEffect)(()=>{t()},[t]),e.length?(0,I.jsxs)(P,{className:`border-amber-500/30`,children:[(0,I.jsxs)(j,{className:`px-4 py-3`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(a,{className:`h-4 w-4 text-amber-400`}),(0,I.jsx)(M,{className:`text-sm font-medium`,children:`Orphaned worktrees`}),(0,I.jsx)(O,{variant:`outline`,className:`border-amber-500/30 text-amber-400 text-[10px]`,children:e.length}),(0,I.jsx)(k,{size:`icon-sm`,variant:`ghost`,className:`ml-auto h-6 w-6`,title:`Rescan`,onClick:()=>void t(),children:(0,I.jsx)(c,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Agent worktrees on disk with no live workspace. Reclaim removes them from the host.`})]}),(0,I.jsx)(N,{className:`p-0`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`flex items-center gap-3 border-t border-border px-4 py-2 text-xs`,children:[(0,I.jsx)(x,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,I.jsx)(`span`,{className:`truncate font-medium`,title:e.branch,children:e.branch||`(detached)`}),(0,I.jsx)(`span`,{className:`truncate font-mono text-muted-foreground`,title:e.worktreePath,children:W(e.worktreePath)}),e.hadTerminalRow&&(0,I.jsx)(O,{variant:`outline`,className:`text-[10px]`,children:`cleanup failed`}),(0,I.jsxs)(k,{size:`sm`,variant:`outline`,className:`ml-auto h-7 text-xs`,onClick:()=>void n(e),children:[(0,I.jsx)(l,{className:`mr-1 h-3.5 w-3.5`}),`Reclaim`]})]},e.worktreePath))})]}):null}function ie(e){let t=e.match(/\/pull\/(\d+)/);return t?`PR #${t[1]}`:`View PR`}function ae({workspace:e}){let t=e.metadata?.mergeResult,n=t?.prUrl,r=t?.error||e.metadata?.mergeError;return!n&&!r?null:(0,I.jsxs)(I.Fragment,{children:[n&&(0,I.jsxs)(`a`,{href:n,target:`_blank`,rel:`noreferrer`,title:n,className:`inline-flex items-center gap-0.5 rounded border border-violet-500/30 px-1.5 py-0 text-[10px] text-violet-400 hover:text-violet-300`,children:[(0,I.jsx)(S,{className:`h-2.5 w-2.5`}),ie(n)]}),r&&(0,I.jsxs)(O,{variant:`outline`,className:`max-w-[16rem] border-amber-500/30 text-amber-400 text-[10px]`,title:r,children:[(0,I.jsx)(y,{className:`mr-0.5 h-2.5 w-2.5 shrink-0`}),(0,I.jsxs)(`span`,{className:`truncate`,children:[`merge: `,r]})]})]})}function oe({workspace:e}){let t=C(),[n,r]=(0,F.useState)(!1),i=w(e=>e.agentsById),a=w(t=>t.workspaceFocusId===e.id),o=e.ownerAgentId?i[e.ownerAgentId]:void 0,s=e.stewardAgentId?i[e.stewardAgentId]:void 0,c=e.worktreePath||e.sourceCwd||e.repoRoot,l=(0,F.useRef)(null);return(0,F.useEffect)(()=>{a&&l.current?.scrollIntoView({behavior:`smooth`,block:`center`})},[a]),(0,I.jsxs)(`div`,{ref:l,className:`border-t border-border ${a?`bg-primary/5 ring-1 ring-inset ring-primary/40`:``}`,children:[(0,I.jsxs)(`div`,{className:`grid gap-3 px-3 py-3 text-sm lg:grid-cols-[minmax(180px,1.2fr)_minmax(220px,1.5fr)_minmax(160px,1fr)_minmax(170px,auto)]`,children:[(0,I.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(x,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`}),(0,I.jsx)(`span`,{className:`truncate font-medium`,title:e.branch||e.id,children:e.branch||e.id})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,I.jsx)(O,{variant:`outline`,className:`text-[10px] ${e.mode===`isolated`?`border-sky-500/30 text-sky-400`:`border-zinc-500/30 text-zinc-400`}`,children:e.mode}),e.requestedMode&&e.requestedMode!==e.mode&&(0,I.jsxs)(O,{variant:`outline`,className:`text-[10px]`,children:[`requested `,e.requestedMode]}),(0,I.jsx)(O,{variant:`outline`,className:`text-[10px] ${K(e.status)}`,children:V[e.status]||e.status}),(0,I.jsx)(ae,{workspace:e})]})]}),(0,I.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,I.jsx)(`div`,{className:`truncate font-mono text-xs`,title:c,children:W(c)}),(0,I.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,title:e.sourceCwd,children:e.sourceCwd}),(0,I.jsx)(Q,{workspace:e})]}),(0,I.jsxs)(`div`,{className:`grid grid-cols-[4.5rem_minmax(0,1fr)] gap-x-2 gap-y-1 text-xs`,children:[(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Owner`}),(0,I.jsx)(`span`,{className:`truncate`,title:e.ownerAgentId,children:G(o,e.ownerPolicyName||e.ownerAgentId)}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Steward`}),(0,I.jsx)(`span`,{className:`truncate`,title:e.stewardAgentId,children:G(s,e.stewardAgentId)}),(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Updated`}),(0,I.jsx)(`span`,{children:E(t,e.updatedAt)}),e.baseRef&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{className:`text-muted-foreground`,children:`Base`}),(0,I.jsx)(`span`,{className:`truncate`,title:e.baseSha,children:e.baseRef})]})]}),(0,I.jsx)(X,{workspace:e,expanded:n,onToggleDetails:()=>r(e=>!e)})]}),n&&(0,I.jsx)(ne,{workspace:e})]})}function se({repoRoot:e,workspaces:t}){let n=t.filter(e=>L.has(e.status)).length,r=t.filter(e=>e.status===`ready`||e.status===`review_requested`||e.status===`merge_planned`).length,i=t.filter(e=>e.status===`conflict`).length;return(0,I.jsxs)(P,{children:[(0,I.jsx)(j,{className:`px-4 py-3`,children:(0,I.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(M,{className:`truncate text-sm font-medium`,title:e,children:e}),(0,I.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1.5`,children:[(0,I.jsxs)(O,{variant:`outline`,className:`text-[10px]`,children:[t.length,` total`]}),(0,I.jsxs)(O,{variant:`outline`,className:`text-[10px]`,children:[n,` live`]}),r>0&&(0,I.jsxs)(O,{variant:`outline`,className:`border-emerald-500/20 text-emerald-400 text-[10px]`,children:[r,` merge signal`]}),i>0&&(0,I.jsxs)(O,{variant:`outline`,className:`border-red-500/20 text-red-400 text-[10px]`,children:[i,` conflict`]})]})]})})}),(0,I.jsx)(N,{className:`p-0`,children:t.map(e=>(0,I.jsx)(oe,{workspace:e},e.id))})]})}function ce(){let[e,t]=(0,F.useState)(`active`),n=w(e=>e.workspaces),r=w(e=>e.set),i=w(e=>e.workspaceFocusId);(0,F.useEffect)(()=>{i&&t(`all`)},[i]),(0,F.useEffect)(()=>()=>{r({workspaceFocusId:null})},[r]);let a=(0,F.useMemo)(()=>Y(n,e),[n,e]),o=(0,F.useMemo)(()=>J(a),[a]),s=n.filter(e=>L.has(e.status)).length,c=n.filter(e=>e.mode===`isolated`).length,l=n.filter(e=>e.status===`ready`||e.status===`review_requested`||e.status===`merge_planned`).length,u=n.filter(e=>e.status===`conflict`).length,d=n.filter(e=>U.has(e.status)).length,f=[{key:`active`,label:`Active`,count:n.length-d},{key:`cleaned`,label:`Done`,count:d},{key:`all`,label:`All`,count:n.length}];return(0,I.jsxs)(`div`,{className:`space-y-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`text-2xl font-semibold`,children:`Workspaces`}),(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Agent worktrees, ownership, and merge readiness.`})]}),(0,I.jsxs)(`div`,{className:`ml-auto flex flex-wrap gap-1.5`,children:[(0,I.jsxs)(O,{variant:`outline`,children:[c,` isolated`]}),(0,I.jsxs)(O,{variant:`outline`,children:[s,` live`]}),(0,I.jsxs)(O,{variant:`outline`,children:[l,` ready`]}),u>0&&(0,I.jsxs)(O,{variant:`outline`,className:`border-red-500/20 text-red-400`,children:[u,` conflict`]})]})]}),(0,I.jsx)(re,{}),(0,I.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,I.jsx)(`div`,{className:`flex rounded-md border border-border bg-card p-1`,children:f.map(n=>(0,I.jsxs)(k,{size:`sm`,variant:e===n.key?`secondary`:`ghost`,className:`h-7 text-xs`,onClick:()=>t(n.key),children:[n.label,(0,I.jsx)(`span`,{className:`ml-1 text-muted-foreground`,children:n.count})]},n.key))})}),o.length===0?(0,I.jsxs)(`div`,{className:`rounded-md border border-border px-3 py-12 text-center text-sm text-muted-foreground`,children:[`No `,e===`all`?``:e,` workspaces`]}):(0,I.jsx)(`div`,{className:`space-y-3`,children:o.map(e=>(0,I.jsx)(se,{repoRoot:e.repoRoot,workspaces:e.workspaces},e.repoRoot))})]})}export{ce as WorkspacesView};
3
- //# sourceMappingURL=workspaces-BMj6zx23.js.map
3
+ //# sourceMappingURL=workspaces-D2EfZh9a.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspaces-BMj6zx23.js","names":[],"sources":["../../dashboard/src/components/views/workspaces.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react'\nimport { ArchiveRestore, ArrowDown, ArrowUp, Check, ChevronDown, ChevronRight, Clock, Eye, FileDiff, FilePen, Flag, FolderOpen, GitBranch, GitCommitHorizontal, GitMerge, PackageOpen, RefreshCw, TriangleAlert, Trash2, X } from 'lucide-react'\nimport { TERMINAL_WORKSPACE_STATUS_VALUES } from 'agent-relay-sdk/types'\nimport { useRelayStore, useNow } from '@/store'\nimport { Badge } from '@/components/ui/badge'\nimport { Button } from '@/components/ui/button'\nimport { CopyButton } from '@/components/shared/copy-button'\nimport { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'\nimport { displayName, timeAgo } from '@/lib/display'\nimport type { Agent, WorkspaceOrphan, WorkspaceRecord, WorkspaceStatus } from '@/types'\n\nconst LIVE_STATUSES = new Set<WorkspaceStatus>(['active', 'ready', 'conflict', 'review_requested', 'merge_planned', 'cleanup_requested'])\nconst GIT_STATE_STATUSES = new Set<WorkspaceStatus>(['active', 'ready', 'conflict', 'review_requested', 'merge_planned'])\nconst MERGEABLE_STATUSES = new Set<WorkspaceStatus>(['active', 'ready', 'review_requested', 'merge_planned', 'conflict'])\n\ntype WorkspaceFilter = 'active' | 'cleaned' | 'all'\n\nconst STATUS_CLASS: Record<WorkspaceStatus, string> = {\n active: 'bg-blue-500/10 text-blue-400 border-blue-500/20',\n ready: 'bg-emerald-500/10 text-emerald-400 border-emerald-500/20',\n conflict: 'bg-red-500/10 text-red-400 border-red-500/20',\n review_requested: 'bg-yellow-500/10 text-yellow-400 border-yellow-500/20',\n merge_planned: 'bg-indigo-500/10 text-indigo-400 border-indigo-500/20',\n merged: 'bg-violet-500/10 text-violet-400 border-violet-500/20',\n abandoned: 'bg-zinc-500/10 text-zinc-400 border-zinc-500/20',\n cleanup_requested: 'bg-orange-500/10 text-orange-400 border-orange-500/20',\n cleaned: 'bg-zinc-500/10 text-zinc-400 border-zinc-500/20',\n}\n\nconst STATUS_LABEL: Record<WorkspaceStatus, string> = {\n active: 'active',\n ready: 'ready',\n conflict: 'conflict',\n review_requested: 'review',\n merge_planned: 'merge planned',\n merged: 'merged',\n abandoned: 'abandoned',\n cleanup_requested: 'cleanup',\n cleaned: 'cleaned',\n}\n\nconst STATUS_ORDER: Record<WorkspaceStatus, number> = {\n conflict: 0,\n ready: 1,\n review_requested: 2,\n merge_planned: 3,\n active: 4,\n cleanup_requested: 5,\n merged: 6,\n abandoned: 7,\n cleaned: 8,\n}\n\nconst TERMINAL_STATUSES = new Set<WorkspaceStatus>(TERMINAL_WORKSPACE_STATUS_VALUES)\n\nfunction shortPath(path: string): string {\n const parts = path.split('/').filter(Boolean)\n if (parts.length <= 3) return path || '-'\n return `/${parts.slice(-3).join('/')}`\n}\n\nfunction agentLabel(agent: Agent | undefined, fallback: string | undefined): string {\n if (agent) return displayName(agent)\n return fallback || '-'\n}\n\nfunction statusTone(status: WorkspaceStatus): string {\n return STATUS_CLASS[status] || 'bg-zinc-500/10 text-zinc-400 border-zinc-500/20'\n}\n\nfunction workspaceSort(a: WorkspaceRecord, b: WorkspaceRecord): number {\n const status = (STATUS_ORDER[a.status] ?? 99) - (STATUS_ORDER[b.status] ?? 99)\n if (status !== 0) return status\n return Number(b.updatedAt || 0) - Number(a.updatedAt || 0)\n}\n\nfunction groupWorkspaces(workspaces: WorkspaceRecord[]): Array<{ repoRoot: string; workspaces: WorkspaceRecord[] }> {\n const grouped = new Map<string, WorkspaceRecord[]>()\n for (const workspace of workspaces) {\n const key = workspace.repoRoot || workspace.sourceCwd || 'unknown repo'\n grouped.set(key, [...(grouped.get(key) || []), workspace])\n }\n return [...grouped.entries()]\n .map(([repoRoot, items]) => ({ repoRoot, workspaces: items.sort(workspaceSort) }))\n .sort((a, b) => {\n const liveA = a.workspaces.some((item) => LIVE_STATUSES.has(item.status))\n const liveB = b.workspaces.some((item) => LIVE_STATUSES.has(item.status))\n if (liveA !== liveB) return liveA ? -1 : 1\n return a.repoRoot.localeCompare(b.repoRoot)\n })\n}\n\nfunction filterWorkspaces(workspaces: WorkspaceRecord[], filter: WorkspaceFilter): WorkspaceRecord[] {\n if (filter === 'all') return workspaces\n if (filter === 'cleaned') return workspaces.filter((workspace) => TERMINAL_STATUSES.has(workspace.status))\n return workspaces.filter((workspace) => !TERMINAL_STATUSES.has(workspace.status))\n}\n\nfunction WorkspaceActions({ workspace, expanded, onToggleDetails }: { workspace: WorkspaceRecord; expanded: boolean; onToggleDetails: () => void }) {\n const workspaceAction = useRelayStore((s) => s.workspaceAction)\n const purgeWorkspace = useRelayStore((s) => s.purgeWorkspace)\n const fetchWorkspaceMergePreview = useRelayStore((s) => s.fetchWorkspaceMergePreview)\n const openFilesAt = useRelayStore((s) => s.openFilesAt)\n const terminal = workspace.status === 'cleaned' || workspace.status === 'merged' || workspace.status === 'abandoned'\n const disabled = terminal || workspace.status === 'cleanup_requested'\n const openPath = workspace.worktreePath || workspace.sourceCwd || workspace.repoRoot\n // Already-landed work (squash/cherry-pick) has nothing left to merge — a merge\n // would open a duplicate/no-op PR, so disable the button.\n const gitState = useRelayStore((s) => s.workspaceGitState[workspace.id])\n const landed = !!gitState && gitState.available !== false && gitState.landed === true\n const mergeable = workspace.mode === 'isolated' && Boolean(workspace.worktreePath) && MERGEABLE_STATUSES.has(workspace.status) && !landed\n\n // Refresh the preview so the confirm dialog states the strategy/outcome, then\n // dispatch the real merge command.\n async function merge() {\n await fetchWorkspaceMergePreview(workspace.id)\n await workspaceAction(workspace.id, 'merge')\n }\n\n return (\n <div className=\"flex flex-wrap justify-end gap-1.5\">\n <Button size=\"icon-sm\" variant=\"ghost\" title={expanded ? 'Hide details' : 'Show diff & timeline'} onClick={onToggleDetails}>\n {expanded ? <ChevronDown className=\"h-3.5 w-3.5\" /> : <ChevronRight className=\"h-3.5 w-3.5\" />}\n </Button>\n <Button\n size=\"icon-sm\"\n variant=\"ghost\"\n title=\"Open workspace\"\n disabled={!openPath || workspace.status === 'cleaned'}\n onClick={() => void openFilesAt({ path: openPath })}\n >\n <FolderOpen className=\"h-3.5 w-3.5\" />\n </Button>\n <CopyButton value={openPath} label=\"Copy path\" copiedLabel=\"Copied path\" size=\"icon-sm\" variant=\"ghost\" disabled={!openPath} />\n <Button size=\"icon-sm\" variant=\"outline\" title=\"Mark ready\" disabled={disabled || workspace.status === 'ready'} onClick={() => void workspaceAction(workspace.id, 'ready')}>\n <Check className=\"h-3.5 w-3.5\" />\n </Button>\n <Button size=\"icon-sm\" variant=\"outline\" title=\"Request review\" disabled={disabled || workspace.status === 'review_requested'} onClick={() => void workspaceAction(workspace.id, 'request-review')}>\n <Eye className=\"h-3.5 w-3.5\" />\n </Button>\n <Button size=\"icon-sm\" variant=\"outline\" title=\"Mark merge planned\" disabled={disabled || workspace.status === 'merge_planned'} onClick={() => void workspaceAction(workspace.id, 'merge-plan')}>\n <Flag className=\"h-3.5 w-3.5\" />\n </Button>\n <Button size=\"icon-sm\" variant=\"default\" title={landed ? 'Already merged into base — nothing to land' : 'Merge & land work'} disabled={!mergeable} onClick={() => void merge()}>\n <GitMerge className=\"h-3.5 w-3.5\" />\n </Button>\n <Button size=\"icon-sm\" variant=\"outline\" title=\"Request cleanup (removes the worktree on the host)\" disabled={workspace.status === 'cleaned' || workspace.status === 'cleanup_requested'} onClick={() => void workspaceAction(workspace.id, 'cleanup')}>\n <Trash2 className=\"h-3.5 w-3.5\" />\n </Button>\n {terminal && (\n <Button size=\"icon-sm\" variant=\"ghost\" title=\"Purge record (clears the row, does not touch disk)\" onClick={() => void purgeWorkspace(workspace.id)}>\n <X className=\"h-3.5 w-3.5\" />\n </Button>\n )}\n </div>\n )\n}\n\n// Pre-merge conflict hint, shown next to git state when the worktree has work to\n// land. Lazily fetched from the owning host (an external sync), so an effect is\n// the right tool. Reports clean-ff vs would-conflict before the user merges.\nfunction MergePreviewHint({ workspace, unmerged }: { workspace: WorkspaceRecord; unmerged: number }) {\n const preview = useRelayStore((s) => s.workspaceMergePreview[workspace.id])\n const fetchWorkspaceMergePreview = useRelayStore((s) => s.fetchWorkspaceMergePreview)\n const eligible = unmerged > 0 && MERGEABLE_STATUSES.has(workspace.status)\n\n useEffect(() => {\n if (eligible && preview === undefined) void fetchWorkspaceMergePreview(workspace.id)\n }, [eligible, preview, workspace.id, fetchWorkspaceMergePreview])\n\n if (!eligible || preview === undefined || preview.available === false) return null\n if (preview.conflict) {\n return (\n <span className=\"flex items-center gap-0.5 text-amber-400\" title={`Merging into ${preview.baseRef || 'base'} would conflict — resolve before merging`}>\n <TriangleAlert className=\"h-3 w-3\" />conflict\n </span>\n )\n }\n if (preview.conflict === false) {\n return (\n <span className=\"flex items-center gap-0.5 text-emerald-400\" title={`Clean to merge via ${preview.strategy === 'pr' ? 'PR' : 'rebase + fast-forward'} into ${preview.baseRef || 'base'}`}>\n <Check className=\"h-3 w-3\" />{preview.strategy === 'pr' ? 'PR ready' : 'clean'}\n </span>\n )\n }\n return null\n}\n\n// Live git state of the worktree, fetched lazily from the owning host. This is\n// an external-system sync (host git over the orchestrator proxy), so an effect\n// is the right tool — it does not derive state from props.\nfunction GitState({ workspace }: { workspace: WorkspaceRecord }) {\n const now = useNow()\n const gitState = useRelayStore((s) => s.workspaceGitState[workspace.id])\n const fetchWorkspaceGitState = useRelayStore((s) => s.fetchWorkspaceGitState)\n const eligible = workspace.mode === 'isolated' && Boolean(workspace.worktreePath) && GIT_STATE_STATUSES.has(workspace.status)\n\n useEffect(() => {\n if (eligible && gitState === undefined) void fetchWorkspaceGitState(workspace.id)\n }, [eligible, gitState, workspace.id, fetchWorkspaceGitState])\n\n if (!eligible) return null\n\n const refresh = (\n <Button\n size=\"icon-sm\"\n variant=\"ghost\"\n className=\"h-5 w-5\"\n title=\"Refresh git state\"\n onClick={() => void fetchWorkspaceGitState(workspace.id)}\n >\n <RefreshCw className=\"h-3 w-3\" />\n </Button>\n )\n\n if (gitState === undefined) {\n return <div className=\"flex items-center gap-1 text-[11px] text-muted-foreground\">Loading git state…</div>\n }\n if (gitState.available === false) {\n return (\n <div className=\"flex items-center gap-1 text-[11px] text-muted-foreground\" title={gitState.reason}>\n <span>git state unavailable</span>\n {refresh}\n </div>\n )\n }\n if (gitState.missing) {\n return <div className=\"flex items-center gap-1 text-[11px] text-muted-foreground\">worktree gone {refresh}</div>\n }\n if (gitState.error) {\n return (\n <div className=\"flex items-center gap-1 text-[11px] text-red-400\" title={gitState.error}>\n <span>git error</span>\n {refresh}\n </div>\n )\n }\n\n const ahead = gitState.ahead ?? 0\n // Work squash/cherry-pick-merged into base leaves `ahead` positive but is\n // effectively landed — surface the unmerged count, not the raw ahead.\n const landed = gitState.landed === true\n const unmerged = landed ? 0 : (gitState.unmergedAhead ?? ahead)\n const behind = gitState.behind ?? 0\n const dirty = gitState.dirtyCount ?? 0\n const clean = unmerged === 0 && dirty === 0 && !landed\n const commit = gitState.lastCommit\n\n return (\n <div className=\"space-y-0.5\">\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px]\">\n {clean ? (\n <span className=\"text-muted-foreground\">no unmerged work</span>\n ) : (\n <>\n {landed ? (\n <span className=\"flex items-center gap-0.5 text-emerald-400\" title={`Work already landed in ${gitState.baseRef || 'base'} via squash/cherry-pick — safe to clean up`}>\n <Check className=\"h-3 w-3\" />landed\n </span>\n ) : (\n <span className={unmerged > 0 ? 'flex items-center text-emerald-400' : 'flex items-center text-muted-foreground'} title={ahead !== unmerged ? `${unmerged} unmerged commit(s) (${ahead} ahead of base)` : `${unmerged} commit(s) ahead of base`}>\n <ArrowUp className=\"h-3 w-3\" />{unmerged}\n </span>\n )}\n <span className={behind > 0 ? 'flex items-center text-amber-400' : 'flex items-center text-muted-foreground'} title={`${behind} commit(s) behind base`}>\n <ArrowDown className=\"h-3 w-3\" />{behind}\n </span>\n {dirty > 0 && (\n <span className=\"flex items-center text-orange-400\" title={`${dirty} uncommitted change(s)`}>\n <FilePen className=\"h-3 w-3\" />{dirty}\n </span>\n )}\n {!landed && <MergePreviewHint workspace={workspace} unmerged={unmerged} />}\n </>\n )}\n {refresh}\n </div>\n {commit && (\n <div className=\"flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground\" title={`${commit.sha.slice(0, 8)} — ${commit.message}`}>\n <GitCommitHorizontal className=\"h-3 w-3 shrink-0\" />\n <span className=\"truncate\">{commit.message || commit.sha.slice(0, 8)}</span>\n {commit.at ? <span className=\"shrink-0 opacity-70\">· {timeAgo(now, commit.at)}</span> : null}\n </div>\n )}\n </div>\n )\n}\n\n// Lifecycle timeline from the timestamps the relay already records:\n// created → ready → merged → cleaned. Surfaces history without a drawer.\nfunction WorkspaceTimeline({ workspace }: { workspace: WorkspaceRecord }) {\n const now = useNow()\n const mergedAt = typeof workspace.metadata?.mergedAt === 'number' ? (workspace.metadata.mergedAt as number) : undefined\n const steps = [\n { label: 'created', at: workspace.createdAt },\n { label: 'ready', at: workspace.readyAt },\n { label: 'merged', at: mergedAt },\n { label: 'cleaned', at: workspace.cleanedAt },\n ].filter((step): step is { label: string; at: number } => typeof step.at === 'number' && step.at > 0)\n\n return (\n <div className=\"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground\">\n <span className=\"flex items-center gap-1 font-medium text-foreground\"><Clock className=\"h-3 w-3\" />Timeline</span>\n {steps.map((step, i) => (\n <span key={step.label} className=\"flex items-center gap-1\">\n {i > 0 && <span className=\"opacity-40\">→</span>}\n <span className=\"text-foreground\">{step.label}</span>\n <span title={new Date(step.at).toLocaleString()}>{timeAgo(now, step.at)}</span>\n </span>\n ))}\n </div>\n )\n}\n\nfunction diffLineClass(line: string): string {\n if (line.startsWith('+') && !line.startsWith('+++')) return 'text-emerald-400'\n if (line.startsWith('-') && !line.startsWith('---')) return 'text-red-400'\n if (line.startsWith('@@')) return 'text-cyan-400'\n if (line.startsWith('diff ') || line.startsWith('index ') || line.startsWith('+++') || line.startsWith('---')) return 'text-muted-foreground'\n return ''\n}\n\n// Diff of committed work against base, lazily fetched from the owning host.\nfunction WorkspaceDiffView({ workspace }: { workspace: WorkspaceRecord }) {\n const diff = useRelayStore((s) => s.workspaceDiff[workspace.id])\n const fetchWorkspaceDiff = useRelayStore((s) => s.fetchWorkspaceDiff)\n const eligible = workspace.mode === 'isolated' && Boolean(workspace.worktreePath)\n\n useEffect(() => {\n if (eligible && diff === undefined) void fetchWorkspaceDiff(workspace.id)\n }, [eligible, diff, workspace.id, fetchWorkspaceDiff])\n\n if (!eligible) return null\n if (diff === undefined) return <div className=\"text-[11px] text-muted-foreground\">Loading diff…</div>\n if (diff.available === false) return <div className=\"text-[11px] text-muted-foreground\">Diff unavailable{diff.reason ? `: ${diff.reason}` : ''}</div>\n if (diff.missing) return <div className=\"text-[11px] text-muted-foreground\">Worktree no longer on disk</div>\n if (diff.error) return <div className=\"text-[11px] text-red-400\">Diff error: {diff.error}</div>\n if (!diff.files.length) return <div className=\"text-[11px] text-muted-foreground\">No committed changes against {diff.baseRef || 'base'}</div>\n\n const refresh = (\n <Button size=\"icon-sm\" variant=\"ghost\" className=\"h-5 w-5\" title=\"Refresh diff\" onClick={() => void fetchWorkspaceDiff(workspace.id)}>\n <RefreshCw className=\"h-3 w-3\" />\n </Button>\n )\n\n return (\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2 text-[11px] font-medium\">\n <FileDiff className=\"h-3 w-3\" />\n <span>{diff.files.length} file{diff.files.length === 1 ? '' : 's'} vs {diff.baseRef || 'base'}</span>\n {refresh}\n </div>\n <ul className=\"space-y-0.5 text-[11px]\">\n {diff.files.map((file) => (\n <li key={file.path} className=\"flex items-center gap-2 font-mono\">\n <span className=\"truncate\" title={file.path}>{file.path}</span>\n {file.binary ? (\n <span className=\"shrink-0 text-muted-foreground\">binary</span>\n ) : (\n <span className=\"shrink-0\">\n <span className=\"text-emerald-400\">+{file.additions ?? 0}</span>{' '}\n <span className=\"text-red-400\">−{file.deletions ?? 0}</span>\n </span>\n )}\n </li>\n ))}\n </ul>\n {diff.patch && (\n <pre className=\"max-h-80 overflow-auto rounded border border-border bg-muted/30 p-2 text-[10.5px] leading-relaxed\">\n {diff.patch.split('\\n').map((line, i) => (\n <div key={i} className={diffLineClass(line)}>{line || ' '}</div>\n ))}\n {diff.truncated && <div className=\"mt-1 text-muted-foreground\">… patch truncated</div>}\n </pre>\n )}\n </div>\n )\n}\n\nfunction WorkspaceDetails({ workspace }: { workspace: WorkspaceRecord }) {\n return (\n <div className=\"space-y-3 border-t border-dashed border-border bg-muted/20 px-3 py-3\">\n <WorkspaceTimeline workspace={workspace} />\n <WorkspaceDiffView workspace={workspace} />\n </div>\n )\n}\n\n// Worktrees on disk with no live workspace row — reclaimable in one click.\nfunction OrphanPanel() {\n const orphans = useRelayStore((s) => s.workspaceOrphans)\n const fetchWorkspaceOrphans = useRelayStore((s) => s.fetchWorkspaceOrphans)\n const reclaimWorkspaceOrphan = useRelayStore((s) => s.reclaimWorkspaceOrphan)\n\n useEffect(() => {\n void fetchWorkspaceOrphans()\n }, [fetchWorkspaceOrphans])\n\n if (!orphans.length) return null\n\n return (\n <Card className=\"border-amber-500/30\">\n <CardHeader className=\"px-4 py-3\">\n <div className=\"flex items-center gap-2\">\n <PackageOpen className=\"h-4 w-4 text-amber-400\" />\n <CardTitle className=\"text-sm font-medium\">Orphaned worktrees</CardTitle>\n <Badge variant=\"outline\" className=\"border-amber-500/30 text-amber-400 text-[10px]\">{orphans.length}</Badge>\n <Button size=\"icon-sm\" variant=\"ghost\" className=\"ml-auto h-6 w-6\" title=\"Rescan\" onClick={() => void fetchWorkspaceOrphans()}>\n <RefreshCw className=\"h-3.5 w-3.5\" />\n </Button>\n </div>\n <p className=\"mt-1 text-xs text-muted-foreground\">Agent worktrees on disk with no live workspace. Reclaim removes them from the host.</p>\n </CardHeader>\n <CardContent className=\"p-0\">\n {orphans.map((orphan) => (\n <div key={orphan.worktreePath} className=\"flex items-center gap-3 border-t border-border px-4 py-2 text-xs\">\n <GitBranch className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate font-medium\" title={orphan.branch}>{orphan.branch || '(detached)'}</span>\n <span className=\"truncate font-mono text-muted-foreground\" title={orphan.worktreePath}>{shortPath(orphan.worktreePath)}</span>\n {orphan.hadTerminalRow && <Badge variant=\"outline\" className=\"text-[10px]\">cleanup failed</Badge>}\n <Button size=\"sm\" variant=\"outline\" className=\"ml-auto h-7 text-xs\" onClick={() => void reclaimWorkspaceOrphan(orphan)}>\n <ArchiveRestore className=\"mr-1 h-3.5 w-3.5\" />Reclaim\n </Button>\n </div>\n ))}\n </CardContent>\n </Card>\n )\n}\n\n// A `pr`-strategy merge lands as an opened PR, not a local fast-forward, so the\n// outcome only shows up here — surface the PR link and any error the orchestrator\n// returned (which the command layer keeps in result even when status=succeeded).\nfunction prLabel(url: string): string {\n const match = url.match(/\\/pull\\/(\\d+)/)\n return match ? `PR #${match[1]}` : 'View PR'\n}\n\nfunction MergeOutcome({ workspace }: { workspace: WorkspaceRecord }) {\n const result = workspace.metadata?.mergeResult as { prUrl?: string; error?: string } | undefined\n const prUrl = result?.prUrl\n const error = result?.error || (workspace.metadata?.mergeError as string | undefined)\n if (!prUrl && !error) return null\n return (\n <>\n {prUrl && (\n <a\n href={prUrl}\n target=\"_blank\"\n rel=\"noreferrer\"\n title={prUrl}\n className=\"inline-flex items-center gap-0.5 rounded border border-violet-500/30 px-1.5 py-0 text-[10px] text-violet-400 hover:text-violet-300\"\n >\n <GitMerge className=\"h-2.5 w-2.5\" />{prLabel(prUrl)}\n </a>\n )}\n {error && (\n <Badge variant=\"outline\" className=\"max-w-[16rem] border-amber-500/30 text-amber-400 text-[10px]\" title={error}>\n <TriangleAlert className=\"mr-0.5 h-2.5 w-2.5 shrink-0\" /><span className=\"truncate\">merge: {error}</span>\n </Badge>\n )}\n </>\n )\n}\n\nfunction WorkspaceRow({ workspace }: { workspace: WorkspaceRecord }) {\n const now = useNow()\n const [expanded, setExpanded] = useState(false)\n const agentsById = useRelayStore((s) => s.agentsById)\n const focused = useRelayStore((s) => s.workspaceFocusId === workspace.id)\n const owner = workspace.ownerAgentId ? agentsById[workspace.ownerAgentId] : undefined\n const steward = workspace.stewardAgentId ? agentsById[workspace.stewardAgentId] : undefined\n const path = workspace.worktreePath || workspace.sourceCwd || workspace.repoRoot\n const rowRef = useRef<HTMLDivElement>(null)\n\n // Click-through landing (#236): scroll the targeted row into view once it mounts.\n useEffect(() => {\n if (focused) rowRef.current?.scrollIntoView({ behavior: 'smooth', block: 'center' })\n }, [focused])\n\n return (\n <div ref={rowRef} className={`border-t border-border ${focused ? 'bg-primary/5 ring-1 ring-inset ring-primary/40' : ''}`}>\n <div className=\"grid gap-3 px-3 py-3 text-sm lg:grid-cols-[minmax(180px,1.2fr)_minmax(220px,1.5fr)_minmax(160px,1fr)_minmax(170px,auto)]\">\n <div className=\"min-w-0 space-y-1\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <GitBranch className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate font-medium\" title={workspace.branch || workspace.id}>{workspace.branch || workspace.id}</span>\n </div>\n <div className=\"flex flex-wrap gap-1\">\n <Badge variant=\"outline\" className={`text-[10px] ${workspace.mode === 'isolated' ? 'border-sky-500/30 text-sky-400' : 'border-zinc-500/30 text-zinc-400'}`}>\n {workspace.mode}\n </Badge>\n {workspace.requestedMode && workspace.requestedMode !== workspace.mode && (\n <Badge variant=\"outline\" className=\"text-[10px]\">requested {workspace.requestedMode}</Badge>\n )}\n <Badge variant=\"outline\" className={`text-[10px] ${statusTone(workspace.status)}`}>{STATUS_LABEL[workspace.status] || workspace.status}</Badge>\n <MergeOutcome workspace={workspace} />\n </div>\n </div>\n\n <div className=\"min-w-0 space-y-1\">\n <div className=\"truncate font-mono text-xs\" title={path}>{shortPath(path)}</div>\n <div className=\"truncate text-xs text-muted-foreground\" title={workspace.sourceCwd}>{workspace.sourceCwd}</div>\n <GitState workspace={workspace} />\n </div>\n\n <div className=\"grid grid-cols-[4.5rem_minmax(0,1fr)] gap-x-2 gap-y-1 text-xs\">\n <span className=\"text-muted-foreground\">Owner</span>\n <span className=\"truncate\" title={workspace.ownerAgentId}>{agentLabel(owner, workspace.ownerPolicyName || workspace.ownerAgentId)}</span>\n <span className=\"text-muted-foreground\">Steward</span>\n <span className=\"truncate\" title={workspace.stewardAgentId}>{agentLabel(steward, workspace.stewardAgentId)}</span>\n <span className=\"text-muted-foreground\">Updated</span>\n <span>{timeAgo(now, workspace.updatedAt)}</span>\n {workspace.baseRef && (\n <>\n <span className=\"text-muted-foreground\">Base</span>\n <span className=\"truncate\" title={workspace.baseSha}>{workspace.baseRef}</span>\n </>\n )}\n </div>\n\n <WorkspaceActions workspace={workspace} expanded={expanded} onToggleDetails={() => setExpanded((value) => !value)} />\n </div>\n {expanded && <WorkspaceDetails workspace={workspace} />}\n </div>\n )\n}\n\nfunction RepoGroup({ repoRoot, workspaces }: { repoRoot: string; workspaces: WorkspaceRecord[] }) {\n const liveCount = workspaces.filter((item) => LIVE_STATUSES.has(item.status)).length\n const readyCount = workspaces.filter((item) => item.status === 'ready' || item.status === 'review_requested' || item.status === 'merge_planned').length\n const conflictCount = workspaces.filter((item) => item.status === 'conflict').length\n\n return (\n <Card>\n <CardHeader className=\"px-4 py-3\">\n <div className=\"flex min-w-0 items-start gap-3\">\n <div className=\"min-w-0 flex-1\">\n <CardTitle className=\"truncate text-sm font-medium\" title={repoRoot}>{repoRoot}</CardTitle>\n <div className=\"mt-1 flex flex-wrap gap-1.5\">\n <Badge variant=\"outline\" className=\"text-[10px]\">{workspaces.length} total</Badge>\n <Badge variant=\"outline\" className=\"text-[10px]\">{liveCount} live</Badge>\n {readyCount > 0 && <Badge variant=\"outline\" className=\"border-emerald-500/20 text-emerald-400 text-[10px]\">{readyCount} merge signal</Badge>}\n {conflictCount > 0 && <Badge variant=\"outline\" className=\"border-red-500/20 text-red-400 text-[10px]\">{conflictCount} conflict</Badge>}\n </div>\n </div>\n </div>\n </CardHeader>\n <CardContent className=\"p-0\">\n {workspaces.map((workspace) => (\n <WorkspaceRow key={workspace.id} workspace={workspace} />\n ))}\n </CardContent>\n </Card>\n )\n}\n\nexport function WorkspacesView() {\n const [filter, setFilter] = useState<WorkspaceFilter>('active')\n const workspaces = useRelayStore((s) => s.workspaces)\n const set = useRelayStore((s) => s.set)\n const workspaceFocusId = useRelayStore((s) => s.workspaceFocusId)\n\n // Badge click-through (#236): a focused workspace may be in any state, so widen\n // the filter to 'all' to guarantee its row renders. Clear the focus when leaving\n // the panel so the highlight doesn't linger on the next visit.\n useEffect(() => {\n if (workspaceFocusId) setFilter('all')\n }, [workspaceFocusId])\n useEffect(() => () => { set({ workspaceFocusId: null }) }, [set])\n\n const visibleWorkspaces = useMemo(() => filterWorkspaces(workspaces, filter), [workspaces, filter])\n const grouped = useMemo(() => groupWorkspaces(visibleWorkspaces), [visibleWorkspaces])\n const liveCount = workspaces.filter((item) => LIVE_STATUSES.has(item.status)).length\n const isolatedCount = workspaces.filter((item) => item.mode === 'isolated').length\n const readyCount = workspaces.filter((item) => item.status === 'ready' || item.status === 'review_requested' || item.status === 'merge_planned').length\n const conflictCount = workspaces.filter((item) => item.status === 'conflict').length\n const doneCount = workspaces.filter((item) => TERMINAL_STATUSES.has(item.status)).length\n const activeCount = workspaces.length - doneCount\n const filters: Array<{ key: WorkspaceFilter; label: string; count: number }> = [\n { key: 'active', label: 'Active', count: activeCount },\n { key: 'cleaned', label: 'Done', count: doneCount },\n { key: 'all', label: 'All', count: workspaces.length },\n ]\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex flex-wrap items-center gap-3\">\n <div>\n <h1 className=\"text-2xl font-semibold\">Workspaces</h1>\n <p className=\"text-sm text-muted-foreground\">Agent worktrees, ownership, and merge readiness.</p>\n </div>\n <div className=\"ml-auto flex flex-wrap gap-1.5\">\n <Badge variant=\"outline\">{isolatedCount} isolated</Badge>\n <Badge variant=\"outline\">{liveCount} live</Badge>\n <Badge variant=\"outline\">{readyCount} ready</Badge>\n {conflictCount > 0 && <Badge variant=\"outline\" className=\"border-red-500/20 text-red-400\">{conflictCount} conflict</Badge>}\n </div>\n </div>\n\n <OrphanPanel />\n\n <div className=\"flex flex-wrap items-center gap-2\">\n <div className=\"flex rounded-md border border-border bg-card p-1\">\n {filters.map((item) => (\n <Button\n key={item.key}\n size=\"sm\"\n variant={filter === item.key ? 'secondary' : 'ghost'}\n className=\"h-7 text-xs\"\n onClick={() => setFilter(item.key)}\n >\n {item.label}\n <span className=\"ml-1 text-muted-foreground\">{item.count}</span>\n </Button>\n ))}\n </div>\n </div>\n\n {grouped.length === 0 ? (\n <div className=\"rounded-md border border-border px-3 py-12 text-center text-sm text-muted-foreground\">\n No {filter === 'all' ? '' : filter} workspaces\n </div>\n ) : (\n <div className=\"space-y-3\">\n {grouped.map((group) => (\n <RepoGroup key={group.repoRoot} repoRoot={group.repoRoot} workspaces={group.workspaces} />\n ))}\n </div>\n )}\n </div>\n )\n}\n"],"mappings":"kjBAWM,EAAgB,IAAI,IAAqB,CAAC,SAAU,QAAS,WAAY,mBAAoB,gBAAiB,oBAAoB,CAAC,CACnI,EAAqB,IAAI,IAAqB,CAAC,SAAU,QAAS,WAAY,mBAAoB,gBAAgB,CAAC,CACnH,EAAqB,IAAI,IAAqB,CAAC,SAAU,QAAS,mBAAoB,gBAAiB,WAAW,CAAC,CAInH,EAAgD,CACpD,OAAQ,kDACR,MAAO,2DACP,SAAU,+CACV,iBAAkB,wDAClB,cAAe,wDACf,OAAQ,wDACR,UAAW,kDACX,kBAAmB,wDACnB,QAAS,kDACV,CAEK,EAAgD,CACpD,OAAQ,SACR,MAAO,QACP,SAAU,WACV,iBAAkB,SAClB,cAAe,gBACf,OAAQ,SACR,UAAW,YACX,kBAAmB,UACnB,QAAS,UACV,CAEK,EAAgD,CACpD,SAAU,EACV,MAAO,EACP,iBAAkB,EAClB,cAAe,EACf,OAAQ,EACR,kBAAmB,EACnB,OAAQ,EACR,UAAW,EACX,QAAS,EACV,CAEK,EAAoB,IAAI,IAAqB,EAAiC,CAEpF,SAAS,EAAU,EAAsB,CACvC,IAAM,EAAQ,EAAK,MAAM,IAAI,CAAC,OAAO,QA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AA,EAAA,KAAC,MAAD,CAAK,UAAU,8CACb,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,4DACZ,EAAQ,IAAK,IACZ,EAAA,EAAA,MAAC,EAAD,CAEE,KAAK,KACL,QAAS,IAAW,EAAK,IAAM,YAAc,QAC7C,UAAU,cACV,YAAe,EAAU,EAAK,IAAI,UALpC,CAOG,EAAK,OACN,EAAA,EAAA,KAAC,OAAD,CAAM,UAAU,sCAA8B,EAAK,MAAa,CAAA,CACzD,EARF,EAAK,IAQH,CACT,CACE,CAAA,CACF,CAAA,CAEL,EAAQ,SAAW,GAClB,EAAA,EAAA,MAAC,MAAD,CAAK,UAAU,gGAAf,CAAsG,MAChG,IAAW,MAAQ,GAAK,EAAO,cAC/B,IAEN,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,qBACZ,EAAQ,IAAK,IACZ,EAAA,EAAA,KAAC,GAAD,CAAgC,SAAU,EAAM,SAAU,WAAY,EAAM,WAAc,CAA1E,EAAM,SAAoE,CAC1F,CACE,CAAA,CAEJ"}
1
+ {"version":3,"file":"workspaces-D2EfZh9a.js","names":[],"sources":["../../dashboard/src/components/views/workspaces.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from 'react'\nimport { ArchiveRestore, ArrowDown, ArrowUp, Check, ChevronDown, ChevronRight, Clock, Eye, FileDiff, FilePen, Flag, FolderOpen, GitBranch, GitCommitHorizontal, GitMerge, PackageOpen, RefreshCw, TriangleAlert, Trash2, X } from 'lucide-react'\nimport { TERMINAL_WORKSPACE_STATUS_VALUES } from 'agent-relay-sdk/types'\nimport { useRelayStore, useNow } from '@/store'\nimport { Badge } from '@/components/ui/badge'\nimport { Button } from '@/components/ui/button'\nimport { CopyButton } from '@/components/shared/copy-button'\nimport { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'\nimport { displayName, timeAgo } from '@/lib/display'\nimport type { Agent, WorkspaceOrphan, WorkspaceRecord, WorkspaceStatus } from '@/types'\n\nconst LIVE_STATUSES = new Set<WorkspaceStatus>(['active', 'ready', 'conflict', 'review_requested', 'merge_planned', 'cleanup_requested'])\nconst GIT_STATE_STATUSES = new Set<WorkspaceStatus>(['active', 'ready', 'conflict', 'review_requested', 'merge_planned'])\nconst MERGEABLE_STATUSES = new Set<WorkspaceStatus>(['active', 'ready', 'review_requested', 'merge_planned', 'conflict'])\n\ntype WorkspaceFilter = 'active' | 'cleaned' | 'all'\n\nconst STATUS_CLASS: Record<WorkspaceStatus, string> = {\n active: 'bg-blue-500/10 text-blue-400 border-blue-500/20',\n ready: 'bg-emerald-500/10 text-emerald-400 border-emerald-500/20',\n conflict: 'bg-red-500/10 text-red-400 border-red-500/20',\n review_requested: 'bg-yellow-500/10 text-yellow-400 border-yellow-500/20',\n merge_planned: 'bg-indigo-500/10 text-indigo-400 border-indigo-500/20',\n merged: 'bg-violet-500/10 text-violet-400 border-violet-500/20',\n abandoned: 'bg-zinc-500/10 text-zinc-400 border-zinc-500/20',\n cleanup_requested: 'bg-orange-500/10 text-orange-400 border-orange-500/20',\n cleaned: 'bg-zinc-500/10 text-zinc-400 border-zinc-500/20',\n}\n\nconst STATUS_LABEL: Record<WorkspaceStatus, string> = {\n active: 'active',\n ready: 'ready',\n conflict: 'conflict',\n review_requested: 'review',\n merge_planned: 'merge planned',\n merged: 'merged',\n abandoned: 'abandoned',\n cleanup_requested: 'cleanup',\n cleaned: 'cleaned',\n}\n\nconst STATUS_ORDER: Record<WorkspaceStatus, number> = {\n conflict: 0,\n ready: 1,\n review_requested: 2,\n merge_planned: 3,\n active: 4,\n cleanup_requested: 5,\n merged: 6,\n abandoned: 7,\n cleaned: 8,\n}\n\nconst TERMINAL_STATUSES = new Set<WorkspaceStatus>(TERMINAL_WORKSPACE_STATUS_VALUES)\n\nfunction shortPath(path: string): string {\n const parts = path.split('/').filter(Boolean)\n if (parts.length <= 3) return path || '-'\n return `/${parts.slice(-3).join('/')}`\n}\n\nfunction agentLabel(agent: Agent | undefined, fallback: string | undefined): string {\n if (agent) return displayName(agent)\n return fallback || '-'\n}\n\nfunction statusTone(status: WorkspaceStatus): string {\n return STATUS_CLASS[status] || 'bg-zinc-500/10 text-zinc-400 border-zinc-500/20'\n}\n\nfunction workspaceSort(a: WorkspaceRecord, b: WorkspaceRecord): number {\n const status = (STATUS_ORDER[a.status] ?? 99) - (STATUS_ORDER[b.status] ?? 99)\n if (status !== 0) return status\n return Number(b.updatedAt || 0) - Number(a.updatedAt || 0)\n}\n\nfunction groupWorkspaces(workspaces: WorkspaceRecord[]): Array<{ repoRoot: string; workspaces: WorkspaceRecord[] }> {\n const grouped = new Map<string, WorkspaceRecord[]>()\n for (const workspace of workspaces) {\n const key = workspace.repoRoot || workspace.sourceCwd || 'unknown repo'\n grouped.set(key, [...(grouped.get(key) || []), workspace])\n }\n return [...grouped.entries()]\n .map(([repoRoot, items]) => ({ repoRoot, workspaces: items.sort(workspaceSort) }))\n .sort((a, b) => {\n const liveA = a.workspaces.some((item) => LIVE_STATUSES.has(item.status))\n const liveB = b.workspaces.some((item) => LIVE_STATUSES.has(item.status))\n if (liveA !== liveB) return liveA ? -1 : 1\n return a.repoRoot.localeCompare(b.repoRoot)\n })\n}\n\nfunction filterWorkspaces(workspaces: WorkspaceRecord[], filter: WorkspaceFilter): WorkspaceRecord[] {\n if (filter === 'all') return workspaces\n if (filter === 'cleaned') return workspaces.filter((workspace) => TERMINAL_STATUSES.has(workspace.status))\n return workspaces.filter((workspace) => !TERMINAL_STATUSES.has(workspace.status))\n}\n\nfunction WorkspaceActions({ workspace, expanded, onToggleDetails }: { workspace: WorkspaceRecord; expanded: boolean; onToggleDetails: () => void }) {\n const workspaceAction = useRelayStore((s) => s.workspaceAction)\n const purgeWorkspace = useRelayStore((s) => s.purgeWorkspace)\n const fetchWorkspaceMergePreview = useRelayStore((s) => s.fetchWorkspaceMergePreview)\n const openFilesAt = useRelayStore((s) => s.openFilesAt)\n const terminal = workspace.status === 'cleaned' || workspace.status === 'merged' || workspace.status === 'abandoned'\n const disabled = terminal || workspace.status === 'cleanup_requested'\n const openPath = workspace.worktreePath || workspace.sourceCwd || workspace.repoRoot\n // Already-landed work (squash/cherry-pick) has nothing left to merge — a merge\n // would open a duplicate/no-op PR, so disable the button.\n const gitState = useRelayStore((s) => s.workspaceGitState[workspace.id])\n const landed = !!gitState && gitState.available !== false && gitState.landed === true\n const mergeable = workspace.mode === 'isolated' && Boolean(workspace.worktreePath) && MERGEABLE_STATUSES.has(workspace.status) && !landed\n\n // Refresh the preview so the confirm dialog states the strategy/outcome, then\n // dispatch the real merge command.\n async function merge() {\n await fetchWorkspaceMergePreview(workspace.id)\n await workspaceAction(workspace.id, 'merge')\n }\n\n return (\n <div className=\"flex flex-wrap justify-end gap-1.5\">\n <Button size=\"icon-sm\" variant=\"ghost\" title={expanded ? 'Hide details' : 'Show diff & timeline'} onClick={onToggleDetails}>\n {expanded ? <ChevronDown className=\"h-3.5 w-3.5\" /> : <ChevronRight className=\"h-3.5 w-3.5\" />}\n </Button>\n <Button\n size=\"icon-sm\"\n variant=\"ghost\"\n title=\"Open workspace\"\n disabled={!openPath || workspace.status === 'cleaned'}\n onClick={() => void openFilesAt({ path: openPath })}\n >\n <FolderOpen className=\"h-3.5 w-3.5\" />\n </Button>\n <CopyButton value={openPath} label=\"Copy path\" copiedLabel=\"Copied path\" size=\"icon-sm\" variant=\"ghost\" disabled={!openPath} />\n <Button size=\"icon-sm\" variant=\"outline\" title=\"Mark ready\" disabled={disabled || workspace.status === 'ready'} onClick={() => void workspaceAction(workspace.id, 'ready')}>\n <Check className=\"h-3.5 w-3.5\" />\n </Button>\n <Button size=\"icon-sm\" variant=\"outline\" title=\"Request review\" disabled={disabled || workspace.status === 'review_requested'} onClick={() => void workspaceAction(workspace.id, 'request-review')}>\n <Eye className=\"h-3.5 w-3.5\" />\n </Button>\n <Button size=\"icon-sm\" variant=\"outline\" title=\"Mark merge planned\" disabled={disabled || workspace.status === 'merge_planned'} onClick={() => void workspaceAction(workspace.id, 'merge-plan')}>\n <Flag className=\"h-3.5 w-3.5\" />\n </Button>\n <Button size=\"icon-sm\" variant=\"default\" title={landed ? 'Already merged into base — nothing to land' : 'Merge & land work'} disabled={!mergeable} onClick={() => void merge()}>\n <GitMerge className=\"h-3.5 w-3.5\" />\n </Button>\n <Button size=\"icon-sm\" variant=\"outline\" title=\"Request cleanup (removes the worktree on the host)\" disabled={workspace.status === 'cleaned' || workspace.status === 'cleanup_requested'} onClick={() => void workspaceAction(workspace.id, 'cleanup')}>\n <Trash2 className=\"h-3.5 w-3.5\" />\n </Button>\n {terminal && (\n <Button size=\"icon-sm\" variant=\"ghost\" title=\"Purge record (clears the row, does not touch disk)\" onClick={() => void purgeWorkspace(workspace.id)}>\n <X className=\"h-3.5 w-3.5\" />\n </Button>\n )}\n </div>\n )\n}\n\n// Pre-merge conflict hint, shown next to git state when the worktree has work to\n// land. Lazily fetched from the owning host (an external sync), so an effect is\n// the right tool. Reports clean-ff vs would-conflict before the user merges.\nfunction MergePreviewHint({ workspace, unmerged }: { workspace: WorkspaceRecord; unmerged: number }) {\n const preview = useRelayStore((s) => s.workspaceMergePreview[workspace.id])\n const fetchWorkspaceMergePreview = useRelayStore((s) => s.fetchWorkspaceMergePreview)\n const eligible = unmerged > 0 && MERGEABLE_STATUSES.has(workspace.status)\n\n useEffect(() => {\n if (eligible && preview === undefined) void fetchWorkspaceMergePreview(workspace.id)\n }, [eligible, preview, workspace.id, fetchWorkspaceMergePreview])\n\n if (!eligible || preview === undefined || preview.available === false) return null\n if (preview.conflict) {\n return (\n <span className=\"flex items-center gap-0.5 text-amber-400\" title={`Merging into ${preview.baseRef || 'base'} would conflict — resolve before merging`}>\n <TriangleAlert className=\"h-3 w-3\" />conflict\n </span>\n )\n }\n if (preview.conflict === false) {\n return (\n <span className=\"flex items-center gap-0.5 text-emerald-400\" title={`Clean to merge via ${preview.strategy === 'pr' ? 'PR' : 'rebase + fast-forward'} into ${preview.baseRef || 'base'}`}>\n <Check className=\"h-3 w-3\" />{preview.strategy === 'pr' ? 'PR ready' : 'clean'}\n </span>\n )\n }\n return null\n}\n\n// Live git state of the worktree, fetched lazily from the owning host. This is\n// an external-system sync (host git over the orchestrator proxy), so an effect\n// is the right tool — it does not derive state from props.\nfunction GitState({ workspace }: { workspace: WorkspaceRecord }) {\n const now = useNow()\n const gitState = useRelayStore((s) => s.workspaceGitState[workspace.id])\n const fetchWorkspaceGitState = useRelayStore((s) => s.fetchWorkspaceGitState)\n const eligible = workspace.mode === 'isolated' && Boolean(workspace.worktreePath) && GIT_STATE_STATUSES.has(workspace.status)\n\n useEffect(() => {\n if (eligible && gitState === undefined) void fetchWorkspaceGitState(workspace.id)\n }, [eligible, gitState, workspace.id, fetchWorkspaceGitState])\n\n if (!eligible) return null\n\n const refresh = (\n <Button\n size=\"icon-sm\"\n variant=\"ghost\"\n className=\"h-5 w-5\"\n title=\"Refresh git state\"\n onClick={() => void fetchWorkspaceGitState(workspace.id)}\n >\n <RefreshCw className=\"h-3 w-3\" />\n </Button>\n )\n\n if (gitState === undefined) {\n return <div className=\"flex items-center gap-1 text-[11px] text-muted-foreground\">Loading git state…</div>\n }\n if (gitState.available === false) {\n return (\n <div className=\"flex items-center gap-1 text-[11px] text-muted-foreground\" title={gitState.reason}>\n <span>git state unavailable</span>\n {refresh}\n </div>\n )\n }\n if (gitState.missing) {\n return <div className=\"flex items-center gap-1 text-[11px] text-muted-foreground\">worktree gone {refresh}</div>\n }\n if (gitState.error) {\n return (\n <div className=\"flex items-center gap-1 text-[11px] text-red-400\" title={gitState.error}>\n <span>git error</span>\n {refresh}\n </div>\n )\n }\n\n const ahead = gitState.ahead ?? 0\n // Work squash/cherry-pick-merged into base leaves `ahead` positive but is\n // effectively landed — surface the unmerged count, not the raw ahead.\n const landed = gitState.landed === true\n const unmerged = landed ? 0 : (gitState.unmergedAhead ?? ahead)\n const behind = gitState.behind ?? 0\n const dirty = gitState.dirtyCount ?? 0\n const clean = unmerged === 0 && dirty === 0 && !landed\n const commit = gitState.lastCommit\n\n return (\n <div className=\"space-y-0.5\">\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[11px]\">\n {clean ? (\n <span className=\"text-muted-foreground\">no unmerged work</span>\n ) : (\n <>\n {landed ? (\n <span className=\"flex items-center gap-0.5 text-emerald-400\" title={`Work already landed in ${gitState.baseRef || 'base'} via squash/cherry-pick — safe to clean up`}>\n <Check className=\"h-3 w-3\" />landed\n </span>\n ) : (\n <span className={unmerged > 0 ? 'flex items-center text-emerald-400' : 'flex items-center text-muted-foreground'} title={ahead !== unmerged ? `${unmerged} unmerged commit(s) (${ahead} ahead of base)` : `${unmerged} commit(s) ahead of base`}>\n <ArrowUp className=\"h-3 w-3\" />{unmerged}\n </span>\n )}\n <span className={behind > 0 ? 'flex items-center text-amber-400' : 'flex items-center text-muted-foreground'} title={`${behind} commit(s) behind base`}>\n <ArrowDown className=\"h-3 w-3\" />{behind}\n </span>\n {dirty > 0 && (\n <span className=\"flex items-center text-orange-400\" title={`${dirty} uncommitted change(s)`}>\n <FilePen className=\"h-3 w-3\" />{dirty}\n </span>\n )}\n {!landed && <MergePreviewHint workspace={workspace} unmerged={unmerged} />}\n </>\n )}\n {refresh}\n </div>\n {commit && (\n <div className=\"flex min-w-0 items-center gap-1 text-[11px] text-muted-foreground\" title={`${commit.sha.slice(0, 8)} — ${commit.message}`}>\n <GitCommitHorizontal className=\"h-3 w-3 shrink-0\" />\n <span className=\"truncate\">{commit.message || commit.sha.slice(0, 8)}</span>\n {commit.at ? <span className=\"shrink-0 opacity-70\">· {timeAgo(now, commit.at)}</span> : null}\n </div>\n )}\n </div>\n )\n}\n\n// Lifecycle timeline from the timestamps the relay already records:\n// created → ready → merged → cleaned. Surfaces history without a drawer.\nfunction WorkspaceTimeline({ workspace }: { workspace: WorkspaceRecord }) {\n const now = useNow()\n const mergedAt = typeof workspace.metadata?.mergedAt === 'number' ? (workspace.metadata.mergedAt as number) : undefined\n const steps = [\n { label: 'created', at: workspace.createdAt },\n { label: 'ready', at: workspace.readyAt },\n { label: 'merged', at: mergedAt },\n { label: 'cleaned', at: workspace.cleanedAt },\n ].filter((step): step is { label: string; at: number } => typeof step.at === 'number' && step.at > 0)\n\n return (\n <div className=\"flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-muted-foreground\">\n <span className=\"flex items-center gap-1 font-medium text-foreground\"><Clock className=\"h-3 w-3\" />Timeline</span>\n {steps.map((step, i) => (\n <span key={step.label} className=\"flex items-center gap-1\">\n {i > 0 && <span className=\"opacity-40\">→</span>}\n <span className=\"text-foreground\">{step.label}</span>\n <span title={new Date(step.at).toLocaleString()}>{timeAgo(now, step.at)}</span>\n </span>\n ))}\n </div>\n )\n}\n\nfunction diffLineClass(line: string): string {\n if (line.startsWith('+') && !line.startsWith('+++')) return 'text-emerald-400'\n if (line.startsWith('-') && !line.startsWith('---')) return 'text-red-400'\n if (line.startsWith('@@')) return 'text-cyan-400'\n if (line.startsWith('diff ') || line.startsWith('index ') || line.startsWith('+++') || line.startsWith('---')) return 'text-muted-foreground'\n return ''\n}\n\n// Diff of committed work against base, lazily fetched from the owning host.\nfunction WorkspaceDiffView({ workspace }: { workspace: WorkspaceRecord }) {\n const diff = useRelayStore((s) => s.workspaceDiff[workspace.id])\n const fetchWorkspaceDiff = useRelayStore((s) => s.fetchWorkspaceDiff)\n const eligible = workspace.mode === 'isolated' && Boolean(workspace.worktreePath)\n\n useEffect(() => {\n if (eligible && diff === undefined) void fetchWorkspaceDiff(workspace.id)\n }, [eligible, diff, workspace.id, fetchWorkspaceDiff])\n\n if (!eligible) return null\n if (diff === undefined) return <div className=\"text-[11px] text-muted-foreground\">Loading diff…</div>\n if (diff.available === false) return <div className=\"text-[11px] text-muted-foreground\">Diff unavailable{diff.reason ? `: ${diff.reason}` : ''}</div>\n if (diff.missing) return <div className=\"text-[11px] text-muted-foreground\">Worktree no longer on disk</div>\n if (diff.error) return <div className=\"text-[11px] text-red-400\">Diff error: {diff.error}</div>\n if (!diff.files.length) return <div className=\"text-[11px] text-muted-foreground\">No committed changes against {diff.baseRef || 'base'}</div>\n\n const refresh = (\n <Button size=\"icon-sm\" variant=\"ghost\" className=\"h-5 w-5\" title=\"Refresh diff\" onClick={() => void fetchWorkspaceDiff(workspace.id)}>\n <RefreshCw className=\"h-3 w-3\" />\n </Button>\n )\n\n return (\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2 text-[11px] font-medium\">\n <FileDiff className=\"h-3 w-3\" />\n <span>{diff.files.length} file{diff.files.length === 1 ? '' : 's'} vs {diff.baseRef || 'base'}</span>\n {refresh}\n </div>\n <ul className=\"space-y-0.5 text-[11px]\">\n {diff.files.map((file) => (\n <li key={file.path} className=\"flex items-center gap-2 font-mono\">\n <span className=\"truncate\" title={file.path}>{file.path}</span>\n {file.binary ? (\n <span className=\"shrink-0 text-muted-foreground\">binary</span>\n ) : (\n <span className=\"shrink-0\">\n <span className=\"text-emerald-400\">+{file.additions ?? 0}</span>{' '}\n <span className=\"text-red-400\">−{file.deletions ?? 0}</span>\n </span>\n )}\n </li>\n ))}\n </ul>\n {diff.patch && (\n <pre className=\"max-h-80 overflow-auto rounded border border-border bg-muted/30 p-2 text-[10.5px] leading-relaxed\">\n {diff.patch.split('\\n').map((line, i) => (\n <div key={i} className={diffLineClass(line)}>{line || ' '}</div>\n ))}\n {diff.truncated && <div className=\"mt-1 text-muted-foreground\">… patch truncated</div>}\n </pre>\n )}\n </div>\n )\n}\n\nfunction WorkspaceDetails({ workspace }: { workspace: WorkspaceRecord }) {\n return (\n <div className=\"space-y-3 border-t border-dashed border-border bg-muted/20 px-3 py-3\">\n <WorkspaceTimeline workspace={workspace} />\n <WorkspaceDiffView workspace={workspace} />\n </div>\n )\n}\n\n// Worktrees on disk with no live workspace row — reclaimable in one click.\nfunction OrphanPanel() {\n const orphans = useRelayStore((s) => s.workspaceOrphans)\n const fetchWorkspaceOrphans = useRelayStore((s) => s.fetchWorkspaceOrphans)\n const reclaimWorkspaceOrphan = useRelayStore((s) => s.reclaimWorkspaceOrphan)\n\n useEffect(() => {\n void fetchWorkspaceOrphans()\n }, [fetchWorkspaceOrphans])\n\n if (!orphans.length) return null\n\n return (\n <Card className=\"border-amber-500/30\">\n <CardHeader className=\"px-4 py-3\">\n <div className=\"flex items-center gap-2\">\n <PackageOpen className=\"h-4 w-4 text-amber-400\" />\n <CardTitle className=\"text-sm font-medium\">Orphaned worktrees</CardTitle>\n <Badge variant=\"outline\" className=\"border-amber-500/30 text-amber-400 text-[10px]\">{orphans.length}</Badge>\n <Button size=\"icon-sm\" variant=\"ghost\" className=\"ml-auto h-6 w-6\" title=\"Rescan\" onClick={() => void fetchWorkspaceOrphans()}>\n <RefreshCw className=\"h-3.5 w-3.5\" />\n </Button>\n </div>\n <p className=\"mt-1 text-xs text-muted-foreground\">Agent worktrees on disk with no live workspace. Reclaim removes them from the host.</p>\n </CardHeader>\n <CardContent className=\"p-0\">\n {orphans.map((orphan) => (\n <div key={orphan.worktreePath} className=\"flex items-center gap-3 border-t border-border px-4 py-2 text-xs\">\n <GitBranch className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate font-medium\" title={orphan.branch}>{orphan.branch || '(detached)'}</span>\n <span className=\"truncate font-mono text-muted-foreground\" title={orphan.worktreePath}>{shortPath(orphan.worktreePath)}</span>\n {orphan.hadTerminalRow && <Badge variant=\"outline\" className=\"text-[10px]\">cleanup failed</Badge>}\n <Button size=\"sm\" variant=\"outline\" className=\"ml-auto h-7 text-xs\" onClick={() => void reclaimWorkspaceOrphan(orphan)}>\n <ArchiveRestore className=\"mr-1 h-3.5 w-3.5\" />Reclaim\n </Button>\n </div>\n ))}\n </CardContent>\n </Card>\n )\n}\n\n// A `pr`-strategy merge lands as an opened PR, not a local fast-forward, so the\n// outcome only shows up here — surface the PR link and any error the orchestrator\n// returned (which the command layer keeps in result even when status=succeeded).\nfunction prLabel(url: string): string {\n const match = url.match(/\\/pull\\/(\\d+)/)\n return match ? `PR #${match[1]}` : 'View PR'\n}\n\nfunction MergeOutcome({ workspace }: { workspace: WorkspaceRecord }) {\n const result = workspace.metadata?.mergeResult as { prUrl?: string; error?: string } | undefined\n const prUrl = result?.prUrl\n const error = result?.error || (workspace.metadata?.mergeError as string | undefined)\n if (!prUrl && !error) return null\n return (\n <>\n {prUrl && (\n <a\n href={prUrl}\n target=\"_blank\"\n rel=\"noreferrer\"\n title={prUrl}\n className=\"inline-flex items-center gap-0.5 rounded border border-violet-500/30 px-1.5 py-0 text-[10px] text-violet-400 hover:text-violet-300\"\n >\n <GitMerge className=\"h-2.5 w-2.5\" />{prLabel(prUrl)}\n </a>\n )}\n {error && (\n <Badge variant=\"outline\" className=\"max-w-[16rem] border-amber-500/30 text-amber-400 text-[10px]\" title={error}>\n <TriangleAlert className=\"mr-0.5 h-2.5 w-2.5 shrink-0\" /><span className=\"truncate\">merge: {error}</span>\n </Badge>\n )}\n </>\n )\n}\n\nfunction WorkspaceRow({ workspace }: { workspace: WorkspaceRecord }) {\n const now = useNow()\n const [expanded, setExpanded] = useState(false)\n const agentsById = useRelayStore((s) => s.agentsById)\n const focused = useRelayStore((s) => s.workspaceFocusId === workspace.id)\n const owner = workspace.ownerAgentId ? agentsById[workspace.ownerAgentId] : undefined\n const steward = workspace.stewardAgentId ? agentsById[workspace.stewardAgentId] : undefined\n const path = workspace.worktreePath || workspace.sourceCwd || workspace.repoRoot\n const rowRef = useRef<HTMLDivElement>(null)\n\n // Click-through landing (#236): scroll the targeted row into view once it mounts.\n useEffect(() => {\n if (focused) rowRef.current?.scrollIntoView({ behavior: 'smooth', block: 'center' })\n }, [focused])\n\n return (\n <div ref={rowRef} className={`border-t border-border ${focused ? 'bg-primary/5 ring-1 ring-inset ring-primary/40' : ''}`}>\n <div className=\"grid gap-3 px-3 py-3 text-sm lg:grid-cols-[minmax(180px,1.2fr)_minmax(220px,1.5fr)_minmax(160px,1fr)_minmax(170px,auto)]\">\n <div className=\"min-w-0 space-y-1\">\n <div className=\"flex min-w-0 items-center gap-2\">\n <GitBranch className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate font-medium\" title={workspace.branch || workspace.id}>{workspace.branch || workspace.id}</span>\n </div>\n <div className=\"flex flex-wrap gap-1\">\n <Badge variant=\"outline\" className={`text-[10px] ${workspace.mode === 'isolated' ? 'border-sky-500/30 text-sky-400' : 'border-zinc-500/30 text-zinc-400'}`}>\n {workspace.mode}\n </Badge>\n {workspace.requestedMode && workspace.requestedMode !== workspace.mode && (\n <Badge variant=\"outline\" className=\"text-[10px]\">requested {workspace.requestedMode}</Badge>\n )}\n <Badge variant=\"outline\" className={`text-[10px] ${statusTone(workspace.status)}`}>{STATUS_LABEL[workspace.status] || workspace.status}</Badge>\n <MergeOutcome workspace={workspace} />\n </div>\n </div>\n\n <div className=\"min-w-0 space-y-1\">\n <div className=\"truncate font-mono text-xs\" title={path}>{shortPath(path)}</div>\n <div className=\"truncate text-xs text-muted-foreground\" title={workspace.sourceCwd}>{workspace.sourceCwd}</div>\n <GitState workspace={workspace} />\n </div>\n\n <div className=\"grid grid-cols-[4.5rem_minmax(0,1fr)] gap-x-2 gap-y-1 text-xs\">\n <span className=\"text-muted-foreground\">Owner</span>\n <span className=\"truncate\" title={workspace.ownerAgentId}>{agentLabel(owner, workspace.ownerPolicyName || workspace.ownerAgentId)}</span>\n <span className=\"text-muted-foreground\">Steward</span>\n <span className=\"truncate\" title={workspace.stewardAgentId}>{agentLabel(steward, workspace.stewardAgentId)}</span>\n <span className=\"text-muted-foreground\">Updated</span>\n <span>{timeAgo(now, workspace.updatedAt)}</span>\n {workspace.baseRef && (\n <>\n <span className=\"text-muted-foreground\">Base</span>\n <span className=\"truncate\" title={workspace.baseSha}>{workspace.baseRef}</span>\n </>\n )}\n </div>\n\n <WorkspaceActions workspace={workspace} expanded={expanded} onToggleDetails={() => setExpanded((value) => !value)} />\n </div>\n {expanded && <WorkspaceDetails workspace={workspace} />}\n </div>\n )\n}\n\nfunction RepoGroup({ repoRoot, workspaces }: { repoRoot: string; workspaces: WorkspaceRecord[] }) {\n const liveCount = workspaces.filter((item) => LIVE_STATUSES.has(item.status)).length\n const readyCount = workspaces.filter((item) => item.status === 'ready' || item.status === 'review_requested' || item.status === 'merge_planned').length\n const conflictCount = workspaces.filter((item) => item.status === 'conflict').length\n\n return (\n <Card>\n <CardHeader className=\"px-4 py-3\">\n <div className=\"flex min-w-0 items-start gap-3\">\n <div className=\"min-w-0 flex-1\">\n <CardTitle className=\"truncate text-sm font-medium\" title={repoRoot}>{repoRoot}</CardTitle>\n <div className=\"mt-1 flex flex-wrap gap-1.5\">\n <Badge variant=\"outline\" className=\"text-[10px]\">{workspaces.length} total</Badge>\n <Badge variant=\"outline\" className=\"text-[10px]\">{liveCount} live</Badge>\n {readyCount > 0 && <Badge variant=\"outline\" className=\"border-emerald-500/20 text-emerald-400 text-[10px]\">{readyCount} merge signal</Badge>}\n {conflictCount > 0 && <Badge variant=\"outline\" className=\"border-red-500/20 text-red-400 text-[10px]\">{conflictCount} conflict</Badge>}\n </div>\n </div>\n </div>\n </CardHeader>\n <CardContent className=\"p-0\">\n {workspaces.map((workspace) => (\n <WorkspaceRow key={workspace.id} workspace={workspace} />\n ))}\n </CardContent>\n </Card>\n )\n}\n\nexport function WorkspacesView() {\n const [filter, setFilter] = useState<WorkspaceFilter>('active')\n const workspaces = useRelayStore((s) => s.workspaces)\n const set = useRelayStore((s) => s.set)\n const workspaceFocusId = useRelayStore((s) => s.workspaceFocusId)\n\n // Badge click-through (#236): a focused workspace may be in any state, so widen\n // the filter to 'all' to guarantee its row renders. Clear the focus when leaving\n // the panel so the highlight doesn't linger on the next visit.\n useEffect(() => {\n if (workspaceFocusId) setFilter('all')\n }, [workspaceFocusId])\n useEffect(() => () => { set({ workspaceFocusId: null }) }, [set])\n\n const visibleWorkspaces = useMemo(() => filterWorkspaces(workspaces, filter), [workspaces, filter])\n const grouped = useMemo(() => groupWorkspaces(visibleWorkspaces), [visibleWorkspaces])\n const liveCount = workspaces.filter((item) => LIVE_STATUSES.has(item.status)).length\n const isolatedCount = workspaces.filter((item) => item.mode === 'isolated').length\n const readyCount = workspaces.filter((item) => item.status === 'ready' || item.status === 'review_requested' || item.status === 'merge_planned').length\n const conflictCount = workspaces.filter((item) => item.status === 'conflict').length\n const doneCount = workspaces.filter((item) => TERMINAL_STATUSES.has(item.status)).length\n const activeCount = workspaces.length - doneCount\n const filters: Array<{ key: WorkspaceFilter; label: string; count: number }> = [\n { key: 'active', label: 'Active', count: activeCount },\n { key: 'cleaned', label: 'Done', count: doneCount },\n { key: 'all', label: 'All', count: workspaces.length },\n ]\n\n return (\n <div className=\"space-y-4\">\n <div className=\"flex flex-wrap items-center gap-3\">\n <div>\n <h1 className=\"text-2xl font-semibold\">Workspaces</h1>\n <p className=\"text-sm text-muted-foreground\">Agent worktrees, ownership, and merge readiness.</p>\n </div>\n <div className=\"ml-auto flex flex-wrap gap-1.5\">\n <Badge variant=\"outline\">{isolatedCount} isolated</Badge>\n <Badge variant=\"outline\">{liveCount} live</Badge>\n <Badge variant=\"outline\">{readyCount} ready</Badge>\n {conflictCount > 0 && <Badge variant=\"outline\" className=\"border-red-500/20 text-red-400\">{conflictCount} conflict</Badge>}\n </div>\n </div>\n\n <OrphanPanel />\n\n <div className=\"flex flex-wrap items-center gap-2\">\n <div className=\"flex rounded-md border border-border bg-card p-1\">\n {filters.map((item) => (\n <Button\n key={item.key}\n size=\"sm\"\n variant={filter === item.key ? 'secondary' : 'ghost'}\n className=\"h-7 text-xs\"\n onClick={() => setFilter(item.key)}\n >\n {item.label}\n <span className=\"ml-1 text-muted-foreground\">{item.count}</span>\n </Button>\n ))}\n </div>\n </div>\n\n {grouped.length === 0 ? (\n <div className=\"rounded-md border border-border px-3 py-12 text-center text-sm text-muted-foreground\">\n No {filter === 'all' ? '' : filter} workspaces\n </div>\n ) : (\n <div className=\"space-y-3\">\n {grouped.map((group) => (\n <RepoGroup key={group.repoRoot} repoRoot={group.repoRoot} workspaces={group.workspaces} />\n ))}\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,IAEN,EAAA,EAAA,KAAC,MAAD,CAAK,UAAU,qBACZ,EAAQ,IAAK,IACZ,EAAA,EAAA,KAAC,GAAD,CAAgC,SAAU,EAAM,SAAU,WAAY,EAAM,WAAc,CAA1E,EAAM,SAAoE,CAC1F,CACE,CAAA,CAEJ"}
package/public/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Crect width='32' height='32' rx='6' fill='%2309090b'/%3E%3Ccircle cx='16' cy='16' r='4.5' fill='%2358a6ff'/%3E%3Ccircle cx='6' cy='8' r='2.5' fill='%233fb950'/%3E%3Ccircle cx='26' cy='8' r='2.5' fill='%233fb950'/%3E%3Ccircle cx='6' cy='24' r='2.5' fill='%233fb950'/%3E%3Ccircle cx='26' cy='24' r='2.5' fill='%233fb950'/%3E%3Cline x1='8' y1='9.5' x2='13' y2='14' stroke='%2330363d' stroke-width='1.5'/%3E%3Cline x1='24' y1='9.5' x2='19' y2='14' stroke='%2330363d' stroke-width='1.5'/%3E%3Cline x1='8' y1='22.5' x2='13' y2='18' stroke='%2330363d' stroke-width='1.5'/%3E%3Cline x1='24' y1='22.5' x2='19' y2='18' stroke='%2330363d' stroke-width='1.5'/%3E%3C/svg%3E">
13
13
  <link rel="manifest" href="manifest.webmanifest">
14
14
  <link rel="apple-touch-icon" href="icons/agent-relay-192.png">
15
- <script type="module" crossorigin src="./assets/index-CCp1V35c.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-BeDncjN4.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="./assets/chunk-CilyBKbf.js">
17
17
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-CP_edrrL.js">
18
18
  <link rel="modulepreload" crossorigin href="./assets/lucide-react-DWYjU-AF.js">
@@ -31,7 +31,7 @@
31
31
  <link rel="modulepreload" crossorigin href="./assets/dist-D3_TJKTC.js">
32
32
  <link rel="modulepreload" crossorigin href="./assets/dist-Pf_3Gf38.js">
33
33
  <link rel="modulepreload" crossorigin href="./assets/display-DzNvOu1j.js">
34
- <link rel="modulepreload" crossorigin href="./assets/store-Buwkqv_7.js">
34
+ <link rel="modulepreload" crossorigin href="./assets/store-iTiheuTD.js">
35
35
  <link rel="modulepreload" crossorigin href="./assets/button-2taQeNHW.js">
36
36
  <link rel="modulepreload" crossorigin href="./assets/copy-button-HEkwi6xX.js">
37
37
  <link rel="modulepreload" crossorigin href="./assets/badge-CZhIdlTJ.js">
@@ -34,6 +34,12 @@ export interface BranchLandedInput {
34
34
  * `undefined` from older orchestrators that don't report it → message stays generic.
35
35
  */
36
36
  pushed?: boolean;
37
+ /**
38
+ * The land came in via a pull request — the subject's trailing `(#NNN)` is the PR
39
+ * number, not an issue. Forwarded to the issue-lifecycle hook so it doesn't mistake
40
+ * the PR number for an issue to close (#482).
41
+ */
42
+ prLand?: boolean;
37
43
  }
38
44
 
39
45
  /**
@@ -172,7 +178,7 @@ export function reconcileLandedWorkspace(ws: WorkspaceRecord, preview: Workspace
172
178
  metadata: { source: "server", maintenanceJobId: "workspace-conflict-scan", workspaceId: ws.id, fromStatus: ws.status, ...(sha ? { landedSha: sha } : {}) },
173
179
  });
174
180
  try {
175
- notifyBranchLanded({ workspace: ws, mergedSha: sha, pushed: true });
181
+ notifyBranchLanded({ workspace: ws, mergedSha: sha, pushed: true, prLand: via === "pr" });
176
182
  } catch {
177
183
  // Notification is best-effort; the merged status + activity event still stand.
178
184
  }
package/src/bus.ts CHANGED
@@ -114,7 +114,9 @@ export function expireStaleBusAgents(graceMs = Number(process.env.AGENT_RELAY_ST
114
114
  .all(cutoff) as Array<{ id: string }>;
115
115
  const orphanedTasks: Task[] = [];
116
116
  for (const row of rows) {
117
- revokeRuntimeTokensForAgent(row.id);
117
+ // Bus-grace staleness across a relay restart/reconnect — the process may be alive.
118
+ // Tag "stale" so a live runner self-heals via orchestrator re-mint (#484).
119
+ revokeRuntimeTokensForAgent(row.id, Date.now(), "stale");
118
120
  setStatus(row.id, "offline");
119
121
  emitAgentStatusEvent(row.id);
120
122
  getLifecycleManager().onAgentDisappeared(row.id);
package/src/db/agents.ts CHANGED
@@ -23,6 +23,7 @@ import { closeOpenPairsForAgent } from "./pairs.ts";
23
23
  import { TASK_SELECT, insertTaskEvent } from "./tasks.ts";
24
24
  import { electWorkspaceStewards, electWorkspaceStewardsForAgent } from "./workspaces.ts";
25
25
  import { DEFAULT_SELF_RESUME_CONFIG } from "../self-resume-config";
26
+ import type { TokenRevokeReason } from "../security";
26
27
  import type {
27
28
  AgentCard,
28
29
  ActivityEvent,
@@ -454,7 +455,10 @@ export function reapStaleAgents(ttlMs: number = STALE_TTL_MS): string[] {
454
455
  )
455
456
  .all(cutoff) as any[];
456
457
  for (const row of rows) {
457
- revokeRuntimeTokensForAgent(row.id, now);
458
+ // Staleness == last_seen lapsed, which is exactly the relay-restart strand: the
459
+ // process may still be alive. Tag "stale" so a live runner can self-heal via an
460
+ // orchestrator re-mint (#484); a genuinely-dead one never re-mints and is pruned.
461
+ revokeRuntimeTokensForAgent(row.id, now, "stale");
458
462
  closeOpenPairsForAgent(row.id, now);
459
463
  }
460
464
  return rows.map((r: any) => r.id);
@@ -518,7 +522,8 @@ export function pruneOfflineAgents(maxOfflineMs: number = DAY_MS): string[] {
518
522
  .run(now, cutoff);
519
523
 
520
524
  for (const row of rows) {
521
- revokeRuntimeTokensForAgent(row.id, now);
525
+ // Offline past the prune horizon and being deleted — a hard kill, not recoverable.
526
+ revokeRuntimeTokensForAgent(row.id, now, "pruned");
522
527
  closeOpenPairsForAgent(row.id, now);
523
528
  }
524
529
 
@@ -551,7 +556,11 @@ export function deleteAgent(id: string): { ok: boolean; error?: string } {
551
556
  return deleted ? { ok: true } : { ok: false, error: "agent not found" };
552
557
  }
553
558
 
554
- export function revokeRuntimeTokensForAgent(agentId: string, now = Date.now()): string[] {
559
+ // #484: `reason` is stamped on each revocation so a stale-on-restart revocation
560
+ // (recoverable via orchestrator re-mint for a still-live process) is distinguishable
561
+ // from a hard kill. Default "agent-removed" (hard) — callers that revoke a possibly-
562
+ // live process across a restart MUST pass "stale".
563
+ export function revokeRuntimeTokensForAgent(agentId: string, now = Date.now(), reason: TokenRevokeReason = "agent-removed"): string[] {
555
564
  const row = getDb().query("SELECT meta FROM agents WHERE id = ?").get(agentId) as { meta?: string } | undefined;
556
565
  const jtis = runtimeTokenJtisFromMeta(parseJson(row?.meta ?? "{}", {}));
557
566
  if (jtis.length === 0) return [];
@@ -559,13 +568,13 @@ export function revokeRuntimeTokensForAgent(agentId: string, now = Date.now()):
559
568
  const placeholders = jtis.map(() => "?").join(",");
560
569
  const rows = getDb().query(`
561
570
  UPDATE tokens
562
- SET revoked_at = ?
571
+ SET revoked_at = ?, revoked_reason = ?
563
572
  WHERE revoked_at IS NULL
564
573
  AND role = 'provider'
565
574
  AND profile_id IN ('provider-agent', 'provider-interactive', 'provider-child')
566
575
  AND jti IN (${placeholders})
567
576
  RETURNING jti
568
- `).all(revokedAt, ...jtis) as Array<{ jti: string }>;
577
+ `).all(revokedAt, reason, ...jtis) as Array<{ jti: string }>;
569
578
  return rows.map((item) => item.jti);
570
579
  }
571
580
 
@@ -275,6 +275,12 @@ export function applyMigrations(): void {
275
275
  if (!tokenColNames.includes("profile_id")) {
276
276
  getDb().run("ALTER TABLE tokens ADD COLUMN profile_id TEXT");
277
277
  }
278
+ // #484: revocation reason distinguishes a stale-on-restart revocation (recoverable via
279
+ // orchestrator re-mint for a still-live process) from a hard kill (admin/rotation). A NULL
280
+ // reason on a legacy revoked token is treated as a hard kill — never re-mintable.
281
+ if (!tokenColNames.includes("revoked_reason")) {
282
+ getDb().run("ALTER TABLE tokens ADD COLUMN revoked_reason TEXT");
283
+ }
278
284
 
279
285
  getDb().run(`
280
286
  CREATE TABLE IF NOT EXISTS message_delivery_attempts (
package/src/db/schema.ts CHANGED
@@ -677,7 +677,8 @@ export function initDb(path: string = "agent-relay.db"): Database {
677
677
  );
678
678
  CREATE INDEX IF NOT EXISTS idx_activity_operator ON activity_events(operator_id, created_at);
679
679
  CREATE INDEX IF NOT EXISTS idx_activity_created ON activity_events(created_at);
680
- CREATE INDEX IF NOT EXISTS idx_activity_agent ON activity_events(agent_id, created_at); CREATE INDEX IF NOT EXISTS idx_activity_issue ON activity_events(issue_ref_id, created_at); CREATE INDEX IF NOT EXISTS idx_activity_agent_issue ON activity_events(agent_id, issue_ref_id, created_at);
680
+ CREATE INDEX IF NOT EXISTS idx_activity_agent ON activity_events(agent_id, created_at);
681
+ -- issue_ref_id/issue_action indexes are created in applyMigrations() AFTER the ALTER — never inline here (#483: inline index over a not-yet-migrated column crashes initDb on existing DBs).
681
682
 
682
683
  CREATE TABLE IF NOT EXISTS channels (
683
684
  id TEXT PRIMARY KEY,
@@ -787,6 +788,7 @@ export function initDb(path: string = "agent-relay.db"): Database {
787
788
  issued_at INTEGER NOT NULL,
788
789
  expires_at INTEGER,
789
790
  revoked_at INTEGER,
791
+ revoked_reason TEXT,
790
792
  created_by TEXT
791
793
  );
792
794
 
@@ -250,6 +250,9 @@ export const patchCommand: Handler = async (req, params) => {
250
250
  subject: prLanded
251
251
  ? cleanString(prLanded.subject, "params.prLanded.subject", { max: 200 })
252
252
  : cleanString(command.result.subject, "result.subject", { max: 200 }),
253
+ // PR-land subjects carry a trailing `(#PR)` GitHub stamps on the squash — not an
254
+ // issue. Tell the lifecycle hook so it won't close the PR number as an issue (#482).
255
+ prLand: Boolean(prLanded),
253
256
  newBranch,
254
257
  pushed: prLanded ? true : typeof command.result.pushed === "boolean" ? command.result.pushed : undefined,
255
258
  });
@@ -85,7 +85,8 @@ export const postOrchestratorBootstrapExchange: Handler = async (req) => {
85
85
  baseDir,
86
86
  createdBy: auth.jti ? `bootstrap:${auth.jti}` : "bootstrap",
87
87
  });
88
- if (auth.jti) revokeToken(auth.jti);
88
+ // One-shot bootstrap token consumed: hard-revoke (rotation), never re-mintable.
89
+ if (auth.jti) revokeToken(auth.jti, "rotation");
89
90
  return json(runtimeToken, 201);
90
91
  } catch (e) {
91
92
  if (e instanceof ValidationError) return error(e.message, 400);