@uniqbit/mate-core 1.0.0-canary.2 → 1.0.0-canary.5

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 (189) hide show
  1. package/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
  2. package/claude-plugin/hooks/hooks.json +21 -1
  3. package/claude-plugin/hooks/session-attention.mjs +10 -0
  4. package/claude-plugin/hooks/session-end.mjs +9 -0
  5. package/claude-plugin/hooks/session-guidance.mjs +1 -1
  6. package/opencode-plugin/src/server.ts +13 -2
  7. package/opencode-plugin/src/tui.tsx +1 -1
  8. package/opencode-plugin/tui.tsx +2 -1
  9. package/package.json +1 -1
  10. package/src/cli/commands/artifact/delivery/archive.ts +2 -2
  11. package/src/cli/commands/artifact/delivery/link.ts +22 -5
  12. package/src/cli/commands/artifact/delivery/output.ts +9 -1
  13. package/src/cli/commands/artifact/finish/openspec.ts +1 -3
  14. package/src/cli/commands/companion/companion.ts +1 -1
  15. package/src/cli/commands/companion/link.ts +36 -4
  16. package/src/cli/commands/companion/open.ts +40 -12
  17. package/src/cli/commands/doctor.ts +122 -0
  18. package/src/cli/commands/session/prepare.ts +32 -4
  19. package/src/cli/commands/session/registry.ts +90 -0
  20. package/src/cli/commands/studio/companion-removal.ts +79 -0
  21. package/src/cli/commands/studio/mate-inventory.ts +1 -1
  22. package/src/cli/commands/studio/payload.ts +12 -1
  23. package/src/cli/commands/studio/server.ts +39 -16
  24. package/src/cli/commands/studio/services.ts +20 -0
  25. package/src/cli/commands/studio/skill-files.ts +133 -0
  26. package/src/cli/commands/studio/vault.ts +218 -44
  27. package/src/cli/commands/studio/views/model.ts +0 -5
  28. package/src/cli/commands/studio/views/vault/markdown-tree.ts +255 -4
  29. package/src/cli/commands/unwrap.ts +8 -0
  30. package/src/cli/commands/update.ts +26 -8
  31. package/src/cli/commands/vscode/setup.ts +155 -0
  32. package/src/cli/commands/vscode/vsix.ts +73 -0
  33. package/src/cli/commands/working/cleanup.ts +34 -10
  34. package/src/cli/commands/working/worktree.ts +58 -8
  35. package/src/cli/commands/wrap.ts +33 -7
  36. package/src/cli/main.ts +9 -2
  37. package/src/cli/usage.ts +6 -1
  38. package/src/hooks/companion-instructions.ts +19 -11
  39. package/src/hooks/hook-io.ts +15 -0
  40. package/src/hooks/session-banner.ts +5 -3
  41. package/src/hooks/session-end.ts +10 -0
  42. package/src/hooks/session-guidance.ts +10 -6
  43. package/src/hooks/session-prepare.ts +47 -31
  44. package/src/hooks/session-register.ts +199 -0
  45. package/src/hooks/tokensave-route.ts +7 -3
  46. package/src/hooks/validate-artifact-path.ts +9 -2
  47. package/src/lib/delivery/archive-change.ts +0 -1
  48. package/src/lib/delivery/branches.ts +15 -0
  49. package/src/lib/delivery/record-delivery.ts +94 -39
  50. package/src/lib/delivery/record.ts +30 -28
  51. package/src/lib/delivery/refresh.ts +37 -17
  52. package/src/lib/delivery/resolve-branch.ts +258 -37
  53. package/src/lib/factory/outcomes/index.ts +11 -1
  54. package/src/lib/factory/runtime.ts +10 -1
  55. package/src/lib/opencode-server.ts +238 -0
  56. package/src/lib/orchestrator/adapters/claude.ts +147 -2
  57. package/src/lib/orchestrator/adapters/opencode.ts +53 -2
  58. package/src/lib/orchestrator/checkout-adoption.ts +125 -0
  59. package/src/lib/orchestrator/companion-registry-store.ts +6 -2
  60. package/src/lib/orchestrator/editor.ts +2 -2
  61. package/src/lib/orchestrator/framework-context.ts +26 -14
  62. package/src/lib/orchestrator/global-config-store.ts +11 -0
  63. package/src/lib/orchestrator/launcher.ts +15 -2
  64. package/src/lib/orchestrator/projection-claude-links.ts +52 -5
  65. package/src/lib/orchestrator/projection-claude-skills.ts +28 -2
  66. package/src/lib/orchestrator/projection-companion-link.ts +12 -1
  67. package/src/lib/orchestrator/registry-checkouts.ts +177 -0
  68. package/src/lib/orchestrator/repository-link.ts +216 -57
  69. package/src/lib/orchestrator/serving-claude-wrap.ts +43 -0
  70. package/src/lib/orchestrator/session-context-link.ts +11 -5
  71. package/src/lib/orchestrator/session-prepare.ts +36 -6
  72. package/src/lib/orchestrator/types.ts +5 -0
  73. package/src/lib/orchestrator/workspace-inventory.ts +5 -1
  74. package/src/lib/public-npm.ts +17 -0
  75. package/src/lib/session-attribution.ts +52 -0
  76. package/src/lib/session-state.ts +285 -0
  77. package/src/lib/session-stop.ts +64 -0
  78. package/src/lib/workset/record.ts +20 -0
  79. package/src/lib/workset/worktree.ts +85 -17
  80. package/src/opencode/background-server.ts +145 -0
  81. package/src/opencode/companion-hooks.ts +3 -1
  82. package/src/opencode/companion-policy.ts +2 -2
  83. package/src/opencode/projected-guidance.ts +2 -1
  84. package/src/opencode/session-register.ts +176 -0
  85. package/src/opencode/tui.tsx +19 -29
  86. package/src/runtime/claude-delivery-plan.ts +14 -3
  87. package/src/runtime/current-branch.ts +10 -0
  88. package/src/runtime/env.ts +13 -7
  89. package/src/runtime/git-layout.ts +164 -17
  90. package/src/runtime/launch-env-guard.ts +65 -0
  91. package/src/runtime/opencode-server-record.ts +136 -0
  92. package/src/runtime/projection.ts +40 -6
  93. package/src/runtime/repo-local.ts +6 -1
  94. package/src/runtime/serving-claude-wrap.ts +28 -0
  95. package/src/runtime/session-context.ts +4 -3
  96. package/src/runtime/session-registry.ts +434 -0
  97. package/src/runtime/tokensave-route.ts +10 -5
  98. package/src/runtime/wrap-state.ts +31 -0
  99. package/src/studio.ts +2 -0
  100. package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +49 -21
  101. package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +0 -5
  102. package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +2 -8
  103. package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +1 -3
  104. package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +2 -4
  105. package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +49 -21
  106. package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +0 -5
  107. package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +2 -8
  108. package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +1 -3
  109. package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +2 -4
  110. package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +404 -30
  111. package/src/tools/setup/dynamic-plugins/hydrate.ts +4 -3
  112. package/src/tools/setup/providers/claude-plugin-hooks.ts +26 -0
  113. package/src/tools/setup/providers/claude.ts +21 -1
  114. package/studio-dist/client/assets/app-CdPiFv59.css +2 -0
  115. package/studio-dist/client/assets/button-BIIHE0EQ.js +3 -0
  116. package/studio-dist/client/assets/companion-view-DM6YyXaR.js +1 -0
  117. package/studio-dist/client/assets/delivery-path-DELxj0Av.js +1 -0
  118. package/studio-dist/client/assets/factory-BZy0E8ty.js +4 -0
  119. package/studio-dist/client/assets/index-B3wkMzjA.js +40 -0
  120. package/studio-dist/client/assets/markdown-view-pQ2Qp_i5.js +1 -0
  121. package/studio-dist/client/assets/panel-CbajlC3p.js +1 -0
  122. package/studio-dist/client/assets/{prepaint-CD5OpmTM.js → prepaint-CwSrpdFA.js} +7 -4
  123. package/studio-dist/client/assets/react-CN2GSx7x.js +1 -0
  124. package/studio-dist/client/assets/reports-DllhYQ5_.js +1 -0
  125. package/studio-dist/client/assets/routes-COm-G3mK.js +1 -0
  126. package/studio-dist/client/assets/skills-DmWAy-jZ.js +1 -0
  127. package/studio-dist/client/assets/specs-BG3Wi3ln.js +1 -0
  128. package/studio-dist/client/assets/steps-DFsH3Neu.js +1 -0
  129. package/studio-dist/client/assets/vault-B2q1nBY5.js +1 -0
  130. package/studio-dist/client/assets/warnings-BSXIyuSQ.js +1 -0
  131. package/studio-dist/client/assets/workflow-DlsQD6Hc.js +1 -0
  132. package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-BQKuMdJW.js → __23tanstack-start-server-fn-resolver-M2GBs8s3.js} +179 -9
  133. package/studio-dist/server/assets/_tanstack-start-manifest_v.js +35 -25
  134. package/studio-dist/server/assets/button-CIJqAhni.js +11929 -0
  135. package/studio-dist/server/assets/{companion-view-aBady57v.js → companion-view-DISASvdJ.js} +13 -7
  136. package/studio-dist/server/assets/companions-BYbHWKOZ.js +15 -0
  137. package/studio-dist/server/assets/delivery-path-C29fBynY.js +654 -0
  138. package/studio-dist/server/assets/{factory-DT3UzHlh.js → factory-DGPmNGbo.js} +1 -0
  139. package/studio-dist/server/assets/{factory-D6xnjedJ.js → factory-DUTa0eDs.js} +317 -530
  140. package/studio-dist/server/assets/markdown-view-Bn7xPdks.js +86 -0
  141. package/studio-dist/server/assets/panel-3Jmn4awF.js +169 -0
  142. package/studio-dist/server/assets/{prepaint-BMke0fo1.js → prepaint-DJfTQ_VH.js} +6 -2
  143. package/studio-dist/server/assets/{react-COs0LHn-.js → react-Ce6dj15C.js} +4 -9
  144. package/studio-dist/server/assets/reports-C06RXVE2.js +18 -0
  145. package/studio-dist/server/assets/reports-D6YMqhnO.js +142 -0
  146. package/studio-dist/server/assets/router-C8MGqlAY.js +13713 -0
  147. package/studio-dist/server/assets/routes-BcFgvqf7.js +622 -0
  148. package/studio-dist/server/assets/{shell-CboT2f66.js → shell-DS3wUexh.js} +1 -0
  149. package/studio-dist/server/assets/skills-BEnOxiDl.js +266 -0
  150. package/studio-dist/server/assets/skills-CtrBAtX3.js +28 -0
  151. package/studio-dist/server/assets/specs-C8rv34-5.js +211 -0
  152. package/studio-dist/server/assets/{start-BW5ovN0k.js → start-h3ICWwd2.js} +4 -1
  153. package/studio-dist/server/assets/steps-Dq_CwY_s.js +181 -0
  154. package/studio-dist/server/assets/{vault-BGulVoNh.js → vault-BmWnryh3.js} +16 -1
  155. package/studio-dist/server/assets/vault-Fvxt2Tzl.js +1032 -0
  156. package/studio-dist/server/assets/{views-Bd7cRr27.js → views-BgYa-za2.js} +1 -3
  157. package/studio-dist/server/assets/warnings-DzR6fyZh.js +23 -0
  158. package/studio-dist/server/assets/workflow-liRYecHk.js +73 -0
  159. package/studio-dist/server/server.js +3 -157
  160. package/studio-dist/client/assets/companion-view-Csva26Ir.js +0 -1
  161. package/studio-dist/client/assets/delivery-path-DJMpRmiY.js +0 -1
  162. package/studio-dist/client/assets/factory-B7l9ZQyx.js +0 -4
  163. package/studio-dist/client/assets/index-n6uo_92S.js +0 -40
  164. package/studio-dist/client/assets/queries-CN3JwMBX.js +0 -1
  165. package/studio-dist/client/assets/react-CabXf2Ds.js +0 -1
  166. package/studio-dist/client/assets/report-time-Dc-KOqQu.js +0 -1
  167. package/studio-dist/client/assets/reports-C01RsnMA.js +0 -1
  168. package/studio-dist/client/assets/routes-4pbC-2Hj.js +0 -1
  169. package/studio-dist/client/assets/skills-CihQganl.js +0 -1
  170. package/studio-dist/client/assets/spec-areas-C2L48N4C.js +0 -1
  171. package/studio-dist/client/assets/specs-D24_35_K.js +0 -1
  172. package/studio-dist/client/assets/studio-DKxfi691.css +0 -1
  173. package/studio-dist/client/assets/studio-queries-rvbJupCy.js +0 -3
  174. package/studio-dist/client/assets/vault-Bd4CQiTK.js +0 -1
  175. package/studio-dist/client/assets/warnings-V_Ys51wJ.js +0 -1
  176. package/studio-dist/client/assets/workflow-BJejeVwQ.js +0 -1
  177. package/studio-dist/server/assets/delivery-path-BkKNjgkf.js +0 -778
  178. package/studio-dist/server/assets/queries-Ag2iL8q2.js +0 -107
  179. package/studio-dist/server/assets/report-time-DAfzln-N.js +0 -8
  180. package/studio-dist/server/assets/reports-BnUNJVtx.js +0 -126
  181. package/studio-dist/server/assets/router-BH--drIx.js +0 -4298
  182. package/studio-dist/server/assets/routes-khSDK1bV.js +0 -361
  183. package/studio-dist/server/assets/skills-MWYnWoKs.js +0 -106
  184. package/studio-dist/server/assets/spec-areas-DcnO6vW-.js +0 -16
  185. package/studio-dist/server/assets/specs-DE3w8hZP.js +0 -155
  186. package/studio-dist/server/assets/studio-queries-CLnP9kGu.js +0 -3365
  187. package/studio-dist/server/assets/vault-CuyyhLyB.js +0 -832
  188. package/studio-dist/server/assets/warnings-BH05rOuG.js +0 -15
  189. package/studio-dist/server/assets/workflow-BSuIKWqH.js +0 -42
@@ -1,13 +1,14 @@
1
1
  import { i as __toESM } from "./rolldown-runtime-DYf_mQCB.js";
2
- import { i as useSuspenseQuery } from "./queries-Ag2iL8q2.js";
3
- import { D as factoryLogRoute, E as TERMINAL_WASM, O as factoryLogStreamRoute, Z as useQueryClient, _ as agentCredentialKey, b as setAgentCredential, g as runFactoryAction, n as afterFactoryAction, nt as useNavigate, s as factoryQuery, v as agentCredentialQuery, x as REPORT_VIEW_PREFIX, y as clearAgentCredential } from "./studio-queries-CLnP9kGu.js";
4
- import { A as require_react, l as require_jsx_runtime } from "./__23tanstack-start-server-fn-resolver-BQKuMdJW.js";
5
- import { t as Warnings } from "./warnings-BH05rOuG.js";
6
- import { n as WorkflowGraphView, r as workflowPlan } from "./delivery-path-BkKNjgkf.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";
7
5
  import { n as outcomeActions } from "./actions-Bvgj9eb8.js";
8
- import { _ as useMutation, d as parseMessage, f as sendMessage, l as loadWTerm, s as Route, u as openTerminalSocket } from "./router-BH--drIx.js";
9
- import { n as useQuery, t as create } from "./react-COs0LHn-.js";
10
- import { r as WORKSET_STAGE_ORDER } from "./studio-BeltxxKt.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";
11
12
  // ../mate-core/src/lib/factory/runner/questions.ts
12
13
  /**
13
14
  * A waiting state's questions; a state written before questions were grouped holds one
@@ -18,57 +19,10 @@ function questionsOf(state) {
18
19
  const single = state;
19
20
  return typeof single.question === "string" ? [single] : [];
20
21
  }
21
- // ../mate-core/src/lib/factory/runner/rank.ts
22
- /**
23
- * The factory work queue's one ordering rule: started Outcomes run in the order they were
24
- * started. A Later Outcome has no rank.
25
- */
26
- function rankOf(record) {
27
- if (!record.queuedAt) return null;
28
- const queued = Date.parse(record.queuedAt);
29
- return Number.isNaN(queued) ? null : queued;
30
- }
31
- /** Lower rank first, then identifier; Later Outcomes keep their relative order at the end. */
32
- function compareRanked(a, b) {
33
- if (a.rank === null || b.rank === null) {
34
- if (a.rank === b.rank) return 0;
35
- return a.rank === null ? 1 : -1;
36
- }
37
- return a.rank - b.rank || (a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
38
- }
39
22
  // src/views/factory/factory-companion.ts
40
23
  var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
41
24
  /** The companion the board acts on; set once by the Factory view. */
42
25
  var FactoryCompanion = (0, import_react.createContext)("");
43
- // src/views/factory/use-modal-dialog.ts
44
- /**
45
- * Shows the dialog modally once, through `show`, and calls the latest `onClose` whenever it
46
- * closes. Close, Esc and the backdrop all end in the native close event.
47
- */
48
- function useModalDialog(onClose, show) {
49
- const close = (0, import_react.useRef)(onClose);
50
- (0, import_react.useEffect)(() => {
51
- close.current = onClose;
52
- });
53
- const ref = (0, import_react.useRef)(null);
54
- const showOnce = (0, import_react.useRef)(show);
55
- (0, import_react.useEffect)(() => {
56
- const dialog = ref.current;
57
- if (!dialog) return;
58
- if (!dialog.open) showOnce.current(dialog);
59
- const backdrop = (event) => {
60
- if (event.target === dialog) dialog.close();
61
- };
62
- const closed = () => close.current();
63
- dialog.addEventListener("click", backdrop);
64
- dialog.addEventListener("close", closed);
65
- return () => {
66
- dialog.removeEventListener("click", backdrop);
67
- dialog.removeEventListener("close", closed);
68
- };
69
- }, []);
70
- return ref;
71
- }
72
26
  // src/views/factory/agents-dialog.tsx
73
27
  var import_jsx_runtime = require_jsx_runtime();
74
28
  /** Each tab's form: what it asks for, and how to get it. */
@@ -156,7 +110,7 @@ function SecretForm({ kind, label, hint, onSaved }) {
156
110
  ]
157
111
  });
158
112
  }
159
- /** The Agents panel: sets the one Claude credential the factory's Workset agents use. */
113
+ /** The Agents panel, sliding over the page: sets the one Claude credential the factory's Workset agents use. */
160
114
  function AgentsDialog({ onClose }) {
161
115
  const queryClient = useQueryClient();
162
116
  const status = useQuery(agentCredentialQuery());
@@ -174,83 +128,84 @@ function AgentsDialog({ onClose }) {
174
128
  setSaved(false);
175
129
  }
176
130
  });
177
- const ref = useModalDialog(onClose, (dialog) => dialog.showModal?.());
178
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dialog", {
179
- ref,
180
- className: "outcome-dialog agents-dialog",
181
- "aria-labelledby": "agents-title",
182
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
183
- className: "outcome-dialog-head",
184
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
185
- className: "outcome-dialog-heading",
186
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
187
- id: "agents-title",
188
- children: "Workset agents"
189
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
190
- className: "outcome-dialog-state",
191
- "data-agents-status": "",
192
- children: status.error ? status.error.message : statusText(status.data)
193
- })]
194
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("form", {
195
- method: "dialog",
196
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
197
- type: "submit",
131
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Sheet, {
132
+ open: true,
133
+ onOpenChange: (open) => {
134
+ if (!open) onClose();
135
+ },
136
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SheetContent, {
137
+ className: "agents-dialog",
138
+ "aria-labelledby": "agents-title",
139
+ initialFocus: () => document.querySelector(".agents-dialog .outcome-dialog-close"),
140
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
141
+ className: "outcome-dialog-head",
142
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
143
+ className: "outcome-dialog-heading",
144
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(SheetTitle, {
145
+ id: "agents-title",
146
+ children: "Workset agents"
147
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
148
+ className: "outcome-dialog-state",
149
+ "data-agents-status": "",
150
+ children: status.error ? status.error.message : statusText(status.data)
151
+ })]
152
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(SheetClose, {
198
153
  className: "outcome-dialog-close",
199
154
  "aria-keyshortcuts": "Escape",
200
155
  children: ["Close ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "Esc" })]
201
- })
156
+ })]
157
+ }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
158
+ className: "agents-dialog-body",
159
+ children: [
160
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
161
+ role: "tablist",
162
+ "aria-label": "How to sign in",
163
+ className: "agents-tabs",
164
+ children: TABS.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
165
+ type: "button",
166
+ role: "tab",
167
+ id: `agents-tab-${entry.kind}`,
168
+ "aria-controls": "agents-panel",
169
+ "aria-selected": tab === entry.kind,
170
+ onClick: () => {
171
+ setTab(entry.kind);
172
+ setSaved(false);
173
+ },
174
+ children: entry.tab
175
+ }, entry.kind))
176
+ }),
177
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
178
+ role: "tabpanel",
179
+ id: "agents-panel",
180
+ "aria-labelledby": `agents-tab-${tab}`,
181
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SecretForm, {
182
+ kind: form.kind,
183
+ label: form.label,
184
+ hint: form.hint,
185
+ onSaved
186
+ }, form.kind)
187
+ }),
188
+ saved ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
189
+ className: "note",
190
+ role: "status",
191
+ children: "Saved. The next agent start uses it."
192
+ }) : null,
193
+ status.data?.source === "studio" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
194
+ className: "factory-sheet-actions agents-clear",
195
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
196
+ type: "button",
197
+ onClick: () => clear.mutate(),
198
+ disabled: clear.isPending,
199
+ children: "Remove the credential set in Studio"
200
+ }), clear.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
201
+ className: "factory-problems",
202
+ role: "alert",
203
+ children: clear.error.message
204
+ }) : null]
205
+ }) : null
206
+ ]
202
207
  })]
203
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
204
- className: "agents-dialog-body",
205
- children: [
206
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
207
- role: "tablist",
208
- "aria-label": "How to sign in",
209
- className: "agents-tabs",
210
- children: TABS.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
211
- type: "button",
212
- role: "tab",
213
- id: `agents-tab-${entry.kind}`,
214
- "aria-controls": "agents-panel",
215
- "aria-selected": tab === entry.kind,
216
- onClick: () => {
217
- setTab(entry.kind);
218
- setSaved(false);
219
- },
220
- children: entry.tab
221
- }, entry.kind))
222
- }),
223
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
224
- role: "tabpanel",
225
- id: "agents-panel",
226
- "aria-labelledby": `agents-tab-${tab}`,
227
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SecretForm, {
228
- kind: form.kind,
229
- label: form.label,
230
- hint: form.hint,
231
- onSaved
232
- }, form.kind)
233
- }),
234
- saved ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
235
- className: "note",
236
- role: "status",
237
- children: "Saved. The next agent start uses it."
238
- }) : null,
239
- status.data?.source === "studio" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
240
- className: "factory-sheet-actions agents-clear",
241
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
242
- type: "button",
243
- onClick: () => clear.mutate(),
244
- disabled: clear.isPending,
245
- children: "Remove the credential set in Studio"
246
- }), clear.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
247
- className: "factory-problems",
248
- role: "alert",
249
- children: clear.error.message
250
- }) : null]
251
- }) : null
252
- ]
253
- })]
208
+ })
254
209
  });
255
210
  }
256
211
  // src/views/factory/factory-form.tsx
@@ -296,7 +251,7 @@ function FactoryForm({ action, id, className, children, ...rest }) {
296
251
  }) : null]
297
252
  });
298
253
  }
299
- // ../../node_modules/.bun/zustand@5.0.16+ea2f17093d73c934/node_modules/zustand/esm/middleware.mjs
254
+ // ../../node_modules/.bun/zustand@5.0.16+d485e2f7e55e3bff/node_modules/zustand/esm/middleware.mjs
300
255
  function createJSONStorage(getStorage, options) {
301
256
  let storage;
302
257
  try {
@@ -485,17 +440,17 @@ function stepRow(rows, focused, delta) {
485
440
  }
486
441
  /** Whether a key press belongs to a field or the terminal rather than to a shortcut. */
487
442
  function typing(target) {
488
- return Boolean(target?.closest?.("input, textarea, select, [contenteditable], .outcome-terminal"));
443
+ return inField(target) || Boolean(target?.closest?.(".outcome-terminal"));
489
444
  }
490
- /** In an open dialog: 1–9 pick a one-click answer, J/K the next or previous Outcome. */
445
+ /** In an open Outcome panel: 1–9 pick a one-click answer, J/K the next or previous Outcome. */
491
446
  function dialogButton(dialog, key) {
492
447
  if (/^[1-9]$/.test(key)) return dialog.querySelector(`[data-option-key="${key}"]`);
493
448
  const step = {
494
- j: "J",
495
- k: "K"
449
+ j: "Next",
450
+ k: "Previous"
496
451
  }[key];
497
452
  if (!step) return null;
498
- return dialog.querySelector(`[data-outcome-goto][aria-keyshortcuts="${step}"]`);
453
+ return (dialog.closest("[data-slot=sheet-content]") ?? dialog).querySelector(`button[aria-label="${step}"]`);
499
454
  }
500
455
  /** On the board: N focuses the new-outcome field, / the filter. */
501
456
  function boardField(doc, key) {
@@ -505,7 +460,7 @@ function boardField(doc, key) {
505
460
  }
506
461
  /**
507
462
  * Board shortcuts: N starts a new outcome, / filters, J/K (arrows on a row) move between
508
- * rows, Enter opens one. In an open dialog J/K step to the next or previous Outcome, 1–9
463
+ * rows, Enter opens one. In an open Outcome panel J/K step to the next or previous Outcome, 1–9
509
464
  * pick a one-click answer and Ctrl/Cmd+Enter sends the form being typed in. Fields and the
510
465
  * terminal keep every other key.
511
466
  */
@@ -524,7 +479,9 @@ function factoryKeyHandler(doc) {
524
479
  return;
525
480
  }
526
481
  if (event.ctrlKey || event.metaKey || typing(target)) return;
527
- const dialog = doc.querySelector("dialog.outcome-dialog[open]");
482
+ const modal = target?.closest?.("[data-slot=\"sheet-content\"], [data-slot=\"dialog-content\"]");
483
+ if (modal && !modal.querySelector("[data-outcome-panel]")) return;
484
+ const dialog = doc.querySelector("[data-outcome-panel]");
528
485
  if (dialog) {
529
486
  const button = dialogButton(dialog, event.key);
530
487
  if (button) {
@@ -553,8 +510,8 @@ function factoryKeyHandler(doc) {
553
510
  function useFactoryKeys() {
554
511
  (0, import_react.useEffect)(() => {
555
512
  const handler = factoryKeyHandler(document);
556
- document.addEventListener("keydown", handler);
557
- return () => document.removeEventListener("keydown", handler);
513
+ window.addEventListener("keydown", handler, true);
514
+ return () => window.removeEventListener("keydown", handler, true);
558
515
  }, []);
559
516
  }
560
517
  /** Puts the decision count in the title and notifies when it grows, once per count. */
@@ -846,205 +803,6 @@ function OutcomeTerminal({ outcome, companion, focus = true }) {
846
803
  children: failed ? "The terminal could not start in this browser. Close and reopen the Outcome to retry." : null
847
804
  });
848
805
  }
849
- // src/views/factory/outcome.ts
850
- var ACTIVE = /* @__PURE__ */ new Set(["queued", "running"]);
851
- /** Why an Outcome waits on a person, or `null` when it does not. */
852
- function attentionKind(workset, run) {
853
- if (workset.stage === "done") return null;
854
- if (run?.control?.mode === "manual") return "control";
855
- if (run?.state === "waiting") return "decision";
856
- if (run?.state === "failed" || run?.state === "interrupted") return "problem";
857
- if (run && ACTIVE.has(run.state)) return null;
858
- if (workset.stage === "human-review") return "review";
859
- if (workset.stage === "merge-wait") return "merge";
860
- if (workset.stage === "publish") return "publish";
861
- return null;
862
- }
863
- function byId(a, b) {
864
- return a.workset.id < b.workset.id ? -1 : a.workset.id > b.workset.id ? 1 : 0;
865
- }
866
- /** When an Outcome started waiting, as far as Studio knows; unknown sorts last. */
867
- function waitingSince(item) {
868
- const parsed = Date.parse(item.run?.updatedAt || item.workset.queuedAt || "");
869
- return Number.isNaN(parsed) ? Number.POSITIVE_INFINITY : parsed;
870
- }
871
- function itemsOf(worksets, runs) {
872
- return worksets.map((workset) => ({
873
- workset,
874
- run: runs?.[workset.id]
875
- }));
876
- }
877
- function rankCompare(a, b) {
878
- return compareRanked({
879
- id: a.workset.id,
880
- rank: rankOf(a.workset)
881
- }, {
882
- id: b.workset.id,
883
- rank: rankOf(b.workset)
884
- });
885
- }
886
- /** When an Outcome last changed, newest-first ordering for the history. */
887
- function lastChange(item) {
888
- const stamps = [
889
- item.run?.situations?.[0]?.at,
890
- item.run?.updatedAt,
891
- item.workset.queuedAt
892
- ];
893
- return Math.max(0, ...stamps.map((stamp) => Date.parse(stamp ?? "")).filter(Number.isFinite));
894
- }
895
- /** A Later Outcome that already has a plan, or a run, is under way all the same. */
896
- function underWay(item) {
897
- return item.workset.queuedAt !== void 0 || item.workset.changes.length > 0 || item.run !== void 0 && item.run.state !== "idle";
898
- }
899
- /** Every Outcome where the home shows it; the view lists one that needs the person only there. */
900
- function factoryHome(worksets, runs) {
901
- const items = itemsOf(worksets, runs);
902
- const attention = items.flatMap((item) => {
903
- const kind = attentionKind(item.workset, item.run);
904
- return kind ? [{
905
- ...item,
906
- kind
907
- }] : [];
908
- }).toSorted((a, b) => waitingSince(a) - waitingSince(b) || byId(a, b));
909
- const open = items.filter((item) => item.workset.stage !== "done");
910
- return {
911
- attention,
912
- active: open.filter(underWay).toSorted(rankCompare),
913
- later: open.filter((item) => !underWay(item)).toSorted(byId),
914
- completed: items.filter((item) => item.workset.stage === "done").toSorted((a, b) => lastChange(b) - lastChange(a) || byId(a, b))
915
- };
916
- }
917
- /** Each milestone is reached once the Outcome's stage is past the one named. */
918
- var MILESTONES = [
919
- {
920
- label: "Understood",
921
- after: "clarify-intent",
922
- next: "The factory is working out what you want"
923
- },
924
- {
925
- label: "Approach chosen",
926
- after: "explore",
927
- next: "The factory is choosing the approach"
928
- },
929
- {
930
- label: "Plan ready",
931
- after: "propose",
932
- next: "The factory is writing the plan"
933
- },
934
- {
935
- label: "Plan approved",
936
- after: "human-review",
937
- next: "Ready for your review"
938
- },
939
- {
940
- label: "Built",
941
- after: "apply",
942
- next: "The factory is building it"
943
- },
944
- {
945
- label: "Merged",
946
- after: "merge-wait",
947
- next: "Ready for you to merge"
948
- },
949
- {
950
- label: "Delivered",
951
- after: "publish",
952
- next: "Ready to publish"
953
- }
954
- ];
955
- function stageIndex(stage) {
956
- return WORKSET_STAGE_ORDER.indexOf(stage);
957
- }
958
- function milestonesOf(workset) {
959
- const at = stageIndex(workset.stage);
960
- return MILESTONES.map((milestone) => ({
961
- label: milestone.label,
962
- reached: at > stageIndex(milestone.after)
963
- }));
964
- }
965
- function savedForLater(workset, run) {
966
- return !workset.queuedAt && workset.changes.length === 0 && (!run || run.state === "idle");
967
- }
968
- /** The next meaningful step, phrased by who acts next. */
969
- function nextStepOf(workset, run) {
970
- if (workset.stage === "done") return "Delivered";
971
- if (run?.control?.mode === "manual") return "You have control";
972
- if (run?.state === "waiting") return "Waiting for your answer";
973
- if (run?.state === "failed" || run?.state === "interrupted") return "Stopped; needs you";
974
- if (savedForLater(workset, run)) return "Saved for later";
975
- const at = stageIndex(workset.stage);
976
- return MILESTONES.find((milestone) => at <= stageIndex(milestone.after))?.next ?? "Delivered";
977
- }
978
- var DERIVED = {
979
- "clarify-intent": "Understanding what you want.",
980
- explore: "Working out the approach.",
981
- propose: "Writing the plan.",
982
- "human-review": "A plan is ready for your review.",
983
- apply: "Building it.",
984
- "merge-wait": "Built; waiting for the merge.",
985
- publish: "Merged; ready to publish.",
986
- done: "Delivered."
987
- };
988
- /** A sentence from the stage, for an Outcome the agent has not reported on. */
989
- function derivedSituation(workset, run) {
990
- if (run?.state === "queued") {
991
- if (run.waiting === "workset-slot") return "Waiting for a Workset slot.";
992
- if (run.waiting === "build-slot") return "Waiting for a build slot.";
993
- return "Waiting for a free slot.";
994
- }
995
- if (run?.state === "failed") return `Stopped: ${run.reason}`;
996
- if (run?.state === "interrupted") return "Stopped when Studio restarted.";
997
- if (run?.state === "waiting") return "Waiting for your answer.";
998
- if (savedForLater(workset, run)) return "Saved for later.";
999
- return DERIVED[workset.stage] ?? workset.stageLabel;
1000
- }
1001
- /** Run states that say more than the last report; queued, waiting, failed and interrupted. */
1002
- var OVERRIDING = /* @__PURE__ */ new Set([
1003
- "queued",
1004
- "waiting",
1005
- "failed",
1006
- "interrupted"
1007
- ]);
1008
- /** The latest reported situation, or a derived one without a time. */
1009
- function situationOf(workset, run) {
1010
- const reported = run?.situations?.[0];
1011
- if (reported && !(run && OVERRIDING.has(run.state))) return reported;
1012
- return { text: derivedSituation(workset, run) };
1013
- }
1014
- var ACTIVITY_LABELS = {
1015
- running: "Running",
1016
- queued: "Queued",
1017
- "needs-you": "Needs you",
1018
- control: "You have control",
1019
- stopped: "Stopped",
1020
- idle: "Idle",
1021
- later: "Saved for later",
1022
- done: "Delivered"
1023
- };
1024
- function activityOf(workset, run) {
1025
- if (workset.stage === "done") return "done";
1026
- if (run?.control?.mode === "manual") return "control";
1027
- if (run?.state === "failed" || run?.state === "interrupted") return "stopped";
1028
- if (run?.state === "running") return "running";
1029
- if (run?.state === "queued") return "queued";
1030
- if (attentionKind(workset, run)) return "needs-you";
1031
- return underWay({
1032
- workset,
1033
- run
1034
- }) ? "idle" : "later";
1035
- }
1036
- /** The Delivery Path map node each stage sits at; `complete` once delivered. */
1037
- var PATH_NODES = {
1038
- "clarify-intent": "clarify-intent",
1039
- explore: "explore",
1040
- propose: "propose",
1041
- "human-review": "reviews",
1042
- apply: "apply",
1043
- "merge-wait": "archive",
1044
- publish: "publish",
1045
- done: "complete"
1046
- };
1047
- var pathNodeOf = (workset) => PATH_NODES[workset.stage];
1048
806
  // src/views/factory/factory-view.tsx
1049
807
  var ATTENTION_LABELS = {
1050
808
  control: "You have control",
@@ -1071,6 +829,18 @@ function attentionLabel(kind, run) {
1071
829
  const count = run?.state === "waiting" ? questionsOf(run).length : 0;
1072
830
  return kind === "decision" && count > 1 ? `Decisions needed (${count})` : ATTENTION_LABELS[kind];
1073
831
  }
832
+ /** Optional Jira key for a new Outcome; it names the Outcome's Delivery Branch. */
833
+ function TicketField({ context }) {
834
+ if (context.ticketFormat !== "jira") return null;
835
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
836
+ name: "ticket",
837
+ className: "outcome-ticket",
838
+ placeholder: "ABC-123",
839
+ "aria-label": "Ticket (optional)",
840
+ autoComplete: "off",
841
+ spellCheck: false
842
+ });
843
+ }
1074
844
  /** The actions that move an Outcome forward; the rest stay quiet. */
1075
845
  var PRIMARY_ACTIONS = /* @__PURE__ */ new Set([
1076
846
  "answer",
@@ -1149,6 +919,7 @@ function OutcomeInput({ repositories, context }) {
1149
919
  value: "later",
1150
920
  children: "Save for later"
1151
921
  }),
922
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TicketField, { context }),
1152
923
  repositories.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
1153
924
  name: "repository",
1154
925
  required: true,
@@ -1266,17 +1037,21 @@ function FeedbackField({ item, context }) {
1266
1037
  if (stage === "publish" || stage === "done") return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FactoryForm, {
1267
1038
  action: "create",
1268
1039
  className: "outcome-feedback",
1269
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
1270
- name: "text",
1271
- rows: 2,
1272
- required: true,
1273
- "aria-label": "A new outcome"
1274
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1275
- type: "submit",
1276
- name: "start",
1277
- value: "start",
1278
- children: "Start as a new outcome"
1279
- })]
1040
+ children: [
1041
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
1042
+ name: "text",
1043
+ rows: 2,
1044
+ required: true,
1045
+ "aria-label": "A new outcome"
1046
+ }),
1047
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TicketField, { context }),
1048
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
1049
+ type: "submit",
1050
+ name: "start",
1051
+ value: "start",
1052
+ children: "Start as a new outcome"
1053
+ })
1054
+ ]
1280
1055
  });
1281
1056
  return actionFor(item, context)("feedback", "Request a change", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
1282
1057
  name: "feedback",
@@ -1850,44 +1625,21 @@ function OutcomeRow({ item, context, lead, progress = true, trailing }) {
1850
1625
  });
1851
1626
  }
1852
1627
  function OutcomeList({ label, section, count, children }) {
1853
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
1628
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
1854
1629
  className: "outcome-list-section",
1855
1630
  "data-section": section,
1856
- "aria-label": label,
1857
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("h3", { children: [
1858
- label,
1859
- " ",
1860
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1861
- className: "outcome-list-count mono",
1862
- children: count
1631
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListCard, {
1632
+ title: label,
1633
+ count,
1634
+ tone: section === "attention" ? "warn" : void 0,
1635
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
1636
+ className: "outcome-list",
1637
+ children
1863
1638
  })
1864
- ] }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
1865
- className: "outcome-list",
1866
- children
1867
- })]
1639
+ })
1868
1640
  });
1869
1641
  }
1870
1642
  var sameText = (a, b) => a.replace(/\.$/, "").toLowerCase() === b.replace(/\.$/, "").toLowerCase();
1871
- function StepButton({ to, label, keyName }) {
1872
- const address = useOutcomeAddress();
1873
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
1874
- type: "button",
1875
- className: "outcome-step",
1876
- "data-outcome-goto": to ? dialogId(to) : void 0,
1877
- disabled: !to,
1878
- "aria-keyshortcuts": keyName,
1879
- onClick: () => {
1880
- if (!to) return;
1881
- useFactoryUi.getState().setStepped(true);
1882
- address.step(to);
1883
- },
1884
- children: [
1885
- label,
1886
- " ",
1887
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: keyName })
1888
- ]
1889
- });
1890
- }
1891
1643
  /** What the person is asked to do, with what it expects of them. */
1892
1644
  function AttentionSection({ item, kind, context }) {
1893
1645
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
@@ -1956,11 +1708,11 @@ function History({ run, now }) {
1956
1708
  });
1957
1709
  }
1958
1710
  /**
1959
- * Everything about one Outcome. The main column leads with what needs the person, then the
1960
- * log, status and the run's actions, and history; the rail shows where the Outcome is on the
1961
- * Delivery Path, with the execution facts under it. In control the terminal takes the width.
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.
1962
1714
  */
1963
- function OutcomeDialog({ item, kind, context, place }) {
1715
+ function OutcomePanel({ item, kind, context }) {
1964
1716
  const { workset, run } = item;
1965
1717
  const situation = situationOf(workset, run);
1966
1718
  const activity = activityOf(workset, run);
@@ -1971,127 +1723,89 @@ function OutcomeDialog({ item, kind, context, place }) {
1971
1723
  activity,
1972
1724
  note: progressNote(item, activity, context.now)
1973
1725
  };
1974
- const ref = useModalDialog(useOutcomeAddress().close, (dialog) => {
1975
- dialog.showModal();
1976
- dialog.querySelector(".outcome-dialog-close")?.focus();
1977
- });
1978
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("dialog", {
1979
- ref,
1726
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1980
1727
  id,
1981
1728
  className: "outcome-dialog",
1729
+ "data-outcome-panel": "",
1982
1730
  "data-workset": workset.id,
1983
1731
  "data-layout": kind === "control" ? "control" : void 0,
1984
- "aria-labelledby": `${id}-title`,
1985
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("header", {
1732
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("header", {
1986
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",
1987
1753
  children: [
1988
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
1989
- className: "outcome-dialog-heading",
1990
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
1991
- id: `${id}-title`,
1992
- children: workset.title
1993
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
1994
- className: "outcome-dialog-state",
1995
- children: [
1996
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ActivityDot, { activity }),
1997
- ACTIVITY_LABELS[activity],
1998
- since ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
1999
- className: "factory-age mono",
2000
- children: ["· ", ageText(since, context.now)]
2001
- }) : null
2002
- ]
2003
- })]
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
2004
1771
  }),
2005
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("nav", {
2006
- className: "outcome-dialog-steps",
2007
- "aria-label": "Other outcomes",
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
1786
+ })]
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",
2008
1795
  children: [
2009
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
2010
- className: "outcome-dialog-place mono",
2011
- children: [
2012
- place.index + 1,
2013
- " of ",
2014
- place.total
2015
- ]
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"
2016
1801
  }),
2017
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StepButton, {
2018
- to: place.prev,
2019
- label: "Previous",
2020
- keyName: "K"
2021
- }),
2022
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StepButton, {
2023
- to: place.next,
2024
- label: "Next",
2025
- keyName: "J"
1802
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Facts, {
1803
+ item,
1804
+ context
2026
1805
  })
2027
1806
  ]
2028
- }),
2029
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("form", {
2030
- method: "dialog",
2031
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
2032
- type: "submit",
2033
- className: "outcome-dialog-close",
2034
- "aria-keyshortcuts": "Escape",
2035
- children: ["Close ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { children: "Esc" })]
2036
- })
2037
1807
  })
2038
1808
  ]
2039
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2040
- className: "outcome-dialog-body",
2041
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
2042
- className: "outcome-dialog-main",
2043
- children: [
2044
- kind ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AttentionSection, {
2045
- item,
2046
- kind,
2047
- context
2048
- }) : null,
2049
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TakeoverPending, {
2050
- run,
2051
- now: context.now
2052
- }),
2053
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeLog, { item }),
2054
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeStatus, {
2055
- item,
2056
- situation
2057
- }),
2058
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(RunActions, {
2059
- item,
2060
- context
2061
- }),
2062
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TakeControl, {
2063
- item,
2064
- context
2065
- }),
2066
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(History, {
2067
- run,
2068
- now: context.now
2069
- }),
2070
- workset.intent ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
2071
- className: "outcome-intent-section",
2072
- "aria-label": "Request",
2073
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { children: "Request" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2074
- className: "outcome-intent",
2075
- children: workset.intent
2076
- })]
2077
- }) : null,
2078
- kind !== "review" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FeedbackField, {
2079
- item,
2080
- context
2081
- }) : null
2082
- ]
2083
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", {
2084
- className: "outcome-dialog-rail",
2085
- "aria-label": "Delivery Path",
2086
- children: [kind === "control" ? null : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(WorkflowGraphView, {
2087
- path: context.path,
2088
- progress,
2089
- label: "Where it is on the Delivery Path"
2090
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Facts, {
2091
- item,
2092
- context
2093
- })]
2094
- })]
2095
1809
  })]
2096
1810
  });
2097
1811
  }
@@ -2184,7 +1898,7 @@ function OpenAgents({ label }) {
2184
1898
  });
2185
1899
  }
2186
1900
  /** The filter, the keys and the offer to notify, above the board. */
2187
- function BoardToolbar({ count, worksets, writable, factoryMode }) {
1901
+ function BoardToolbar({ count, worksets, writable, factoryMode, onPass, children }) {
2188
1902
  const filter = useFactoryUi((state) => state.filter);
2189
1903
  const setFilter = useFactoryUi((state) => state.setFilter);
2190
1904
  const notifications = useNotificationOffer();
@@ -2193,6 +1907,7 @@ function BoardToolbar({ count, worksets, writable, factoryMode }) {
2193
1907
  "data-factory-live": "",
2194
1908
  "data-needs-you": count,
2195
1909
  children: [
1910
+ children,
2196
1911
  worksets > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
2197
1912
  type: "search",
2198
1913
  className: "outcome-filter",
@@ -2231,49 +1946,111 @@ function BoardToolbar({ count, worksets, writable, factoryMode }) {
2231
1946
  onClick: notifications.ask,
2232
1947
  children: "Notify me about decisions"
2233
1948
  }),
2234
- factoryMode && writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OpenAgents, { label: "Agents" }) : null
1949
+ factoryMode && writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OpenAgents, { label: "Agents" }) : null,
1950
+ onPass ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
1951
+ type: "button",
1952
+ className: "factory-primary factory-pass",
1953
+ onClick: onPass,
1954
+ children: ["Clear what needs you ", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
1955
+ className: "mono",
1956
+ children: count
1957
+ })]
1958
+ }) : null
2235
1959
  ]
2236
1960
  });
2237
1961
  }
2238
- /** Outcomes as lists of one line each; everything else opens in the Outcome's dialog. */
1962
+ /** The board's Outcomes and the context every row and panel reads. */
1963
+ function contextOf({ payload, companionDigest, writable, sessions = null, runs = null, now }) {
1964
+ return {
1965
+ home: factoryHome(payload.worksets, runs),
1966
+ context: {
1967
+ companionDigest,
1968
+ writable,
1969
+ sessions,
1970
+ runner: runs !== null,
1971
+ now,
1972
+ path: workflowPlan({ topology: payload.topology }).paths[0],
1973
+ ticketFormat: payload.ticketFormat
1974
+ }
1975
+ };
1976
+ }
1977
+ /** Outcomes as lists of one line each; everything else opens in the Outcome's panel. */
2239
1978
  function Factory({ payload, companionDigest, writable, sessions = null, runs = null, now, openId, factoryMode = false }) {
2240
- const home = factoryHome(payload.worksets, runs);
2241
- const context = {
1979
+ const { home, context } = contextOf({
1980
+ payload,
2242
1981
  companionDigest,
2243
1982
  writable,
2244
1983
  sessions,
2245
- runner: runs !== null,
2246
- now,
2247
- path: workflowPlan({ topology: payload.topology }).paths[0]
2248
- };
1984
+ runs,
1985
+ now
1986
+ });
2249
1987
  const { kinds, ordered, attention, running, later, completed, shownCount, query } = useBoard(home);
2250
- const openIndex = openId ? ordered.findIndex((item) => item.workset.id === openId) : -1;
2251
1988
  const idle = running.all.length === 0 && home.attention.length === 0;
2252
1989
  useFactoryKeys();
2253
1990
  useNeedsYou(home.attention.length);
2254
- const open = openIndex >= 0 ? {
2255
- item: ordered[openIndex],
2256
- index: openIndex
2257
- } : null;
1991
+ const [list, setList] = (0, import_react.useState)("all");
1992
+ const [pass, setPass] = (0, import_react.useState)(false);
1993
+ const address = useOutcomeAddress();
1994
+ const shows = (section) => list === "all" || list === section;
1995
+ const walk = pass ? home.attention : ordered;
1996
+ const open = openId ? ordered.find((item) => item.workset.id === openId) ?? null : null;
2258
1997
  const agentsOpen = useFactoryUi((state) => state.agentsOpen);
2259
1998
  const setAgentsOpen = useFactoryUi((state) => state.setAgentsOpen);
2260
1999
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FactoryCompanion.Provider, {
2261
2000
  value: companionDigest,
2262
2001
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
2263
- className: "view-section factory-home",
2002
+ className: cn(PAGE_PAD, "view-section factory-home grid content-start gap-4 pb-10"),
2264
2003
  "aria-label": "Factory",
2265
2004
  children: [
2005
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeInput, {
2006
+ repositories: payload.linkedRepositories,
2007
+ context
2008
+ }),
2266
2009
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BoardToolbar, {
2267
2010
  count: home.attention.length,
2268
2011
  worksets: payload.worksets.length,
2269
2012
  writable,
2270
- factoryMode
2271
- }),
2272
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeInput, {
2273
- repositories: payload.linkedRepositories,
2274
- context
2013
+ factoryMode,
2014
+ onPass: home.attention.length > 0 ? () => {
2015
+ setPass(true);
2016
+ useFactoryUi.getState().setStepped(false);
2017
+ address.open(home.attention[0].workset.id);
2018
+ } : void 0,
2019
+ children: payload.worksets.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Pills, {
2020
+ label: "Show outcomes",
2021
+ value: list,
2022
+ onChange: setList,
2023
+ options: [
2024
+ {
2025
+ value: "all",
2026
+ label: "All",
2027
+ count: payload.worksets.length
2028
+ },
2029
+ {
2030
+ value: "attention",
2031
+ label: "Needs you",
2032
+ count: home.attention.length,
2033
+ tone: "warn"
2034
+ },
2035
+ {
2036
+ value: "active",
2037
+ label: "Running",
2038
+ count: running.all.length
2039
+ },
2040
+ {
2041
+ value: "later",
2042
+ label: "Later",
2043
+ count: home.later.length
2044
+ },
2045
+ {
2046
+ value: "completed",
2047
+ label: "Done",
2048
+ count: home.completed.length
2049
+ }
2050
+ ]
2051
+ }) : null
2275
2052
  }),
2276
- attention.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeList, {
2053
+ shows("attention") && attention.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeList, {
2277
2054
  label: "Needs you",
2278
2055
  section: "attention",
2279
2056
  count: attention.length,
@@ -2287,7 +2064,7 @@ function Factory({ payload, companionDigest, writable, sessions = null, runs = n
2287
2064
  })
2288
2065
  }, item.workset.id))
2289
2066
  }) : null,
2290
- running.shown.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeList, {
2067
+ shows("active") && running.shown.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeList, {
2291
2068
  label: "Running",
2292
2069
  section: "active",
2293
2070
  count: running.shown.length,
@@ -2306,7 +2083,7 @@ function Factory({ payload, companionDigest, writable, sessions = null, runs = n
2306
2083
  hidden: !query || shownCount > 0,
2307
2084
  children: "No outcomes match the filter."
2308
2085
  }),
2309
- later.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeList, {
2086
+ shows("later") && later.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeList, {
2310
2087
  label: "Later",
2311
2088
  section: "later",
2312
2089
  count: later.length,
@@ -2317,22 +2094,32 @@ function Factory({ payload, companionDigest, writable, sessions = null, runs = n
2317
2094
  trailing: actionFor(item, context)("start", "Start")
2318
2095
  }, item.workset.id))
2319
2096
  }) : null,
2320
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Completed, {
2097
+ shows("completed") ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Completed, {
2321
2098
  items: completed,
2322
2099
  context,
2323
2100
  expanded: Boolean(query)
2101
+ }) : null,
2102
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SidePanel, {
2103
+ items: walk.map((item) => item.workset.id),
2104
+ current: open?.workset.id ?? null,
2105
+ onSelect: (id) => {
2106
+ if (id === null) {
2107
+ setPass(false);
2108
+ address.close();
2109
+ return;
2110
+ }
2111
+ useFactoryUi.getState().setStepped(true);
2112
+ address.step(id);
2113
+ },
2114
+ pass: pass ? "Needs you" : void 0,
2115
+ wide: true,
2116
+ title: open ? open.workset.title : "Outcome",
2117
+ children: open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomePanel, {
2118
+ item: open,
2119
+ kind: kinds.get(open.workset.id) ?? null,
2120
+ context
2121
+ }, open.workset.id) : null
2324
2122
  }),
2325
- open ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OutcomeDialog, {
2326
- item: open.item,
2327
- kind: kinds.get(open.item.workset.id) ?? null,
2328
- context,
2329
- place: {
2330
- index: open.index,
2331
- total: ordered.length,
2332
- prev: ordered[open.index - 1]?.workset.id,
2333
- next: ordered[open.index + 1]?.workset.id
2334
- }
2335
- }, open.item.workset.id) : null,
2336
2123
  payload.worksetProblems.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Warnings, { warnings: payload.worksetProblems.map((problem) => `${problem.path} ${problem.reason}`) }) : null,
2337
2124
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Warnings, { warnings: payload.warnings }),
2338
2125
  factoryMode && writable && agentsOpen ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgentsDialog, { onClose: () => setAgentsOpen(false) }) : null
@@ -2365,9 +2152,9 @@ function FactoryRoute() {
2365
2152
  function FactoryBoard({ companion, outcome }) {
2366
2153
  const { data } = useSuspenseQuery(factoryQuery(companion));
2367
2154
  if (!data.payload) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("section", {
2368
- className: "panel",
2155
+ className: "mx-8 max-sm:mx-4",
2369
2156
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
2370
- className: "empty",
2157
+ className: "empty m-0 rounded-card border border-dashed border-rule px-6 py-7 text-muted",
2371
2158
  children: data.error ?? "No state collected for this companion."
2372
2159
  })
2373
2160
  });