@1agh/maude 2.0.4 → 2.0.8

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 (272) hide show
  1. package/apps/hub/src/project-transactions/kernel.mjs +10 -1
  2. package/apps/studio/access/closure.ts +156 -16
  3. package/apps/studio/access/filters.ts +39 -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/actions/agents.ts +59 -0
  7. package/apps/studio/actions/ctx.ts +3 -0
  8. package/apps/studio/actions/defs/app.ts +12 -0
  9. package/apps/studio/actions/defs/sync.ts +13 -0
  10. package/apps/studio/actions/defs/view.ts +59 -3
  11. package/apps/studio/actions/keymap.gen.ts +35 -0
  12. package/apps/studio/actions/menu.ts +2 -0
  13. package/apps/studio/actions/types.ts +3 -1
  14. package/apps/studio/actions.manifest.json +148 -1
  15. package/apps/studio/actions.parity.json +31 -1
  16. package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
  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/ride.ts +2 -1
  20. package/apps/studio/annotations/ui/text-style.ts +1 -1
  21. package/apps/studio/annotations-context-toolbar.tsx +5 -4
  22. package/apps/studio/annotations-layer.tsx +4 -15
  23. package/apps/studio/api.ts +425 -128
  24. package/apps/studio/artboard-activity-overlay.tsx +4 -4
  25. package/apps/studio/artboard-ai-copies.tsx +4 -4
  26. package/apps/studio/artboard-freeze.ts +108 -0
  27. package/apps/studio/artboard-live-gate.tsx +636 -0
  28. package/apps/studio/artboard-live.ts +831 -0
  29. package/apps/studio/artboard-placeholder.ts +197 -0
  30. package/apps/studio/artboard-still-raster.ts +485 -0
  31. package/apps/studio/artboard-still-warmup.ts +221 -0
  32. package/apps/studio/artboard-still.ts +1188 -0
  33. package/apps/studio/artboard-webgl.ts +669 -0
  34. package/apps/studio/asset-placeholder.tsx +237 -132
  35. package/apps/studio/asset-upload-bars.tsx +4 -4
  36. package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
  37. package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
  38. package/apps/studio/bin/_canvas-reasons.mjs +34 -0
  39. package/apps/studio/bin/_ds-check-live.mjs +37 -0
  40. package/apps/studio/bin/_ds-check.mjs +4 -1
  41. package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
  42. package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
  43. package/apps/studio/bin/_import-asset.mjs +2 -1
  44. package/apps/studio/bin/_perf-probe-open.mjs +364 -0
  45. package/apps/studio/bin/_perf-probe.mjs +2 -1
  46. package/apps/studio/bin/_perf-shared.mjs +12 -7
  47. package/apps/studio/bin/_pw-launch.mjs +26 -1
  48. package/apps/studio/bin/_studio-verb.mjs +24 -3
  49. package/apps/studio/bin/_thumb-blank.mjs +70 -0
  50. package/apps/studio/bin/_thumb-cover.mjs +35 -0
  51. package/apps/studio/bin/_thumbs-playwright.mjs +89 -12
  52. package/apps/studio/bin/ds-check.sh +5 -1
  53. package/apps/studio/bin/perf.sh +30 -1
  54. package/apps/studio/bin/server-up.sh +7 -2
  55. package/apps/studio/bin/smoke.sh +19 -0
  56. package/apps/studio/bridge/dgn-protocol.ts +35 -0
  57. package/apps/studio/canvas-build-sandbox.ts +69 -13
  58. package/apps/studio/canvas-camera.ts +90 -0
  59. package/apps/studio/canvas-comment-mount.tsx +9 -9
  60. package/apps/studio/canvas-lib.tsx +289 -44
  61. package/apps/studio/canvas-pages-view.tsx +465 -0
  62. package/apps/studio/canvas-pages.ts +305 -0
  63. package/apps/studio/canvas-rows.ts +62 -0
  64. package/apps/studio/canvas-shell.tsx +62 -16
  65. package/apps/studio/canvas-theme-icons.tsx +41 -0
  66. package/apps/studio/canvas-theme-pill.tsx +15 -6
  67. package/apps/studio/canvas-theme.ts +12 -11
  68. package/apps/studio/client/app.jsx +7 -0
  69. package/apps/studio/client/canvas-url.js +36 -1
  70. package/apps/studio/client/home/HomeAccounts.jsx +262 -0
  71. package/apps/studio/client/home/Shelves.jsx +4 -3
  72. package/apps/studio/client/home/home-accounts-model.js +121 -0
  73. package/apps/studio/client/home/home-api.js +6 -0
  74. package/apps/studio/client/home/home-app.jsx +141 -40
  75. package/apps/studio/client/home/home-model.js +172 -6
  76. package/apps/studio/client/home/home.css +169 -5
  77. package/apps/studio/client/home/shell-mode.js +8 -1
  78. package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
  79. package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
  80. package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
  81. package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
  82. package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
  83. package/apps/studio/client/hooks/use-project-data.jsx +13 -2
  84. package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
  85. package/apps/studio/client/index-loader.ts +41 -21
  86. package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
  87. package/apps/studio/client/panels/ChatPanel.jsx +27 -20
  88. package/apps/studio/client/panels/CreateProject.jsx +19 -5
  89. package/apps/studio/client/panels/caps-cache.js +46 -0
  90. package/apps/studio/client/shell/viewport.jsx +66 -22
  91. package/apps/studio/client/tree/tree.jsx +17 -0
  92. package/apps/studio/client/v2/access/access-client.js +2 -0
  93. package/apps/studio/client/v2/access/access-host.jsx +12 -1
  94. package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
  95. package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
  96. package/apps/studio/client/v2/ai/Composer.jsx +27 -10
  97. package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
  98. package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
  99. package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
  100. package/apps/studio/client/v2/code/canvas-imports-card.jsx +19 -14
  101. package/apps/studio/client/v2/code/canvas-imports-words.js +60 -0
  102. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
  103. package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
  104. package/apps/studio/client/v2/code/code-bus.js +5 -0
  105. package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
  106. package/apps/studio/client/v2/code/code-consent.js +67 -0
  107. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
  108. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
  109. package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
  110. package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
  111. package/apps/studio/client/v2/ds/library-host.jsx +45 -45
  112. package/apps/studio/client/v2/ds/make-host.jsx +13 -15
  113. package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
  114. package/apps/studio/client/v2/ds/review-host.jsx +7 -1
  115. package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
  116. package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
  117. package/apps/studio/client/v2/history/branch-actions.js +13 -9
  118. package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
  119. package/apps/studio/client/v2/history/git-model.js +3 -1
  120. package/apps/studio/client/v2/history/git-parts.jsx +16 -1
  121. package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
  122. package/apps/studio/client/v2/layers/layers-request.js +49 -0
  123. package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
  124. package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
  125. package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
  126. package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
  127. package/apps/studio/client/v2/presence/faces.jsx +42 -14
  128. package/apps/studio/client/v2/shell/account-card.jsx +10 -4
  129. package/apps/studio/client/v2/shell/canvas-crash-guard.js +172 -0
  130. package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
  131. package/apps/studio/client/v2/shell/floating-panels.css +37 -1
  132. package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
  133. package/apps/studio/client/v2/shell/menu-runner.js +11 -0
  134. package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
  135. package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
  136. package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
  137. package/apps/studio/client/v2/shell/pages-pick.js +49 -0
  138. package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
  139. package/apps/studio/client/v2/shell/project-account-model.js +182 -0
  140. package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
  141. package/apps/studio/client/v2/shell/share-cluster-host.jsx +140 -11
  142. package/apps/studio/client/v2/shell/share-cluster.css +58 -0
  143. package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
  144. package/apps/studio/client/v2/shell/shell-parity.json +8 -0
  145. package/apps/studio/client/v2/shell/team-switch.js +94 -0
  146. package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
  147. package/apps/studio/client/v2/shell/use-account.js +8 -1
  148. package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
  149. package/apps/studio/collab/persistence.ts +9 -1
  150. package/apps/studio/collab/registry.ts +32 -0
  151. package/apps/studio/collab/room.ts +8 -0
  152. package/apps/studio/comments-overlay.tsx +12 -11
  153. package/apps/studio/config-reload-wire.ts +56 -0
  154. package/apps/studio/config.schema.json +6 -0
  155. package/apps/studio/context.ts +37 -1
  156. package/apps/studio/dist/client.bundle.js +1198 -1198
  157. package/apps/studio/dist/comment-mount.js +2 -2
  158. package/apps/studio/dist/styles.css +1 -1
  159. package/apps/studio/ds/board/board.css +6 -0
  160. package/apps/studio/ds/board/ds-bar.tsx +21 -3
  161. package/apps/studio/ds/board/specimen.tsx +16 -2
  162. package/apps/studio/ds/board/template.ts +39 -19
  163. package/apps/studio/ds/canvas-cli.ts +58 -2
  164. package/apps/studio/ds/check.ts +26 -1
  165. package/apps/studio/ds/cli.ts +14 -4
  166. package/apps/studio/ds/component-list.ts +2 -1
  167. package/apps/studio/ds/convert.ts +34 -6
  168. package/apps/studio/ds/default.ts +6 -1
  169. package/apps/studio/ds/ds-resolver.ts +58 -8
  170. package/apps/studio/ds/ds-verb.ts +13 -0
  171. package/apps/studio/ds/engine.ts +3 -1
  172. package/apps/studio/ds/folder-systems.ts +199 -0
  173. package/apps/studio/ds/pairing-css.ts +2 -1
  174. package/apps/studio/ds/post-build.ts +38 -0
  175. package/apps/studio/ds/rename.ts +10 -3
  176. package/apps/studio/ds/shell-fallbacks.ts +2 -1
  177. package/apps/studio/ds/upgrade-apply.ts +27 -5
  178. package/apps/studio/ds/upgrade-cli.ts +22 -2
  179. package/apps/studio/ds/upgrade-prove.ts +198 -15
  180. package/apps/studio/ds/upgrade-stage.ts +10 -3
  181. package/apps/studio/editing/ai-point-ring.tsx +4 -4
  182. package/apps/studio/editing/ai-scope-outline.tsx +4 -4
  183. package/apps/studio/editing/align-bar.tsx +4 -4
  184. package/apps/studio/editing/anchor-report.ts +3 -2
  185. package/apps/studio/editing/artboard-handles.tsx +4 -4
  186. package/apps/studio/editing/corner-dots.tsx +4 -4
  187. package/apps/studio/editing/crop-mode.tsx +4 -4
  188. package/apps/studio/editing/drop-chip.tsx +4 -4
  189. package/apps/studio/editing/empty-report.ts +3 -2
  190. package/apps/studio/editing/focus-model.tsx +4 -4
  191. package/apps/studio/editing/gap-bands.tsx +3 -3
  192. package/apps/studio/editing/hold-rings.tsx +4 -4
  193. package/apps/studio/editing/lock-badge.tsx +3 -3
  194. package/apps/studio/editing/long-page.ts +23 -1
  195. package/apps/studio/editing/nudge.tsx +2 -2
  196. package/apps/studio/editing/page-activity.ts +4 -3
  197. package/apps/studio/editing/paste-bar.tsx +4 -4
  198. package/apps/studio/editing/pen/overlay.tsx +4 -3
  199. package/apps/studio/editing/place-freely.tsx +3 -3
  200. package/apps/studio/editing/reorder-slot.tsx +3 -3
  201. package/apps/studio/editing/selection.tsx +4 -4
  202. package/apps/studio/editing/size-ghost.tsx +4 -4
  203. package/apps/studio/editing/tab-order.tsx +4 -4
  204. package/apps/studio/editing/text-in-place.tsx +4 -4
  205. package/apps/studio/editing/undo-preview.tsx +3 -3
  206. package/apps/studio/equal-spacing-handles.tsx +3 -3
  207. package/apps/studio/frame-clock.ts +89 -0
  208. package/apps/studio/history/trash.ts +6 -0
  209. package/apps/studio/home/accounts.ts +87 -0
  210. package/apps/studio/home/index-reader.ts +24 -2
  211. package/apps/studio/home/routes.ts +19 -0
  212. package/apps/studio/http.ts +80 -34
  213. package/apps/studio/index/ds-usage.ts +4 -1
  214. package/apps/studio/index-cache.ts +272 -0
  215. package/apps/studio/inspect-overlay.tsx +4 -3
  216. package/apps/studio/inspect.ts +7 -2
  217. package/apps/studio/link-chip-overlay.tsx +4 -3
  218. package/apps/studio/measure-overlay.tsx +4 -3
  219. package/apps/studio/present/pointer-dot.tsx +3 -2
  220. package/apps/studio/present/present-media.ts +6 -2
  221. package/apps/studio/present/present-stage.tsx +3 -2
  222. package/apps/studio/preview/preview-camera.tsx +3 -2
  223. package/apps/studio/routes/ds-convert.ts +18 -0
  224. package/apps/studio/routes/sync.ts +176 -0
  225. package/apps/studio/routes/trash.ts +16 -1
  226. package/apps/studio/safe-zones-overlay.tsx +3 -2
  227. package/apps/studio/server.ts +8 -10
  228. package/apps/studio/skip-dirs.ts +103 -47
  229. package/apps/studio/studio-page-host.ts +70 -0
  230. package/apps/studio/sync/accepted-cold-start.ts +28 -13
  231. package/apps/studio/sync/asset-push.ts +146 -23
  232. package/apps/studio/sync/asset-state.ts +3 -2
  233. package/apps/studio/sync/code-module-consent.ts +86 -0
  234. package/apps/studio/sync/file-ledger.ts +24 -0
  235. package/apps/studio/sync/file-membership.ts +28 -3
  236. package/apps/studio/sync/file-plane.ts +497 -61
  237. package/apps/studio/sync/file-pull.ts +304 -33
  238. package/apps/studio/sync/held-deletes.ts +230 -0
  239. package/apps/studio/sync/hub-link.ts +1 -2
  240. package/apps/studio/sync/hubs-config.ts +59 -2
  241. package/apps/studio/sync/index.ts +405 -163
  242. package/apps/studio/sync/journal-client.ts +94 -5
  243. package/apps/studio/sync/pending-deletes.ts +100 -0
  244. package/apps/studio/sync/projection.ts +77 -12
  245. package/apps/studio/sync/seed-progress.ts +104 -3
  246. package/apps/studio/sync/settings.ts +36 -1
  247. package/apps/studio/sync/status.ts +17 -1
  248. package/apps/studio/sync/writer-registry.ts +5 -0
  249. package/apps/studio/text-caret.ts +5 -3
  250. package/apps/studio/thumbs/service.ts +12 -2
  251. package/apps/studio/thumbs/validate.ts +7 -0
  252. package/apps/studio/toolbars/toolbar-rect.ts +3 -2
  253. package/apps/studio/ui-prefs-migrate.ts +4 -0
  254. package/apps/studio/use-annotation-resize.tsx +4 -3
  255. package/apps/studio/use-artboard-drag.tsx +3 -2
  256. package/apps/studio/use-element-resize.tsx +7 -6
  257. package/apps/studio/use-grid-track-handles.tsx +5 -4
  258. package/apps/studio/use-selection-set.tsx +64 -4
  259. package/apps/studio/use-spacing-handles.tsx +7 -6
  260. package/apps/studio/video-comp.tsx +75 -39
  261. package/apps/studio/video-play-overlay.tsx +4 -3
  262. package/apps/studio/whats-new.json +99 -0
  263. package/cli/commands/design.mjs +5 -2
  264. package/cli/commands/hub.mjs +10 -1
  265. package/cli/lib/bash-guard.mjs +27 -1
  266. package/cli/lib/design-help.gen.mjs +1 -1
  267. package/cli/lib/design-hook.mjs +20 -0
  268. package/cli/lib/design-link.mjs +42 -17
  269. package/cli/lib/hub-purge.mjs +183 -0
  270. package/cli/lib/studio-locate.mjs +35 -10
  271. package/package.json +8 -8
  272. package/plugins/design/templates/_shell.html +164 -1
@@ -249,33 +249,111 @@ export async function hubHealth(opts: {
249
249
  hubUrl: string;
250
250
  fetchImpl?: typeof fetch;
251
251
  signal?: AbortSignal;
252
- }): Promise<{ capabilities: string[] | null; formatVersion: number | null }> {
252
+ /** Override the 4 s ceiling (the lane probe asks with a longer one). */
253
+ timeoutMs?: number;
254
+ }): Promise<{
255
+ capabilities: string[] | null;
256
+ formatVersion: number | null;
257
+ /**
258
+ * Did the HUB answer (2.0.5)? False for a timeout, a network error, a 5xx, a
259
+ * 429 or an unreadable body — none of which says anything about what the hub
260
+ * can do. `capabilities: null` with `answered: true` is a real answer: a hub
261
+ * that predates capabilities.
262
+ */
263
+ answered: boolean;
264
+ }> {
253
265
  const fetchImpl = opts.fetchImpl ?? fetch;
254
266
  const base = opts.hubUrl.replace(/\/+$/, '');
255
267
  try {
256
- const timeout = AbortSignal.timeout(HEALTH_TIMEOUT_MS);
268
+ const timeout = AbortSignal.timeout(opts.timeoutMs ?? HEALTH_TIMEOUT_MS);
257
269
  const res = await fetchImpl(`${base}/health`, {
258
270
  // a hub answers its own /health: a redirect is never followed (gate-b-sec1 A5 — a bounce to an internal
259
271
  // http address from a cell). The other sync requests do not follow one either (`redirect: 'manual'`).
260
272
  redirect: 'error',
261
273
  signal: opts.signal ? AbortSignal.any([opts.signal, timeout]) : timeout,
262
274
  });
263
- if (!res.ok) return { capabilities: null, formatVersion: null };
275
+ if (!res.ok) {
276
+ // A hub without the route (404) has answered: it has no capabilities. A
277
+ // server error or a rate limit has not.
278
+ const answered = res.status < 500 && res.status !== 429 && res.status !== 408;
279
+ return { capabilities: null, formatVersion: null, answered };
280
+ }
264
281
  const body = (await res.json()) as { capabilities?: unknown; formatVersion?: unknown };
265
282
  const fv = body?.formatVersion;
266
283
  const formatVersion = typeof fv === 'number' && Number.isSafeInteger(fv) && fv >= 1 ? fv : null;
267
- if (!Array.isArray(body?.capabilities)) return { capabilities: null, formatVersion };
284
+ if (!Array.isArray(body?.capabilities))
285
+ return { capabilities: null, formatVersion, answered: true };
268
286
  return {
269
287
  capabilities: body.capabilities
270
288
  .filter((c): c is string => typeof c === 'string')
271
289
  .slice(0, 32),
272
290
  formatVersion,
291
+ answered: true,
273
292
  };
274
293
  } catch {
275
- return { capabilities: null, formatVersion: null };
294
+ return { capabilities: null, formatVersion: null, answered: false };
276
295
  }
277
296
  }
278
297
 
298
+ /** The lane probe's patience: a longer ceiling than the 4 s boot probe. */
299
+ const LANE_PROBE_TIMEOUT_MS = 10_000;
300
+ /** Waits between attempts — a cold cell or a busy hub gets a moment. */
301
+ const LANE_PROBE_BACKOFF_MS = [2_000, 5_000] as const;
302
+
303
+ /**
304
+ * Which file lane this hub needs, decided only from an ANSWER (2.0.5).
305
+ *
306
+ * The boot used to ask `/health` once with a 4 s ceiling and read a timeout as
307
+ * "no journal here" — so a hub that was merely slow sent a 2.0 desktop down the
308
+ * legacy v1 lane on a ledger hub for the whole boot: no ledger, no held
309
+ * states, files the person had deleted pulled back, and (with the poll's
310
+ * overlapping passes) a core pinned at 2–4 GB. Now: up to `attempts` tries
311
+ * with a backoff and a longer ceiling; `legacy` only from a hub that answered
312
+ * without `ledger`; `unknown` when it never answered — the caller asks again
313
+ * later and runs no file lane meanwhile.
314
+ */
315
+ export async function probeFileLane(opts: {
316
+ hubUrl: string;
317
+ fetchImpl?: typeof fetch;
318
+ signal?: AbortSignal;
319
+ attempts?: number;
320
+ timeoutMs?: number;
321
+ backoffMs?: readonly number[];
322
+ sleep?: (ms: number) => Promise<void>;
323
+ }): Promise<{
324
+ lane: 'plane' | 'legacy' | 'unknown';
325
+ capabilities: string[] | null;
326
+ formatVersion: number | null;
327
+ }> {
328
+ const attempts = Math.max(1, opts.attempts ?? 3);
329
+ const backoff = opts.backoffMs ?? LANE_PROBE_BACKOFF_MS;
330
+ const sleep =
331
+ opts.sleep ??
332
+ ((ms: number) =>
333
+ new Promise<void>((r) => {
334
+ const t = setTimeout(r, ms);
335
+ (t as { unref?: () => void }).unref?.();
336
+ }));
337
+ for (let i = 0; i < attempts; i++) {
338
+ if (opts.signal?.aborted) break;
339
+ const h = await hubHealth({
340
+ hubUrl: opts.hubUrl,
341
+ ...(opts.fetchImpl ? { fetchImpl: opts.fetchImpl } : {}),
342
+ ...(opts.signal ? { signal: opts.signal } : {}),
343
+ timeoutMs: opts.timeoutMs ?? LANE_PROBE_TIMEOUT_MS,
344
+ });
345
+ if (h.answered) {
346
+ return {
347
+ lane: hasLedger(h.capabilities) ? 'plane' : 'legacy',
348
+ capabilities: h.capabilities,
349
+ formatVersion: h.formatVersion,
350
+ };
351
+ }
352
+ if (i < attempts - 1) await sleep(backoff[Math.min(i, backoff.length - 1)] ?? 5_000);
353
+ }
354
+ return { lane: 'unknown', capabilities: null, formatVersion: null };
355
+ }
356
+
279
357
  /** Does this hub keep annotations as the v2 element model (DDR-242)? */
280
358
  export function hasAnnotationsV2(capabilities: string[] | null): boolean {
281
359
  return Array.isArray(capabilities) && capabilities.includes('annotations-v2');
@@ -297,3 +375,14 @@ export const FILE_CLASSES_V2_CAPABILITY = 'file-classes-v2';
297
375
  export function hasFileClassesV2(capabilities: string[] | null): boolean {
298
376
  return Array.isArray(capabilities) && capabilities.includes(FILE_CLASSES_V2_CAPABILITY);
299
377
  }
378
+
379
+ /** The capability a hub advertises when its doors take paths up to 32 segments deep (fix/205). */
380
+ export const FILE_DEPTH_V2_CAPABILITY = 'file-depth-v2';
381
+
382
+ /**
383
+ * Does this hub take paths deeper than 8 segments? Every hub before fix/205 answers them
384
+ * `400 invalid path`, so the desktop holds them for it with a reason (`olderDoorRefusesDepth`).
385
+ */
386
+ export function hasFileDepthV2(capabilities: string[] | null): boolean {
387
+ return Array.isArray(capabilities) && capabilities.includes(FILE_DEPTH_V2_CAPABILITY);
388
+ }
@@ -0,0 +1,100 @@
1
+ // sync/pending-deletes.ts — fix/ds-convert-hooks-cli #7: a deletion made while no studio runs.
2
+ //
3
+ // "This canvas is gone" travels only on the `canvas-deleted` bus event (sync/index.ts `noteToHub`):
4
+ // a file missing from disk is "this machine stopped carrying it", never a deletion. A verb that
5
+ // runs IN-PROCESS because no studio answers (`maude design ds convert <ds> --restore`,
6
+ // ds/ds-verb.ts) has no bus — so its deletion went nowhere, and the next boot's pull brought the
7
+ // hub's copy straight back (and with it, on the next convert, `ds-convert-exists`).
8
+ //
9
+ // So the in-process run writes the deletion down here, and the next sync boot (1) keeps the boot
10
+ // pull from fetching those canvases and (2) emits `canvas-deleted` for each one whose file is
11
+ // still absent — the same signal the routes send, so the hub hears it exactly as it would have.
12
+ // A canvas whose file is back by then (re-created offline) is not a deletion any more: dropped.
13
+ //
14
+ // `<designRoot>/_state/pending-deletes.json` — `_state/` is per-machine runtime state in every
15
+ // DDR-115 list, so this never syncs, never commits, and a clone never carries one.
16
+
17
+ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
18
+ import path from 'node:path';
19
+
20
+ const FILE = ['_state', 'pending-deletes.json'] as const;
21
+ const MAX = 256;
22
+ const SLUG_RE = /^[a-z0-9][a-z0-9._-]{0,199}$/;
23
+
24
+ export interface PendingDelete {
25
+ slug: string;
26
+ /** The canvas file, design-root-relative, POSIX — checked for absence at boot. */
27
+ rel: string;
28
+ at: number;
29
+ }
30
+
31
+ const fileOf = (designRoot: string) => path.join(designRoot, ...FILE);
32
+
33
+ function safeRel(rel: unknown): rel is string {
34
+ return (
35
+ typeof rel === 'string' &&
36
+ rel.length > 0 &&
37
+ rel.length <= 1024 &&
38
+ !rel.startsWith('/') &&
39
+ !rel.split('/').some((s) => s === '..' || s === '' || s.startsWith('_'))
40
+ );
41
+ }
42
+
43
+ /** The recorded deletions; `[]` for none, a missing file or anything malformed. */
44
+ export function readPendingDeletes(designRoot: string): PendingDelete[] {
45
+ let doc: unknown;
46
+ try {
47
+ doc = JSON.parse(readFileSync(fileOf(designRoot), 'utf8'));
48
+ } catch {
49
+ return [];
50
+ }
51
+ const list = (doc as { v?: unknown; deletes?: unknown })?.deletes;
52
+ if ((doc as { v?: unknown })?.v !== 1 || !Array.isArray(list)) return [];
53
+ return list
54
+ .filter(
55
+ (d): d is PendingDelete =>
56
+ !!d &&
57
+ typeof d.slug === 'string' &&
58
+ SLUG_RE.test(d.slug) &&
59
+ safeRel(d.rel) &&
60
+ typeof d.at === 'number'
61
+ )
62
+ .slice(0, MAX);
63
+ }
64
+
65
+ /** Write one deletion down (deduplicated by slug, newest kept). Best-effort, never throws. */
66
+ export function recordPendingDelete(
67
+ designRoot: string,
68
+ d: { slug: string; rel: string },
69
+ now = Date.now()
70
+ ): boolean {
71
+ if (!SLUG_RE.test(d.slug) || !safeRel(d.rel)) return false;
72
+ try {
73
+ const next = [
74
+ ...readPendingDeletes(designRoot).filter((x) => x.slug !== d.slug),
75
+ { slug: d.slug, rel: d.rel, at: now },
76
+ ].slice(-MAX);
77
+ const abs = fileOf(designRoot);
78
+ mkdirSync(path.dirname(abs), { recursive: true });
79
+ const tmp = `${abs}.${process.pid}.tmp`;
80
+ writeFileSync(tmp, `${JSON.stringify({ v: 1, deletes: next })}\n`, { mode: 0o600 });
81
+ renameSync(tmp, abs);
82
+ return true;
83
+ } catch {
84
+ return false;
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Boot: take the recorded deletions. Returns the ones still deletions (their file is absent) and
90
+ * clears the record — what it held is either told now or no longer true.
91
+ */
92
+ export function takePendingDeletes(designRoot: string): PendingDelete[] {
93
+ const all = readPendingDeletes(designRoot);
94
+ try {
95
+ rmSync(fileOf(designRoot), { force: true });
96
+ } catch {
97
+ /* a record we cannot clear is told again next boot — the hub's delete is idempotent */
98
+ }
99
+ return all.filter((d) => !existsSync(path.join(designRoot, ...d.rel.split('/'))));
100
+ }
@@ -281,6 +281,12 @@ export interface DocProjection {
281
281
  * while this replica still shows the value before it.
282
282
  */
283
283
  adoptOwnAccepted(value: string): void;
284
+ /**
285
+ * #14 (2.0.5) — the css twin's `adoptOwnAccepted`: `value` is this disk's own css proposal a
286
+ * previous run left unanswered, which the outbox drain just had accepted. It is the css base
287
+ * (persisted), and the replica's older css is never written over it while its publication comes.
288
+ */
289
+ adoptOwnAcceptedCss(value: string): void;
284
290
  /**
285
291
  * Accepted-revisions mode: propose one lane value that did not come through
286
292
  * the watcher (a comment/annotation API write). Resolves with the outcome;
@@ -345,6 +351,11 @@ export interface DocProjection {
345
351
  * recovery slots. Returns false when nothing is held.
346
352
  */
347
353
  takeAccepted(): boolean;
354
+ /**
355
+ * #14 (2.0.5) — the css twin's held conflict, when its lane holds one: this disk's css and the
356
+ * project's. Keep mine proposes `mine` on top of `theirs`; `takeAccepted` takes `theirs`.
357
+ */
358
+ heldCss(): { mine: string | null; theirs: string } | null;
348
359
  /** T28 — current sides plus the first candidate and proven base (null when unknown). */
349
360
  conflictSides(): {
350
361
  mine: string | null;
@@ -416,6 +427,9 @@ export function createDocProjection(opts: DocProjectionOptions): DocProjection {
416
427
  });
417
428
  return;
418
429
  }
430
+ // #14 — the canvas's conflict is also its css twin's: an accepted html save is no answer to
431
+ // a held css, so the notice (and its dedupe key) stays until that lane is resolved too.
432
+ if (held.has('css') || pending.has('css')) return;
419
433
  if (rejectedKey !== null) opts.onRecovered?.();
420
434
  rejectedKey = null;
421
435
  }
@@ -437,6 +451,21 @@ export function createDocProjection(opts: DocProjectionOptions): DocProjection {
437
451
  }
438
452
  }
439
453
 
454
+ /**
455
+ * #14 — the css twin's agreed value, persisted like the body's (journal hash + recovery slot): a
456
+ * cold start judges a css edited while the studio was closed against it. Only ever a value the
457
+ * project accepted or wrote here — never a hold's base.
458
+ */
459
+ function rememberCssBase(css: string): void {
460
+ opts.journal?.record(slug, { cssHash: hashBytes(css) }); // DDR-102 checkpoint
461
+ if (!opts.historyDir || !paths.css) return;
462
+ try {
463
+ saveRecoveryBody(opts.historyDir, paths.css, 'base', css);
464
+ } catch {
465
+ /* the journal hash still covers the common case */
466
+ }
467
+ }
468
+
440
469
  function preserveLocal(body: string | null): void {
441
470
  if (opts.historyDir && body?.trim()) {
442
471
  // An invalid local draft can still contain authored work. Keep its raw
@@ -669,20 +698,19 @@ export function createDocProjection(opts: DocProjectionOptions): DocProjection {
669
698
  next = repeated.unit;
670
699
  }
671
700
  }
701
+ if (acceptedOwnCss !== null) {
702
+ // #14 — our own accepted css whose publication has not reached this replica: the replica's
703
+ // older css is never written over it. Once the replica moves (to it, or past it), it is over.
704
+ if (next === lastCss) return;
705
+ acceptedOwnCss = null;
706
+ }
672
707
  if (next === lastCss) return;
673
708
  lastCss = next;
674
709
  if (next === null) return; // doc carries no css yet — nothing to write
675
710
  if (!withinCap(paths.css, next, MAX_CSS_BYTES)) return;
676
711
  recordEcho(paths.css, next);
677
712
  writeAndAnnounce(paths.css, next);
678
- opts.journal?.record(slug, { cssHash: hashBytes(next) }); // DDR-102 checkpoint
679
- if (opts.historyDir) {
680
- try {
681
- saveRecoveryBody(opts.historyDir, paths.css, 'base', next);
682
- } catch {
683
- /* the journal hash still covers the common case */
684
- }
685
- }
713
+ rememberCssBase(next);
686
714
  }
687
715
 
688
716
  function writeMetaIfChanged(): void {
@@ -840,11 +868,13 @@ export function createDocProjection(opts: DocProjectionOptions): DocProjection {
840
868
  * overlaps an incoming change").
841
869
  */
842
870
  let acceptedOwn: string | null = null;
871
+ /** #14 — the css twin's `acceptedOwn`. */
872
+ let acceptedOwnCss: string | null = null;
843
873
 
844
874
  /** The value disk and the accepted replica last agreed on for `lane`. */
845
875
  function agreedValue(lane: ProposalLane): string {
846
876
  if (lane === 'html') return acceptedOwn ?? lastHtml ?? htmlFromDoc(doc);
847
- if (lane === 'css') return lastCss ?? cssFromDoc(doc) ?? '';
877
+ if (lane === 'css') return acceptedOwnCss ?? lastCss ?? cssFromDoc(doc) ?? '';
848
878
  return readLaneFromDoc(doc, lane);
849
879
  }
850
880
 
@@ -958,7 +988,16 @@ export function createDocProjection(opts: DocProjectionOptions): DocProjection {
958
988
  rememberBase(value);
959
989
  } else acceptedOwn = value;
960
990
  }
961
- if (lane === 'html') recovered();
991
+ if (lane === 'css' && !pending.has(lane)) {
992
+ // #14 — the css twin's accepted value is its base too, persisted at the ANSWER: a studio
993
+ // that closes before the publication comes back (or whose html writer is busy then)
994
+ // restarted with the base before this save, and its next closed-studio edit of the css
995
+ // was refused against its own accepted save — "changed here and in the cloud".
996
+ rememberCssBase(value);
997
+ if ((cssFromDoc(doc) ?? '') === value) lastCss = value;
998
+ else acceptedOwnCss = value;
999
+ }
1000
+ if (lane === 'html' || lane === 'css') recovered();
962
1001
  if (outcome.actionId) {
963
1002
  try {
964
1003
  opts.onAccepted?.({ lane, value, actionId: outcome.actionId });
@@ -1341,6 +1380,12 @@ export function createDocProjection(opts: DocProjectionOptions): DocProjection {
1341
1380
  // on disk now: the rest of its revision may show.
1342
1381
  const stamped = acceptedOn() ? stampedCohort() : null;
1343
1382
  if (stamped && !seenStamp) observeStamp(stamped);
1383
+ // fix/205-s515 — a publication that arrived before the cold start decided (the creator's own
1384
+ // `doc.create`, published over the socket before its HTTP answer) was refused by `flush`
1385
+ // (not ready) and is first seen HERE. It is on disk now: say it is applied, exactly as
1386
+ // `flush` would — or nothing else changes on this document and the replica's applied
1387
+ // revision stays one behind the head.
1388
+ if (stamped && !held.has('html') && !pending.has('html')) opts.onRevisionApplied?.(stamped[0]);
1344
1389
  }
1345
1390
 
1346
1391
  return {
@@ -1372,6 +1417,7 @@ export function createDocProjection(opts: DocProjectionOptions): DocProjection {
1372
1417
  observedBody = null;
1373
1418
  lastHtml = null;
1374
1419
  lastCss = null;
1420
+ acceptedOwnCss = null;
1375
1421
  lastMeta = null;
1376
1422
  deferredBeforeReady.clear();
1377
1423
  },
@@ -1386,6 +1432,15 @@ export function createDocProjection(opts: DocProjectionOptions): DocProjection {
1386
1432
  }
1387
1433
  rememberBase(value);
1388
1434
  },
1435
+ adoptOwnAcceptedCss(value: string) {
1436
+ const replica = cssFromDoc(doc) ?? '';
1437
+ if (replica === value) lastCss = value;
1438
+ else {
1439
+ lastCss = cssFromDoc(doc);
1440
+ acceptedOwnCss = value;
1441
+ }
1442
+ rememberCssBase(value);
1443
+ },
1389
1444
  hold(lane, base, local) {
1390
1445
  held.add(lane);
1391
1446
  if (lane === 'html') {
@@ -1397,8 +1452,14 @@ export function createDocProjection(opts: DocProjectionOptions): DocProjection {
1397
1452
  reject('local-edit', local, readLaneFromDoc(doc, lane), pathOfLane(lane));
1398
1453
  },
1399
1454
  takeAccepted() {
1400
- if (!held.has('html') && rejectedKey === null) return false;
1455
+ if (!held.has('html') && !held.has('css') && rejectedKey === null) return false;
1401
1456
  held.delete('html');
1457
+ // #14 — the css twin's conflict is taken with it: the project's css returns to disk (the
1458
+ // local css is in its recovery slot since the refusal).
1459
+ if (held.delete('css')) {
1460
+ lastCss = null;
1461
+ acceptedOwnCss = null;
1462
+ }
1402
1463
  // The local-edit guard compares disk with `observedBody`; declaring the
1403
1464
  // current disk bytes observed lets the writer replace them.
1404
1465
  observedBody = readLocal(paths.html);
@@ -1407,8 +1468,12 @@ export function createDocProjection(opts: DocProjectionOptions): DocProjection {
1407
1468
  void flush();
1408
1469
  return true;
1409
1470
  },
1471
+ heldCss() {
1472
+ if (!paths.css || !held.has('css') || pending.has('css')) return null;
1473
+ return { mine: readLocal(paths.css), theirs: cssFromDoc(doc) ?? '' };
1474
+ },
1410
1475
  conflictSides() {
1411
- if (!held.has('html') && rejectedKey === null) return null;
1476
+ if (!held.has('html') && !held.has('css') && rejectedKey === null) return null;
1412
1477
  const candidate = opts.historyDir ? readRecoveryCandidate(opts.historyDir, paths.html) : null;
1413
1478
  return {
1414
1479
  mine: readLocal(paths.html),
@@ -41,8 +41,13 @@ export interface SeedProgress {
41
41
  tracked: number;
42
42
  /** Rows in a terminal-good state. */
43
43
  delivered: number;
44
- /** `tracked - delivered - blocked - held`, floored at 0. */
44
+ /** `tracked - delivered - blocked - held - ignored`, floored at 0. */
45
45
  remaining: number;
46
+ /**
47
+ * Issue #207 — rows in a folder the project does not sync (`linkedHub.ignoreFolders`). A
48
+ * person's choice, not waiting and not a fault: their own count, outside `remaining`.
49
+ */
50
+ ignored?: number;
46
51
  /**
47
52
  * Issue #204 — rows this Mac REFUSES to take (a code module from a hub it has not vouched for).
48
53
  * Not waiting — nothing moves them but a person's consent — and not "blocked" on the hub's side
@@ -50,6 +55,16 @@ export interface SeedProgress {
50
55
  * `computeSeedProgress`; optional only so older snapshots still type.
51
56
  */
52
57
  held?: number;
58
+ /**
59
+ * fix/207 — `held` split by WHY. The status line used to say "N held: shared code not accepted"
60
+ * for both, and on Michal's desktop 6 555 render PNGs moved out of the project (held by the
61
+ * delete rule, `DELETED_HERE_HELD_REASON`) read as 6 942 files of shared code. Always set by
62
+ * `computeSeedProgress`; optional only so older snapshots still type.
63
+ */
64
+ heldCode?: number;
65
+ heldDeletedHere?: number;
66
+ /** Issue #207 (7b) — deleted on this Mac in a large batch, waiting for the person's answer. */
67
+ heldDeleteAsk?: number;
53
68
  /**
54
69
  * Outstanding rows whose last attempt FAILED and that wait out a backoff (`stuck`, `attempts`
55
70
  * ≥ 1) — counted inside `remaining` (they are not delivered), named here so a status line can say
@@ -95,9 +110,69 @@ const DELIVERED: ReadonlySet<DeliveryState> = new Set<DeliveryState>([
95
110
  export const CODE_MODULE_HELD_REASON =
96
111
  'code modules replicate only from an owner-vouched or loopback hub';
97
112
 
113
+ /**
114
+ * 2.0.5 — the ledger reason for a file this person deleted here while the project keeps deletes
115
+ * to itself (`linkedHub.propagateDeletes: false`). Neither side will move it, so it is held — and
116
+ * no longer counted as delivered, which the field ledger did for 1 814 files that were not here.
117
+ */
118
+ export const DELETED_HERE_HELD_REASON =
119
+ 'deleted on this Mac — this project does not sync deletions, so the project keeps it and it is not put back here';
120
+
98
121
  /** A row the receiver itself refuses, by consent: held, not waiting. */
99
122
  export function isHeldByConsent(row: LedgerRow): boolean {
100
- return row.state === 'stuck' && row.reason === CODE_MODULE_HELD_REASON;
123
+ return (
124
+ row.state === 'stuck' &&
125
+ (row.reason === CODE_MODULE_HELD_REASON || row.reason === DELETED_HERE_HELD_REASON)
126
+ );
127
+ }
128
+
129
+ /**
130
+ * fix/207 — the paths THIS Mac holds because it has not allowed shared code from the hub: the rows
131
+ * behind Sync details' "Allow shared code…" (a `code-consent` held row). Sorted, so the panel's list
132
+ * is stable between passes.
133
+ */
134
+ export function codeConsentHeldPaths(rows: Readonly<Record<string, LedgerRow>>): string[] {
135
+ const out: string[] = [];
136
+ for (const [rel, row] of Object.entries(rows))
137
+ if (row.state === 'stuck' && row.reason === CODE_MODULE_HELD_REASON) out.push(rel);
138
+ return out.sort();
139
+ }
140
+
141
+ /**
142
+ * fix/207 — Sync details' sentence for that row (CONTRACT §4: what happened · what is safe · one
143
+ * verb). The verb is the row's button, Allow shared code… — the only place the answer changes in
144
+ * the app (the summary used to read "shared code not accepted on this Mac", a choice nobody could
145
+ * make there).
146
+ */
147
+ export function codeConsentHeldDetail(count: number): string {
148
+ const n = count.toLocaleString('en-US');
149
+ return count === 1
150
+ ? '1 file of shared code from this project is waiting: shared code reaches this Mac only once you allow it. Nothing is lost. Allow shared code and it arrives with the next sync.'
151
+ : `${n} files of shared code from this project are waiting: shared code reaches this Mac only once you allow it. Nothing is lost. Allow shared code and they arrive with the next sync.`;
152
+ }
153
+
154
+ /**
155
+ * fix/207 — the status line's words for what this Mac holds, one phrase per reason, so a deleted
156
+ * PNG is never "shared code" and no phrase names a choice the app does not offer.
157
+ */
158
+ export function heldWords(
159
+ p: Pick<SeedProgress, 'heldCode' | 'heldDeletedHere' | 'heldDeleteAsk'>
160
+ ): string[] {
161
+ const out: string[] = [];
162
+ const files = (n: number) => `${n.toLocaleString('en-US')} ${n === 1 ? 'file' : 'files'}`;
163
+ const code = p.heldCode ?? 0;
164
+ const deleted = p.heldDeletedHere ?? 0;
165
+ const ask = p.heldDeleteAsk ?? 0;
166
+ if (ask > 0)
167
+ out.push(
168
+ `${files(ask)} deleted on this Mac ${ask === 1 ? 'waits' : 'wait'} for your answer (Sync details)`
169
+ );
170
+ if (code > 0)
171
+ out.push(
172
+ `${files(code)} of shared code ${code === 1 ? 'waits' : 'wait'} for your yes (Sync details)`
173
+ );
174
+ if (deleted > 0) out.push(`${files(deleted)} deleted on this Mac stay deleted here`);
175
+ return out;
101
176
  }
102
177
 
103
178
  /** States that will not move again without something changing. */
@@ -135,6 +210,10 @@ export function computeSeedProgress(input: SeedProgressInput): SeedProgress {
135
210
  let delivered = 0;
136
211
  let bytesRemaining = 0;
137
212
  let held = 0;
213
+ let heldCode = 0;
214
+ let heldDeletedHere = 0;
215
+ let heldDeleteAsk = 0;
216
+ let ignored = 0;
138
217
  let retrying = 0;
139
218
  let retryingFile: { rel: string; reason: string } | undefined;
140
219
  const blockedCounts = new Map<BlockedClass, number>();
@@ -146,8 +225,26 @@ export function computeSeedProgress(input: SeedProgressInput): SeedProgress {
146
225
  delivered += 1;
147
226
  continue;
148
227
  }
228
+ if (state === 'ignored') {
229
+ ignored += 1;
230
+ continue;
231
+ }
232
+ // Issue #207 (7b) — a delete waiting for the person's answer, and a file kept on the hub: held
233
+ // here by a choice (asked, or made), never "waiting" to move.
234
+ if (state === 'delete-held') {
235
+ held += 1;
236
+ heldDeleteAsk += 1;
237
+ continue;
238
+ }
239
+ if (state === 'hub-only') {
240
+ held += 1;
241
+ heldDeletedHere += 1;
242
+ continue;
243
+ }
149
244
  if (isHeldByConsent(row)) {
150
245
  held += 1;
246
+ if (row.reason === CODE_MODULE_HELD_REASON) heldCode += 1;
247
+ else heldDeletedHere += 1;
151
248
  continue;
152
249
  }
153
250
  if (state && BLOCKED.has(state)) {
@@ -171,7 +268,7 @@ export function computeSeedProgress(input: SeedProgressInput): SeedProgress {
171
268
  .map(([cls, count]) => ({ class: cls, count }))
172
269
  .sort((a, b) => b.count - a.count);
173
270
  const blockedTotal = blocked.reduce((n, b) => n + b.count, 0);
174
- const remaining = Math.max(0, tracked - delivered - blockedTotal - held);
271
+ const remaining = Math.max(0, tracked - delivered - blockedTotal - held - ignored);
175
272
 
176
273
  const paused =
177
274
  typeof input.pausedUntil === 'number' && Number.isFinite(input.pausedUntil)
@@ -194,6 +291,10 @@ export function computeSeedProgress(input: SeedProgressInput): SeedProgress {
194
291
  delivered,
195
292
  remaining,
196
293
  held,
294
+ heldCode,
295
+ heldDeletedHere,
296
+ ...(heldDeleteAsk > 0 ? { heldDeleteAsk } : {}),
297
+ ...(ignored > 0 ? { ignored } : {}),
197
298
  retrying,
198
299
  ...(retryingFile ? { retryingFile } : {}),
199
300
  bytesRemaining,
@@ -14,6 +14,8 @@
14
14
  import { existsSync, readFileSync } from 'node:fs';
15
15
  import { join } from 'node:path';
16
16
 
17
+ import { normalizeIgnoreFolders } from './file-plane.ts';
18
+
17
19
  export const FIRST_ANCHOR_MODES = ['ask', 'keep-local', 'keep-cloud'] as const;
18
20
  export type FirstAnchorMode = (typeof FIRST_ANCHOR_MODES)[number];
19
21
 
@@ -24,6 +26,14 @@ export interface SyncSettings {
24
26
  propagateDeletes: boolean;
25
27
  /** First-anchor resolution; 'ask' = the key is absent = hold and keep asking. */
26
28
  resolveFirstAnchor: FirstAnchorMode;
29
+ /** Issue #207 — folders this project does not sync (`linkedHub.ignoreFolders`); [] = every folder. */
30
+ ignoreFolders: string[];
31
+ }
32
+
33
+ /** Issue #207 — a change to the ignore list: one folder in or out (never a wholesale rewrite). */
34
+ export interface IgnoreFolderPatch {
35
+ addIgnoreFolder?: string;
36
+ removeIgnoreFolder?: string;
27
37
  }
28
38
 
29
39
  export function isFirstAnchorMode(v: unknown): v is FirstAnchorMode {
@@ -58,9 +68,19 @@ export function readSyncSettings(repoRoot: string): SyncSettings | null {
58
68
  syncFiles: hub.syncFiles !== false,
59
69
  propagateDeletes: hub.propagateDeletes !== false,
60
70
  resolveFirstAnchor: isFirstAnchorMode(hub.resolveFirstAnchor) ? hub.resolveFirstAnchor : 'ask',
71
+ ignoreFolders: normalizeIgnoreFolders(hub.ignoreFolders),
61
72
  };
62
73
  }
63
74
 
75
+ /**
76
+ * Issue #207 — whether deletions propagate, read NOW from the project config. The file plane calls
77
+ * this at the start of every pass, so a change in `config.json` (or in Sync settings) applies at the
78
+ * next pass. `fallback` answers when the config names no hub (a cell's pairing has no `linkedHub`).
79
+ */
80
+ export function livePropagateDeletes(repoRoot: string, fallback: boolean): boolean {
81
+ return readSyncSettings(repoRoot)?.propagateDeletes ?? fallback;
82
+ }
83
+
64
84
  /**
65
85
  * Patch ONLY the provided keys into `linkedHub`, preserving everything else.
66
86
  * Booleans are written explicitly when false and REMOVED when true (true is
@@ -71,7 +91,7 @@ export function readSyncSettings(repoRoot: string): SyncSettings | null {
71
91
  */
72
92
  export async function writeSyncSettings(
73
93
  repoRoot: string,
74
- patch: Partial<SyncSettings>
94
+ patch: Partial<Omit<SyncSettings, 'ignoreFolders'>> & IgnoreFolderPatch
75
95
  ): Promise<SyncSettings> {
76
96
  const p = configPath(repoRoot);
77
97
  if (existsSync(p)) {
@@ -103,6 +123,21 @@ export async function writeSyncSettings(
103
123
  next.resolveFirstAnchor = patch.resolveFirstAnchor;
104
124
  else throw new Error(`invalid resolveFirstAnchor: ${String(patch.resolveFirstAnchor)}`);
105
125
  }
126
+ if (patch.addIgnoreFolder !== undefined || patch.removeIgnoreFolder !== undefined) {
127
+ const list = normalizeIgnoreFolders(hub.ignoreFolders);
128
+ if (patch.addIgnoreFolder !== undefined) {
129
+ const [add] = normalizeIgnoreFolders([patch.addIgnoreFolder]);
130
+ if (!add) throw new Error(`not a folder inside the design root: ${patch.addIgnoreFolder}`);
131
+ if (!list.includes(add)) list.push(add);
132
+ }
133
+ const [drop] =
134
+ patch.removeIgnoreFolder !== undefined
135
+ ? normalizeIgnoreFolders([patch.removeIgnoreFolder])
136
+ : [];
137
+ const kept = drop ? list.filter((f) => f !== drop) : list;
138
+ // undefined, not delete: JSON.stringify drops it, so an empty list leaves no key behind.
139
+ next.ignoreFolders = kept.length > 0 ? kept : undefined;
140
+ }
106
141
  await Bun.write(p, `${JSON.stringify({ ...cfg, linkedHub: next }, null, 2)}\n`);
107
142
  const settings = readSyncSettings(repoRoot);
108
143
  if (!settings) throw new Error('settings write did not persist');