@uniqbit/mate-core 0.20.0 → 0.21.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 (286) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
  2. package/claude-capability-plugins/companion-mentions/hooks/register.ts +1 -1
  3. package/claude-plugin/hooks/hooks.json +10 -1
  4. package/claude-plugin/hooks/rtk-worktree-git.mjs +58 -0
  5. package/opencode-plugin/src/server.ts +9 -2
  6. package/package.json +2 -1
  7. package/src/cli/commands/artifact/delivery/environment.ts +28 -8
  8. package/src/cli/commands/artifact/delivery/link.ts +28 -9
  9. package/src/cli/commands/artifact/delivery/output.ts +7 -0
  10. package/src/cli/commands/companion/update.ts +2 -19
  11. package/src/cli/commands/factory/factory.ts +11 -1
  12. package/src/cli/commands/install.ts +47 -36
  13. package/src/cli/commands/launch/claude.ts +2 -0
  14. package/src/cli/commands/launch/shared.ts +33 -6
  15. package/src/cli/commands/plugin/install.ts +27 -11
  16. package/src/cli/commands/report/index.ts +180 -184
  17. package/src/cli/commands/report/markdown.ts +67 -72
  18. package/src/cli/commands/shared/companion-selection.ts +3 -1
  19. package/src/cli/commands/studio/access.ts +6 -14
  20. package/src/cli/commands/studio/areas.ts +112 -33
  21. package/src/cli/commands/studio/companion-add.ts +87 -0
  22. package/src/cli/commands/studio/companion-removal.ts +15 -8
  23. package/src/cli/commands/studio/factory-credential.ts +1 -15
  24. package/src/cli/commands/studio/factory-git-tokens.ts +40 -0
  25. package/src/cli/commands/studio/factory-relay.ts +18 -0
  26. package/src/cli/commands/studio/graph-model.ts +61 -0
  27. package/src/cli/commands/studio/graph.ts +336 -0
  28. package/src/cli/commands/studio/index.ts +4 -4
  29. package/src/cli/commands/studio/payload.ts +42 -15
  30. package/src/cli/commands/studio/repository-add.ts +116 -0
  31. package/src/cli/commands/studio/routes.ts +6 -0
  32. package/src/cli/commands/studio/selection.ts +12 -3
  33. package/src/cli/commands/studio/server.ts +127 -5
  34. package/src/cli/commands/studio/services.ts +40 -0
  35. package/src/cli/commands/studio/terminal.ts +45 -3
  36. package/src/cli/commands/studio/views/vault/markdown-tree.ts +84 -3
  37. package/src/cli/commands/studio/workset-session.ts +47 -14
  38. package/src/cli/commands/unwrap.ts +3 -0
  39. package/src/cli/commands/update.ts +2 -0
  40. package/src/cli/commands/vscode/release-vsix.json +4 -0
  41. package/src/cli/commands/vscode/setup.ts +71 -13
  42. package/src/cli/commands/vscode/vsix.ts +48 -7
  43. package/src/cli/commands/working/cleanup.ts +40 -8
  44. package/src/cli/commands/working/worktree.ts +176 -35
  45. package/src/cli/main.ts +17 -2
  46. package/src/cli/usage.ts +1 -1
  47. package/src/hooks/rtk-worktree-git.ts +48 -0
  48. package/src/hooks/validate-artifact-path.ts +38 -7
  49. package/src/lib/delivery/branch-template.ts +122 -0
  50. package/src/lib/delivery/branches.ts +21 -16
  51. package/src/lib/delivery/checkout.ts +102 -0
  52. package/src/lib/delivery/environment.ts +2 -0
  53. package/src/lib/delivery/merge-git.ts +13 -1
  54. package/src/lib/delivery/record-delivery.ts +83 -29
  55. package/src/lib/delivery/record.ts +15 -3
  56. package/src/lib/delivery/resolve-branch.ts +157 -110
  57. package/src/lib/factory/attach-client.ts +11 -1
  58. package/src/lib/factory/broker.ts +37 -40
  59. package/src/lib/factory/client.ts +22 -1
  60. package/src/lib/factory/clone-url.ts +39 -0
  61. package/src/lib/factory/command.ts +21 -5
  62. package/src/lib/factory/git-auth.ts +61 -0
  63. package/src/lib/factory/git-credential-store.ts +181 -0
  64. package/src/lib/factory/ids.ts +12 -2
  65. package/src/lib/factory/outcomes/actions.ts +20 -4
  66. package/src/lib/factory/outcomes/index.ts +77 -11
  67. package/src/lib/factory/outcomes/lifecycle.ts +9 -2
  68. package/src/lib/factory/outcomes/sessions.ts +23 -1
  69. package/src/lib/factory/prepare.ts +9 -3
  70. package/src/lib/factory/runner/scheduler.ts +96 -14
  71. package/src/lib/factory/runner/workflow.ts +5 -1
  72. package/src/lib/factory/runtime.ts +143 -43
  73. package/src/lib/orchestrator/companion-hub.ts +6 -1
  74. package/src/lib/orchestrator/engine-floor.ts +48 -0
  75. package/src/lib/orchestrator/launcher.ts +34 -1
  76. package/src/lib/orchestrator/projection-claude-commands.ts +2 -2
  77. package/src/lib/orchestrator/projection-claude-entry.ts +42 -21
  78. package/src/lib/orchestrator/projection-claude-links.ts +32 -8
  79. package/src/lib/orchestrator/projection-claude-skills.ts +2 -2
  80. package/src/lib/orchestrator/projection-entries.ts +22 -18
  81. package/src/lib/orchestrator/projection-opencode-copies.ts +65 -21
  82. package/src/lib/orchestrator/projection-runtime-documents.ts +66 -43
  83. package/src/lib/orchestrator/projection-types.ts +28 -1
  84. package/src/lib/orchestrator/refresh-working-claude-links.ts +3 -1
  85. package/src/lib/orchestrator/session-prepare.ts +6 -1
  86. package/src/lib/orchestrator/setup-compatibilities.ts +1 -1
  87. package/src/lib/orchestrator/types.ts +4 -0
  88. package/src/lib/orchestrator/umbrella-checkouts.ts +102 -0
  89. package/src/lib/orchestrator/working-repo-projection.ts +24 -4
  90. package/src/lib/orchestrator/wrap-pass.ts +1 -0
  91. package/src/lib/public-npm.ts +95 -50
  92. package/src/lib/session-state.ts +72 -2
  93. package/src/lib/update-checker.ts +7 -1
  94. package/src/lib/usage/aggregate.ts +202 -0
  95. package/src/lib/usage/cache.ts +87 -0
  96. package/src/lib/usage/claude-pricing.ts +71 -0
  97. package/src/lib/usage/claude.ts +189 -0
  98. package/src/lib/usage/collect.ts +56 -0
  99. package/src/lib/usage/opencode.ts +188 -0
  100. package/src/lib/usage/records.ts +80 -0
  101. package/src/lib/usage/rtk-database.ts +72 -0
  102. package/src/lib/usage/savings.ts +209 -0
  103. package/src/lib/usage/scope.ts +182 -0
  104. package/src/lib/usage/source.ts +102 -0
  105. package/src/lib/usage/types.ts +143 -0
  106. package/src/lib/usage/window.ts +37 -0
  107. package/src/lib/workset/factory-local.ts +157 -0
  108. package/src/lib/workset/record.ts +25 -11
  109. package/src/lib/workset/repositories.ts +118 -25
  110. package/src/lib/workset/worktree-include.ts +161 -0
  111. package/src/lib/workset/worktree-index.ts +6 -2
  112. package/src/lib/workset/worktree.ts +591 -101
  113. package/src/opencode/companion-hooks.ts +46 -8
  114. package/src/opencode/companion-policy.ts +18 -5
  115. package/src/opencode/enter-worktree.ts +254 -6
  116. package/src/opencode/session-register.ts +2 -2
  117. package/src/runtime/claude-bg-isolation.ts +138 -0
  118. package/src/runtime/companion-git.ts +10 -2
  119. package/src/runtime/companion-guidance.ts +17 -4
  120. package/src/runtime/current-branch.ts +16 -2
  121. package/src/runtime/entered-worktree.ts +24 -0
  122. package/src/runtime/git-tracked.ts +60 -0
  123. package/src/runtime/repo-destination.ts +72 -0
  124. package/src/runtime/repo-local.ts +25 -3
  125. package/src/runtime/rtk-git-guard.ts +66 -0
  126. package/src/runtime/runtime-document-manifest.ts +229 -19
  127. package/src/runtime/runtime-document-manifest.typecheck.ts +10 -0
  128. package/src/runtime/secret-guard.ts +9 -2
  129. package/src/runtime/secret-policy-weakening.ts +122 -0
  130. package/src/runtime/serving-claude-wrap.ts +15 -2
  131. package/src/runtime/umbrella-folder.ts +56 -0
  132. package/src/runtime/wrap-state.ts +5 -13
  133. package/src/studio.ts +37 -0
  134. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +61 -6
  135. package/src/templates/mate-skills/agents/mate-explore-change/SKILL.md +8 -4
  136. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +9 -5
  137. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +5 -4
  138. package/src/templates/mate-skills/agents/mate-show-me/SKILL.md +10 -4
  139. package/src/templates/mate-skills/agents/mate-simplify-code/SKILL.md +5 -1
  140. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +61 -6
  141. package/src/templates/mate-skills/claude/mate-explore-change/SKILL.md +8 -4
  142. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +9 -5
  143. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +5 -4
  144. package/src/templates/mate-skills/claude/mate-show-me/SKILL.md +10 -4
  145. package/src/templates/mate-skills/claude/mate-simplify-code/SKILL.md +5 -1
  146. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +305 -42
  147. package/src/tools/setup/capabilities/rtk.ts +93 -1
  148. package/src/tools/setup/dynamic-plugins/audiences.ts +65 -21
  149. package/src/tools/setup/dynamic-plugins/frozen.ts +32 -13
  150. package/src/tools/setup/dynamic-plugins/hydrate.ts +4 -4
  151. package/src/tools/setup/dynamic-plugins/install.ts +24 -22
  152. package/src/tools/setup/dynamic-plugins/loader.ts +11 -7
  153. package/src/tools/setup/dynamic-plugins/paths.ts +30 -10
  154. package/src/tools/setup/dynamic-plugins/verify.ts +10 -7
  155. package/src/tools/setup/dynamic-plugins/workspaces.ts +153 -0
  156. package/src/tools/setup/mate.ts +3 -3
  157. package/src/tools/setup/plugins/gitignore.ts +15 -9
  158. package/src/tools/setup/providers/claude-plugin-hooks.ts +12 -0
  159. package/src/tools/setup/providers/claude.ts +25 -3
  160. package/src/tools/setup/utils.ts +4 -2
  161. package/src/tools/setup/working-repo-cleanup.ts +2 -2
  162. package/src/tools/setup.ts +25 -14
  163. package/studio-dist/client/assets/app-D9cw6szy.css +2 -0
  164. package/studio-dist/client/assets/artifacts-WD2ZXYrx.js +1 -0
  165. package/studio-dist/client/assets/button-Br0O1sXw.js +1 -0
  166. package/studio-dist/client/assets/combobox-DA7RAUUZ.js +1 -0
  167. package/studio-dist/client/assets/companion-view-CrabvxS8.js +1 -0
  168. package/studio-dist/client/assets/factory-DGS0E16C.js +6 -0
  169. package/studio-dist/client/assets/fields-6aXBpFhJ.js +1 -0
  170. package/studio-dist/client/assets/getting-started-Clde4w6P.js +1 -0
  171. package/studio-dist/client/assets/getting-started-D6kgWwWZ.js +1 -0
  172. package/studio-dist/client/assets/getting-started._topic-BiunccbT.js +1 -0
  173. package/studio-dist/client/assets/getting-started.index-DpiNoGw8.js +1 -0
  174. package/studio-dist/client/assets/graph-B_TCBVbu.js +2 -0
  175. package/studio-dist/client/assets/graph-canvas-Ba37Y5AE.js +3242 -0
  176. package/studio-dist/client/assets/guides-Du_RtJxP.js +1 -0
  177. package/studio-dist/client/assets/index-Df8L1LQa.js +40 -0
  178. package/studio-dist/client/assets/jsx-runtime-MZURdZre.js +1 -0
  179. package/studio-dist/client/assets/markdown-view-BOX6x0rL.js +1 -0
  180. package/studio-dist/client/assets/panel-dbmCx7Mx.js +1 -0
  181. package/studio-dist/client/assets/queries-RvHeXY12.js +1 -0
  182. package/studio-dist/client/assets/react-3QStrcDO.js +27 -0
  183. package/studio-dist/client/assets/report-url-XRL0x1SY.js +1 -0
  184. package/studio-dist/client/assets/reports-r3IK7Doz.js +1 -0
  185. package/studio-dist/client/assets/routes-C0A5LTFc.js +1 -0
  186. package/studio-dist/client/assets/select-CnaMd617.js +1 -0
  187. package/studio-dist/client/assets/skills-CzjzHpBT.js +1 -0
  188. package/studio-dist/client/assets/specs-B0ldF_6J.js +1 -0
  189. package/studio-dist/client/assets/specs-view-BnCLA0gW.js +1 -0
  190. package/studio-dist/client/assets/spinner-Dcm3fqK1.js +1 -0
  191. package/studio-dist/client/assets/steps-C0p2N1Pb.js +1 -0
  192. package/studio-dist/client/assets/store-Dw34catY.js +1 -0
  193. package/studio-dist/client/assets/studio-Cpz_HRHp.js +100 -0
  194. package/studio-dist/client/assets/studio-queries-ibmpFo6R.js +2 -0
  195. package/studio-dist/client/assets/usage-C2QJ_0IZ.js +55 -0
  196. package/studio-dist/client/assets/useAnchoredPopupScrollLock-Bj-FWb8z.js +1 -0
  197. package/studio-dist/client/assets/useMutation-aAr2uiay.js +1 -0
  198. package/studio-dist/client/assets/useSelector-AYcH7lB0.js +2 -0
  199. package/studio-dist/client/assets/vault-BGcxkSIY.js +1 -0
  200. package/studio-dist/client/assets/warnings-R1cE1rLf.js +1 -0
  201. package/studio-dist/client/assets/workflow-C2qTrMDH.js +1 -0
  202. package/studio-dist/server/assets/__23tanstack-start-server-fn-resolver-Bn896ZYj.js +122 -0
  203. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +102 -35
  204. package/studio-dist/server/assets/{actions-Bvgj9eb8.js → actions-DYSv-9VV.js} +10 -4
  205. package/studio-dist/server/assets/artifacts-DnF9L3dZ.js +216 -0
  206. package/studio-dist/server/assets/{button-CIJqAhni.js → button-CgOIVdmD.js} +13 -1702
  207. package/studio-dist/server/assets/combobox-DV_s9W0s.js +483 -0
  208. package/studio-dist/server/assets/{companion-view-DISASvdJ.js → companion-view-BKVXD3TO.js} +3 -3
  209. package/studio-dist/server/assets/companions-C7fctnU9.js +31 -0
  210. package/studio-dist/server/assets/{createServerRpc-tK2lE9R2.js → createServerRpc-bFKFpGFG.js} +1 -1
  211. package/studio-dist/server/assets/{factory-DUTa0eDs.js → factory-C7Ybg0xG.js} +1256 -353
  212. package/studio-dist/server/assets/{factory-DGPmNGbo.js → factory-Df5uAHjb.js} +53 -6
  213. package/studio-dist/server/assets/fields-BbieQTD0.js +1190 -0
  214. package/studio-dist/server/assets/getting-started-B136TP57.js +4 -0
  215. package/studio-dist/server/assets/getting-started-CRxMWorQ.js +67 -0
  216. package/studio-dist/server/assets/getting-started._topic-DJKQAzYl.js +13 -0
  217. package/studio-dist/server/assets/getting-started.index-D84gec1t.js +13 -0
  218. package/studio-dist/server/assets/graph-CSje3029.js +801 -0
  219. package/studio-dist/server/assets/graph-DDZzXM1L.js +16 -0
  220. package/studio-dist/server/assets/graph-canvas-22bWB5-2.js +21066 -0
  221. package/studio-dist/server/assets/graph-wire-BdSUx0G5.js +58 -0
  222. package/studio-dist/server/assets/guides-D9dk1Frq.js +13 -0
  223. package/studio-dist/server/assets/guides-IE-19POz.js +5 -0
  224. package/studio-dist/server/assets/guides.server-vcYRY5wx.js +66 -0
  225. package/studio-dist/server/assets/jsx-runtime-Bt0s0YKS.js +451 -0
  226. package/studio-dist/server/assets/{markdown-view-Bn7xPdks.js → markdown-view-BR8dJ7aR.js} +28 -9
  227. package/studio-dist/server/assets/{panel-3Jmn4awF.js → panel-BR_t9iMM.js} +4 -4
  228. package/studio-dist/server/assets/queries-DWoTin-q.js +32 -0
  229. package/studio-dist/server/assets/react-CdqSUhaL.js +89 -0
  230. package/studio-dist/server/assets/redirect-BaZ_QyqF.js +39 -0
  231. package/studio-dist/server/assets/report-url-BUXPcE_8.js +9 -0
  232. package/studio-dist/server/assets/{reports-D6YMqhnO.js → reports-CQ9qQ1-n.js} +9 -10
  233. package/studio-dist/server/assets/{reports-C06RXVE2.js → reports-dYDEoBeq.js} +3 -3
  234. package/studio-dist/server/assets/{router-C8MGqlAY.js → router-DkRHNTpE.js} +787 -2862
  235. package/studio-dist/server/assets/{routes-BcFgvqf7.js → routes-B6GfOew4.js} +22 -171
  236. package/studio-dist/server/assets/{search-JAKurDNh.js → search-BJnWLfkG.js} +21 -2
  237. package/studio-dist/server/assets/select-Af7Wibii.js +1609 -0
  238. package/studio-dist/server/assets/{shell-DS3wUexh.js → shell-Hq-hXgnT.js} +6 -5
  239. package/studio-dist/server/assets/{skills-BEnOxiDl.js → skills-B7nEuVbx.js} +9 -8
  240. package/studio-dist/server/assets/{skills-CtrBAtX3.js → skills-B_YYL7q8.js} +3 -3
  241. package/studio-dist/server/assets/specs-BpLUFntA.js +51 -0
  242. package/studio-dist/server/assets/specs-view-0peMVd22.js +426 -0
  243. package/studio-dist/server/assets/spinner-CdwJW4VB.js +20 -0
  244. package/studio-dist/server/assets/{steps-Dq_CwY_s.js → steps-D56DApvK.js} +1 -1
  245. package/studio-dist/server/assets/store-Cs17okNG.js +280 -0
  246. package/studio-dist/server/assets/studio-CAcKp3bM.js +10340 -0
  247. package/studio-dist/server/assets/studio-queries-BtRGzDdh.js +1451 -0
  248. package/studio-dist/server/assets/usage-COdjd1gD.js +25570 -0
  249. package/studio-dist/server/assets/usage-f6pqE1tm.js +24 -0
  250. package/studio-dist/server/assets/useAnchoredPopupScrollLock-DlBKHRw7.js +756 -0
  251. package/studio-dist/server/assets/useMutation-DzTZGenE.js +690 -0
  252. package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-M2GBs8s3.js → useSelector-DUmCUXAs.js} +4 -668
  253. package/studio-dist/server/assets/{vault-Fvxt2Tzl.js → vault-BDuIUq0F.js} +8 -5
  254. package/studio-dist/server/assets/{vault-BmWnryh3.js → vault-BVLp6zu3.js} +3 -3
  255. package/studio-dist/server/assets/{views-BgYa-za2.js → views-flRUr21z.js} +4 -4
  256. package/studio-dist/server/assets/{warnings-DzR6fyZh.js → warnings-CDy9pdgL.js} +3 -2
  257. package/studio-dist/server/assets/{delivery-path-C29fBynY.js → workflow-D9GKI2EV.js} +132 -106
  258. package/studio-dist/server/server.js +582 -8
  259. package/src/cli/commands/report/collector.ts +0 -288
  260. package/studio-dist/client/assets/app-CdPiFv59.css +0 -2
  261. package/studio-dist/client/assets/button-BIIHE0EQ.js +0 -3
  262. package/studio-dist/client/assets/companion-view-DM6YyXaR.js +0 -1
  263. package/studio-dist/client/assets/delivery-path-DELxj0Av.js +0 -1
  264. package/studio-dist/client/assets/factory-BZy0E8ty.js +0 -4
  265. package/studio-dist/client/assets/index-B3wkMzjA.js +0 -40
  266. package/studio-dist/client/assets/markdown-view-pQ2Qp_i5.js +0 -1
  267. package/studio-dist/client/assets/panel-CbajlC3p.js +0 -1
  268. package/studio-dist/client/assets/prepaint-CwSrpdFA.js +0 -27
  269. package/studio-dist/client/assets/react-CN2GSx7x.js +0 -1
  270. package/studio-dist/client/assets/reports-DllhYQ5_.js +0 -1
  271. package/studio-dist/client/assets/rolldown-runtime-WkwZ5CU-.js +0 -1
  272. package/studio-dist/client/assets/routes-COm-G3mK.js +0 -1
  273. package/studio-dist/client/assets/skills-DmWAy-jZ.js +0 -1
  274. package/studio-dist/client/assets/specs-BG3Wi3ln.js +0 -1
  275. package/studio-dist/client/assets/steps-DFsH3Neu.js +0 -1
  276. package/studio-dist/client/assets/vault-B2q1nBY5.js +0 -1
  277. package/studio-dist/client/assets/warnings-BSXIyuSQ.js +0 -1
  278. package/studio-dist/client/assets/workflow-DlsQD6Hc.js +0 -1
  279. package/studio-dist/server/assets/companions-BYbHWKOZ.js +0 -15
  280. package/studio-dist/server/assets/createServerFn-F5sAOF8V.js +0 -459
  281. package/studio-dist/server/assets/prepaint-DJfTQ_VH.js +0 -45
  282. package/studio-dist/server/assets/react-Ce6dj15C.js +0 -46
  283. package/studio-dist/server/assets/rolldown-runtime-DYf_mQCB.js +0 -34
  284. package/studio-dist/server/assets/specs-C8rv34-5.js +0 -211
  285. package/studio-dist/server/assets/studio-BeltxxKt.js +0 -216
  286. package/studio-dist/server/assets/workflow-liRYecHk.js +0 -73
@@ -1,14 +1,20 @@
1
- import { i as __toESM } from "./rolldown-runtime-DYf_mQCB.js";
2
- import { B as useMutation, O as inField, V as useSuspenseQuery, _ as nextStepOf, d as parseMessage, f as sendMessage, g as milestonesOf, h as factoryHome, l as loadWTerm, m as activityOf, p as ACTIVITY_LABELS, s as Route, u as openTerminalSocket, v as pathNodeOf, y as situationOf } from "./router-C8MGqlAY.js";
3
- import { Ar as cn, Br as factoryQuery, Fr as afterFactoryAction, Ii as useQueryClient, Qr as runFactoryAction, Vi as useNavigate, at as Pills, di as factoryLogStreamRoute, ei as agentCredentialKey, fi as useQuery, ii as REPORT_VIEW_PREFIX, li as TERMINAL_WASM, ni as clearAgentCredential, nt as ListCard, ri as setAgentCredential, rt as PAGE_PAD, ti as agentCredentialQuery, ui as factoryLogRoute } from "./button-CIJqAhni.js";
4
- import { j as require_react, u as require_jsx_runtime } from "./__23tanstack-start-server-fn-resolver-M2GBs8s3.js";
5
- import { n as outcomeActions } from "./actions-Bvgj9eb8.js";
6
- import { t as Warnings } from "./warnings-DzR6fyZh.js";
7
- import { a as SheetClose, i as Sheet, o as SheetContent, r as SidePanel, s as SheetTitle } from "./panel-3Jmn4awF.js";
8
- import { n as WorkflowGraphView } from "./delivery-path-C29fBynY.js";
9
- import { t as create } from "./react-Ce6dj15C.js";
10
- import "./studio-BeltxxKt.js";
11
- import { n as workflowPlan } from "./steps-Dq_CwY_s.js";
1
+ import { A as gitTokensQuery, B as inField, C as pathPositionOf, D as GitTokenForm, G as DialogTitle, H as DialogClose, M as tokenCovers, O as clearGitToken, S as nextStepOf, St as useSuspenseQuery, U as DialogContent, V as Dialog, W as DialogDescription, _ as ACTIVITY_LABELS, b as factoryHome, d as Route, g as sendMessage, h as parseMessage, j as hostOf, k as gitTokensKey, m as openTerminalSocket, mt as useAppearance, p as loadWTerm, v as PATH_STEPS, w as situationOf, x as milestonesOf, y as activityOf } from "./router-DkRHNTpE.js";
2
+ import { D as clearAgentCredential, F as TERMINAL_WASM, I as factoryLogRoute, L as factoryLogStreamRoute, O as setAgentCredential, S as runFactoryAction, T as agentCredentialQuery, b as addRepository, n as afterFactoryAction, p as vaultChildrenQuery, pt as useNavigate, s as factoryQuery, w as agentCredentialKey, x as removeRepository } from "./studio-queries-BtRGzDdh.js";
3
+ import { n as require_react, o as __toESM, t as require_jsx_runtime } from "./jsx-runtime-Bt0s0YKS.js";
4
+ import { Dr as useQuery, Tr as cn, r as Icon, t as Button, zr as useQueryClient } from "./button-CgOIVdmD.js";
5
+ import { i as require_react_dom } from "../server.js";
6
+ import { t as Warnings } from "./warnings-CDy9pdgL.js";
7
+ import { n as outcomeActions } from "./actions-DYSv-9VV.js";
8
+ import { i as PathSteps, t as ArtifactBody } from "./artifacts-DnF9L3dZ.js";
9
+ import { c as PAGE_PAD, d as Progress, s as ListCard, u as Pills } from "./store-Cs17okNG.js";
10
+ import { a as Select, c as SelectTrigger, l as SelectValue, o as SelectContent, s as SelectItem } from "./select-Af7Wibii.js";
11
+ import { a as SheetClose, i as Sheet, o as SheetContent, r as SidePanel, s as SheetTitle } from "./panel-BR_t9iMM.js";
12
+ import { t as useMutation } from "./useMutation-DzTZGenE.js";
13
+ import { t as Input } from "./fields-BbieQTD0.js";
14
+ import { t as create } from "./react-CdqSUhaL.js";
15
+ import { t as reportSrc } from "./report-url-BUXPcE_8.js";
16
+ import "./studio-CAcKp3bM.js";
17
+ import { t as Spinner } from "./spinner-CdwJW4VB.js";
12
18
  // ../mate-core/src/lib/factory/runner/questions.ts
13
19
  /**
14
20
  * A waiting state's questions; a state written before questions were grouped holds one
@@ -19,12 +25,78 @@ function questionsOf(state) {
19
25
  const single = state;
20
26
  return typeof single.question === "string" ? [single] : [];
21
27
  }
22
- // src/views/factory/factory-companion.ts
28
+ // src/views/factory/change-doc.tsx
29
+ var import_react_dom = /* @__PURE__ */ __toESM(require_react_dom(), 1);
23
30
  var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
31
+ var import_jsx_runtime = require_jsx_runtime();
32
+ var TITLES = {
33
+ spec: "Spec",
34
+ tasks: "Tasks"
35
+ };
36
+ /** The change's spec deltas, one section per capability folder. */
37
+ function SpecDocs({ companion, dir }) {
38
+ const folders = useQuery(vaultChildrenQuery(companion, `${dir}/specs`));
39
+ if (folders.isPending) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
40
+ className: "m-0 text-sm text-muted",
41
+ children: "Loading…"
42
+ });
43
+ if (folders.isError) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
44
+ className: "m-0 text-sm text-muted",
45
+ children: "The spec could not be read."
46
+ });
47
+ const specs = (folders.data?.entries ?? []).filter((entry) => entry.kind === "directory");
48
+ if (specs.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
49
+ className: "m-0 text-sm text-muted",
50
+ children: "The change has no spec yet."
51
+ });
52
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: specs.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
53
+ "aria-label": `Spec ${entry.name}`,
54
+ children: [specs.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", {
55
+ className: "mono",
56
+ children: entry.name
57
+ }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArtifactBody, {
58
+ companion,
59
+ path: `${entry.path}/spec.md`
60
+ })]
61
+ }, entry.path)) });
62
+ }
63
+ /** A change's spec or task list in place of the Outcome's content, like a report; Back returns. */
64
+ function ChangeDoc({ companion, change, doc, onBack }) {
65
+ const dir = `openspec/changes/${change}`;
66
+ const back = (0, import_react.useRef)(null);
67
+ (0, import_react.useEffect)(() => back.current?.focus(), []);
68
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
69
+ className: "outcome-dialog-head outcome-report-head",
70
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
71
+ ref: back,
72
+ type: "button",
73
+ className: "outcome-report-back",
74
+ onClick: onBack,
75
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "left" }), " Back"]
76
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", { children: [
77
+ TITLES[doc],
78
+ " · ",
79
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
80
+ className: "mono",
81
+ children: change
82
+ })
83
+ ] })]
84
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
85
+ className: "outcome-doc",
86
+ "data-outcome-doc": doc,
87
+ children: doc === "spec" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SpecDocs, {
88
+ companion,
89
+ dir
90
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ArtifactBody, {
91
+ companion,
92
+ path: `${dir}/tasks.md`
93
+ })
94
+ })] });
95
+ }
96
+ // src/views/factory/factory-companion.ts
24
97
  /** The companion the board acts on; set once by the Factory view. */
25
98
  var FactoryCompanion = (0, import_react.createContext)("");
26
99
  // src/views/factory/agents-dialog.tsx
27
- var import_jsx_runtime = require_jsx_runtime();
28
100
  /** Each tab's form: what it asks for, and how to get it. */
29
101
  var TABS = [{
30
102
  kind: "subscription",
@@ -208,13 +280,322 @@ function AgentsDialog({ onClose }) {
208
280
  })
209
281
  });
210
282
  }
283
+ // src/views/factory/git-access-dialog.tsx
284
+ function sourceText(token) {
285
+ return token.source === "studio" ? `set in Studio${token.setAt ? ` on ${token.setAt.slice(0, 10)}` : ""}` : "supplied at startup";
286
+ }
287
+ /** The Git access panel, sliding over the page: Git tokens per host or organization for cloning. */
288
+ function GitAccessDialog({ onClose }) {
289
+ const queryClient = useQueryClient();
290
+ const status = useQuery(gitTokensQuery());
291
+ const [saved, setSaved] = (0, import_react.useState)(false);
292
+ const clear = useMutation({
293
+ mutationFn: clearGitToken,
294
+ onSuccess: (next) => {
295
+ queryClient.setQueryData(gitTokensKey, next);
296
+ setSaved(false);
297
+ }
298
+ });
299
+ const tokens = status.data?.tokens ?? [];
300
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sheet, {
301
+ open: true,
302
+ onOpenChange: (open) => {
303
+ if (!open) onClose();
304
+ },
305
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SheetContent, {
306
+ className: "agents-dialog",
307
+ "aria-labelledby": "git-access-title",
308
+ initialFocus: () => document.querySelector(".agents-dialog .outcome-dialog-close"),
309
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
310
+ className: "outcome-dialog-head",
311
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
312
+ className: "outcome-dialog-heading",
313
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SheetTitle, {
314
+ id: "git-access-title",
315
+ children: "Git access"
316
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
317
+ className: "outcome-dialog-state",
318
+ "data-git-access-status": "",
319
+ children: status.error ? status.error.message : status.data ? `${tokens.length} ${tokens.length === 1 ? "key" : "keys"} set.` : "Checking…"
320
+ })]
321
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SheetClose, {
322
+ className: "outcome-dialog-close",
323
+ "aria-keyshortcuts": "Escape",
324
+ children: ["Close ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "Esc" })]
325
+ })]
326
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
327
+ className: "agents-dialog-body",
328
+ children: [
329
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
330
+ className: "note",
331
+ children: "A token clones private repositories. Set it for a host, or for a host and organization; the organization's token wins. Tokens are kept by the factory and never shown again."
332
+ }),
333
+ tokens.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
334
+ className: "git-access-keys",
335
+ "data-git-access-keys": "",
336
+ children: tokens.map((token) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
337
+ "data-git-access-key": token.key,
338
+ children: [
339
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
340
+ className: "mono",
341
+ children: token.key
342
+ }),
343
+ " ",
344
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
345
+ className: "note",
346
+ children: sourceText(token)
347
+ }),
348
+ token.source === "studio" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
349
+ type: "button",
350
+ onClick: () => clear.mutate(token.key),
351
+ disabled: clear.isPending,
352
+ children: "Remove"
353
+ }) : null
354
+ ]
355
+ }, token.key))
356
+ }) : null,
357
+ clear.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
358
+ className: "factory-problems",
359
+ role: "alert",
360
+ children: clear.error.message
361
+ }) : null,
362
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GitTokenForm, { onSaved: () => setSaved(true) }),
363
+ saved ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
364
+ className: "note",
365
+ role: "status",
366
+ children: "Saved. The next clone uses it."
367
+ }) : null
368
+ ]
369
+ })]
370
+ })
371
+ });
372
+ }
373
+ // src/views/factory/repository-dialog.tsx
374
+ var MODES = [{
375
+ mode: "url",
376
+ label: "Git URL",
377
+ field: "Git URL of the repository",
378
+ placeholder: "https://git.acme.test/acme/web.git",
379
+ hint: "The factory checks the remote answers before it is listed. A private repository asks for a Git token."
380
+ }, {
381
+ mode: "path",
382
+ label: "Local path",
383
+ field: "Absolute path of a checkout",
384
+ placeholder: "/home/dev/acme-web",
385
+ hint: "Only the checkout's origin URL is listed. The factory clones from that URL, so commits not pushed there are not seen."
386
+ }];
387
+ /** Adds a Working Repository to the companion's list by Git URL or from a local checkout, and removes listed ones. */
388
+ function RepositoryDialog({ open, companion, listed, onClose, onAdded }) {
389
+ const queryClient = useQueryClient();
390
+ const [mode, setMode] = (0, import_react.useState)("url");
391
+ const [value, setValue] = (0, import_react.useState)("");
392
+ const [refusal, setRefusal] = (0, import_react.useState)(null);
393
+ const [note, setNote] = (0, import_react.useState)(null);
394
+ const form = MODES.find((entry) => entry.mode === mode);
395
+ const input = () => mode === "url" ? {
396
+ kind: "url",
397
+ url: value
398
+ } : {
399
+ kind: "path",
400
+ path: value
401
+ };
402
+ const add = useMutation({
403
+ mutationFn: () => addRepository({ data: {
404
+ companion,
405
+ input: input()
406
+ } }),
407
+ onSuccess: async (result) => {
408
+ if (!result.ok) {
409
+ setRefusal(result);
410
+ return;
411
+ }
412
+ await afterFactoryAction(queryClient, companion);
413
+ setValue("");
414
+ setNote(result.warning ?? null);
415
+ onAdded(result.identity);
416
+ if (!result.warning) onClose();
417
+ }
418
+ });
419
+ const remove = useMutation({
420
+ mutationFn: (identity) => removeRepository({ data: {
421
+ companion,
422
+ identity
423
+ } }),
424
+ onSuccess: async (result) => {
425
+ if (result.ok) await afterFactoryAction(queryClient, companion);
426
+ else setRefusal(result);
427
+ }
428
+ });
429
+ function reset() {
430
+ setValue("");
431
+ setRefusal(null);
432
+ setNote(null);
433
+ add.reset();
434
+ }
435
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog, {
436
+ open,
437
+ onOpenChange: (next) => {
438
+ if (next) return;
439
+ reset();
440
+ onClose();
441
+ },
442
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogContent, {
443
+ className: "grid w-[min(520px,calc(100vw-32px))] gap-4 p-5",
444
+ children: [
445
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
446
+ className: "grid gap-1.5",
447
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTitle, {
448
+ className: "text-md",
449
+ children: "Add a repository"
450
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogDescription, { children: form.hint })]
451
+ }),
452
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
453
+ role: "tablist",
454
+ "aria-label": "How to add",
455
+ className: "flex gap-1.5",
456
+ children: MODES.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
457
+ type: "button",
458
+ role: "tab",
459
+ "aria-selected": mode === entry.mode,
460
+ className: cn("h-7 rounded-full border border-rule bg-transparent px-3 text-sm text-muted", mode === entry.mode && "border-accent bg-accent-soft text-text"),
461
+ onClick: () => {
462
+ setMode(entry.mode);
463
+ reset();
464
+ },
465
+ children: entry.label
466
+ }, entry.mode))
467
+ }),
468
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
469
+ className: "grid gap-3",
470
+ "data-add-repository-form": "",
471
+ onSubmit: (event) => {
472
+ event.preventDefault();
473
+ setRefusal(null);
474
+ setNote(null);
475
+ add.mutate();
476
+ },
477
+ children: [
478
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
479
+ className: "grid gap-1.5 text-sm",
480
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: form.field }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Input, {
481
+ value,
482
+ placeholder: form.placeholder,
483
+ autoComplete: "off",
484
+ spellCheck: false,
485
+ required: true,
486
+ onChange: (event) => setValue(event.currentTarget.value),
487
+ "aria-label": form.field
488
+ })]
489
+ }),
490
+ refusal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
491
+ className: "m-0 text-sm text-bad",
492
+ role: "alert",
493
+ children: refusal.reason
494
+ }) : null,
495
+ add.isError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
496
+ className: "m-0 text-sm text-bad",
497
+ role: "alert",
498
+ children: add.error instanceof Error ? add.error.message : "The repository was not added."
499
+ }) : null,
500
+ note ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
501
+ className: "m-0 text-sm text-muted",
502
+ role: "status",
503
+ children: ["Added. ", note]
504
+ }) : null,
505
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
506
+ className: "flex justify-end gap-2",
507
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogClose, {
508
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
509
+ variant: "ghost",
510
+ type: "button"
511
+ }),
512
+ children: "Close"
513
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
514
+ type: "submit",
515
+ disabled: add.isPending || value.trim() === "",
516
+ children: add.isPending ? "Checking…" : "Add repository"
517
+ })]
518
+ })
519
+ ]
520
+ }),
521
+ refusal && "tokenKey" in refusal && refusal.tokenKey ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
522
+ className: "grid gap-2 border-t border-rule pt-3",
523
+ "data-add-repository-token": "",
524
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
525
+ className: "m-0 text-sm text-muted",
526
+ children: "Set a Git token for this host, then add the repository again."
527
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GitTokenForm, {
528
+ defaultKey: refusal.tokenKey,
529
+ onSaved: () => {
530
+ setRefusal(null);
531
+ add.mutate();
532
+ }
533
+ })]
534
+ }) : null,
535
+ listed.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
536
+ className: "m-0 grid list-none gap-1.5 border-t border-rule p-0 pt-3",
537
+ "data-listed-repositories": "",
538
+ children: listed.map((identity) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
539
+ className: "flex items-center justify-between gap-2 text-sm",
540
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
541
+ className: "font-mono",
542
+ children: identity
543
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
544
+ type: "button",
545
+ variant: "ghost",
546
+ disabled: remove.isPending,
547
+ onClick: () => remove.mutate(identity),
548
+ children: "Remove"
549
+ })]
550
+ }, identity))
551
+ }) : null
552
+ ]
553
+ })
554
+ });
555
+ }
556
+ // src/views/factory/repository-token.tsx
557
+ /** Sets a Git token for the chosen repository's `host/org`, beside the Outcome form, never in it. */
558
+ function RepositoryTokenDialog({ open, tokenKey, onClose }) {
559
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Dialog, {
560
+ open,
561
+ onOpenChange: (next) => {
562
+ if (!next) onClose();
563
+ },
564
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(DialogContent, {
565
+ className: "grid w-[min(520px,calc(100vw-32px))] gap-4 p-5",
566
+ children: [
567
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
568
+ className: "grid gap-1.5",
569
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogTitle, {
570
+ className: "text-md",
571
+ children: "Set a Git token"
572
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogDescription, { children: "A token clones private repositories from this host. It is kept by the factory and never shown again." })]
573
+ }),
574
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GitTokenForm, {
575
+ defaultKey: tokenKey,
576
+ onSaved: onClose
577
+ }, tokenKey),
578
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
579
+ className: "flex justify-end",
580
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DialogClose, {
581
+ render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
582
+ variant: "ghost",
583
+ type: "button"
584
+ }),
585
+ children: "Close"
586
+ })
587
+ })
588
+ ]
589
+ })
590
+ });
591
+ }
211
592
  // src/views/factory/factory-form.tsx
212
593
  /**
213
594
  * A board action as a form: its own fields (and the pressed button's name and value) are sent
214
595
  * through one validated server function, then the board refetches. The markup stays the form
215
596
  * the server-rendered board posted, so keyboard submission and field names are unchanged.
216
597
  */
217
- function FactoryForm({ action, id, className, children, ...rest }) {
598
+ function FactoryForm({ action, id, className, children, onDone, ...rest }) {
218
599
  const companion = (0, import_react.useContext)(FactoryCompanion);
219
600
  const queryClient = useQueryClient();
220
601
  const mutation = useMutation({
@@ -232,7 +613,10 @@ function FactoryForm({ action, id, className, children, ...rest }) {
232
613
  const submitter = event.nativeEvent.submitter;
233
614
  const fields = {};
234
615
  for (const [name, value] of new FormData(form, submitter)) if (typeof value === "string") fields[name] = value;
235
- mutation.mutate(fields, { onSuccess: () => form.reset() });
616
+ mutation.mutate(fields, { onSuccess: () => {
617
+ form.reset();
618
+ onDone?.();
619
+ } });
236
620
  };
237
621
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", {
238
622
  className,
@@ -251,7 +635,7 @@ function FactoryForm({ action, id, className, children, ...rest }) {
251
635
  }) : null]
252
636
  });
253
637
  }
254
- // ../../node_modules/.bun/zustand@5.0.16+d485e2f7e55e3bff/node_modules/zustand/esm/middleware.mjs
638
+ // ../../node_modules/.bun/zustand@5.0.16+f73d66fb2ea5e116/node_modules/zustand/esm/middleware.mjs
255
639
  function createJSONStorage(getStorage, options) {
256
640
  let storage;
257
641
  try {
@@ -414,7 +798,9 @@ var useFactoryUi = create()(persist((set) => ({
414
798
  stepped: false,
415
799
  setStepped: (stepped) => set({ stepped }),
416
800
  agentsOpen: false,
417
- setAgentsOpen: (agentsOpen) => set({ agentsOpen })
801
+ setAgentsOpen: (agentsOpen) => set({ agentsOpen }),
802
+ gitAccessOpen: false,
803
+ setGitAccessOpen: (gitAccessOpen) => set({ gitAccessOpen })
418
804
  }), {
419
805
  name: "mate.factory.filter",
420
806
  storage: createJSONStorage(() => sessionStorage),
@@ -631,7 +1017,7 @@ function logReducer(state, event) {
631
1017
  }
632
1018
  }
633
1019
  /**
634
- * Follows one Outcome's run log for as long as its dialog is open. The stream keeps going
1020
+ * Follows one Outcome's run log for as long as its dialog is open; `null` follows none. The stream keeps going
635
1021
  * across stages; when a stage ends the board's own update shows the new state in place.
636
1022
  */
637
1023
  function useOutcomeLog(url) {
@@ -646,8 +1032,8 @@ function useOutcomeLog(url) {
646
1032
  ended: false
647
1033
  });
648
1034
  (0, import_react.useEffect)(() => {
649
- if (typeof EventSource === "undefined") return;
650
1035
  dispatch({ type: "reset" });
1036
+ if (!url || typeof EventSource === "undefined") return;
651
1037
  const source = new EventSource(url);
652
1038
  source.addEventListener("message", (message) => {
653
1039
  try {
@@ -662,6 +1048,14 @@ function useOutcomeLog(url) {
662
1048
  };
663
1049
  }
664
1050
  // src/terminal/outcome-terminal.tsx
1051
+ /** What the terminal says when its session ends: Claude's quit and the Outcome's return are told apart. */
1052
+ function endNotice(message) {
1053
+ if (message.reason === "returned") return "The Outcome is back with automation.";
1054
+ if (message.reason === "deleted") return "The Outcome was deleted.";
1055
+ if (message.type === "ended") return "The session ended. Return to automation when you are done, or close and reopen the Outcome to start it again.";
1056
+ if (message.status === 0 || message.status === 130) return "Claude closed. The Outcome returns to automation; if it does not, return it with the button.";
1057
+ return "Claude stopped unexpectedly. The Outcome stays with you; return it to automation when you are done.";
1058
+ }
665
1059
  /**
666
1060
  * One Outcome's Workset session in a terminal view: starts it, or attaches to the live one,
667
1061
  * and restarts a session that went away. Closing only detaches; the session keeps running for
@@ -672,17 +1066,25 @@ var OutcomeSession = class {
672
1066
  outcome;
673
1067
  companion;
674
1068
  failed;
1069
+ phase;
675
1070
  focus;
676
1071
  term = null;
677
1072
  ws = null;
678
1073
  sessionId = null;
679
1074
  observer = null;
680
1075
  closed = false;
681
- constructor(mount, outcome, companion, failed, focus) {
1076
+ /** Set at the first output, or when the session ended: from then on reasons are notices. */
1077
+ live = false;
1078
+ /** A `gone` answer restarts once; the next `ready` clears it. */
1079
+ restarted = false;
1080
+ /** Set while an `attach` awaits its `ready`. */
1081
+ attaching = false;
1082
+ constructor(mount, outcome, companion, failed, phase, focus) {
682
1083
  this.mount = mount;
683
1084
  this.outcome = outcome;
684
1085
  this.companion = companion;
685
1086
  this.failed = failed;
1087
+ this.phase = phase;
686
1088
  this.focus = focus;
687
1089
  this.open();
688
1090
  }
@@ -741,40 +1143,78 @@ var OutcomeSession = class {
741
1143
  ws.onopen = () => {
742
1144
  if (!this.term) return;
743
1145
  const { cols, rows } = this.term;
744
- if (this.sessionId) this.send({
745
- type: "attach",
746
- sessionId: this.sessionId,
747
- cols,
748
- rows
749
- });
750
- else this.start();
1146
+ if (this.sessionId) {
1147
+ this.attaching = true;
1148
+ this.send({
1149
+ type: "attach",
1150
+ sessionId: this.sessionId,
1151
+ cols,
1152
+ rows
1153
+ });
1154
+ } else this.start();
751
1155
  };
752
1156
  ws.onmessage = (event) => this.receive(event.data);
753
1157
  ws.onclose = () => {
754
- if (this.ws === ws) this.ws = null;
1158
+ if (this.ws !== ws) return;
1159
+ this.ws = null;
1160
+ if (!this.live && !this.closed) this.show({
1161
+ kind: "refused",
1162
+ reason: "The connection closed before the session started."
1163
+ });
755
1164
  };
756
1165
  }
757
1166
  receive(data) {
758
1167
  const term = this.term;
759
1168
  if (!term) return;
760
1169
  if (typeof data !== "string") {
1170
+ if (!this.live) this.show({ kind: "live" });
761
1171
  term.write(new Uint8Array(data));
762
1172
  return;
763
1173
  }
764
1174
  const message = parseMessage(data);
765
1175
  if (!message) return;
766
1176
  if (message.type === "ready") {
1177
+ this.restarted = false;
767
1178
  this.sessionId = message.sessionId ?? null;
1179
+ if (this.attaching) this.show({ kind: "live" });
1180
+ this.attaching = false;
768
1181
  term.write("\x1Bc");
769
1182
  if (this.focus) term.focus();
770
1183
  } else if (message.type === "gone") {
771
1184
  this.sessionId = null;
1185
+ this.attaching = false;
1186
+ if (this.restarted) {
1187
+ this.show({
1188
+ kind: "refused",
1189
+ reason: "The session could not be started."
1190
+ });
1191
+ return;
1192
+ }
1193
+ this.restarted = true;
1194
+ this.show({ kind: "starting" });
772
1195
  this.start();
773
1196
  } else if (message.type === "exit" || message.type === "ended") {
774
1197
  this.sessionId = null;
775
- this.notice("The session ended. Return to automation when you are done, or close and reopen the Outcome to start it again.");
1198
+ this.show({ kind: "live" });
1199
+ this.notice(endNotice(message));
776
1200
  } else if (message.type === "takenOver") this.notice("Another tab has this session now.");
777
- else if (message.type === "error" && message.reason) this.notice(message.reason);
1201
+ else if (message.type === "error" && message.reason) {
1202
+ if (this.live) this.notice(message.reason);
1203
+ else this.show({
1204
+ kind: "refused",
1205
+ reason: message.reason
1206
+ });
1207
+ }
1208
+ }
1209
+ show(phase) {
1210
+ this.live = phase.kind === "live";
1211
+ this.phase(phase);
1212
+ }
1213
+ /** Starts again after a refusal. */
1214
+ retry() {
1215
+ this.restarted = false;
1216
+ this.show({ kind: "starting" });
1217
+ this.start();
778
1218
  }
779
1219
  close() {
780
1220
  this.closed = true;
@@ -789,18 +1229,42 @@ var OutcomeSession = class {
789
1229
  function OutcomeTerminal({ outcome, companion, focus = true }) {
790
1230
  const mount = (0, import_react.useRef)(null);
791
1231
  const [failed, setFailed] = (0, import_react.useState)(false);
1232
+ const [phase, setPhase] = (0, import_react.useState)({ kind: "starting" });
1233
+ const key = `${companion}\n${outcome}`;
1234
+ const [sessionKey, setSessionKey] = (0, import_react.useState)(key);
1235
+ if (sessionKey !== key) {
1236
+ setSessionKey(key);
1237
+ setPhase({ kind: "starting" });
1238
+ }
792
1239
  const focusOnReady = (0, import_react.useRef)(focus);
1240
+ const current = (0, import_react.useRef)(null);
793
1241
  (0, import_react.useEffect)(() => {
794
- const session = new OutcomeSession(mount.current, outcome, companion, () => setFailed(true), focusOnReady.current);
1242
+ const session = new OutcomeSession(mount.current, outcome, companion, () => setFailed(true), setPhase, focusOnReady.current);
1243
+ current.current = session;
795
1244
  return () => session.close();
796
1245
  }, [outcome, companion]);
797
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
798
- ref: mount,
799
- className: "outcome-terminal",
800
- "data-outcome-terminal": outcome,
801
- "data-companion": companion,
802
- "data-terminal-error": failed ? "" : void 0,
803
- children: failed ? "The terminal could not start in this browser. Close and reopen the Outcome to retry." : null
1246
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1247
+ className: "outcome-terminal-frame",
1248
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1249
+ ref: mount,
1250
+ className: "outcome-terminal",
1251
+ "data-outcome-terminal": outcome,
1252
+ "data-companion": companion,
1253
+ "data-terminal-error": failed ? "" : void 0,
1254
+ children: failed ? "The terminal could not start in this browser. Close and reopen the Outcome to retry." : null
1255
+ }), phase.kind === "live" || failed ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1256
+ className: "outcome-terminal-cover",
1257
+ role: phase.kind === "refused" ? "alert" : "status",
1258
+ "data-terminal-phase": phase.kind,
1259
+ children: phase.kind === "refused" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: phase.reason }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1260
+ type: "button",
1261
+ onClick: () => current.current?.retry(),
1262
+ children: "Try again"
1263
+ })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Spinner, {
1264
+ "aria-hidden": "true",
1265
+ className: "size-7 text-accent"
1266
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "Starting the session…" })] })
1267
+ })]
804
1268
  });
805
1269
  }
806
1270
  // src/views/factory/factory-view.tsx
@@ -812,15 +1276,8 @@ var ATTENTION_LABELS = {
812
1276
  publish: "Ready to publish",
813
1277
  problem: "Something went wrong"
814
1278
  };
815
- /** What each kind of attention expects of the person, under its heading in the dialog. */
816
- var ATTENTION_HINTS = {
817
- decision: "The run is paused on this. Pick an option or answer in your words; it continues on its own.",
818
- review: "Read each report, then approve to start building, or request a change to revise the plan.",
819
- merge: "Merge the delivery branch on your forge; the board picks it up on its next refresh.",
820
- publish: "Publishing commits, tags and pushes the archived specs to the companion.",
821
- problem: "Retry runs the stage again; take control to fix it yourself.",
822
- control: "You work in the factory's own conversation. Exit Claude, then return the Outcome to automation; the factory checks what changed and continues."
823
- };
1279
+ /** What being in control means, in the note card above the terminal. */
1280
+ var CONTROL_HINT = "You work in the factory's own conversation. Exit Claude, then return the Outcome to automation; the factory checks what changed and continues.";
824
1281
  /** What Take control does, beside the button. */
825
1282
  var TAKE_CONTROL_HINT = "Pauses automation after the current stage; you continue the factory's own conversation here.";
826
1283
  var RECENT_COMPLETED = 5;
@@ -850,14 +1307,14 @@ var PRIMARY_ACTIONS = /* @__PURE__ */ new Set([
850
1307
  "retry",
851
1308
  "start"
852
1309
  ]);
853
- function ActionForm({ id, action, label, children }) {
1310
+ function ActionForm({ id, action, label, primary = PRIMARY_ACTIONS.has(action), children }) {
854
1311
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
855
1312
  id,
856
1313
  action,
857
1314
  className: "factory-action",
858
1315
  children: [children, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
859
1316
  type: "submit",
860
- className: PRIMARY_ACTIONS.has(action) ? "factory-primary" : void 0,
1317
+ className: primary ? "factory-primary" : void 0,
861
1318
  children: label
862
1319
  })]
863
1320
  });
@@ -865,13 +1322,62 @@ function ActionForm({ id, action, label, children }) {
865
1322
  /** A control for one action; none when Studio is read-only or the Outcome does not accept it. */
866
1323
  function actionFor(item, context) {
867
1324
  const accepted = outcomeActions(item.workset, item.run, context);
868
- return (action, label, children) => context.writable && accepted.has(action) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionForm, {
1325
+ return (action, label, children, primary) => context.writable && accepted.has(action) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActionForm, {
869
1326
  id: item.workset.id,
870
1327
  action,
871
1328
  label,
1329
+ primary,
872
1330
  children
873
1331
  }) : null;
874
1332
  }
1333
+ var canDelete = (item, context) => context.writable && outcomeActions(item.workset, item.run, context).has("delete");
1334
+ /**
1335
+ * Delete, offered only while the factory accepts it and behind a confirm step that names the
1336
+ * Outcome. A refusal shows in the form; `onDeleted` runs once the Outcome is gone.
1337
+ */
1338
+ function DeleteOutcome({ item, context, onDeleted }) {
1339
+ const [confirming, setConfirming] = (0, import_react.useState)(false);
1340
+ const confirm = (0, import_react.useRef)(null);
1341
+ (0, import_react.useEffect)(() => {
1342
+ if (confirming) confirm.current?.focus();
1343
+ }, [confirming]);
1344
+ const { workset, run } = item;
1345
+ if (!canDelete(item, context)) return null;
1346
+ if (!confirming) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1347
+ type: "button",
1348
+ className: "factory-delete",
1349
+ onClick: () => setConfirming(true),
1350
+ children: "Delete"
1351
+ });
1352
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
1353
+ id: workset.id,
1354
+ action: "delete",
1355
+ className: "factory-action factory-confirm",
1356
+ onDone: onDeleted,
1357
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1358
+ className: "note",
1359
+ children: [
1360
+ "Delete “",
1361
+ workset.title,
1362
+ "”?",
1363
+ runActive(run) ? " Its run will be stopped first." : "",
1364
+ " Its request is removed; branches stay."
1365
+ ]
1366
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1367
+ className: "factory-confirm-actions",
1368
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1369
+ ref: confirm,
1370
+ type: "submit",
1371
+ className: "factory-delete",
1372
+ children: "Delete outcome"
1373
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1374
+ type: "button",
1375
+ onClick: () => setConfirming(false),
1376
+ children: "Cancel"
1377
+ })]
1378
+ })]
1379
+ });
1380
+ }
875
1381
  /** The Outcome's state as a coloured dot; the text beside it says the same in words. */
876
1382
  function ActivityDot({ activity }) {
877
1383
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
@@ -881,57 +1387,162 @@ function ActivityDot({ activity }) {
881
1387
  "aria-hidden": "true"
882
1388
  });
883
1389
  }
1390
+ /** Opens the Add repository dialog and keeps the repository chosen for the next Outcome. */
1391
+ function useRepositoryChoice(repositories, sources, companion) {
1392
+ const [open, setOpen] = (0, import_react.useState)(false);
1393
+ const [chosen, setChosen] = (0, import_react.useState)(null);
1394
+ const listed = Object.entries(sources ?? {}).flatMap(([identity, kind]) => kind === "list" ? [identity] : []);
1395
+ return {
1396
+ ask: () => setOpen(true),
1397
+ dialog: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RepositoryDialog, {
1398
+ open,
1399
+ companion,
1400
+ listed,
1401
+ onClose: () => setOpen(false),
1402
+ onAdded: setChosen
1403
+ }),
1404
+ value: chosen !== null && repositories.includes(chosen) ? chosen : repositories[0] ?? "",
1405
+ choose: setChosen
1406
+ };
1407
+ }
1408
+ var SOURCE_LABELS = {
1409
+ linked: "linked",
1410
+ list: "listed",
1411
+ environment: "configured"
1412
+ };
1413
+ /** `acme/web · git.acme.test · listed`: the repository, the Git host it clones from and its source. */
1414
+ function repositoryText(repository, sources, keys) {
1415
+ const key = keys?.[repository];
1416
+ const host = key ? hostOf(key) : null;
1417
+ const source = sources?.[repository];
1418
+ return [
1419
+ repository,
1420
+ host,
1421
+ source ? SOURCE_LABELS[source] : null
1422
+ ].filter(Boolean).join(" · ");
1423
+ }
1424
+ /** Whether the factory holds a Git token for the chosen repository, and Set token when it can. */
1425
+ function TokenState({ tokenKey, covered, onSet }) {
1426
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1427
+ className: "note",
1428
+ "data-repository-token": covered ? "covered" : "none",
1429
+ children: [
1430
+ covered ? `A Git token is set for ${hostOf(tokenKey)}.` : `No Git token for ${tokenKey}: only public repositories clone.`,
1431
+ " ",
1432
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1433
+ type: "button",
1434
+ "data-open-set-token": "",
1435
+ onClick: onSet,
1436
+ children: "Set token…"
1437
+ })
1438
+ ]
1439
+ });
1440
+ }
884
1441
  /** Plain-language input; Start runs it at once, Save for later keeps it unstarted. */
885
- function OutcomeInput({ repositories, context }) {
1442
+ function OutcomeInput({ repositories, sources, keys, factoryMode, context }) {
1443
+ const choice = useRepositoryChoice(repositories, sources, context.companionDigest);
1444
+ const [setting, setSetting] = (0, import_react.useState)(false);
1445
+ const tokens = useQuery({
1446
+ ...gitTokensQuery(),
1447
+ enabled: factoryMode && context.writable
1448
+ });
1449
+ const options = repositories.map((repository) => ({
1450
+ value: repository,
1451
+ label: repositoryText(repository, sources, keys)
1452
+ }));
1453
+ const tokenKey = keys?.[choice.value];
1454
+ const tokenState = factoryMode && tokens.data && tokenKey ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TokenState, {
1455
+ tokenKey,
1456
+ covered: tokenCovers(tokenKey, tokens.data.tokens),
1457
+ onSet: () => setSetting(true)
1458
+ }) : null;
1459
+ const addButton = factoryMode ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1460
+ type: "button",
1461
+ "data-open-add-repository": "",
1462
+ onClick: choice.ask,
1463
+ children: "Add repository…"
1464
+ }) : null;
886
1465
  if (!context.writable) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
887
1466
  className: "note",
888
1467
  children: "Read-only mode. Start Studio with --writable to describe outcomes."
889
1468
  });
890
- if (repositories.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
891
- className: "note",
892
- children: "Link a Working Repository to this companion to describe outcomes."
893
- });
894
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
895
- action: "create",
896
- className: "outcome-input",
897
- "data-outcome-input": "",
898
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
899
- className: "outcome-input-label",
900
- children: "What should we build or improve?"
901
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
902
- name: "text",
903
- rows: 3,
904
- required: true,
905
- placeholder: "Make onboarding easier: fewer signup steps, and keep authentication working."
906
- })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
907
- className: "outcome-input-actions",
1469
+ if (repositories.length === 0) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1470
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1471
+ className: "note",
1472
+ children: "Link a Working Repository to this companion to describe outcomes."
1473
+ }),
1474
+ addButton,
1475
+ factoryMode ? choice.dialog : null
1476
+ ] });
1477
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1478
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
1479
+ action: "create",
1480
+ className: "outcome-input",
1481
+ "data-outcome-input": "",
908
1482
  children: [
909
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
910
- type: "submit",
911
- name: "start",
912
- value: "start",
913
- className: "factory-primary",
914
- children: ["Start ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "⌘↵" })]
915
- }),
916
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
917
- type: "submit",
918
- name: "start",
919
- value: "later",
920
- children: "Save for later"
921
- }),
922
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TicketField, { context }),
923
- repositories.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
924
- name: "repository",
1483
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1484
+ className: "outcome-input-label",
1485
+ children: "What should we build or improve?"
1486
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
1487
+ name: "text",
1488
+ rows: 3,
925
1489
  required: true,
926
- "aria-label": "Working Repository",
927
- children: repositories.map((repository) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
928
- value: repository,
929
- children: repository
930
- }, repository))
931
- }) : null
1490
+ placeholder: "Make onboarding easier: fewer signup steps, and keep authentication working."
1491
+ })] }),
1492
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1493
+ className: "outcome-input-actions",
1494
+ children: [
1495
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
1496
+ type: "submit",
1497
+ name: "start",
1498
+ value: "start",
1499
+ className: "factory-primary",
1500
+ children: ["Start ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "⌘↵" })]
1501
+ }),
1502
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1503
+ type: "submit",
1504
+ name: "start",
1505
+ value: "later",
1506
+ children: "Save for later"
1507
+ }),
1508
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TicketField, { context }),
1509
+ repositories.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Select, {
1510
+ name: "repository",
1511
+ required: true,
1512
+ items: options,
1513
+ value: choice.value,
1514
+ onValueChange: (value) => {
1515
+ if (value !== null) choice.choose(value);
1516
+ },
1517
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectTrigger, {
1518
+ "aria-label": "Working Repository",
1519
+ className: "w-auto max-w-80",
1520
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectValue, {})
1521
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectContent, { children: options.map((option) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SelectItem, {
1522
+ value: option.value,
1523
+ children: option.label
1524
+ }, option.value)) })]
1525
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1526
+ "data-working-repository": "",
1527
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
1528
+ type: "hidden",
1529
+ name: "repository",
1530
+ value: choice.value
1531
+ }), repositoryText(choice.value, sources, keys)]
1532
+ }),
1533
+ addButton
1534
+ ]
1535
+ }),
1536
+ tokenState
932
1537
  ]
933
- })]
934
- });
1538
+ }),
1539
+ factoryMode ? choice.dialog : null,
1540
+ tokenKey ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RepositoryTokenDialog, {
1541
+ open: setting,
1542
+ tokenKey,
1543
+ onClose: () => setSetting(false)
1544
+ }) : null
1545
+ ] });
935
1546
  }
936
1547
  /** Milestones as a row of pips and a count; the title names the next one. */
937
1548
  function MilestoneTrack({ workset }) {
@@ -970,18 +1581,33 @@ function Checks({ checks }) {
970
1581
  }, check.name))
971
1582
  });
972
1583
  }
973
- /** Review plan and View changes, when there is something to look at. */
974
- function ResultLinks({ item }) {
975
- const reports = Object.entries(item.run?.reviewReports ?? {});
1584
+ /** Opens `change`'s report; names the change only when there are several. */
1585
+ function ReportButton({ label, change, several, onOpenReport }) {
1586
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
1587
+ type: "button",
1588
+ className: "outcome-report-open",
1589
+ "data-open-report": change,
1590
+ onClick: (event) => onOpenReport(change, event.currentTarget),
1591
+ children: [label, several ? ` · ${change}` : ""]
1592
+ });
1593
+ }
1594
+ /** Report controls name their change once the Outcome has several changes or reports. */
1595
+ function namesChanges(item) {
1596
+ const reports = Object.keys(item.run?.reviewReports ?? {});
1597
+ return item.workset.changes.length > 1 || reports.length > 1;
1598
+ }
1599
+ /** Review plan, opened in the panel, and View changes, when there is something to look at. */
1600
+ function ResultLinks({ item, onOpenReport }) {
1601
+ const reports = Object.keys(item.run?.reviewReports ?? {});
976
1602
  const compare = item.run?.compareUrl;
977
1603
  if (reports.length === 0 && !compare) return null;
978
1604
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
979
1605
  className: "outcome-results",
980
- children: [reports.map(([change, id]) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", {
981
- href: `${REPORT_VIEW_PREFIX}${id}`,
982
- target: "_blank",
983
- rel: "noreferrer",
984
- children: ["Review plan", reports.length > 1 ? ` · ${change}` : ""]
1606
+ children: [reports.map((change) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportButton, {
1607
+ label: "Review plan",
1608
+ change,
1609
+ several: namesChanges(item),
1610
+ onOpenReport
985
1611
  }, change)), compare ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
986
1612
  href: compare,
987
1613
  target: "_blank",
@@ -990,45 +1616,40 @@ function ResultLinks({ item }) {
990
1616
  }) : null]
991
1617
  });
992
1618
  }
993
- /** The stored review report per linked change, each in a frame; missing ones are named. */
994
- function ReviewReports({ item }) {
995
- const stored = item.run?.reviewReports ?? {};
996
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
997
- className: "factory-review-reports",
998
- children: item.workset.changes.map((change) => stored[change] ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("figure", {
999
- className: "factory-review-report",
1000
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("figcaption", {
1619
+ /** One review report in place of the Outcome's content, in Studio's appearance; Back returns. */
1620
+ function OutcomeReport({ change, report, onBack }) {
1621
+ const theme = useAppearance((state) => state.theme);
1622
+ const src = reportSrc(report, theme);
1623
+ const back = (0, import_react.useRef)(null);
1624
+ (0, import_react.useEffect)(() => back.current?.focus(), []);
1625
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
1626
+ className: "outcome-dialog-head outcome-report-head",
1627
+ children: [
1628
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
1629
+ ref: back,
1630
+ type: "button",
1631
+ className: "outcome-report-back",
1632
+ onClick: onBack,
1633
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "left" }), " Back"]
1634
+ }),
1635
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h2", { children: ["Review report · ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1001
1636
  className: "mono",
1002
- children: [
1003
- change,
1004
- " ·",
1005
- " ",
1006
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("a", {
1007
- href: `${REPORT_VIEW_PREFIX}${stored[change]}`,
1008
- target: "_blank",
1009
- rel: "noreferrer",
1010
- children: "open"
1011
- })
1012
- ]
1013
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("iframe", {
1014
- src: `${REPORT_VIEW_PREFIX}${stored[change]}`,
1015
- title: `Review report for ${change}`,
1016
- loading: "lazy",
1017
- sandbox: "allow-scripts allow-modals"
1018
- })]
1019
- }, change) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1020
- className: "note",
1021
- "data-report-missing": change,
1022
- children: [
1023
- "No review report for ",
1024
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1025
- className: "mono",
1026
- children: change
1027
- }),
1028
- "."
1029
- ]
1030
- }, change))
1031
- });
1637
+ children: change
1638
+ })] }),
1639
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", {
1640
+ href: src,
1641
+ target: "_blank",
1642
+ rel: "noopener noreferrer",
1643
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "external" }), " Open in new tab"]
1644
+ })
1645
+ ]
1646
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("iframe", {
1647
+ className: "outcome-report-frame",
1648
+ src,
1649
+ title: `Review report for ${change}`,
1650
+ sandbox: "allow-scripts allow-modals",
1651
+ referrerPolicy: "no-referrer"
1652
+ })] });
1032
1653
  }
1033
1654
  /** Before archive feedback revises the plan; after it, it starts a new Outcome. */
1034
1655
  function FeedbackField({ item, context }) {
@@ -1062,8 +1683,17 @@ function FeedbackField({ item, context }) {
1062
1683
  }));
1063
1684
  }
1064
1685
  var runActive = (run) => run?.state === "running" || run?.state === "queued";
1065
- /** The run's log in its dialog; the client follows it live while the dialog is open. */
1066
- function OutcomeLog({ item }) {
1686
+ /** The last lines the run wrote, for the running focus block. */
1687
+ function lastLines(pieces, count) {
1688
+ const lines = [];
1689
+ for (const piece of pieces.toReversed()) for (const line of piece.text.split("\n").toReversed()) {
1690
+ if (line.trim() !== "") lines.unshift(line);
1691
+ if (lines.length === count) return lines;
1692
+ }
1693
+ return lines;
1694
+ }
1695
+ /** The run's log in the Activity row; the client follows it live while the dialog is open. */
1696
+ function OutcomeLog({ item, log }) {
1067
1697
  const { workset, run } = item;
1068
1698
  const active = runActive(run);
1069
1699
  if (!run?.hasLog && !active) return null;
@@ -1085,12 +1715,15 @@ function OutcomeLog({ item }) {
1085
1715
  children: "Full log"
1086
1716
  })
1087
1717
  ]
1088
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LiveLog, { id: workset.id })]
1718
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LiveLog, {
1719
+ id: workset.id,
1720
+ log
1721
+ })]
1089
1722
  });
1090
1723
  }
1091
1724
  /** The stored log, then the running stage's text and tool activity as it arrives, by who wrote it. */
1092
- function LiveLog({ id }) {
1093
- const { pieces, ended } = useOutcomeLog(factoryLogStreamRoute(id));
1725
+ function LiveLog({ id, log }) {
1726
+ const { pieces, ended } = log;
1094
1727
  const ref = (0, import_react.useRef)(null);
1095
1728
  const following = (0, import_react.useRef)(true);
1096
1729
  const [reading, setReading] = (0, import_react.useState)(false);
@@ -1135,18 +1768,21 @@ function LiveLog({ id }) {
1135
1768
  }) : null]
1136
1769
  });
1137
1770
  }
1138
- /** While a person has control: the way back first, then their session on the factory's conversation. */
1771
+ /** While a person has control: a note on what that means, then their session on the factory's conversation. */
1139
1772
  function ControlSheet({ item, context }) {
1140
1773
  const { workset, run } = item;
1141
1774
  const stepped = useFactoryUi((state) => state.stepped);
1142
1775
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1143
1776
  className: "factory-sheet outcome-control",
1144
1777
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1145
- className: "outcome-control-bar",
1778
+ className: "outcome-control-note",
1146
1779
  children: [run?.control?.reason ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1147
1780
  className: "outcome-control-reason",
1148
1781
  children: run.control.reason
1149
- }) : null, actionFor(item, context)("return", "Return to automation")]
1782
+ }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1783
+ className: "note",
1784
+ children: CONTROL_HINT
1785
+ })]
1150
1786
  }), context.sessions && run?.control?.mode === "manual" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeTerminal, {
1151
1787
  outcome: workset.id,
1152
1788
  companion: context.companionDigest,
@@ -1157,56 +1793,38 @@ function ControlSheet({ item, context }) {
1157
1793
  })]
1158
1794
  });
1159
1795
  }
1160
- /** Take control and what it does, for an Outcome whose conversation the factory still drives. */
1161
- function TakeControl({ item, context }) {
1162
- const { workset, run } = item;
1163
- if (!run?.conversation || run.control || workset.stage === "done") return null;
1164
- const form = actionFor(item, context)("take-control", "Take control");
1165
- if (!form) return null;
1166
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1167
- className: "outcome-control-offer",
1168
- children: [form, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1169
- className: "note",
1170
- children: TAKE_CONTROL_HINT
1171
- })]
1172
- });
1173
- }
1174
1796
  /** Between Take control and the handover: what the person waits for, above the live log. */
1175
1797
  function TakeoverPending({ run, now }) {
1176
1798
  if (run?.control?.mode !== "takeover-requested") return null;
1177
1799
  const stage = run.state === "running" ? run.stage : null;
1178
1800
  const since = run.control.updatedAt ? ageText(run.control.updatedAt, now) : "";
1179
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
1180
- className: "outcome-dialog-attention",
1181
- "data-kind": "control",
1801
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1802
+ className: "outcome-attention-hint",
1182
1803
  "data-pending": "",
1183
1804
  role: "status",
1184
1805
  "aria-label": "Taking control",
1185
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Taking control" }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1186
- className: "outcome-attention-hint",
1187
- children: [
1188
- "Control passes to you once",
1189
- " ",
1190
- stage ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1191
- "the ",
1192
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1193
- className: "mono",
1194
- children: stage
1195
- }),
1196
- " stage"
1197
- ] }) : "the current stage",
1198
- " ",
1199
- "ends; the log below keeps following it. The terminal opens here then.",
1200
- since ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1201
- className: "factory-age mono",
1202
- children: [
1203
- " · asked ",
1204
- since,
1205
- " ago"
1206
- ]
1207
- }) : null
1208
- ]
1209
- })]
1806
+ children: [
1807
+ "Control passes to you once",
1808
+ " ",
1809
+ stage ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
1810
+ "the ",
1811
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1812
+ className: "mono",
1813
+ children: stage
1814
+ }),
1815
+ " stage"
1816
+ ] }) : "the current stage",
1817
+ " ",
1818
+ "ends; the log below keeps following it. The terminal opens here then.",
1819
+ since ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1820
+ className: "factory-age mono",
1821
+ children: [
1822
+ " · asked ",
1823
+ since,
1824
+ " ago"
1825
+ ]
1826
+ }) : null
1827
+ ]
1210
1828
  });
1211
1829
  }
1212
1830
  /** The run in a few words: what it does at which stage, and for how long. */
@@ -1215,24 +1833,59 @@ function runText(run, now) {
1215
1833
  const since = run.state === "running" ? run.startedAt : run.updatedAt;
1216
1834
  return `${run.state} ${run.stage}${since ? ` · ${ageText(since, now)}` : ""}`;
1217
1835
  }
1218
- var reportsMissing = ({ workset, run }) => workset.changes.some((change) => !run?.reviewReports?.[change]);
1219
- /** What can be done to the run itself, always in view; nothing when nothing applies. */
1220
- function RunActions({ item, context }) {
1836
+ /**
1837
+ * What can be done to the run itself, always in reach and quiet: Return to automation is the
1838
+ * primary action while the person has control. Nothing renders when nothing applies.
1839
+ */
1840
+ function OutcomeFooter({ item, context, onDeleted }) {
1221
1841
  const { workset, run } = item;
1222
1842
  const form = actionFor(item, context);
1223
- const active = runActive(run);
1224
1843
  const open = workset.stage !== "done";
1225
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1226
- className: "outcome-actions",
1227
- role: "group",
1228
- "aria-label": "Run actions",
1229
- children: [
1230
- open && !workset.queuedAt ? form("start", "Start") : null,
1231
- active ? form("cancel", "Cancel run") : null,
1232
- workset.stage === "human-review" && !reportsMissing(item) ? form("regenerate", "Regenerate reports") : null,
1233
- open && workset.queuedAt ? form("later", "Move to later") : null
1234
- ]
1844
+ const back = form("return", "Return to automation");
1845
+ const start = open && !workset.queuedAt ? form("start", "Start") : null;
1846
+ const cancel = runActive(run) ? form("cancel", "Cancel run") : null;
1847
+ const regenerate = workset.stage === "human-review" ? form("regenerate", "Regenerate reports") : null;
1848
+ const later = open && workset.queuedAt ? form("later", "Move to later") : null;
1849
+ const take = takeControlOf(item, context);
1850
+ const remove = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeleteOutcome, {
1851
+ item,
1852
+ context,
1853
+ onDeleted
1235
1854
  });
1855
+ if (![
1856
+ back,
1857
+ start,
1858
+ cancel,
1859
+ regenerate,
1860
+ later,
1861
+ take
1862
+ ].some(Boolean) && !canDelete(item, context)) return null;
1863
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("footer", {
1864
+ className: "outcome-dialog-foot",
1865
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1866
+ className: "outcome-actions",
1867
+ role: "group",
1868
+ "aria-label": "Run actions",
1869
+ children: [
1870
+ back,
1871
+ start,
1872
+ cancel,
1873
+ regenerate,
1874
+ later,
1875
+ take,
1876
+ remove
1877
+ ]
1878
+ }), take ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1879
+ className: "note",
1880
+ children: TAKE_CONTROL_HINT
1881
+ }) : null]
1882
+ });
1883
+ }
1884
+ /** Take control, for an Outcome whose conversation the factory still drives. */
1885
+ function takeControlOf(item, context) {
1886
+ const { workset, run } = item;
1887
+ if (!run?.conversation || run.control || workset.stage === "done") return null;
1888
+ return actionFor(item, context)("take-control", "Take control");
1236
1889
  }
1237
1890
  /** The execution facts beside the map: stage, changes, run and branch. */
1238
1891
  function Facts({ item, context }) {
@@ -1261,13 +1914,6 @@ function Facts({ item, context }) {
1261
1914
  ]
1262
1915
  });
1263
1916
  }
1264
- /** The current node's note on the map: how the stage stands, with an age while it runs. */
1265
- function progressNote(item, activity, now) {
1266
- const { run } = item;
1267
- const label = ACTIVITY_LABELS[activity].toLowerCase();
1268
- if (run?.state === "running" && now !== void 0) return `${label} · ${ageText(run.startedAt, now)}`;
1269
- return activity === "idle" ? "" : label;
1270
- }
1271
1917
  /** The recommendation, marked in words beside the option it belongs to. */
1272
1918
  function RecommendedTag() {
1273
1919
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
@@ -1494,8 +2140,110 @@ function DecisionSheet({ item, run, context }) {
1494
2140
  context
1495
2141
  });
1496
2142
  }
2143
+ /** The plan under review: what to read, then Approve plan or Request changes, in place. */
2144
+ function PlanReview({ item, context, onOpenReport, onOpenDoc }) {
2145
+ const { workset, run } = item;
2146
+ const stored = run?.reviewReports ?? {};
2147
+ const several = namesChanges(item);
2148
+ const named = (label, change) => several ? `${label} · ${change}` : label;
2149
+ const canRequest = context.writable && outcomeActions(workset, run, context).has("feedback");
2150
+ const [open, setOpen] = (0, import_react.useState)(false);
2151
+ const [draft, setDraft] = (0, import_react.useState)("");
2152
+ const field = (0, import_react.useRef)(null);
2153
+ const toggle = (0, import_react.useRef)(null);
2154
+ (0, import_react.useEffect)(() => {
2155
+ if (open) field.current?.focus();
2156
+ }, [open]);
2157
+ const close = () => {
2158
+ (0, import_react_dom.flushSync)(() => setOpen(false));
2159
+ toggle.current?.focus();
2160
+ };
2161
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2162
+ className: "outcome-plan",
2163
+ children: [
2164
+ workset.changes.map((change) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
2165
+ className: "outcome-read",
2166
+ children: [
2167
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2168
+ className: "muted",
2169
+ children: "Read"
2170
+ }),
2171
+ stored[change] ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReportButton, {
2172
+ label: "Show me",
2173
+ change,
2174
+ several,
2175
+ onOpenReport
2176
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2177
+ className: "note",
2178
+ "data-report-missing": change,
2179
+ children: [
2180
+ "No review report for ",
2181
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2182
+ className: "mono",
2183
+ children: change
2184
+ }),
2185
+ "."
2186
+ ]
2187
+ }),
2188
+ ["spec", "tasks"].map((doc) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2189
+ type: "button",
2190
+ className: "outcome-report-open",
2191
+ "data-open-doc": `${doc}:${change}`,
2192
+ onClick: (event) => onOpenDoc(change, doc, event.currentTarget),
2193
+ children: named(`Show ${doc}`, change)
2194
+ }, doc))
2195
+ ]
2196
+ }, change)),
2197
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2198
+ className: "factory-sheet-actions",
2199
+ children: [actionFor(item, context)("start-apply", "Approve plan", void 0, !open), canRequest ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2200
+ ref: toggle,
2201
+ type: "button",
2202
+ "aria-expanded": open,
2203
+ onClick: () => open ? close() : setOpen(true),
2204
+ children: "Request changes"
2205
+ }) : null]
2206
+ }),
2207
+ canRequest && open ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
2208
+ id: workset.id,
2209
+ action: "feedback",
2210
+ className: "outcome-request",
2211
+ onDone: () => {
2212
+ setDraft("");
2213
+ setOpen(false);
2214
+ },
2215
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
2216
+ ref: field,
2217
+ name: "feedback",
2218
+ rows: 3,
2219
+ "aria-label": "What should change?",
2220
+ placeholder: "What should change?",
2221
+ value: draft,
2222
+ onChange: (event) => setDraft(event.target.value),
2223
+ onKeyDown: (event) => {
2224
+ if (event.key !== "Escape") return;
2225
+ event.stopPropagation();
2226
+ close();
2227
+ }
2228
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2229
+ className: "factory-sheet-actions",
2230
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2231
+ type: "submit",
2232
+ className: "factory-primary",
2233
+ disabled: draft.trim() === "",
2234
+ children: "Send changes"
2235
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2236
+ type: "button",
2237
+ onClick: close,
2238
+ children: "Cancel"
2239
+ })]
2240
+ })]
2241
+ }) : null
2242
+ ]
2243
+ });
2244
+ }
1497
2245
  /** What a person does for one attention item, opened in place. */
1498
- function AttentionBody({ item, kind, context }) {
2246
+ function FocusBody({ item, kind, context, onOpenReport, onOpenDoc }) {
1499
2247
  const { run } = item;
1500
2248
  const form = actionFor(item, context);
1501
2249
  if (kind === "control") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ControlSheet, {
@@ -1518,23 +2266,12 @@ function AttentionBody({ item, kind, context }) {
1518
2266
  form("retry", "Retry")
1519
2267
  ]
1520
2268
  });
1521
- if (kind === "review") {
1522
- const missing = reportsMissing(item);
1523
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1524
- className: "factory-sheet",
1525
- children: [
1526
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ReviewReports, { item }),
1527
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1528
- className: "factory-sheet-actions",
1529
- children: [form("start-apply", "Approve"), missing ? form("regenerate", "Regenerate") : null]
1530
- }),
1531
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FeedbackField, {
1532
- item,
1533
- context
1534
- })
1535
- ]
1536
- });
1537
- }
2269
+ if (kind === "review") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PlanReview, {
2270
+ item,
2271
+ context,
2272
+ onOpenReport,
2273
+ onOpenDoc
2274
+ });
1538
2275
  if (kind === "merge") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1539
2276
  className: "factory-sheet",
1540
2277
  children: run?.compareUrl ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", {
@@ -1640,54 +2377,97 @@ function OutcomeList({ label, section, count, children }) {
1640
2377
  });
1641
2378
  }
1642
2379
  var sameText = (a, b) => a.replace(/\.$/, "").toLowerCase() === b.replace(/\.$/, "").toLowerCase();
1643
- /** What the person is asked to do, with what it expects of them. */
1644
- function AttentionSection({ item, kind, context }) {
1645
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
1646
- className: "outcome-dialog-attention",
1647
- "data-kind": kind,
1648
- "aria-label": "Needs you",
2380
+ /** Whether something failed or is wrong, so checks, problems and results belong in view. */
2381
+ function hasTrouble(item, situation) {
2382
+ return item.workset.problems.length > 0 || (situation.checks?.some((check) => !check.passed) ?? false);
2383
+ }
2384
+ /** Failed checks, problems and result links; in the focus block only while something is wrong. */
2385
+ function Findings({ item, situation, onOpenReport }) {
2386
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
2387
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checks, { checks: situation.checks }),
2388
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResultLinks, {
2389
+ item,
2390
+ onOpenReport
2391
+ }),
2392
+ item.workset.problems.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
2393
+ className: "factory-problems",
2394
+ children: item.workset.problems.map((problem) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: problem }, problem))
2395
+ }) : null
2396
+ ] });
2397
+ }
2398
+ /** The step being worked on, its task progress when tracked, and the latest output. */
2399
+ function WorkingOn({ text, tasks, tail }) {
2400
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2401
+ className: "outcome-working",
2402
+ role: "status",
2403
+ "aria-label": "Working on",
1649
2404
  children: [
1650
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: attentionLabel(kind, item.run) }),
1651
- ATTENTION_HINTS[kind] ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1652
- className: "outcome-attention-hint",
1653
- children: ATTENTION_HINTS[kind]
2405
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2406
+ className: "outcome-working-step",
2407
+ children: text
2408
+ }),
2409
+ tasks ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Progress, {
2410
+ done: tasks.done,
2411
+ total: tasks.total
1654
2412
  }) : null,
1655
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AttentionBody, {
1656
- item,
1657
- kind,
1658
- context
2413
+ tail.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ol", {
2414
+ className: "outcome-tail",
2415
+ "aria-label": "Latest log",
2416
+ children: tail.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: line }, index))
2417
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2418
+ className: "note",
2419
+ children: "Waiting for output."
1659
2420
  })
1660
2421
  ]
1661
2422
  });
1662
2423
  }
1663
- /** Where the Outcome is: its situation, the next step, checks, results and problems. */
1664
- function OutcomeStatus({ item, situation }) {
2424
+ /**
2425
+ * The one thing the panel is about: what is happening or what is asked of the person, as one
2426
+ * sentence, with its action. A running Outcome shows the last lines of its log.
2427
+ */
2428
+ function FocusBlock({ item, kind, context, situation, log, onOpenReport, onOpenDoc }) {
1665
2429
  const { workset, run } = item;
1666
2430
  const next = nextStepOf(workset, run);
2431
+ const tail = run?.state === "running" ? lastLines(log.pieces, 3) : null;
1667
2432
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
1668
- className: "outcome-dialog-status",
1669
- "aria-label": "Where it is",
2433
+ className: "outcome-focus",
2434
+ "data-kind": kind ?? void 0,
2435
+ "aria-label": kind ? "Needs you" : "Where it is",
1670
2436
  children: [
1671
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2437
+ kind ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: attentionLabel(kind, run) }) : null,
2438
+ tail ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WorkingOn, {
2439
+ text: situation.text,
2440
+ tasks: context.tasksOf(workset),
2441
+ tail
2442
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1672
2443
  className: "outcome-situation",
1673
- children: situation.text
2444
+ children: [situation.text, sameText(next, situation.text) ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2445
+ className: "outcome-next",
2446
+ children: [
2447
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2448
+ className: "muted",
2449
+ children: "Next:"
2450
+ }),
2451
+ " ",
2452
+ next
2453
+ ]
2454
+ })]
1674
2455
  }),
1675
- sameText(next, situation.text) ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1676
- className: "outcome-next",
1677
- children: [
1678
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1679
- className: "muted",
1680
- children: "Next"
1681
- }),
1682
- " ",
1683
- next
1684
- ]
2456
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TakeoverPending, {
2457
+ run,
2458
+ now: context.now
1685
2459
  }),
1686
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Checks, { checks: situation.checks }),
1687
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ResultLinks, { item }),
1688
- workset.problems.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
1689
- className: "factory-problems",
1690
- children: workset.problems.map((problem) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: problem }, problem))
2460
+ hasTrouble(item, situation) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Findings, {
2461
+ item,
2462
+ situation,
2463
+ onOpenReport
2464
+ }) : null,
2465
+ kind ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FocusBody, {
2466
+ item,
2467
+ kind,
2468
+ context,
2469
+ onOpenReport,
2470
+ onOpenDoc
1691
2471
  }) : null
1692
2472
  ]
1693
2473
  });
@@ -1707,106 +2487,191 @@ function History({ run, now }) {
1707
2487
  })]
1708
2488
  });
1709
2489
  }
2490
+ /** One line until opened: its name and a short summary of what it holds. */
2491
+ function Row({ label, summary, className, children }) {
2492
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", {
2493
+ className: cn("outcome-row-fold", className),
2494
+ "aria-label": label,
2495
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("summary", { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2496
+ className: "outcome-row-fold-label",
2497
+ children: label
2498
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
2499
+ className: "outcome-row-fold-summary",
2500
+ children: summary
2501
+ })] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2502
+ className: "outcome-row-fold-body",
2503
+ children
2504
+ })]
2505
+ });
2506
+ }
2507
+ /** Activity, Request and Details: everything the focus block leaves out, one line each. */
2508
+ function OutcomeRows({ item, kind, context, situation, log, onOpenReport }) {
2509
+ const { workset, run } = item;
2510
+ const updates = run?.situations?.length ?? 0;
2511
+ const hasLog = Boolean(run?.hasLog) || runActive(run);
2512
+ const activity = [updates > 0 ? `${updates} ${updates === 1 ? "update" : "updates"}` : "", hasLog ? "log" : ""].filter(Boolean).join(" · ");
2513
+ const feedback = kind !== "review" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FeedbackField, {
2514
+ item,
2515
+ context
2516
+ }) : null;
2517
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
2518
+ activity ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Row, {
2519
+ label: "Activity",
2520
+ summary: activity,
2521
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(History, {
2522
+ run,
2523
+ now: context.now
2524
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeLog, {
2525
+ item,
2526
+ log
2527
+ })]
2528
+ }) : null,
2529
+ workset.intent || feedback ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Row, {
2530
+ label: "Request",
2531
+ summary: workset.intent.split("\n")[0] ?? "",
2532
+ children: [workset.intent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2533
+ className: "outcome-intent",
2534
+ children: workset.intent
2535
+ }) : null, feedback]
2536
+ }) : null,
2537
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Row, {
2538
+ label: "Details",
2539
+ summary: `${workset.stageLabel} · ${runText(run, context.now)}`,
2540
+ className: "outcome-dialog-rail",
2541
+ children: [hasTrouble(item, situation) ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Findings, {
2542
+ item,
2543
+ situation,
2544
+ onOpenReport
2545
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Facts, {
2546
+ item,
2547
+ context
2548
+ })]
2549
+ })
2550
+ ] });
2551
+ }
1710
2552
  /**
1711
- * Everything about one Outcome, in the slide-over panel. It leads with what needs the person,
1712
- * then the log, status and the run's actions, and history; Details holds where the Outcome is
1713
- * on the Delivery Path and the execution facts. In control the terminal takes the width.
2553
+ * Everything about one Outcome, in the slide-over panel: the state, the Delivery Path on one
2554
+ * line, one focus block, the Activity, Request and Details rows, and the run's actions.
2555
+ * In control the terminal takes the width. A review report opens in its place, with Back.
1714
2556
  */
1715
- function OutcomePanel({ item, kind, context }) {
2557
+ function OutcomePanel({ item, kind, context, onDeleted }) {
1716
2558
  const { workset, run } = item;
1717
2559
  const situation = situationOf(workset, run);
1718
2560
  const activity = activityOf(workset, run);
1719
2561
  const since = run?.state === "running" ? run.startedAt : run?.updatedAt || situation.at;
1720
2562
  const id = dialogId(workset.id);
1721
- const progress = {
1722
- current: pathNodeOf(workset),
1723
- activity,
1724
- note: progressNote(item, activity, context.now)
2563
+ const log = useOutcomeLog(run?.hasLog || runActive(run) ? factoryLogStreamRoute(workset.id) : null);
2564
+ const [openReport, setOpenReport] = (0, import_react.useState)(null);
2565
+ const opener = (0, import_react.useRef)(null);
2566
+ if (openReport && run?.reviewReports?.[openReport.change] !== openReport.report) setOpenReport(null);
2567
+ const [openDoc, setOpenDoc] = (0, import_react.useState)(null);
2568
+ if (openDoc && (workset.stage !== "human-review" || !workset.changes.includes(openDoc.change))) setOpenDoc(null);
2569
+ const showReport = (change, from) => {
2570
+ const stored = run?.reviewReports?.[change];
2571
+ if (!stored) return;
2572
+ opener.current = from;
2573
+ setOpenDoc(null);
2574
+ setOpenReport({
2575
+ change,
2576
+ report: stored
2577
+ });
2578
+ };
2579
+ const showDoc = (change, doc, from) => {
2580
+ opener.current = from;
2581
+ setOpenReport(null);
2582
+ setOpenDoc({
2583
+ change,
2584
+ doc
2585
+ });
1725
2586
  };
2587
+ const back = () => {
2588
+ (0, import_react_dom.flushSync)(() => {
2589
+ setOpenReport(null);
2590
+ setOpenDoc(null);
2591
+ });
2592
+ opener.current?.focus();
2593
+ };
2594
+ const reportOpen = openReport !== null || openDoc !== null;
2595
+ let layout;
2596
+ if (reportOpen) layout = "report";
2597
+ else if (kind === "control") layout = "control";
1726
2598
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1727
2599
  id,
1728
2600
  className: "outcome-dialog",
1729
2601
  "data-outcome-panel": "",
1730
2602
  "data-workset": workset.id,
1731
- "data-layout": kind === "control" ? "control" : void 0,
1732
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("header", {
1733
- className: "outcome-dialog-head",
1734
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1735
- className: "outcome-dialog-heading",
1736
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
1737
- id: `${id}-title`,
1738
- children: workset.title
1739
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1740
- className: "outcome-dialog-state",
1741
- children: [
1742
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActivityDot, { activity }),
1743
- ACTIVITY_LABELS[activity],
1744
- since ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1745
- className: "factory-age mono",
1746
- children: ["· ", ageText(since, context.now)]
1747
- }) : null
1748
- ]
1749
- })]
1750
- })
1751
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1752
- className: "outcome-dialog-main",
1753
- children: [
1754
- kind ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AttentionSection, {
1755
- item,
1756
- kind,
1757
- context
1758
- }) : null,
1759
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TakeoverPending, {
1760
- run,
1761
- now: context.now
1762
- }),
1763
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeLog, { item }),
1764
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeStatus, {
1765
- item,
1766
- situation
1767
- }),
1768
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RunActions, {
1769
- item,
1770
- context
1771
- }),
1772
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TakeControl, {
1773
- item,
1774
- context
1775
- }),
1776
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(History, {
1777
- run,
1778
- now: context.now
1779
- }),
1780
- workset.intent ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
1781
- className: "outcome-intent-section",
1782
- "aria-label": "Request",
1783
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Request" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
1784
- className: "outcome-intent",
1785
- children: workset.intent
2603
+ "data-layout": layout,
2604
+ children: [
2605
+ openReport ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeReport, {
2606
+ change: openReport.change,
2607
+ report: openReport.report,
2608
+ onBack: back
2609
+ }) : null,
2610
+ openDoc ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChangeDoc, {
2611
+ companion: context.companionDigest,
2612
+ change: openDoc.change,
2613
+ doc: openDoc.doc,
2614
+ onBack: back
2615
+ }) : null,
2616
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("header", {
2617
+ className: "outcome-dialog-head",
2618
+ hidden: reportOpen,
2619
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2620
+ className: "outcome-dialog-heading",
2621
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
2622
+ id: `${id}-title`,
2623
+ children: workset.title
2624
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
2625
+ className: "outcome-dialog-state",
2626
+ "data-activity": activity,
2627
+ children: [
2628
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActivityDot, { activity }),
2629
+ ACTIVITY_LABELS[activity],
2630
+ since ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2631
+ className: "factory-age mono",
2632
+ children: ["· ", ageText(since, context.now)]
2633
+ }) : null
2634
+ ]
1786
2635
  })]
1787
- }) : null,
1788
- kind !== "review" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FeedbackField, {
1789
- item,
1790
- context
1791
- }) : null,
1792
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", {
1793
- className: "outcome-dialog-rail",
1794
- "aria-label": "Details",
1795
- children: [
1796
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("summary", { children: "Details" }),
1797
- kind === "control" ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WorkflowGraphView, {
1798
- path: context.path,
1799
- progress,
1800
- label: "Where it is on the Delivery Path"
1801
- }),
1802
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Facts, {
1803
- item,
1804
- context
1805
- })
1806
- ]
1807
2636
  })
1808
- ]
1809
- })]
2637
+ }),
2638
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2639
+ className: "outcome-dialog-main",
2640
+ hidden: reportOpen,
2641
+ children: [
2642
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
2643
+ className: "outcome-path",
2644
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(PathSteps, {
2645
+ compact: true,
2646
+ steps: PATH_STEPS,
2647
+ ...pathPositionOf(workset, run)
2648
+ })
2649
+ }),
2650
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FocusBlock, {
2651
+ item,
2652
+ kind,
2653
+ context,
2654
+ situation,
2655
+ log,
2656
+ onOpenReport: showReport,
2657
+ onOpenDoc: showDoc
2658
+ }),
2659
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeRows, {
2660
+ item,
2661
+ kind,
2662
+ context,
2663
+ situation,
2664
+ log,
2665
+ onOpenReport: showReport
2666
+ }),
2667
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeFooter, {
2668
+ item,
2669
+ context,
2670
+ onDeleted
2671
+ })
2672
+ ]
2673
+ })
2674
+ ]
1810
2675
  });
1811
2676
  }
1812
2677
  function Completed({ items, context, expanded }) {
@@ -1897,6 +2762,16 @@ function OpenAgents({ label }) {
1897
2762
  children: label
1898
2763
  });
1899
2764
  }
2765
+ /** Opens the Git access panel. */
2766
+ function OpenGitAccess() {
2767
+ const setGitAccessOpen = useFactoryUi((state) => state.setGitAccessOpen);
2768
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
2769
+ type: "button",
2770
+ "data-open-git-access": "",
2771
+ onClick: () => setGitAccessOpen(true),
2772
+ children: "Git access"
2773
+ });
2774
+ }
1900
2775
  /** The filter, the keys and the offer to notify, above the board. */
1901
2776
  function BoardToolbar({ count, worksets, writable, factoryMode, onPass, children }) {
1902
2777
  const filter = useFactoryUi((state) => state.filter);
@@ -1947,6 +2822,7 @@ function BoardToolbar({ count, worksets, writable, factoryMode, onPass, children
1947
2822
  children: "Notify me about decisions"
1948
2823
  }),
1949
2824
  factoryMode && writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OpenAgents, { label: "Agents" }) : null,
2825
+ factoryMode && writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OpenGitAccess, {}) : null,
1950
2826
  onPass ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
1951
2827
  type: "button",
1952
2828
  className: "factory-primary factory-pass",
@@ -1959,6 +2835,23 @@ function BoardToolbar({ count, worksets, writable, factoryMode, onPass, children
1959
2835
  ]
1960
2836
  });
1961
2837
  }
2838
+ /** Task counts summed over a Workset's changes; null when none are tracked. */
2839
+ function tasksIn(changes) {
2840
+ const byName = new Map((changes ?? []).map((change) => [change.name, change]));
2841
+ return (workset) => {
2842
+ let done = 0;
2843
+ let total = 0;
2844
+ for (const name of workset.changes) {
2845
+ const change = byName.get(name);
2846
+ done += change?.completedTasks ?? 0;
2847
+ total += change?.totalTasks ?? 0;
2848
+ }
2849
+ return total > 0 ? {
2850
+ done,
2851
+ total
2852
+ } : null;
2853
+ };
2854
+ }
1962
2855
  /** The board's Outcomes and the context every row and panel reads. */
1963
2856
  function contextOf({ payload, companionDigest, writable, sessions = null, runs = null, now }) {
1964
2857
  return {
@@ -1969,8 +2862,8 @@ function contextOf({ payload, companionDigest, writable, sessions = null, runs =
1969
2862
  sessions,
1970
2863
  runner: runs !== null,
1971
2864
  now,
1972
- path: workflowPlan({ topology: payload.topology }).paths[0],
1973
- ticketFormat: payload.ticketFormat
2865
+ ticketFormat: payload.ticketFormat,
2866
+ tasksOf: tasksIn(payload.changes)
1974
2867
  }
1975
2868
  };
1976
2869
  }
@@ -1996,6 +2889,8 @@ function Factory({ payload, companionDigest, writable, sessions = null, runs = n
1996
2889
  const open = openId ? ordered.find((item) => item.workset.id === openId) ?? null : null;
1997
2890
  const agentsOpen = useFactoryUi((state) => state.agentsOpen);
1998
2891
  const setAgentsOpen = useFactoryUi((state) => state.setAgentsOpen);
2892
+ const gitAccessOpen = useFactoryUi((state) => state.gitAccessOpen);
2893
+ const setGitAccessOpen = useFactoryUi((state) => state.setGitAccessOpen);
1999
2894
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FactoryCompanion.Provider, {
2000
2895
  value: companionDigest,
2001
2896
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
@@ -2004,6 +2899,9 @@ function Factory({ payload, companionDigest, writable, sessions = null, runs = n
2004
2899
  children: [
2005
2900
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeInput, {
2006
2901
  repositories: payload.linkedRepositories,
2902
+ sources: payload.repositorySources,
2903
+ keys: payload.repositoryKeys,
2904
+ factoryMode,
2007
2905
  context
2008
2906
  }),
2009
2907
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BoardToolbar, {
@@ -2091,7 +2989,10 @@ function Factory({ payload, companionDigest, writable, sessions = null, runs = n
2091
2989
  item,
2092
2990
  context,
2093
2991
  progress: false,
2094
- trailing: actionFor(item, context)("start", "Start")
2992
+ trailing: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [actionFor(item, context)("start", "Start"), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeleteOutcome, {
2993
+ item,
2994
+ context
2995
+ })] })
2095
2996
  }, item.workset.id))
2096
2997
  }) : null,
2097
2998
  shows("completed") ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Completed, {
@@ -2117,12 +3018,14 @@ function Factory({ payload, companionDigest, writable, sessions = null, runs = n
2117
3018
  children: open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomePanel, {
2118
3019
  item: open,
2119
3020
  kind: kinds.get(open.workset.id) ?? null,
2120
- context
3021
+ context,
3022
+ onDeleted: address.close
2121
3023
  }, open.workset.id) : null
2122
3024
  }),
2123
3025
  payload.worksetProblems.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Warnings, { warnings: payload.worksetProblems.map((problem) => `${problem.path} ${problem.reason}`) }) : null,
2124
3026
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Warnings, { warnings: payload.warnings }),
2125
- factoryMode && writable && agentsOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgentsDialog, { onClose: () => setAgentsOpen(false) }) : null
3027
+ factoryMode && writable && agentsOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgentsDialog, { onClose: () => setAgentsOpen(false) }) : null,
3028
+ factoryMode && writable && gitAccessOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GitAccessDialog, { onClose: () => setGitAccessOpen(false) }) : null
2126
3029
  ]
2127
3030
  })
2128
3031
  });