agent-relay-server 0.107.0 → 0.108.0

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 (143) hide show
  1. package/docs/openapi.json +475 -1
  2. package/package.json +4 -4
  3. package/public/assets/{MessageBubble-PEdvVh_m.js → MessageBubble-DYJezSjU.js} +2 -2
  4. package/public/assets/{MessageBubble-PEdvVh_m.js.map → MessageBubble-DYJezSjU.js.map} +1 -1
  5. package/public/assets/{PlanGraphPanel-DSts7Rtq.js → PlanGraphPanel-MWcVw38W.js} +2 -2
  6. package/public/assets/{PlanGraphPanel-DSts7Rtq.js.map → PlanGraphPanel-MWcVw38W.js.map} +1 -1
  7. package/public/assets/{activity-BcYf8YNO.js → activity-Db3X3dg8.js} +2 -2
  8. package/public/assets/{activity-BcYf8YNO.js.map → activity-Db3X3dg8.js.map} +1 -1
  9. package/public/assets/{agent-profiles-CuTQtmV6.js → agent-profiles-Di2w5U1o.js} +2 -2
  10. package/public/assets/{agent-profiles-CuTQtmV6.js.map → agent-profiles-Di2w5U1o.js.map} +1 -1
  11. package/public/assets/{agents-CgRFJyks.js → agents-GSJXvmU1.js} +2 -2
  12. package/public/assets/{agents-CgRFJyks.js.map → agents-GSJXvmU1.js.map} +1 -1
  13. package/public/assets/{analytics-C3OTFIXo.js → analytics-B9USQLl5.js} +2 -2
  14. package/public/assets/{analytics-C3OTFIXo.js.map → analytics-B9USQLl5.js.map} +1 -1
  15. package/public/assets/{automation-CH9YGYoE.js → automation-XRePs1dT.js} +2 -2
  16. package/public/assets/{automation-CH9YGYoE.js.map → automation-XRePs1dT.js.map} +1 -1
  17. package/public/assets/{branch-state-badge-CcLZ_u86.js → branch-state-badge-C_VNyER3.js} +2 -2
  18. package/public/assets/{branch-state-badge-CcLZ_u86.js.map → branch-state-badge-C_VNyER3.js.map} +1 -1
  19. package/public/assets/{channels-CcSnLzCG.js → channels-DACvNoC2.js} +2 -2
  20. package/public/assets/{channels-CcSnLzCG.js.map → channels-DACvNoC2.js.map} +1 -1
  21. package/public/assets/{chat-BLcm2Aht.js → chat-D_0uHgB6.js} +2 -2
  22. package/public/assets/{chat-BLcm2Aht.js.map → chat-D_0uHgB6.js.map} +1 -1
  23. package/public/assets/{connectors-DbPOlQhL.js → connectors-C0B38LUK.js} +2 -2
  24. package/public/assets/{connectors-DbPOlQhL.js.map → connectors-C0B38LUK.js.map} +1 -1
  25. package/public/assets/display-1J__Ti1K.js +3 -0
  26. package/public/assets/display-1J__Ti1K.js.map +1 -0
  27. package/public/assets/{formatted-body-impl-BJTthVHg.js → formatted-body-impl-BKWCAjBd.js} +2 -2
  28. package/public/assets/{formatted-body-impl-BJTthVHg.js.map → formatted-body-impl-BKWCAjBd.js.map} +1 -1
  29. package/public/assets/index-DlBSuzd2.js +23 -0
  30. package/public/assets/index-DlBSuzd2.js.map +1 -0
  31. package/public/assets/{insights-DklrIhb6.js → insights-BzNoYvDe.js} +2 -2
  32. package/public/assets/{insights-DklrIhb6.js.map → insights-BzNoYvDe.js.map} +1 -1
  33. package/public/assets/{integrations-hkSW8CzM.js → integrations-DLzJpt9G.js} +2 -2
  34. package/public/assets/{integrations-hkSW8CzM.js.map → integrations-DLzJpt9G.js.map} +1 -1
  35. package/public/assets/{maintenance-FAAMGpuZ.js → maintenance-B6_0-ECm.js} +2 -2
  36. package/public/assets/{maintenance-FAAMGpuZ.js.map → maintenance-B6_0-ECm.js.map} +1 -1
  37. package/public/assets/{managed-agents-CVca-s3t.js → managed-agents-CpzKXDtV.js} +2 -2
  38. package/public/assets/{managed-agents-CVca-s3t.js.map → managed-agents-CpzKXDtV.js.map} +1 -1
  39. package/public/assets/{markdown-preview-impl-BPW4OQo9.js → markdown-preview-impl-DxBnlJ2k.js} +2 -2
  40. package/public/assets/{markdown-preview-impl-BPW4OQo9.js.map → markdown-preview-impl-DxBnlJ2k.js.map} +1 -1
  41. package/public/assets/{memory-BzuDTHC5.js → memory-Bnm7ILWL.js} +2 -2
  42. package/public/assets/{memory-BzuDTHC5.js.map → memory-Bnm7ILWL.js.map} +1 -1
  43. package/public/assets/{messages-_W24PNvT.js → messages-D9LkocTc.js} +2 -2
  44. package/public/assets/{messages-_W24PNvT.js.map → messages-D9LkocTc.js.map} +1 -1
  45. package/public/assets/{orchestrators-Du6I_n8i.js → orchestrators-C__JfrNr.js} +2 -2
  46. package/public/assets/{orchestrators-Du6I_n8i.js.map → orchestrators-C__JfrNr.js.map} +1 -1
  47. package/public/assets/{overview-Dyvm1qpT.js → overview-BQ0b0V7Q.js} +2 -2
  48. package/public/assets/{overview-Dyvm1qpT.js.map → overview-BQ0b0V7Q.js.map} +1 -1
  49. package/public/assets/{pairs-B8x1RCNd.js → pairs-ChyeBs0Z.js} +2 -2
  50. package/public/assets/{pairs-B8x1RCNd.js.map → pairs-ChyeBs0Z.js.map} +1 -1
  51. package/public/assets/{projects-vt63bwHN.js → projects-v5Kp1Oaq.js} +2 -2
  52. package/public/assets/{projects-vt63bwHN.js.map → projects-v5Kp1Oaq.js.map} +1 -1
  53. package/public/assets/{prompt-settings-xVXmvxB5.js → prompt-settings-YhAOlYc6.js} +2 -2
  54. package/public/assets/{prompt-settings-xVXmvxB5.js.map → prompt-settings-YhAOlYc6.js.map} +1 -1
  55. package/public/assets/{registry-ypiICauZ.js → registry-DZoAfrzx.js} +2 -2
  56. package/public/assets/{registry-ypiICauZ.js.map → registry-DZoAfrzx.js.map} +1 -1
  57. package/public/assets/{security-BfOQ6T5r.js → security-DRCj00eA.js} +2 -2
  58. package/public/assets/{security-BfOQ6T5r.js.map → security-DRCj00eA.js.map} +1 -1
  59. package/public/assets/{select-Dx8Ro-A3.js → select-ZOpLw2Fd.js} +2 -2
  60. package/public/assets/{select-Dx8Ro-A3.js.map → select-ZOpLw2Fd.js.map} +1 -1
  61. package/public/assets/{settings-87clTx4N.js → settings-DGgwr9WH.js} +2 -2
  62. package/public/assets/{settings-87clTx4N.js.map → settings-DGgwr9WH.js.map} +1 -1
  63. package/public/assets/{store-DUfrGvOE.js → store-Bnag1kY-.js} +2 -2
  64. package/public/assets/{store-DUfrGvOE.js.map → store-Bnag1kY-.js.map} +1 -1
  65. package/public/assets/{tasks-1Kvp53wh.js → tasks-DUTu8ZhA.js} +2 -2
  66. package/public/assets/{tasks-1Kvp53wh.js.map → tasks-DUTu8ZhA.js.map} +1 -1
  67. package/public/assets/{teams-DJWp4AKi.js → teams-BJpaoG2m.js} +2 -2
  68. package/public/assets/{teams-DJWp4AKi.js.map → teams-BJpaoG2m.js.map} +1 -1
  69. package/public/assets/{terminal-viewer-impl-DgMuRAe_.js → terminal-viewer-impl-CQhh6oXa.js} +2 -2
  70. package/public/assets/{terminal-viewer-impl-DgMuRAe_.js.map → terminal-viewer-impl-CQhh6oXa.js.map} +1 -1
  71. package/public/assets/types-BiJFuTiL.js +2 -0
  72. package/public/assets/types-BiJFuTiL.js.map +1 -0
  73. package/public/assets/{user-avatar-CfAUS3PZ.js → user-avatar-BYGrUx1U.js} +2 -2
  74. package/public/assets/{user-avatar-CfAUS3PZ.js.map → user-avatar-BYGrUx1U.js.map} +1 -1
  75. package/public/assets/{work-queue-D-Otxd9u.js → work-queue-BH2-mARc.js} +2 -2
  76. package/public/assets/{work-queue-D-Otxd9u.js.map → work-queue-BH2-mARc.js.map} +1 -1
  77. package/public/assets/{workspaces-CIsQqQby.js → workspaces-DldYyXZR.js} +2 -2
  78. package/public/assets/{workspaces-CIsQqQby.js.map → workspaces-DldYyXZR.js.map} +1 -1
  79. package/public/index.html +4 -4
  80. package/runner/plugins/claude/.claude-plugin/plugin.json +1 -1
  81. package/runner/plugins/claude/monitors/relay-monitor.provisioned.mjs +6 -0
  82. package/src/branch-landed.ts +17 -3
  83. package/src/config-store.ts +12 -1
  84. package/src/db/agents.ts +3 -2
  85. package/src/db/continuations.ts +13 -3
  86. package/src/db/index.ts +3 -0
  87. package/src/db/issue-lifecycle.ts +12 -0
  88. package/src/db/mappers.ts +17 -0
  89. package/src/db/messages.ts +9 -4
  90. package/src/db/migrations.ts +91 -1
  91. package/src/db/notification-subscriptions.ts +1 -1
  92. package/src/db/prompt-templates.ts +19 -0
  93. package/src/db/schema.ts +67 -1
  94. package/src/db/stats.ts +3 -2
  95. package/src/db/task-comment-through.ts +112 -0
  96. package/src/db/task-core.ts +14 -1
  97. package/src/db/task-entity.ts +629 -0
  98. package/src/db/task-maintenance.ts +4 -3
  99. package/src/db/task-memory.ts +180 -0
  100. package/src/db/tasks.ts +24 -10
  101. package/src/issue-tracker/adapter.ts +15 -0
  102. package/src/issue-tracker/github.ts +40 -2
  103. package/src/issue-tracker/index.ts +1 -0
  104. package/src/mcp/index.ts +12 -1
  105. package/src/mcp/tools-spawn.ts +4 -0
  106. package/src/mcp-dispatch-tools.ts +164 -0
  107. package/src/mcp-notification-subscription-tools.ts +62 -4
  108. package/src/mcp-plan-tools.ts +30 -3
  109. package/src/mcp-release-tools.ts +33 -0
  110. package/src/mcp-task-memory-tools.ts +132 -0
  111. package/src/mcp-task-tools.ts +232 -0
  112. package/src/mcp-task-weave-tools.ts +66 -0
  113. package/src/notification-router.ts +24 -2
  114. package/src/notification-rules.ts +4 -0
  115. package/src/notification-types.ts +23 -0
  116. package/src/prompt-resolver.ts +66 -3
  117. package/src/routes/agents-spawn.ts +10 -0
  118. package/src/routes/index.ts +14 -1
  119. package/src/routes/plans.ts +10 -2
  120. package/src/routes/tasks.ts +276 -2
  121. package/src/routing-policy-store.ts +147 -2
  122. package/src/self-resume.ts +13 -2
  123. package/src/services/issue-lifecycle.ts +9 -1
  124. package/src/services/plan-graph.ts +107 -9
  125. package/src/services/release-readiness.ts +142 -0
  126. package/src/services/send-message.ts +31 -0
  127. package/src/services/spawn-agent.ts +81 -4
  128. package/src/services/task-context-hydration.ts +361 -0
  129. package/src/services/task-entity.ts +149 -0
  130. package/src/services/task-issue-weave.ts +558 -0
  131. package/src/services/task-lifecycle.ts +465 -0
  132. package/src/services/task-plan-view.ts +178 -0
  133. package/src/services/task-semantic-events.ts +137 -0
  134. package/src/services/transient-agent-reaper.ts +55 -22
  135. package/src/spawn-targets.ts +27 -2
  136. package/src/task-dispatcher.ts +461 -0
  137. package/src/upgrade-install-verify.ts +20 -1
  138. package/public/assets/display-BWi8DQCp.js +0 -3
  139. package/public/assets/display-BWi8DQCp.js.map +0 -1
  140. package/public/assets/index-3ydeNO0c.js +0 -23
  141. package/public/assets/index-3ydeNO0c.js.map +0 -1
  142. package/public/assets/types-DorDDvEb.js +0 -2
  143. package/public/assets/types-DorDDvEb.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"workspaces-CIsQqQby.js","names":[],"sources":["../../dashboard/src/components/views/workspaces-list.tsx","../../dashboard/src/components/views/workspaces.tsx"],"sourcesContent":["import { useEffect, type ReactNode } from 'react'\nimport { FolderOpen, PackageOpen, RefreshCw } from 'lucide-react'\nimport { TERMINAL_WORKSPACE_STATUS_VALUES } from 'agent-relay-sdk/types'\nimport { useRelayStore } from '@/store'\nimport { Badge } from '@/components/ui/badge'\nimport { Button } from '@/components/ui/button'\nimport { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'\nimport type { WorkspaceOrphan, WorkspaceRecord, WorkspaceStatus } from '@/types'\n\nexport const LIVE_WORKSPACE_STATUSES = new Set<WorkspaceStatus>(['active', 'ready', 'conflict', 'review_requested', 'merge_planned', 'cleanup_requested'])\nconst TERMINAL_STATUSES = new Set<WorkspaceStatus>(TERMINAL_WORKSPACE_STATUS_VALUES)\n\nexport type WorkspaceFilter = 'active' | 'cleaned' | 'all'\nexport type WorkspaceProjectFilter = string\n\nexport const ALL_PROJECTS = '__all__'\nexport const UNASSIGNED_PROJECTS = '__unassigned__'\n\ntype RepoWorkspaceGroup = {\n repoRoot: string\n workspaces: WorkspaceRecord[]\n}\n\nexport type WorkspaceProjectGroup = {\n key: string\n title: string\n projectId?: string\n projectSlug?: string\n unassigned: boolean\n repoGroups: RepoWorkspaceGroup[]\n}\n\nfunction repoWorkspaceGroups(workspaces: WorkspaceRecord[], workspaceSort: (a: WorkspaceRecord, b: WorkspaceRecord) => number): RepoWorkspaceGroup[] {\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) => a.repoRoot.localeCompare(b.repoRoot))\n}\n\nexport function groupWorkspaces(workspaces: WorkspaceRecord[], workspaceSort: (a: WorkspaceRecord, b: WorkspaceRecord) => number): WorkspaceProjectGroup[] {\n const grouped = new Map<string, WorkspaceRecord[]>()\n for (const workspace of workspaces) {\n const key = workspace.projectSlug || workspace.repoRoot || workspace.sourceCwd || 'unassigned'\n grouped.set(key, [...(grouped.get(key) || []), workspace])\n }\n return [...grouped.entries()]\n .map(([key, items]) => {\n const sample = items[0]!\n const unassigned = !sample.projectId\n const title = unassigned ? (sample.repoRoot || sample.sourceCwd || 'unknown repo') : (sample.projectTitle || sample.projectSlug || sample.repoRoot)\n return {\n key,\n title,\n ...(sample.projectId ? { projectId: sample.projectId } : {}),\n ...(sample.projectSlug ? { projectSlug: sample.projectSlug } : {}),\n unassigned,\n repoGroups: repoWorkspaceGroups(items, workspaceSort),\n }\n })\n .sort((a, b) => {\n const liveA = a.repoGroups.some((group) => group.workspaces.some((item) => LIVE_WORKSPACE_STATUSES.has(item.status)))\n const liveB = b.repoGroups.some((group) => group.workspaces.some((item) => LIVE_WORKSPACE_STATUSES.has(item.status)))\n if (liveA !== liveB) return liveA ? -1 : 1\n return a.title.localeCompare(b.title)\n })\n}\n\nexport function filterWorkspaces(workspaces: WorkspaceRecord[], filter: WorkspaceFilter, projectFilter: WorkspaceProjectFilter): WorkspaceRecord[] {\n const byStatus = filter === 'all'\n ? workspaces\n : filter === 'cleaned'\n ? workspaces.filter((workspace) => TERMINAL_STATUSES.has(workspace.status))\n : workspaces.filter((workspace) => !TERMINAL_STATUSES.has(workspace.status))\n if (projectFilter === ALL_PROJECTS) return byStatus\n if (projectFilter === UNASSIGNED_PROJECTS) return byStatus.filter((workspace) => !workspace.projectId)\n return byStatus.filter((workspace) => workspace.projectId === projectFilter)\n}\n\nexport function ProjectGroup({\n group,\n renderWorkspaceRow,\n}: {\n group: WorkspaceProjectGroup\n renderWorkspaceRow: (workspace: WorkspaceRecord) => ReactNode\n}) {\n const workspaces = group.repoGroups.flatMap((repoGroup) => repoGroup.workspaces)\n const liveCount = workspaces.filter((item) => LIVE_WORKSPACE_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 const showRepoSubgroups = group.repoGroups.length > 1\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 <div className=\"flex flex-wrap items-center gap-2\">\n <CardTitle className=\"truncate text-sm font-medium\" title={group.title}>{group.title}</CardTitle>\n {group.unassigned && <Badge variant=\"outline\" className=\"text-[10px]\">Unassigned</Badge>}\n </div>\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 {group.repoGroups.map((repoGroup) => (\n <div key={repoGroup.repoRoot} className=\"border-t border-border first:border-t-0\">\n {showRepoSubgroups && (\n <div className=\"flex items-center gap-2 border-b border-dashed border-border/80 px-3 py-2\">\n <FolderOpen className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate font-mono text-[11px] text-muted-foreground\" title={repoGroup.repoRoot}>{repoGroup.repoRoot}</span>\n </div>\n )}\n {repoGroup.workspaces.map((workspace) => renderWorkspaceRow(workspace))}\n </div>\n ))}\n </CardContent>\n </Card>\n )\n}\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\nexport function 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 const renderOrphan = (orphan: WorkspaceOrphan) => (\n <div key={orphan.worktreePath} className=\"flex items-center gap-3 border-t border-border px-4 py-2 text-xs\">\n <FolderOpen 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 <PackageOpen className=\"mr-1 h-3.5 w-3.5\" />Reclaim\n </Button>\n </div>\n )\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\">{orphans.map(renderOrphan)}</CardContent>\n </Card>\n )\n}\n","import { useEffect, useMemo, useRef, useState } from 'react'\nimport { ArrowDown, ArrowUp, Check, ChevronDown, ChevronRight, Clock, Eye, FileDiff, FilePen, Flag, FolderOpen, GitBranch, GitCommitHorizontal, GitMerge, RefreshCw, TriangleAlert, Trash2, X } from 'lucide-react'\nimport { api } from '@/lib/api'\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 { displayName, timeAgo } from '@/lib/display'\nimport { ALL_PROJECTS, filterWorkspaces, groupWorkspaces, LIVE_WORKSPACE_STATUSES, OrphanPanel, ProjectGroup, UNASSIGNED_PROJECTS, type WorkspaceFilter, type WorkspaceProjectFilter } from './workspaces-list'\nimport type { Agent, Project, WorkspaceRecord, WorkspaceStatus } from '@/types'\n\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\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\nfunction agentLabel(agent: Agent | undefined, fallback: string | undefined): string {\n if (agent) return displayName(agent)\n return fallback || '-'\n}\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 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 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// 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\nexport function WorkspacesView() {\n const [filter, setFilter] = useState<WorkspaceFilter>('active')\n const [projectFilter, setProjectFilter] = useState<WorkspaceProjectFilter>(ALL_PROJECTS)\n const [projects, setProjects] = useState<Project[]>([])\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) {\n setFilter('all')\n setProjectFilter(ALL_PROJECTS)\n }\n }, [workspaceFocusId])\n useEffect(() => () => { set({ workspaceFocusId: null }) }, [set])\n useEffect(() => {\n let cancelled = false\n api<{ projects: Project[] }>('GET', '/projects')\n .then((res) => { if (!cancelled) setProjects(res.projects ?? []) })\n .catch(() => { if (!cancelled) setProjects([]) })\n return () => { cancelled = true }\n }, [])\n\n const visibleWorkspaces = useMemo(() => filterWorkspaces(workspaces, filter, projectFilter), [workspaces, filter, projectFilter])\n const grouped = useMemo(() => groupWorkspaces(visibleWorkspaces, workspaceSort), [visibleWorkspaces])\n const liveCount = workspaces.filter((item) => LIVE_WORKSPACE_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) => item.status === 'merged' || item.status === 'abandoned' || item.status === 'cleaned').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 const projectOptions = useMemo(() => {\n const options = [{ value: ALL_PROJECTS, label: 'All Projects' }]\n for (const project of projects) {\n options.push({ value: project.id, label: project.title || project.slug })\n }\n options.push({ value: UNASSIGNED_PROJECTS, label: 'Unassigned' })\n return options\n }, [projects])\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 <select\n className=\"h-8 min-w-[12rem] rounded-md border border-border bg-card px-2.5 text-sm text-foreground\"\n value={projectFilter}\n onChange={(e) => setProjectFilter(e.target.value)}\n >\n {projectOptions.map((option) => (\n <option key={option.value} value={option.value}>{option.label}</option>\n ))}\n </select>\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{projectFilter !== ALL_PROJECTS ? ' in this project filter' : ''}\n </div>\n ) : (\n <div className=\"space-y-3\">\n {grouped.map((group) => (\n <ProjectGroup key={group.key} group={group} renderWorkspaceRow={(workspace) => <WorkspaceRow key={workspace.id} workspace={workspace} />} />\n ))}\n </div>\n )}\n </div>\n )\n}\n"],"mappings":"olBASa,EAA0B,IAAI,IAAqB,CAAC,SAAU,QAAS,WAAY,mBAA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A,EAAA,KAAC,MAAD,CAAK,UAAU,qBACZ,EAAQ,IAAK,IACZ,EAAA,EAAA,KAAC,EAAD,CAAqC,QAAO,mBAAqB,IAAc,EAAA,EAAA,KAAC,GAAD,CAA4C,YAAa,CAAtC,EAAU,GAA4B,CAAI,CAAzH,EAAM,IAAmH,CAC5I,CACE,CAAA,CAEJ"}
1
+ {"version":3,"file":"workspaces-DldYyXZR.js","names":[],"sources":["../../dashboard/src/components/views/workspaces-list.tsx","../../dashboard/src/components/views/workspaces.tsx"],"sourcesContent":["import { useEffect, type ReactNode } from 'react'\nimport { FolderOpen, PackageOpen, RefreshCw } from 'lucide-react'\nimport { TERMINAL_WORKSPACE_STATUS_VALUES } from 'agent-relay-sdk/types'\nimport { useRelayStore } from '@/store'\nimport { Badge } from '@/components/ui/badge'\nimport { Button } from '@/components/ui/button'\nimport { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'\nimport type { WorkspaceOrphan, WorkspaceRecord, WorkspaceStatus } from '@/types'\n\nexport const LIVE_WORKSPACE_STATUSES = new Set<WorkspaceStatus>(['active', 'ready', 'conflict', 'review_requested', 'merge_planned', 'cleanup_requested'])\nconst TERMINAL_STATUSES = new Set<WorkspaceStatus>(TERMINAL_WORKSPACE_STATUS_VALUES)\n\nexport type WorkspaceFilter = 'active' | 'cleaned' | 'all'\nexport type WorkspaceProjectFilter = string\n\nexport const ALL_PROJECTS = '__all__'\nexport const UNASSIGNED_PROJECTS = '__unassigned__'\n\ntype RepoWorkspaceGroup = {\n repoRoot: string\n workspaces: WorkspaceRecord[]\n}\n\nexport type WorkspaceProjectGroup = {\n key: string\n title: string\n projectId?: string\n projectSlug?: string\n unassigned: boolean\n repoGroups: RepoWorkspaceGroup[]\n}\n\nfunction repoWorkspaceGroups(workspaces: WorkspaceRecord[], workspaceSort: (a: WorkspaceRecord, b: WorkspaceRecord) => number): RepoWorkspaceGroup[] {\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) => a.repoRoot.localeCompare(b.repoRoot))\n}\n\nexport function groupWorkspaces(workspaces: WorkspaceRecord[], workspaceSort: (a: WorkspaceRecord, b: WorkspaceRecord) => number): WorkspaceProjectGroup[] {\n const grouped = new Map<string, WorkspaceRecord[]>()\n for (const workspace of workspaces) {\n const key = workspace.projectSlug || workspace.repoRoot || workspace.sourceCwd || 'unassigned'\n grouped.set(key, [...(grouped.get(key) || []), workspace])\n }\n return [...grouped.entries()]\n .map(([key, items]) => {\n const sample = items[0]!\n const unassigned = !sample.projectId\n const title = unassigned ? (sample.repoRoot || sample.sourceCwd || 'unknown repo') : (sample.projectTitle || sample.projectSlug || sample.repoRoot)\n return {\n key,\n title,\n ...(sample.projectId ? { projectId: sample.projectId } : {}),\n ...(sample.projectSlug ? { projectSlug: sample.projectSlug } : {}),\n unassigned,\n repoGroups: repoWorkspaceGroups(items, workspaceSort),\n }\n })\n .sort((a, b) => {\n const liveA = a.repoGroups.some((group) => group.workspaces.some((item) => LIVE_WORKSPACE_STATUSES.has(item.status)))\n const liveB = b.repoGroups.some((group) => group.workspaces.some((item) => LIVE_WORKSPACE_STATUSES.has(item.status)))\n if (liveA !== liveB) return liveA ? -1 : 1\n return a.title.localeCompare(b.title)\n })\n}\n\nexport function filterWorkspaces(workspaces: WorkspaceRecord[], filter: WorkspaceFilter, projectFilter: WorkspaceProjectFilter): WorkspaceRecord[] {\n const byStatus = filter === 'all'\n ? workspaces\n : filter === 'cleaned'\n ? workspaces.filter((workspace) => TERMINAL_STATUSES.has(workspace.status))\n : workspaces.filter((workspace) => !TERMINAL_STATUSES.has(workspace.status))\n if (projectFilter === ALL_PROJECTS) return byStatus\n if (projectFilter === UNASSIGNED_PROJECTS) return byStatus.filter((workspace) => !workspace.projectId)\n return byStatus.filter((workspace) => workspace.projectId === projectFilter)\n}\n\nexport function ProjectGroup({\n group,\n renderWorkspaceRow,\n}: {\n group: WorkspaceProjectGroup\n renderWorkspaceRow: (workspace: WorkspaceRecord) => ReactNode\n}) {\n const workspaces = group.repoGroups.flatMap((repoGroup) => repoGroup.workspaces)\n const liveCount = workspaces.filter((item) => LIVE_WORKSPACE_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 const showRepoSubgroups = group.repoGroups.length > 1\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 <div className=\"flex flex-wrap items-center gap-2\">\n <CardTitle className=\"truncate text-sm font-medium\" title={group.title}>{group.title}</CardTitle>\n {group.unassigned && <Badge variant=\"outline\" className=\"text-[10px]\">Unassigned</Badge>}\n </div>\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 {group.repoGroups.map((repoGroup) => (\n <div key={repoGroup.repoRoot} className=\"border-t border-border first:border-t-0\">\n {showRepoSubgroups && (\n <div className=\"flex items-center gap-2 border-b border-dashed border-border/80 px-3 py-2\">\n <FolderOpen className=\"h-3.5 w-3.5 shrink-0 text-muted-foreground\" />\n <span className=\"truncate font-mono text-[11px] text-muted-foreground\" title={repoGroup.repoRoot}>{repoGroup.repoRoot}</span>\n </div>\n )}\n {repoGroup.workspaces.map((workspace) => renderWorkspaceRow(workspace))}\n </div>\n ))}\n </CardContent>\n </Card>\n )\n}\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\nexport function 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 const renderOrphan = (orphan: WorkspaceOrphan) => (\n <div key={orphan.worktreePath} className=\"flex items-center gap-3 border-t border-border px-4 py-2 text-xs\">\n <FolderOpen 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 <PackageOpen className=\"mr-1 h-3.5 w-3.5\" />Reclaim\n </Button>\n </div>\n )\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\">{orphans.map(renderOrphan)}</CardContent>\n </Card>\n )\n}\n","import { useEffect, useMemo, useRef, useState } from 'react'\nimport { ArrowDown, ArrowUp, Check, ChevronDown, ChevronRight, Clock, Eye, FileDiff, FilePen, Flag, FolderOpen, GitBranch, GitCommitHorizontal, GitMerge, RefreshCw, TriangleAlert, Trash2, X } from 'lucide-react'\nimport { api } from '@/lib/api'\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 { displayName, timeAgo } from '@/lib/display'\nimport { ALL_PROJECTS, filterWorkspaces, groupWorkspaces, LIVE_WORKSPACE_STATUSES, OrphanPanel, ProjectGroup, UNASSIGNED_PROJECTS, type WorkspaceFilter, type WorkspaceProjectFilter } from './workspaces-list'\nimport type { Agent, Project, WorkspaceRecord, WorkspaceStatus } from '@/types'\n\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\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\nfunction agentLabel(agent: Agent | undefined, fallback: string | undefined): string {\n if (agent) return displayName(agent)\n return fallback || '-'\n}\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 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 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// 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\nexport function WorkspacesView() {\n const [filter, setFilter] = useState<WorkspaceFilter>('active')\n const [projectFilter, setProjectFilter] = useState<WorkspaceProjectFilter>(ALL_PROJECTS)\n const [projects, setProjects] = useState<Project[]>([])\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) {\n setFilter('all')\n setProjectFilter(ALL_PROJECTS)\n }\n }, [workspaceFocusId])\n useEffect(() => () => { set({ workspaceFocusId: null }) }, [set])\n useEffect(() => {\n let cancelled = false\n api<{ projects: Project[] }>('GET', '/projects')\n .then((res) => { if (!cancelled) setProjects(res.projects ?? []) })\n .catch(() => { if (!cancelled) setProjects([]) })\n return () => { cancelled = true }\n }, [])\n\n const visibleWorkspaces = useMemo(() => filterWorkspaces(workspaces, filter, projectFilter), [workspaces, filter, projectFilter])\n const grouped = useMemo(() => groupWorkspaces(visibleWorkspaces, workspaceSort), [visibleWorkspaces])\n const liveCount = workspaces.filter((item) => LIVE_WORKSPACE_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) => item.status === 'merged' || item.status === 'abandoned' || item.status === 'cleaned').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 const projectOptions = useMemo(() => {\n const options = [{ value: ALL_PROJECTS, label: 'All Projects' }]\n for (const project of projects) {\n options.push({ value: project.id, label: project.title || project.slug })\n }\n options.push({ value: UNASSIGNED_PROJECTS, label: 'Unassigned' })\n return options\n }, [projects])\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 <select\n className=\"h-8 min-w-[12rem] rounded-md border border-border bg-card px-2.5 text-sm text-foreground\"\n value={projectFilter}\n onChange={(e) => setProjectFilter(e.target.value)}\n >\n {projectOptions.map((option) => (\n <option key={option.value} value={option.value}>{option.label}</option>\n ))}\n </select>\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{projectFilter !== ALL_PROJECTS ? ' in this project filter' : ''}\n </div>\n ) : (\n <div className=\"space-y-3\">\n {grouped.map((group) => (\n <ProjectGroup key={group.key} group={group} renderWorkspaceRow={(workspace) => <WorkspaceRow key={workspace.id} workspace={workspace} />} />\n ))}\n </div>\n )}\n </div>\n )\n}\n"],"mappings":"olBASa,EAA0B,IAAI,IAAqB,CAAC,SAAU,QAAS,WAAY,mBAAoB,gBAAiB,oBAAoB,CAAC,CACpJ,EAAoB,IAAI,IAAqB,EAAiC,CAKvE,EAAe,UACf,EAAsB,iBAgBnC,SAAS,EAAoB,EAA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AA,EAAA,KAAC,GAAD,CAA4C,YAAa,CAAtC,EAAU,GAA4B,CAAI,CAAzH,EAAM,IAAmH,CAC5I,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-3ydeNO0c.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-DlBSuzd2.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="./assets/chunk-CilyBKbf.js">
17
17
  <link rel="modulepreload" crossorigin href="./assets/preload-helper-C_JMBXql.js">
18
18
  <link rel="modulepreload" crossorigin href="./assets/lucide-react-C4eXYCwx.js">
@@ -30,9 +30,9 @@
30
30
  <link rel="modulepreload" crossorigin href="./assets/dist-CgqfdHSt.js">
31
31
  <link rel="modulepreload" crossorigin href="./assets/dist-BwwlmyBq.js">
32
32
  <link rel="modulepreload" crossorigin href="./assets/dist-DC-TqTz2.js">
33
- <link rel="modulepreload" crossorigin href="./assets/types-DorDDvEb.js">
34
- <link rel="modulepreload" crossorigin href="./assets/display-BWi8DQCp.js">
35
- <link rel="modulepreload" crossorigin href="./assets/store-DUfrGvOE.js">
33
+ <link rel="modulepreload" crossorigin href="./assets/types-BiJFuTiL.js">
34
+ <link rel="modulepreload" crossorigin href="./assets/display-1J__Ti1K.js">
35
+ <link rel="modulepreload" crossorigin href="./assets/store-Bnag1kY-.js">
36
36
  <link rel="modulepreload" crossorigin href="./assets/button-KASZcscA.js">
37
37
  <link rel="modulepreload" crossorigin href="./assets/copy-button-d9DFNX9v.js">
38
38
  <link rel="modulepreload" crossorigin href="./assets/badge-D8fABzMs.js">
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "agent-relay-runner",
3
3
  "description": "Thin Agent Relay runner bridge for Claude Code",
4
- "version": "0.107.0",
4
+ "version": "0.108.0",
5
5
  "agentRelayContracts": {
6
6
  "providerPluginProtocol": 1
7
7
  }
@@ -65,6 +65,9 @@ var claudeProviderManifest = {
65
65
  launch: {
66
66
  managedPolicyPrompt: {
67
67
  alwaysOn: "append-system-prompt"
68
+ },
69
+ taskHydration: {
70
+ channel: "append-system-prompt"
68
71
  }
69
72
  },
70
73
  catalog: {
@@ -188,6 +191,9 @@ var codexProviderManifest = {
188
191
  launch: {
189
192
  managedPolicyPrompt: {
190
193
  alwaysOn: "prompt"
194
+ },
195
+ taskHydration: {
196
+ channel: "prompt"
191
197
  }
192
198
  },
193
199
  catalog: {
@@ -7,6 +7,7 @@ import { renderTemplate } from "./prompt-resolver";
7
7
  import { resolveCoordinatorAgentId } from "./steward-identity";
8
8
  import { stewardFallbackTarget } from "./config";
9
9
  import { handleLandedIssueLifecycle } from "./services/issue-lifecycle";
10
+ import { handleLandedTaskLifecycle } from "./services/task-lifecycle";
10
11
  import type { WorkspaceMergePreview, WorkspaceRecord } from "./types";
11
12
 
12
13
  // #444 — branch.landed is the first rule-driven type: the on-main "merged" fan-out audience comes
@@ -133,9 +134,22 @@ export function notifyBranchLanded(input: BranchLandedInput): void {
133
134
  notification: "landed-success",
134
135
  },
135
136
  });
136
- void handleLandedIssueLifecycle({ ...input, commitSubjects }, { log: lifecycleLog }).catch((error) => {
137
- console.warn(`issue lifecycle land hook failed for ${workspace.id}: ${errMessage(error)}`);
138
- });
137
+ // #482/#833 issue close FIRST, then the #831 Task drive: the Task's close PROJECTION
138
+ // (taskCloseBridge) reads the canonical close ledger the issue hook writes, so chaining makes the
139
+ // receipt accurate. Both are best-effort + isolated — a throw in either can never fail the merge
140
+ // (it already landed before notifyBranchLanded runs). A non-task branch makes the Task drive a no-op.
141
+ void (async () => {
142
+ try {
143
+ await handleLandedIssueLifecycle({ ...input, commitSubjects }, { log: lifecycleLog });
144
+ } catch (error) {
145
+ console.warn(`issue lifecycle land hook failed for ${workspace.id}: ${errMessage(error)}`);
146
+ }
147
+ try {
148
+ await handleLandedTaskLifecycle({ ...input, commitSubjects }, { log: lifecycleLog });
149
+ } catch (error) {
150
+ console.warn(`task lifecycle land hook failed for ${workspace.id}: ${errMessage(error)}`);
151
+ }
152
+ })();
139
153
 
140
154
  const author = workspace.ownerAgentId;
141
155
  const shaLabel = shortSha ? ` as \`${shortSha}\`` : "";
@@ -73,7 +73,7 @@ function builtInAgentProfiles(): AgentProfile[] {
73
73
  agentProfileDefaults({ name: "vanilla", icon: "🫥", description: "Zero host bleed (#552): isolated provider home with host plugins, skills, hooks, MCP, and the CLAUDE.md/AGENTS.md cascade (repo + global) all suppressed at launch. Relay provisions any surface explicitly per profile.", base: "vanilla" }),
74
74
  agentProfileDefaults({ name: "lean-worker", icon: "🪶", description: "Lean worker profile (#570): vanilla host-dependency drop with only Relay context/MCP restored and Project knowledge injected from the spawn cwd.", base: "vanilla", relay: { context: true, skills: false, plugins: false, statusLine: false, mcp: true, tools: { groups: WORKER_TOOL_GROUPS } }, projectInstructions: { policy: "all" } }),
75
75
  agentProfileDefaults({ name: "coordinator", icon: "🧭", description: "Relay-aware coordination lead for spawning worker teams, maintaining shared state, and driving review and release.", base: "host", instructions: { append: [renderTemplate("profile.coordinator.charter")], repoInstructions: "allow", globalInstructions: "allow" }, maxSpawnedAgents: 8 }),
76
- agentProfileDefaults({ name: "ops-assistant", icon: "🛠️", description: "Relay-aware ops lieutenant for a coordinator: runs tests, releases, smoke probes, gates, and host checks, then reports crisp outcomes back up.", provider: "codex", base: "host", instructions: { append: [renderTemplate("profile.ops-assistant.brief")], repoInstructions: "allow", globalInstructions: "allow" }, permissions: { mode: "open", filesystem: "host" } }),
76
+ agentProfileDefaults({ name: "ops-assistant", icon: "🛠️", description: "Relay-aware ops lieutenant for a coordinator: runs tests, releases, smoke probes, gates, and host checks, then reports crisp outcomes back up.", provider: "codex", base: "host", instructions: { append: [renderTemplate("profile.ops-assistant.brief")], repoInstructions: "allow", globalInstructions: "allow" }, notifications: { responseMode: "results-only" }, permissions: { mode: "open", filesystem: "host" } }),
77
77
  agentProfileDefaults({ name: "worker", icon: "🔨", description: "Relay-aware focused implementer with open approval posture and no delegated spawn capability.", base: "host", instructions: { system: renderTemplate("profile.worker.system"), append: [], repoInstructions: "allow", globalInstructions: "allow" }, mcp: { mode: "none" }, permissions: { mode: "open", filesystem: "host" }, relay: { tools: { groups: WORKER_TOOL_GROUPS } } }),
78
78
  agentProfileDefaults({ name: "reviewer", icon: "🔍", description: "Relay-aware read-only reviewer for audit and review passes without file writes.", base: "host", mcp: { mode: "none" }, permissions: { mode: "read-only", filesystem: "host" }, relay: { tools: { groups: WORKER_TOOL_GROUPS } } }),
79
79
  ].map((profile) => ({ ...profile, builtIn: true }));
@@ -272,6 +272,15 @@ function cleanAgentProfileSharedMcp(value: unknown): AgentProfile["sharedMcp"] {
272
272
  return { policy: cleanEnum(policy, "sharedMcp.policy", SHARED_MCP_POLICY_NAMES) as NonNullable<AgentProfile["sharedMcp"]>["policy"] };
273
273
  }
274
274
 
275
+ function cleanAgentProfileNotifications(value: unknown): AgentProfile["notifications"] {
276
+ if (value === undefined || value === null) return undefined;
277
+ if (!isRecord(value)) throw new ValidationError("notifications must be an object");
278
+ const responseMode = value.responseMode === undefined || value.responseMode === null
279
+ ? undefined
280
+ : cleanEnum(value.responseMode, "notifications.responseMode", ["normal", "results-only"] as const);
281
+ return responseMode ? { responseMode } : {};
282
+ }
283
+
275
284
  function agentProfileDefaults(input: Pick<AgentProfile, "name" | "base"> & Omit<Partial<AgentProfile>, "relay"> & { relay?: Partial<AgentProfile["relay"]> }): AgentProfile {
276
285
  const isolated = input.base !== "host";
277
286
  // "vanilla" (#552) additionally suppresses the REPO instruction cascade
@@ -297,6 +306,7 @@ function agentProfileDefaults(input: Pick<AgentProfile, "name" | "base"> & Omit<
297
306
  ...(input.projectSkills ? { projectSkills: input.projectSkills } : {}),
298
307
  ...(input.projectSettings ? { projectSettings: input.projectSettings } : {}),
299
308
  ...(input.sharedMcp ? { sharedMcp: input.sharedMcp } : {}),
309
+ ...(input.notifications ? { notifications: input.notifications } : {}),
300
310
  relay: {
301
311
  context: input.relay?.context ?? !isolated,
302
312
  skills: input.relay?.skills ?? !isolated,
@@ -379,6 +389,7 @@ function validateAgentProfile(key: string, value: unknown, opts: { allowBuiltIn?
379
389
  projectSkills: cleanAgentProfileProjectSkills(value.projectSkills),
380
390
  projectSettings: cleanAgentProfileProjectSettings(value.projectSettings),
381
391
  sharedMcp: cleanAgentProfileSharedMcp(value.sharedMcp),
392
+ notifications: cleanAgentProfileNotifications(value.notifications),
382
393
  relay: {
383
394
  context: relay.context === undefined ? defaults.relay.context : cleanBoolean(relay.context, "relay.context"),
384
395
  skills: relay.skills === undefined ? defaults.relay.skills : cleanBoolean(relay.skills, "relay.skills"),
package/src/db/agents.ts CHANGED
@@ -24,6 +24,7 @@ import { closeOpenPairsForAgent } from "./pair-maintenance.ts";
24
24
  import { parseStringArray } from "./shared.ts";
25
25
  import { listAgentQuotaSnapshotsFromProviderStore } from "./provider-quotas.ts";
26
26
  import { settleSingleTargetOnDemandTasks } from "./task-maintenance.ts";
27
+ import { claimTaskWhere } from "./task-core.ts";
27
28
  import { electWorkspaceStewards, electWorkspaceStewardsForAgent } from "./workspaces.ts";
28
29
  import { DEFAULT_SELF_RESUME_CONFIG } from "../self-resume-config";
29
30
  import type { TokenRevokeReason } from "../security";
@@ -535,7 +536,7 @@ export function pruneOfflineAgents(maxOfflineMs: number = DAY_MS): string[] {
535
536
 
536
537
  getDb()
537
538
  .query(
538
- `UPDATE tasks SET status = 'open', claimed_by = NULL, claimed_at = NULL, claim_expires_at = NULL, updated_at = ? WHERE ${offlineClaimCondition} AND status IN ('claimed', 'in_progress', 'blocked')`
539
+ `UPDATE tasks SET status = 'open', claimed_by = NULL, claimed_at = NULL, claim_expires_at = NULL, updated_at = ? WHERE ${claimTaskWhere()} AND ${offlineClaimCondition} AND status IN ('claimed', 'in_progress', 'blocked')`
539
540
  )
540
541
  .run(now, cutoff);
541
542
 
@@ -566,7 +567,7 @@ export function deleteAgent(id: string): { ok: boolean; error?: string } {
566
567
  const now = Date.now();
567
568
  getDb().query(`UPDATE messages SET claimed_by = NULL, claimed_at = NULL, claim_expires_at = NULL WHERE claimed_by = ? AND NOT ${messageTaskClosed("messages.id")}`).run(id);
568
569
  settleSingleTargetOnDemandTasks("claimed_by = ?", [id], now, "agent-removed");
569
- getDb().query("UPDATE tasks SET status = 'open', claimed_by = NULL, claimed_at = NULL, claim_expires_at = NULL, updated_at = ? WHERE claimed_by = ? AND status IN ('claimed', 'in_progress', 'blocked')").run(now, id);
570
+ getDb().query(`UPDATE tasks SET status = 'open', claimed_by = NULL, claimed_at = NULL, claim_expires_at = NULL, updated_at = ? WHERE ${claimTaskWhere()} AND claimed_by = ? AND status IN ('claimed', 'in_progress', 'blocked')`).run(now, id);
570
571
  revokeRuntimeTokensForAgent(id, now);
571
572
  closeOpenPairsForAgent(id, now);
572
573
  return getDb().query("DELETE FROM agents WHERE id = ?").run(id).changes > 0;
@@ -1,7 +1,7 @@
1
1
  import { isRecord } from "agent-relay-sdk";
2
2
  import { parseJson } from "../utils";
3
3
  import { getDb, ValidationError } from "./connection.ts";
4
- import type { ContinuationBudget, ContinuationEnvelope, ContinuationLedgerEntry, SelfResumeConfig } from "../types";
4
+ import type { ContinuationBudget, ContinuationDecisionEntry, ContinuationEnvelope, ContinuationLedgerEntry, SelfResumeConfig } from "../types";
5
5
 
6
6
  interface ContinuationRow {
7
7
  agent_id: string;
@@ -113,7 +113,8 @@ function rowToEnvelope(row: ContinuationRow): ContinuationEnvelope {
113
113
  agentId: row.agent_id,
114
114
  objective: row.objective,
115
115
  generation: row.generation,
116
- ledger: parseJson<ContinuationLedgerEntry[]>(row.ledger, []).filter(isLedgerEntry),
116
+ ledger: parseJson<ContinuationLedgerEntry[]>(row.ledger, []).filter(isContinuationLedgerEntry),
117
+ decisions: [],
117
118
  workingState: row.working_state,
118
119
  archiveRefs: parseJson<string[]>(row.archive_refs, []).filter((value): value is string => typeof value === "string"),
119
120
  budget: parseBudget(row.budget),
@@ -140,7 +141,7 @@ function parseBudget(raw: string): ContinuationBudget {
140
141
  };
141
142
  }
142
143
 
143
- function isLedgerEntry(value: unknown): value is ContinuationLedgerEntry {
144
+ export function isContinuationLedgerEntry(value: unknown): value is ContinuationLedgerEntry {
144
145
  return isRecord(value)
145
146
  && typeof value.gen === "number"
146
147
  && typeof value.ruledOut === "string"
@@ -148,6 +149,15 @@ function isLedgerEntry(value: unknown): value is ContinuationLedgerEntry {
148
149
  && typeof value.at === "number";
149
150
  }
150
151
 
152
+ export function isContinuationDecisionEntry(value: unknown): value is ContinuationDecisionEntry {
153
+ return isRecord(value)
154
+ && typeof value.gen === "number"
155
+ && typeof value.decision === "string"
156
+ && typeof value.rationale === "string"
157
+ && (value.by === undefined || typeof value.by === "string")
158
+ && typeof value.at === "number";
159
+ }
160
+
151
161
  function numberValue(value: unknown): number {
152
162
  return typeof value === "number" && Number.isFinite(value) ? value : 0;
153
163
  }
package/src/db/index.ts CHANGED
@@ -9,6 +9,9 @@ export * from "./channels.ts";
9
9
  export * from "./agents.ts";
10
10
  export * from "./agent-search.ts";
11
11
  export * from "./tasks.ts";
12
+ export * from "./task-entity.ts";
13
+ export * from "./task-memory.ts";
14
+ export * from "./task-comment-through.ts";
12
15
  export * from "./integrations.ts";
13
16
  export * from "./pairs.ts";
14
17
  export * from "./artifacts.ts";
@@ -116,6 +116,18 @@ export function getSuccessfulIssueLifecycleAction(issueRefId: string, action: Is
116
116
  return row ? rowToIssueLifecycleAction(row) : null;
117
117
  }
118
118
 
119
+ // #833 — the Task close-bridge projection reads this: every successful #482/#474 close
120
+ // recorded for a given issue ref, newest first. The Task surfaces the canonical record
121
+ // instead of duplicating it (no drift), closing the "did relay already close it?" gap.
122
+ export function listSuccessfulCloseActionsForIssueRef(issueRefId: string): IssueLifecycleActionRecord[] {
123
+ const rows = getDb().query(`
124
+ SELECT * FROM issue_lifecycle_actions
125
+ WHERE issue_ref_id = ? AND action = 'close' AND status = 'succeeded'
126
+ ORDER BY updated_at DESC, id DESC
127
+ `).all(cleanRequiredText(issueRefId, "issueRefId", 120)) as IssueLifecycleActionRow[];
128
+ return rows.map(rowToIssueLifecycleAction);
129
+ }
130
+
119
131
  export function listSuccessfulCloseActionsForCommit(input: { commitSha?: string; commitSubject?: string }): IssueLifecycleActionRecord[] {
120
132
  const commitSha = cleanText(input.commitSha, "commitSha", 64);
121
133
  const commitSubject = cleanText(input.commitSubject, "commitSubject", 500);
package/src/db/mappers.ts CHANGED
@@ -295,6 +295,23 @@ export function rowToTask(row: any): Task {
295
295
  createdAt: row.created_at,
296
296
  updatedAt: row.updated_at,
297
297
  lastSeenAt: row.last_seen_at,
298
+ // #834 durable-Task facet. `kind` is always populated (column default 'claim'); the
299
+ // rest stay absent for claim rows so claim payloads remain wire-identical.
300
+ kind: (row.kind ?? "claim") as Task["kind"],
301
+ ...(row.intent != null ? { intent: row.intent } : {}),
302
+ ...(row.latest_steer != null ? { latestSteer: row.latest_steer } : {}),
303
+ ...(row.deliverable_stage != null && row.deliverable_stage !== "none"
304
+ ? { deliverableStage: row.deliverable_stage as Task["deliverableStage"] }
305
+ : {}),
306
+ ...(row.blocked_by != null ? { blockedBy: parseJson(row.blocked_by, []) } : {}),
307
+ ...(row.branch != null ? { branch: row.branch } : {}),
308
+ ...(row.commits != null ? { commits: parseJson(row.commits, []) } : {}),
309
+ ...(row.done_when != null ? { doneWhen: row.done_when } : {}),
310
+ ...(row.team_id != null ? { teamId: row.team_id } : {}),
311
+ ...(row.created_by != null ? { createdBy: row.created_by } : {}),
312
+ ...(row.owner_agent_id != null ? { ownerAgentId: row.owner_agent_id } : {}),
313
+ ...(row.dispatch != null ? { dispatch: parseJson(row.dispatch, {}) } : {}),
314
+ ...(row.reaped_at != null ? { reapedAt: row.reaped_at } : {}),
298
315
  };
299
316
  }
300
317
 
@@ -26,7 +26,7 @@ import { getMessage } from "./message-queries.ts";
26
26
  import { childStreamSubscribed, type ChildStream } from "./notification-subscriptions.ts";
27
27
  import { runningAgentForPolicy } from "./policy-runtime.ts";
28
28
  import { getTask, releaseExpiredClaims } from "./tasks.ts";
29
- import { insertTaskEvent } from "./task-core.ts";
29
+ import { insertTaskEvent, claimTaskWhere, CLAIM_TASK_KIND } from "./task-core.ts";
30
30
  import type {
31
31
  AgentCard,
32
32
  ActivityEvent,
@@ -621,11 +621,15 @@ export function claimMessage(messageId: number, agentId: string, guard?: AgentSe
621
621
 
622
622
  const task = getTask(taskId);
623
623
  if (!task) return { ok: true };
624
+ // Fence (#834): the claim-lease lane only manages kind='claim' tasks. A deliverable Task
625
+ // is never lease-managed, so neither the same-agent refresh nor the claim update below may
626
+ // touch it — even via a stray linked-message payload.
627
+ if (task.kind !== CLAIM_TASK_KIND) return { ok: true };
624
628
 
625
629
  // Same-agent re-claim: this agent already holds the linked task. Refresh the lease in place
626
630
  // rather than re-transitioning (which would throw, since the task is no longer open/blocked).
627
631
  if (task.claimedBy === agentId && ["claimed", "in_progress"].includes(task.status)) {
628
- getDb().query("UPDATE tasks SET claim_expires_at = ?, updated_at = ? WHERE id = ? AND claimed_by = ?")
632
+ getDb().query(`UPDATE tasks SET claim_expires_at = ?, updated_at = ? WHERE id = ? AND ${claimTaskWhere()} AND claimed_by = ?`)
629
633
  .run(expiresAt, now, taskId, agentId);
630
634
  return { ok: true, task: getTask(taskId)! };
631
635
  }
@@ -636,7 +640,7 @@ export function claimMessage(messageId: number, agentId: string, guard?: AgentSe
636
640
 
637
641
  const taskClaim = getDb().query(`
638
642
  UPDATE tasks SET status = 'claimed', claimed_by = ?, claimed_at = ?, claim_expires_at = ?, updated_at = ?
639
- WHERE id = ? AND message_id = ? AND status IN ('open', 'blocked')
643
+ WHERE id = ? AND message_id = ? AND ${claimTaskWhere()} AND status IN ('open', 'blocked')
640
644
  `).run(agentId, now, expiresAt, now, taskId, messageId);
641
645
  if (taskClaim.changes === 0) throw new ClaimError("linked task claim race — already claimed");
642
646
 
@@ -678,7 +682,8 @@ export function renewMessageClaim(messageId: number, agentId: string, guard?: Ag
678
682
  ? msg.payload.taskId
679
683
  : null;
680
684
  if (taskId) {
681
- getDb().query("UPDATE tasks SET claim_expires_at = ?, updated_at = ? WHERE id = ? AND claimed_by = ?").run(expiresAt, now, taskId, agentId);
685
+ // Fenced to the claim lane (#834): never refresh a deliverable Task's (non-existent) lease.
686
+ getDb().query(`UPDATE tasks SET claim_expires_at = ?, updated_at = ? WHERE id = ? AND ${claimTaskWhere()} AND claimed_by = ?`).run(expiresAt, now, taskId, agentId);
682
687
  task = getTask(taskId) ?? undefined;
683
688
  }
684
689
  })();