@1agh/maude 2.0.3 → 2.0.6

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 (242) hide show
  1. package/README.md +6 -5
  2. package/apps/hub/src/project-transactions/kernel.mjs +10 -1
  3. package/apps/studio/access/filters.ts +12 -5
  4. package/apps/studio/access/known-canvases.ts +24 -1
  5. package/apps/studio/access/refused-inputs.ts +89 -0
  6. package/apps/studio/access/request.ts +0 -1
  7. package/apps/studio/acp/adapter-stderr.ts +43 -13
  8. package/apps/studio/acp/background-tasks.ts +155 -0
  9. package/apps/studio/acp/bridge.ts +44 -5
  10. package/apps/studio/acp/connected-fact.ts +15 -4
  11. package/apps/studio/acp/index.ts +14 -5
  12. package/apps/studio/actions/agents.ts +10 -0
  13. package/apps/studio/actions/defs/app.ts +12 -0
  14. package/apps/studio/actions/defs/view.ts +12 -0
  15. package/apps/studio/actions.manifest.json +25 -1
  16. package/apps/studio/actions.parity.json +13 -1
  17. package/apps/studio/annotations/ui/element-node.tsx +139 -54
  18. package/apps/studio/annotations/ui/lod.tsx +1 -1
  19. package/apps/studio/annotations/ui/text-style.ts +1 -1
  20. package/apps/studio/annotations-layer.tsx +0 -12
  21. package/apps/studio/api.ts +73 -24
  22. package/apps/studio/artboard-live-gate.tsx +267 -0
  23. package/apps/studio/artboard-live.ts +336 -0
  24. package/apps/studio/artboard-webgl.ts +668 -0
  25. package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
  26. package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
  27. package/apps/studio/bin/_canvas-reasons.mjs +34 -0
  28. package/apps/studio/bin/_ds-check-live.mjs +37 -0
  29. package/apps/studio/bin/_ds-check.mjs +4 -1
  30. package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
  31. package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
  32. package/apps/studio/bin/_import-asset.mjs +2 -1
  33. package/apps/studio/bin/_perf-probe.mjs +2 -1
  34. package/apps/studio/bin/_png-playwright.mjs +10 -1
  35. package/apps/studio/bin/_pw-launch.mjs +14 -0
  36. package/apps/studio/bin/_studio-verb.mjs +24 -3
  37. package/apps/studio/bin/_thumb-blank.mjs +70 -0
  38. package/apps/studio/bin/_thumb-cover.mjs +35 -0
  39. package/apps/studio/bin/_thumbs-playwright.mjs +93 -13
  40. package/apps/studio/bin/ds-check.sh +5 -1
  41. package/apps/studio/bin/perf.sh +11 -1
  42. package/apps/studio/bin/server-up.sh +7 -2
  43. package/apps/studio/bin/smoke.sh +19 -0
  44. package/apps/studio/boot-progress.ts +31 -0
  45. package/apps/studio/canvas-build-sandbox.ts +275 -42
  46. package/apps/studio/canvas-build-worker.ts +10 -0
  47. package/apps/studio/canvas-create.ts +24 -0
  48. package/apps/studio/canvas-lib.tsx +131 -12
  49. package/apps/studio/canvas-module-cache.ts +93 -0
  50. package/apps/studio/canvas-source/errors.ts +39 -0
  51. package/apps/studio/canvas-source/waiting.ts +290 -0
  52. package/apps/studio/client/actions/shell-key-handlers.js +5 -0
  53. package/apps/studio/client/app.jsx +19 -9
  54. package/apps/studio/client/canvas-url.js +13 -0
  55. package/apps/studio/client/github.js +23 -3
  56. package/apps/studio/client/home/HomeAccounts.jsx +262 -0
  57. package/apps/studio/client/home/Shelves.jsx +4 -3
  58. package/apps/studio/client/home/home-accounts-model.js +121 -0
  59. package/apps/studio/client/home/home-api.js +36 -19
  60. package/apps/studio/client/home/home-app.jsx +141 -40
  61. package/apps/studio/client/home/home-model.js +172 -6
  62. package/apps/studio/client/home/home.css +169 -5
  63. package/apps/studio/client/home/shell-mode.js +8 -1
  64. package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
  65. package/apps/studio/client/hooks/use-project-data.jsx +2 -0
  66. package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
  67. package/apps/studio/client/hooks/use-tabs.jsx +64 -35
  68. package/apps/studio/client/index-loader.ts +23 -3
  69. package/apps/studio/client/panels/ChatPanel.jsx +49 -57
  70. package/apps/studio/client/panels/CreateProject.jsx +19 -5
  71. package/apps/studio/client/panels/DiffView.jsx +314 -248
  72. package/apps/studio/client/panels/TeamProjects.jsx +119 -69
  73. package/apps/studio/client/panels/acp-runtime.js +25 -0
  74. package/apps/studio/client/panels/caps-cache.js +46 -0
  75. package/apps/studio/client/panels/chat-finish.js +66 -0
  76. package/apps/studio/client/shell/frame-cap.js +53 -0
  77. package/apps/studio/client/shell/viewport.jsx +45 -8
  78. package/apps/studio/client/styles/_index.css +2 -0
  79. package/apps/studio/client/tree/tree.jsx +48 -21
  80. package/apps/studio/client/v2/access/access-client.js +2 -0
  81. package/apps/studio/client/v2/access/access-host.jsx +12 -1
  82. package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
  83. package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
  84. package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
  85. package/apps/studio/client/v2/ai/Composer.jsx +27 -10
  86. package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
  87. package/apps/studio/client/v2/ai/ai-run.css +87 -3
  88. package/apps/studio/client/v2/ai/background-model.js +113 -0
  89. package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
  90. package/apps/studio/client/v2/ai/run-api.js +7 -3
  91. package/apps/studio/client/v2/ai/runs-store.js +2 -1
  92. package/apps/studio/client/v2/annotations/vote-store.js +11 -5
  93. package/apps/studio/client/v2/assets/asset-state-lane.js +6 -3
  94. package/apps/studio/client/v2/assets/assets-bus.js +10 -8
  95. package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
  96. package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
  97. package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
  98. package/apps/studio/client/v2/assets/spotlight.css +153 -0
  99. package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
  100. package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
  101. package/apps/studio/client/v2/assets/tile.jsx +3 -0
  102. package/apps/studio/client/v2/assets/use-assets.js +2 -1
  103. package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
  104. package/apps/studio/client/v2/canvases/covers.js +11 -5
  105. package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
  106. package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
  107. package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
  108. package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
  109. package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
  110. package/apps/studio/client/v2/canvases/use-pins.js +2 -1
  111. package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
  112. package/apps/studio/client/v2/code/canvas-imports-card.jsx +15 -14
  113. package/apps/studio/client/v2/code/canvas-imports-words.js +44 -0
  114. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
  115. package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
  116. package/apps/studio/client/v2/code/code-bus.js +5 -0
  117. package/apps/studio/client/v2/code/code.css +67 -0
  118. package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
  119. package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
  120. package/apps/studio/client/v2/create/name-dialog.css +10 -0
  121. package/apps/studio/client/v2/ds/advanced-host.jsx +11 -23
  122. package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
  123. package/apps/studio/client/v2/ds/library-host.jsx +45 -45
  124. package/apps/studio/client/v2/ds/make-host.jsx +13 -12
  125. package/apps/studio/client/v2/ds/off-system-host.jsx +18 -16
  126. package/apps/studio/client/v2/ds/review-host.jsx +7 -1
  127. package/apps/studio/client/v2/ds/truth-host.jsx +15 -14
  128. package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
  129. package/apps/studio/client/v2/empty/arriving.jsx +29 -12
  130. package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
  131. package/apps/studio/client/v2/empty/not-local.jsx +31 -1
  132. package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
  133. package/apps/studio/client/v2/export/last-finished.js +2 -1
  134. package/apps/studio/client/v2/history/branch-actions.js +13 -9
  135. package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
  136. package/apps/studio/client/v2/history/git-model.js +21 -5
  137. package/apps/studio/client/v2/history/git-parts.jsx +76 -43
  138. package/apps/studio/client/v2/history/history.css +6 -0
  139. package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
  140. package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
  141. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
  142. package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
  143. package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
  144. package/apps/studio/client/v2/presence/faces.jsx +42 -14
  145. package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
  146. package/apps/studio/client/v2/search/search-recent.js +3 -1
  147. package/apps/studio/client/v2/search/search-remote.js +6 -4
  148. package/apps/studio/client/v2/settings/connections-model.js +1 -1
  149. package/apps/studio/client/v2/shell/account-card.jsx +10 -4
  150. package/apps/studio/client/v2/shell/canvas-crash-guard.js +137 -0
  151. package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
  152. package/apps/studio/client/v2/shell/menu-runner.js +12 -0
  153. package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
  154. package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
  155. package/apps/studio/client/v2/shell/project-account-model.js +182 -0
  156. package/apps/studio/client/v2/shell/recovery-store.js +2 -1
  157. package/apps/studio/client/v2/shell/served-routes.js +120 -0
  158. package/apps/studio/client/v2/shell/share-cluster-host.jsx +139 -11
  159. package/apps/studio/client/v2/shell/share-cluster.css +58 -0
  160. package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
  161. package/apps/studio/client/v2/shell/shell-activity.js +19 -0
  162. package/apps/studio/client/v2/shell/team-switch.js +94 -0
  163. package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
  164. package/apps/studio/client/v2/shell/use-account.js +8 -1
  165. package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
  166. package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
  167. package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
  168. package/apps/studio/cloud/endpoints.ts +23 -1
  169. package/apps/studio/collab/persistence.ts +9 -1
  170. package/apps/studio/collab/registry.ts +32 -0
  171. package/apps/studio/collab/room.ts +8 -0
  172. package/apps/studio/config-reload-wire.ts +53 -0
  173. package/apps/studio/dist/client.bundle.js +1098 -1102
  174. package/apps/studio/dist/styles.css +1 -1
  175. package/apps/studio/ds/board/specimen.tsx +12 -1
  176. package/apps/studio/ds/canvas-cli.ts +58 -2
  177. package/apps/studio/ds/check.ts +26 -1
  178. package/apps/studio/ds/cli.ts +7 -3
  179. package/apps/studio/ds/convert.ts +34 -6
  180. package/apps/studio/ds/ds-verb.ts +13 -0
  181. package/apps/studio/ds/post-build.ts +38 -0
  182. package/apps/studio/ds/upgrade-apply.ts +27 -5
  183. package/apps/studio/ds/upgrade-cli.ts +22 -2
  184. package/apps/studio/ds/upgrade-prove.ts +198 -15
  185. package/apps/studio/ds/upgrade-stage.ts +4 -1
  186. package/apps/studio/editing/minimap-context.tsx +3 -3
  187. package/apps/studio/editing/page-activity.ts +251 -0
  188. package/apps/studio/editing/rotate-handle.tsx +9 -5
  189. package/apps/studio/editing/sticky-name.tsx +4 -4
  190. package/apps/studio/history/restore-artboard-action.ts +40 -0
  191. package/apps/studio/history/trash.ts +6 -0
  192. package/apps/studio/home/accounts.ts +87 -0
  193. package/apps/studio/home/hub.ts +77 -175
  194. package/apps/studio/home/index-reader.ts +24 -2
  195. package/apps/studio/home/routes.ts +66 -8
  196. package/apps/studio/http.ts +131 -68
  197. package/apps/studio/index-flight.ts +40 -0
  198. package/apps/studio/managed-projects.ts +52 -24
  199. package/apps/studio/migrate/hub.ts +7 -1
  200. package/apps/studio/routes/canvas-source.ts +44 -2
  201. package/apps/studio/routes/ds-convert.ts +18 -0
  202. package/apps/studio/routes/history.ts +28 -5
  203. package/apps/studio/routes/hub-signin.ts +115 -0
  204. package/apps/studio/routes/index.ts +4 -0
  205. package/apps/studio/routes/table.ts +7 -0
  206. package/apps/studio/routes/trash.ts +19 -1
  207. package/apps/studio/server.ts +19 -10
  208. package/apps/studio/sync/accepted-cold-start.ts +54 -16
  209. package/apps/studio/sync/accepted-link.ts +9 -4
  210. package/apps/studio/sync/asset-push.ts +146 -23
  211. package/apps/studio/sync/asset-state.ts +3 -2
  212. package/apps/studio/sync/code-module-consent.ts +74 -0
  213. package/apps/studio/sync/file-ledger.ts +35 -0
  214. package/apps/studio/sync/file-membership.ts +28 -3
  215. package/apps/studio/sync/file-plane.ts +483 -86
  216. package/apps/studio/sync/file-pull.ts +304 -33
  217. package/apps/studio/sync/hub-browser-signin.ts +377 -0
  218. package/apps/studio/sync/hub-link.ts +1 -2
  219. package/apps/studio/sync/hub-text-undo.ts +30 -10
  220. package/apps/studio/sync/index.ts +381 -161
  221. package/apps/studio/sync/journal-client.ts +94 -5
  222. package/apps/studio/sync/pending-deletes.ts +100 -0
  223. package/apps/studio/sync/projection.ts +121 -14
  224. package/apps/studio/sync/pull-pacer.ts +160 -0
  225. package/apps/studio/sync/pull-priority.ts +119 -0
  226. package/apps/studio/sync/seed-progress.ts +58 -3
  227. package/apps/studio/sync/status.ts +3 -1
  228. package/apps/studio/sync/transaction-client.ts +71 -6
  229. package/apps/studio/sync/workspace-signin.ts +6 -256
  230. package/apps/studio/sync/writer-registry.ts +5 -1
  231. package/apps/studio/thumbs/service.ts +12 -2
  232. package/apps/studio/thumbs/validate.ts +7 -0
  233. package/apps/studio/ui-prefs-migrate.ts +4 -0
  234. package/apps/studio/video-comp.tsx +23 -0
  235. package/apps/studio/video-links-overlay.tsx +3 -2
  236. package/apps/studio/whats-new.json +126 -0
  237. package/cli/lib/bash-guard.mjs +13 -1
  238. package/cli/lib/design-help.gen.mjs +1 -1
  239. package/cli/lib/design-hook.mjs +20 -0
  240. package/cli/lib/studio-locate.mjs +35 -10
  241. package/cli/lib/workspace-plan.mjs +14 -0
  242. package/package.json +8 -8
@@ -5,9 +5,12 @@
5
5
  // two halves:
6
6
  //
7
7
  // 1. HERE (the running studio, which holds the Maude Cloud device session or
8
- // takes a team-server sign-in): obtain and store the hub credential, then
9
- // ask the project what it looks like (its bootstrap) — name, canvas
10
- // groups — so the local copy can be declared correctly before it exists.
8
+ // a team-server credential the browser sign-in already stored): obtain the
9
+ // hub credential, then ask the project what it looks like (its bootstrap)
10
+ // — name, canvas groups — so the local copy can be declared correctly
11
+ // before it exists. Issue #204: the desktop owns NO login method for a
12
+ // team server — no email, no password. A team server is signed in to on
13
+ // its OWN page (routes/hub-signin.ts); `known-hub` opens what that stored.
11
14
  // 2. The native shell (`managed_project_open`) creates the project's own
12
15
  // copy under the app's data directory from exactly what this returns,
13
16
  // and switches to it; the sync runtime then brings everything down.
@@ -16,17 +19,54 @@
16
19
 
17
20
  import { createCloudEndpoints } from './cloud/endpoints.ts';
18
21
  import type { Context } from './context.ts';
19
- import { saveHubCredential } from './sync/hub-link.ts';
20
22
  import { getHubRecord, normalizeUrl } from './sync/hubs-config.ts';
21
- import { signInToWorkspace } from './sync/workspace-signin.ts';
22
23
 
23
24
  export type PrepareInput =
24
25
  | { kind: 'cloud'; projectId: string }
25
26
  | { kind: 'handoff'; code: string; claimedProject?: string }
26
- | { kind: 'hub'; url: string; email: string; password: string }
27
- /** A team server this machine already holds a credential for. */
27
+ /** A team server this machine already holds a credential for (the browser sign-in stored it). */
28
28
  | { kind: 'known-hub'; url: string };
29
29
 
30
+ /** The words for an email or password sent to open a team-server project — the app takes neither
31
+ * (issue #204). Signing in is the hub's own page; the one fallback is the pasted access token. */
32
+ export const NO_PASSWORD_WORDS = "Sign in on the team server's own page — press Sign in.";
33
+
34
+ export type PrepareBody =
35
+ | { ok: true; input: PrepareInput }
36
+ | { ok: false; status: 400; error: string; reason?: 'password-retired' };
37
+
38
+ /** True for a body that carries a team-server email or password, or the retired `hub` kind. */
39
+ function carriesPassword(b: Record<string, unknown>): boolean {
40
+ return b.email !== undefined || b.password !== undefined || b.kind === 'hub';
41
+ }
42
+
43
+ /** `POST /_api/projects/prepare` body → a typed input, or a plain 400. Anything carrying an email
44
+ * or a password is refused for EVERY kind before an input is built — the secret is never read,
45
+ * forwarded or echoed. */
46
+ export function parsePrepareBody(body: unknown): PrepareBody {
47
+ const b = (body && typeof body === 'object' ? body : {}) as Record<string, unknown>;
48
+ if (carriesPassword(b))
49
+ return { ok: false, status: 400, reason: 'password-retired', error: NO_PASSWORD_WORDS };
50
+ const str = (v: unknown) => (typeof v === 'string' ? v : '');
51
+ switch (b.kind) {
52
+ case 'cloud':
53
+ return { ok: true, input: { kind: 'cloud', projectId: str(b.projectId) } };
54
+ case 'handoff':
55
+ return {
56
+ ok: true,
57
+ input: {
58
+ kind: 'handoff',
59
+ code: str(b.code),
60
+ claimedProject: str(b.claimedProject) || undefined,
61
+ },
62
+ };
63
+ case 'known-hub':
64
+ return { ok: true, input: { kind: 'known-hub', url: str(b.url) } };
65
+ default:
66
+ return { ok: false, status: 400, error: 'unknown kind' };
67
+ }
68
+ }
69
+
30
70
  export interface PreparedProject {
31
71
  ok: true;
32
72
  serverUrl: string;
@@ -119,9 +159,13 @@ export async function prepareManagedProject(
119
159
  /** `hubsConfigPath`: where the hub credential is stored and read back (N-H1 — Home prepares
120
160
  * for one profile at a time, so never the process-global file for another profile).
121
161
  * `fetchImpl` (S6.6): every request to a team server goes through it — Home passes one that
122
- * refuses redirects, so a 307 can never carry the password or the token to another host. */
162
+ * refuses redirects, so a 307 can never carry the token to another host. */
123
163
  opts: { cloudConfigPath?: string; hubsConfigPath?: string; fetchImpl?: typeof fetch } = {}
124
164
  ): Promise<PrepareResult> {
165
+ // A caller outside the types can still hand over a retired shape (an email, a password, the old
166
+ // `hub` kind): refused before any request, here as well as at the route.
167
+ if (carriesPassword(input as unknown as Record<string, unknown>))
168
+ return { ok: false, error: NO_PASSWORD_WORDS, status: 400 };
125
169
  let serverUrl: string;
126
170
  let projectId: string | null = null;
127
171
  let role: string | null = null;
@@ -161,22 +205,6 @@ export async function prepareManagedProject(
161
205
  projectId = j.project ?? (input.kind === 'cloud' ? input.projectId : null);
162
206
  role = j.role ?? null;
163
207
  name = projectId;
164
- } else if (input.kind === 'hub') {
165
- const hubsPath = opts.hubsConfigPath;
166
- const r = await signInToWorkspace(
167
- { url: input.url, email: input.email, password: input.password },
168
- {
169
- fetchImpl: opts.fetchImpl,
170
- // S6.6: the credential goes to the SAME hubs.json it is read back from below — before,
171
- // a non-default profile stored it in the process-global file and then could not find it
172
- save: hubsPath
173
- ? (u, t, role, exp, account) => saveHubCredential(u, t, role, exp, hubsPath, account)
174
- : undefined,
175
- }
176
- );
177
- if (!r.json.ok) return { ok: false, error: r.json.error, status: r.status };
178
- serverUrl = r.json.url;
179
- role = r.json.user.role;
180
208
  } else {
181
209
  try {
182
210
  serverUrl = normalizeUrl(input.url);
@@ -149,7 +149,13 @@ export function createHubFormatClient(
149
149
  const res = await fetchImpl(`${base}${MODE_PATH}`, {
150
150
  method: 'POST',
151
151
  headers: { 'content-type': 'application/json', authorization: `Bearer ${hub.token}` },
152
- body: JSON.stringify({ mode, expectEpoch, ...(dryRun ? { dryRun: true } : {}) }),
152
+ // #166 (2.0.4): a dry run here reads only the blockers, so it asks for them alone —
153
+ // the hub's full preview imports (opens) every document. An older hub ignores the flag.
154
+ body: JSON.stringify({
155
+ mode,
156
+ expectEpoch,
157
+ ...(dryRun ? { dryRun: true, preview: false } : {}),
158
+ }),
153
159
  // The switch answers after it imported every document (T30) — a big project takes a
154
160
  // while. A timeout is not a refusal: the hub may finish, and the next run reads it.
155
161
  signal: AbortSignal.timeout(dryRun ? 30_000 : 180_000),
@@ -39,13 +39,17 @@ import path from 'node:path';
39
39
 
40
40
  import { currentAccess, notInScopeResponse, toDesignRel } from '../access/request.ts';
41
41
  import type { Access } from '../access/scope.ts';
42
+ import { sandboxBuildRunning } from '../canvas-build-sandbox.ts';
42
43
  import {
44
+ type BuildFailure,
43
45
  type CanvasError,
44
46
  canvasSourceSig,
45
47
  checkCanvasSyntax,
48
+ recalledBuildFailure,
46
49
  recalledCanvasError,
47
50
  } from '../canvas-source/errors.ts';
48
51
  import { canvasSourceMap } from '../canvas-source/source-map.ts';
52
+ import { canvasWaiting, type LedgerView, readLedgerView } from '../canvas-source/waiting.ts';
49
53
  import { isUnderOrEqual } from '../path-containment.ts';
50
54
  import type { RouteSpec } from './table.ts';
51
55
 
@@ -65,6 +69,14 @@ export interface CanvasSourceRouteDeps {
65
69
  historicalSource?: (repoRel: string, ref: string) => Promise<string | null | 'busy'>;
66
70
  /** The DNS-rebinding guard (http.ts `isTrustedRequestHost`); absent = every Host passes. */
67
71
  trustedHost?: (req: Request) => boolean;
72
+ /**
73
+ * 2.0.4 — the file plane's ledger, for "what is this canvas still waiting for"
74
+ * (`canvas-source/waiting.ts`). Default: the ledger file this Mac's plane persists under
75
+ * `<designRoot>/_state/file-ledger/` (none in a cell, or before a project links).
76
+ */
77
+ ledger?: () => LedgerView | null;
78
+ /** 2.0.4 task P — whether a sandboxed build of this canvas is running. Default: the sandbox's own. */
79
+ buildRunning?: (canvasAbs: string) => boolean;
68
80
  }
69
81
 
70
82
  const json = (status: number, body: unknown) =>
@@ -179,6 +191,17 @@ function errorsOfFile(deps: CanvasSourceRouteDeps, abs: string): CanvasError[] |
179
191
  return built ? [built] : [];
180
192
  }
181
193
 
194
+ /** #189 — the last build's failure class, while the source is still the one that failed. */
195
+ function buildFailureOfFile(abs: string): BuildFailure | null {
196
+ try {
197
+ const st = statSync(abs);
198
+ if (st.size > MAX_SOURCE_BYTES) return null;
199
+ return recalledBuildFailure(abs, canvasSourceSig(readFileSync(abs, 'utf8')));
200
+ } catch {
201
+ return null;
202
+ }
203
+ }
204
+
182
205
  /** Every canvas under the design root (design-root-relative, sorted), runtime folders skipped. */
183
206
  export function listCanvases(designRoot: string): string[] {
184
207
  const out: string[] = [];
@@ -282,9 +305,28 @@ export function createCanvasSourceRoutes(deps: CanvasSourceRouteDeps): RouteSpec
282
305
  if (refused) return refused;
283
306
  const file = canvasFile(deps.designRoot, rel);
284
307
  const list = file ? errorsOfFile(deps, file) : null;
285
- if (list === null)
308
+ if (list === null || !file)
286
309
  return access.canvasOnly ? notInScopeResponse() : json(404, { error: 'not-found' });
287
- return json(200, { canvas: repoRelOf(deps.designRel, rel), errors: list });
310
+ // 2.0.4 — what it is still waiting for (an import this Mac does not hold yet, or holds back),
311
+ // and why the last build stopped when the reason is not in its code (#189). Both are our own
312
+ // words and numbers: no file content, no build text, no specifier.
313
+ const waiting = canvasWaiting({
314
+ designRoot: deps.designRoot,
315
+ canvasAbs: file,
316
+ ledger: (deps.ledger ?? (() => readLedgerView(deps.designRoot)))(),
317
+ project: !access.canvasOnly,
318
+ });
319
+ // 2.0.4 task P — a sandboxed build of it is still running (it outlived the request that
320
+ // started it): not a failure, and the last failure on record is about to be replaced.
321
+ const building = !list.length && (deps.buildRunning ?? sandboxBuildRunning)(file);
322
+ const buildFailure = list.length || building ? null : buildFailureOfFile(file);
323
+ return json(200, {
324
+ canvas: repoRelOf(deps.designRel, rel),
325
+ errors: list,
326
+ ...(waiting ? { waiting } : {}),
327
+ ...(building ? { building: true } : {}),
328
+ ...(buildFailure ? { buildFailure } : {}),
329
+ });
288
330
  }
289
331
  const canvases: Array<{ canvas: string; errors: CanvasError[] }> = [];
290
332
  for (const rel of listCanvases(deps.designRoot)) {
@@ -9,10 +9,27 @@
9
9
  // Permissions (S10 Q15, V2-1.6 §5.12, rule 12): convert and Restore need Can edit on the WHOLE
10
10
  // project; a canvas-scoped grant is refused, the dry run included (it lists every system).
11
11
 
12
+ import { canvasSlugFromRel } from '../canvas-slug.ts';
12
13
  import { createDsConvert, DsConvertError } from '../ds/convert.ts';
14
+ import { DS_CANVAS } from '../ds/engine.ts';
13
15
  import type { DsOpAnswer, DsOpContext } from './ds.ts';
14
16
 
15
17
  const invalid = (m: string) => new DsConvertError('ds-convert-usage', m);
18
+
19
+ /**
20
+ * fix/ds-convert-hooks-cli #7 — Restore moved the Design system canvas to the Trash: say so the way
21
+ * the canvas delete route does. `canvas-deleted` is what sync turns into a project deletion (a
22
+ * tombstone); a bare rename is only "gone from this disk", and the hub brought the canvas straight
23
+ * back (and with it, on the next convert, `ds-convert-exists`).
24
+ */
25
+ function noteDsCanvasTrashed(c: DsOpContext, system: string): void {
26
+ const s = c.engine.systems().find((x) => x.name === system);
27
+ if (!s || !c.emit) return;
28
+ const rel = `${s.path}/${DS_CANVAS}`;
29
+ const slug = canvasSlugFromRel(rel, '');
30
+ c.emit('canvas-list-update', { action: 'removed', rel, slug });
31
+ c.emit('canvas-deleted', { slug });
32
+ }
16
33
  const NAME_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
17
34
 
18
35
  export async function runConvertOp(
@@ -33,6 +50,7 @@ export async function runConvertOp(
33
50
  const r = await cv.restore({ ds: input.restore, by: c.by });
34
51
  c.outside?.invalidate(r.system);
35
52
  c.emit?.('ds:changed', { system: r.system });
53
+ if (r.moved.includes(DS_CANVAS)) noteDsCanvasTrashed(c, r.system);
36
54
  return { status: 200, body: { format: 'maude.ds-result', v: 1, ...r } };
37
55
  }
38
56
  let systems: string[] | undefined;
@@ -4,6 +4,8 @@
4
4
  // POST /_api/project/restore { path, at | revision } → { ok, status, actionId? } · 409 (moved from http.ts)
5
5
  // { path, at, artboard? | element? } · { path, at: '@last-good' }
6
6
  // → { ok, actionId, line, sharedKept?, why? } · 409 { reason, line? } (S1.13)
7
+ // every restore: 409 { reason: unsaved-change|still-saving, line } when this
8
+ // disk has a change the project lacks (F14, settleBeforeRestore)
7
9
  // GET /_api/project/versions ?path&before&limit&filter → { ok, now, rows, next?, source, offline? }
8
10
  // GET /_api/project/changes ?path&from&to → { ok, changes, detail, blame }
9
11
  // GET /_api/project/source ?path&at&lane → { ok, source } (raw source: `export`)
@@ -36,6 +38,7 @@ import {
36
38
  readSide,
37
39
  refusalStatus,
38
40
  restoreArtboardAt,
41
+ settleBeforeRestore,
39
42
  } from '../history/restore-artboard-action.ts';
40
43
  import { type ObjectKey, parseObjectKey, restoreObject } from '../history/restore-object.ts';
41
44
  import { formatTime } from '../history/titles.ts';
@@ -90,6 +93,8 @@ type Outcome = {
90
93
 
91
94
  /** The runtime methods these routes read — all optional (an older home has none). */
92
95
  export interface HistoryRuntime extends VersionsRuntime {
96
+ /** F14 — this disk's change goes up before a restore reads the newest version (sync/index.ts). */
97
+ settleSource?(repoRel: string, ms?: number): Promise<'settled' | 'held' | 'pending' | null>;
93
98
  /** S1.13 — `o.lanes`: one artboard / object / kept-aside body as ONE `restore` action. */
94
99
  acceptedRestore?(repoRel: string, revision: number, o?: RestoreOptions): Promise<Outcome | null>;
95
100
  /** S1.13 — the annotations lane, and `{ aside: true }` (a kept-aside body at exactly `revision`). */
@@ -301,6 +306,17 @@ export function createHistoryRoutes(deps: HistoryRouteDeps): RouteSpec[] {
301
306
  return json(200, { ok: true, actionId: r.actionId, line: label, ...extra });
302
307
  }
303
308
 
309
+ /**
310
+ * F14 (2.0.4, #166) — every restore here reads (or lands on) the canvas's NEWEST version, but the
311
+ * person sees THIS disk: its change the project has not taken yet goes up first. A held change
312
+ * answers 409 `unsaved-change`, one still unanswered `still-saving`, each with its line; null:
313
+ * settled (or a home without the seam), go on.
314
+ */
315
+ async function unsettled(rt: HistoryRuntime, t: Target): Promise<Response | null> {
316
+ const s = await settleBeforeRestore(rt, t.repoRel);
317
+ return s.ok ? null : json(s.status, { ok: false, reason: s.reason, line: s.line });
318
+ }
319
+
304
320
  /** `at` names a version nobody kept → that body back over Now (§5.8 last row), else null. */
305
321
  async function restoreAside(at: unknown, t: Target): Promise<Response | null> {
306
322
  const ref = parseRef(at);
@@ -309,6 +325,8 @@ export function createHistoryRoutes(deps: HistoryRouteDeps): RouteSpec[] {
309
325
  if (!rt?.acceptedHistory || !rt.acceptedVersion) return null;
310
326
  const row = await rowAt(rt, t.repoRel, ref.rev).catch(() => null);
311
327
  if (row?.kind !== 'aside') return null;
328
+ const refused = await unsettled(rt, t);
329
+ if (refused) return refused;
312
330
  const newest = await revisionOf(rt, 'now', t).catch(() => null);
313
331
  for (const lane of ASIDE_ORDER) {
314
332
  const body = await rt
@@ -338,6 +356,8 @@ export function createHistoryRoutes(deps: HistoryRouteDeps): RouteSpec[] {
338
356
  if (b.at === LAST_GOOD) {
339
357
  if (b.artboard !== undefined || b.element !== undefined)
340
358
  return json(400, { ok: false, reason: '@last-good restores the whole canvas' });
359
+ const refused = await unsettled(rt, t);
360
+ if (refused) return refused;
341
361
  const lg = await findLastGood({
342
362
  runtime: rt,
343
363
  designRoot: deps.designRoot ?? null,
@@ -366,6 +386,8 @@ export function createHistoryRoutes(deps: HistoryRouteDeps): RouteSpec[] {
366
386
  ok: false,
367
387
  reason: 'element must be <artboard>/<id> or an annotation id',
368
388
  });
389
+ const refused = await unsettled(rt, t);
390
+ if (refused) return refused;
369
391
  const newest = await revisionOf(rt, 'now', t).catch(() => undefined);
370
392
  if (newest === undefined) return json(503, { ok: false, reason: 'unreachable' });
371
393
  const row = await rowAt(rt, t.repoRel, ref.rev).catch(() => null);
@@ -497,12 +519,13 @@ export function createHistoryRoutes(deps: HistoryRouteDeps): RouteSpec[] {
497
519
  // "Restored 5 Oct, 18:40", §5.8): the row in Version history and the toast read it. The v1 body
498
520
  // (`revision`) gets it too — the panel's own "Restore this version" sends that body, and without a
499
521
  // label the row read "Restore Smoke to version 4" (P8 B1: an internal revision number, never shown).
522
+ const rt = runtime();
523
+ if (rt?.acceptedRestore) {
524
+ const refused = await unsettled(rt, t);
525
+ if (refused) return refused;
526
+ }
500
527
  const label = await restoreLabel(t, revision);
501
- const r = await runtime()?.acceptedRestore?.(
502
- t.repoRel,
503
- revision,
504
- ...(label ? [{ label }] : [])
505
- );
528
+ const r = await rt?.acceptedRestore?.(t.repoRel, revision, ...(label ? [{ label }] : []));
506
529
  // The v1 answer shape is kept: `maude design history restore` reads it.
507
530
  if (!r) return json(200, { ok: false, reason: 'legacy' });
508
531
  if (r.status === 'accepted' && r.actionId && !r.queued)
@@ -0,0 +1,115 @@
1
+ // Sign in to a team server in the browser — issue #204 (sync/hub-browser-signin.ts has the flow).
2
+ //
3
+ // POST /_api/hub-signin/start { url } → { ok, id, signInUrl, expiresIn } | { ok:false, error }
4
+ // POST /_api/hub-signin/poll { id } → { ok, pending } | { ok, url, user } | { ok:false, error }
5
+ // POST /_api/hub-signin/cancel { id } → { ok }
6
+ // GET /_api/hub-signin/return ?state&code | ?state&error (the browser's hop back from the hub)
7
+ //
8
+ // MAIN ORIGIN ONLY: these mint and store a team-server credential, which the untrusted canvas
9
+ // origin (DDR-054) must never reach. `guardTableRoute` applies the CSRF + DNS-rebind gates to all
10
+ // four — the return route is the ONE table spec a cross-site page may reach, and only as a
11
+ // top-level navigation (`crossSiteNavigation`): it is where the hub's page sends the browser, so
12
+ // a navigation from the hub's origin is its whole job. What protects it is what protects any
13
+ // OAuth redirect endpoint: it acts only on a `state` this process minted, once, and the code is
14
+ // worthless without the verifier that never left this process.
15
+ //
16
+ // A cell never serves these (apps/hub/src/studio-manifest.mjs: REFUSED) — a cell holds no team
17
+ // server credential of its own.
18
+
19
+ import {
20
+ createHubBrowserSignIn,
21
+ type HubBrowserSignIn,
22
+ returnPage,
23
+ } from '../sync/hub-browser-signin.ts';
24
+ import type { RouteSpec } from './table.ts';
25
+
26
+ export interface HubSigninRouteDeps {
27
+ /** The flow; a test passes one with a fake hub. */
28
+ signIn?: HubBrowserSignIn;
29
+ /** The team server this project syncs with — a renewed sign-in for it cycles sync. */
30
+ linkedHubUrl?: () => string | null | undefined;
31
+ restartSync?: () => Promise<unknown> | undefined;
32
+ }
33
+
34
+ async function body(req: Request): Promise<Record<string, unknown>> {
35
+ try {
36
+ const text = await req.text();
37
+ if (text.length > 4096) return {};
38
+ const j = JSON.parse(text || '{}');
39
+ return j && typeof j === 'object' ? (j as Record<string, unknown>) : {};
40
+ } catch {
41
+ return {};
42
+ }
43
+ }
44
+
45
+ const json = (payload: unknown, status = 200) =>
46
+ Response.json(payload, { status, headers: { 'Cache-Control': 'no-store' } });
47
+
48
+ const sameServer = (a: string | null | undefined, b: string) => {
49
+ try {
50
+ return !!a && new URL(a).origin === new URL(b).origin;
51
+ } catch {
52
+ return false;
53
+ }
54
+ };
55
+
56
+ export function createHubSigninRoutes(deps: HubSigninRouteDeps = {}): RouteSpec[] {
57
+ const signIn =
58
+ deps.signIn ??
59
+ createHubBrowserSignIn({
60
+ // SIGN IN AGAIN: a new credential for the team server this project already syncs with. The
61
+ // running sync still holds the one the server refused — cycle it onto the one just stored
62
+ // (the move the retired email/password sign-in used to make).
63
+ onSignedIn: async (url) => {
64
+ if (sameServer(deps.linkedHubUrl?.(), url)) await deps.restartSync?.();
65
+ },
66
+ });
67
+ return [
68
+ {
69
+ method: 'POST',
70
+ path: '/_api/hub-signin/start',
71
+ origin: 'main',
72
+ readOnly: 'allowed',
73
+ async handle(req) {
74
+ const b = await body(req);
75
+ const r = await signIn.start(b.url, new URL(req.url).origin);
76
+ return r.ok
77
+ ? json(r)
78
+ : json(
79
+ { ok: false, error: r.error, ...(r.reason ? { reason: r.reason } : {}) },
80
+ r.status
81
+ );
82
+ },
83
+ },
84
+ {
85
+ method: 'POST',
86
+ path: '/_api/hub-signin/poll',
87
+ origin: 'main',
88
+ readOnly: 'allowed',
89
+ async handle(req) {
90
+ return json(signIn.poll((await body(req)).id));
91
+ },
92
+ },
93
+ {
94
+ method: 'POST',
95
+ path: '/_api/hub-signin/cancel',
96
+ origin: 'main',
97
+ readOnly: 'allowed',
98
+ async handle(req) {
99
+ signIn.cancel((await body(req)).id);
100
+ return json({ ok: true });
101
+ },
102
+ },
103
+ {
104
+ method: 'GET',
105
+ // A literal (the route scrapers read `path:` strings) — HUB_SIGNIN_RETURN_PATH, asserted by the test.
106
+ path: '/_api/hub-signin/return',
107
+ origin: 'main',
108
+ readOnly: 'allowed',
109
+ crossSiteNavigation: true,
110
+ async handle(req) {
111
+ return returnPage(await signIn.onReturn(new URL(req.url).searchParams));
112
+ },
113
+ },
114
+ ];
115
+ }
@@ -45,6 +45,7 @@ import { createGenerateRoutes, type GenerateRouteDeps } from './generate.ts';
45
45
  import { createHandoffRoutes, type HandoffRouteDeps } from './handoff.ts';
46
46
  import { createHelpGuidesRoutes, type HelpGuidesDeps } from './help-guides.ts';
47
47
  import { createHistoryRoutes, type HistoryRouteDeps } from './history.ts';
48
+ import { createHubSigninRoutes, type HubSigninRouteDeps } from './hub-signin.ts';
48
49
  import { createImportLinkRoutes, type ImportLinkRouteDeps } from './import-link.ts';
49
50
  import { createKindRoutes } from './kinds.ts';
50
51
  import { createLinksRoutes, type LinksRouteDeps } from './links.ts';
@@ -140,6 +141,8 @@ export interface RouteDeps {
140
141
  cloudPlan?: CloudPlanDeps;
141
142
  /** S11.14 — `GET /_api/connections/hub` (main origin): the linked team server's Advanced details */
142
143
  connections?: ConnectionsRouteDeps;
144
+ /** Issue #204 — `/_api/hub-signin/*` (main origin): sign in to a team server on its own page */
145
+ hubSignin?: HubSigninRouteDeps;
143
146
  /** S8.19 — `GET /_api/asset-state` (main origin): disk + upload queue + hub presence */
144
147
  assetState?: AssetStateRouteDeps;
145
148
  /** S8.13 — `POST /_api/assets/trash` (main origin, Can edit on the project): assets + sidecars to `_trash/`;
@@ -266,6 +269,7 @@ export function allSpecs(deps: RouteDeps): RouteSpec[] {
266
269
  ...(deps.cloudPlan ? createCloudPlanRoutes(deps.cloudPlan) : []),
267
270
  ...(deps.helpGuides ? createHelpGuidesRoutes(deps.helpGuides) : []),
268
271
  ...(deps.connections ? createConnectionsRoutes(deps.connections) : []),
272
+ ...createHubSigninRoutes(deps.hubSignin ?? {}),
269
273
  ...createAssetStateRoutes(deps.assetState ?? { service: () => null }),
270
274
  ...(deps.assetTrash ? createAssetTrashRoutes(deps.assetTrash) : []),
271
275
  // P8 round 7 — POST /_api/assets/rename (routes/asset-rename.ts): the same deps and verdict as Move to trash
@@ -41,6 +41,13 @@ export interface RouteSpec {
41
41
  * GATES stay exactly the same; only the words differ.
42
42
  */
43
43
  refuse?(reason: 'cross-origin' | 'untrusted-host'): Response;
44
+ /**
45
+ * Issue #204 — a GET a cross-site page may reach, as a TOP-LEVEL NAVIGATION only
46
+ * (`Sec-Fetch-Mode: navigate` + `Sec-Fetch-Dest: document`): the loopback return a team
47
+ * server's sign-in page sends the browser to. A cross-site fetch, image or frame is still
48
+ * refused, and so is a rebound Host. The handler must act only on state it minted itself.
49
+ */
50
+ crossSiteNavigation?: true;
44
51
  handle(req: Request, params: Record<string, string>): Response | Promise<Response>;
45
52
  }
46
53
 
@@ -20,6 +20,7 @@
20
20
  // what to draw; the clear route refuses an editor with 403 whatever the client drew.
21
21
 
22
22
  import type { Access } from '../access/scope.ts';
23
+ import { SETTLE_REFUSAL_LINES } from '../history/restore-artboard-action.ts';
23
24
  import {
24
25
  ARTBOARD_ID,
25
26
  ARTBOARD_NOT_YET_LINE,
@@ -88,6 +89,8 @@ const refused = (code: string | undefined, extra: Record<string, unknown> = {})
88
89
  ok: false,
89
90
  reason: r.reason,
90
91
  ...(r.reason === 'needs-hub-update' ? { line: NEEDS_HUB_UPDATE_LINE } : {}),
92
+ // F14 — a restore over this disk's unsaved change says why (the card shows the line)
93
+ ...(SETTLE_REFUSAL_LINES[r.reason] ? { line: SETTLE_REFUSAL_LINES[r.reason] } : {}),
91
94
  ...extra,
92
95
  });
93
96
  };
@@ -273,10 +276,25 @@ export function createTrashRoutes(deps: TrashRouteDeps): RouteSpec[] {
273
276
  if (!runtime?.acceptedTrash) return null;
274
277
  const listing = await runtime.acceptedTrash().catch(() => undefined);
275
278
  if (!listing) return listing;
276
- return visibleTrash(
279
+ const items = visibleTrash(
277
280
  deriveTrash(listing, { readSource: deps.readSource, now: deps.now?.() }),
278
281
  access
279
282
  );
283
+ // 2.0.5: which canvas items sit at the path of a LIVE canvas (the same test the write stop uses) —
284
+ // they are older copies, never "the canvas you have open, moved to the trash".
285
+ const linkDocs = (
286
+ runtime as {
287
+ acceptedLinkDocs?(): Promise<{ path: string | null; retired: boolean }[] | null>;
288
+ }
289
+ ).acceptedLinkDocs;
290
+ const docs = linkDocs ? await linkDocs.call(runtime).catch(() => null) : null;
291
+ if (!docs) return items;
292
+ const live = new Set(
293
+ docs.filter((d) => !d.retired && d.path).map((d) => canvasStemOf(d.path as string))
294
+ );
295
+ return items.map((i) =>
296
+ i.kind === 'canvas' ? { ...i, liveAtPath: live.has(canvasStemOf(i.path)) } : i
297
+ );
280
298
  }
281
299
 
282
300
  return [
@@ -40,6 +40,7 @@ import { saveHold, withSaveRequest } from './ai/save-hold.ts';
40
40
  import { migrateAnnotationsV2 } from './annotations/migrate-boot.ts';
41
41
  import { runContext, runTagOf, stageRunAnnotations } from './annotations/run-tag.ts';
42
42
  import { ASSET_MAX_VIDEO_BYTES, createApi } from './api.ts';
43
+ import { bootFinished, bootStep } from './boot-progress.ts';
43
44
  import { bootSelfHeal } from './boot-self-heal.ts';
44
45
  import { isSandboxArmed } from './canvas-build-sandbox.ts';
45
46
  import { createCanvasListWatch } from './canvas-list-watch.ts';
@@ -48,7 +49,8 @@ import { type AiActivityEntry, createAiActivity } from './collab/ai-activity.ts'
48
49
  import { createGitLifecycle } from './collab/git-lifecycle.ts';
49
50
  import { personHoldsOf } from './collab/holds.ts';
50
51
  import { createCollab } from './collab/index.ts';
51
- import { createContext, reloadConfig } from './context.ts';
52
+ import { wireConfigReload } from './config-reload-wire.ts';
53
+ import { createContext } from './context.ts';
52
54
  import { installLogRing } from './debug-bundle.ts';
53
55
  import { initDiagnostics, registerStatus, stopDiagnostics } from './diagnostics/store.ts';
54
56
  import { parseEmbedOrigins } from './embed-origins.ts';
@@ -102,10 +104,12 @@ if (process.argv.includes('--home')) {
102
104
  }
103
105
 
104
106
  const ctx = createContext();
107
+ bootStep('context');
105
108
 
106
109
  // V2-2.9 (T23) — persist the per-source diagnostics (server · sync · ai · export) under
107
110
  // ~/.maude/logs (or $MAUDE_LOG_DIR), scrubbed, 7 days. Local only: nothing is sent anywhere.
108
111
  await initDiagnostics({ repoRoot: ctx.paths.repoRoot });
112
+ bootStep('diagnostics');
109
113
 
110
114
  // DDR-064 — the collab room's Y.Doc is THE doc per canvas, everywhere. Since p8-v1-drop there is no
111
115
  // opt-out: `MAUDE_SHARED_DOC=0` (the rollback onto the two-doc + disk-reconcile path) is gone. Set on
@@ -244,7 +248,9 @@ const inspects = createInspectRegistry(ctx, (file) => api.loadCommentsForFile(fi
244
248
  inspectHandle = inspects;
245
249
  // The shared instance is the desktop's, and a cell's fallback for anything that
246
250
  // arrives without a vouched session.
251
+ bootStep('api');
247
252
  await inspects.for('').load();
253
+ bootStep('inspect');
248
254
 
249
255
  // Semantic structural notifications include remote sync operations as well as
250
256
  // API actions. Keep every session's agent/inspector context on the live path.
@@ -305,6 +311,7 @@ const runRegistry = createRunRegistry({
305
311
  }),
306
312
  });
307
313
  await runRegistry.boot();
314
+ bootStep('runs');
308
315
  // S5.15 — every accepted action reaches the shell as `project:action`, not only a run's publish and the
309
316
  // undo routes': a person's edit (yours, or a teammate's arriving from the hub) clears "Made by AI".
310
317
  const actionFeed = createActionFeed({
@@ -389,6 +396,7 @@ const ws = createWs(
389
396
  const exportJobs = createExportJobQueue(ctx.bus, ctx.paths.designRoot, { runs: () => runRegistry });
390
397
  // feature-ai-media-generation (DDR-16x) — background AI-media generation queue.
391
398
  const generateJobs = createGenerationJobQueue(ctx.bus, ctx.paths.designRoot);
399
+ bootStep('sockets');
392
400
  const http = createHttp(ctx, api, inspects, aiActivity, exportJobs, generateJobs, {
393
401
  shellCount: () => ws.shellCount(),
394
402
  runs: runRegistry,
@@ -412,7 +420,9 @@ if (!isWorkspaceMode()) {
412
420
  });
413
421
  ctx.bus.on('config-updated', narrowSockets);
414
422
  }
423
+ bootStep('http');
415
424
  const fsWatch = createFsWatch(ctx);
425
+ bootStep('watcher');
416
426
 
417
427
  // Port: --port arg > $PORT > $MDCC_DEV_PORT > $MAUDE_PORT_BASE > 47399 (e2e) > 46399 (the desktop app) > 4399 — port.ts.
418
428
  // When the port wasn't explicitly chosen and the default is busy (another
@@ -942,6 +952,7 @@ function startCanvasServer(
942
952
  });
943
953
  }
944
954
 
955
+ bootStep('routes');
945
956
  let server: BunServer;
946
957
  {
947
958
  const r = bindFirst(PORT_CANDIDATES, (p) => listenLoopback((h, port) => startServer(port, h), p));
@@ -1060,6 +1071,7 @@ const captureServer =
1060
1071
  if (captureServer) ctx.captureOrigin = `http://localhost:${captureServer.port}`;
1061
1072
 
1062
1073
  const startedAt = new Date().toISOString();
1074
+ bootFinished();
1063
1075
  await Bun.write(
1064
1076
  ctx.paths.serverInfoFile,
1065
1077
  JSON.stringify(
@@ -1116,18 +1128,15 @@ const canvasListWatch = createCanvasListWatch(ctx);
1116
1128
  // canvasListWatch's set-diff emit `canvas-list-update` for canvases the new
1117
1129
  // groups uncover, and tell shells to refetch /_config.
1118
1130
  // RCA: .ai/logs/rca/issue-ds-scaffold-files-not-in-filetree-stale-config.md
1119
- const CONFIG_RELOAD_DEBOUNCE_MS = 150;
1120
- let configReloadTimer: ReturnType<typeof setTimeout> | null = null;
1121
- ctx.bus.on('fs:json', (rel: string) => {
1122
- if (rel.replace(/\\/g, '/').replace(/^\/+/, '') !== 'config.json') return;
1123
- if (configReloadTimer) clearTimeout(configReloadTimer);
1124
- configReloadTimer = setTimeout(() => {
1125
- configReloadTimer = null;
1126
- if (!reloadConfig(ctx)) return;
1131
+ // A cell child has no watcher, so a peer's config.json write arrives as
1132
+ // `fs:any` only (journal heal) — wireConfigReload listens on both events
1133
+ // behind one debounce (#205, config-reload-wire.ts).
1134
+ wireConfigReload(ctx, {
1135
+ onReloaded: () => {
1127
1136
  console.log(' config.json changed — reloaded live.');
1128
1137
  void canvasListWatch.refresh();
1129
1138
  ctx.bus.emit('config-updated');
1130
- }, CONFIG_RELOAD_DEBOUNCE_MS);
1139
+ },
1131
1140
  });
1132
1141
 
1133
1142
  // Phase 9 Task 4 — bidirectional sync agent. No-op when the project isn't