@1agh/maude 2.1.0 → 2.1.2

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 (153) hide show
  1. package/apps/studio/access/request.ts +1 -0
  2. package/apps/studio/actions/agents.ts +45 -42
  3. package/apps/studio/actions/defs/app.ts +28 -1
  4. package/apps/studio/actions/defs/sync.ts +4 -0
  5. package/apps/studio/actions/verbs.ts +49 -0
  6. package/apps/studio/actions.manifest.json +162 -20
  7. package/apps/studio/actions.parity.json +13 -1
  8. package/apps/studio/ai/create-claim.ts +1 -1
  9. package/apps/studio/bin/_asset-file.mjs +117 -0
  10. package/apps/studio/bin/_canvas-file.mjs +146 -0
  11. package/apps/studio/bin/_curl-local.mjs +7 -4
  12. package/apps/studio/bin/_footage.mjs +123 -0
  13. package/apps/studio/bin/_pdf-playwright.mjs +14 -0
  14. package/apps/studio/bin/_png-playwright.mjs +15 -1
  15. package/apps/studio/bin/_pw-launch.mjs +98 -0
  16. package/apps/studio/bin/_retry-save.mjs +49 -0
  17. package/apps/studio/bin/_sync.mjs +145 -2
  18. package/apps/studio/bin/asset-rename.sh +12 -0
  19. package/apps/studio/bin/asset-trash.sh +12 -0
  20. package/apps/studio/bin/canvas-move.sh +12 -0
  21. package/apps/studio/bin/canvas-new.sh +12 -0
  22. package/apps/studio/bin/footage.sh +12 -0
  23. package/apps/studio/bin/generate.sh +7 -0
  24. package/apps/studio/bin/retry-save.sh +13 -0
  25. package/apps/studio/bridge/canvas-mode-store.ts +11 -2
  26. package/apps/studio/bridge/dgn-protocol.ts +8 -3
  27. package/apps/studio/bridge/occlusion.ts +45 -0
  28. package/apps/studio/canvas-theme-pill.tsx +169 -26
  29. package/apps/studio/client/app.jsx +16 -4
  30. package/apps/studio/client/export-center.jsx +32 -3
  31. package/apps/studio/client/home/HomeAccountBanner.jsx +61 -0
  32. package/apps/studio/client/home/HomeAccountsChip.jsx +404 -0
  33. package/apps/studio/client/home/HomeConnection.jsx +112 -0
  34. package/apps/studio/client/home/ProjectRows.jsx +514 -0
  35. package/apps/studio/client/home/home-accounts-model.js +234 -76
  36. package/apps/studio/client/home/home-api.js +10 -2
  37. package/apps/studio/client/home/home-app.jsx +151 -394
  38. package/apps/studio/client/home/home-icons.jsx +8 -0
  39. package/apps/studio/client/home/home-model.js +149 -1
  40. package/apps/studio/client/home/home-where-model.js +105 -0
  41. package/apps/studio/client/home/home.css +621 -53
  42. package/apps/studio/client/home/use-account-fix.js +123 -0
  43. package/apps/studio/client/hooks/use-palette-and-panels.jsx +3 -1
  44. package/apps/studio/client/hooks/use-tabs.jsx +11 -4
  45. package/apps/studio/client/panels/TeamProjects.jsx +137 -134
  46. package/apps/studio/client/share-link.js +12 -0
  47. package/apps/studio/client/styles/_index.css +4 -0
  48. package/apps/studio/client/v2/assets/generate-ask.jsx +3 -1
  49. package/apps/studio/client/v2/diagnostics/diagnostics-host.jsx +1 -0
  50. package/apps/studio/client/v2/diagnostics/diagnostics-model.js +32 -2
  51. package/apps/studio/client/v2/diagnostics/diagnostics-sheet.jsx +35 -8
  52. package/apps/studio/client/v2/diagnostics/diagnostics.css +34 -0
  53. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +94 -3
  54. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +187 -4
  55. package/apps/studio/client/v2/export/done-toast.jsx +2 -5
  56. package/apps/studio/client/v2/export/export-sheet.jsx +9 -2
  57. package/apps/studio/client/v2/export/export.css +9 -0
  58. package/apps/studio/client/v2/export/exports-model.js +16 -3
  59. package/apps/studio/client/v2/export/file-rows.jsx +81 -5
  60. package/apps/studio/client/v2/export/native-save.js +33 -0
  61. package/apps/studio/client/v2/export/sections/print-copy.js +3 -0
  62. package/apps/studio/client/v2/export/sections/print.jsx +37 -20
  63. package/apps/studio/client/v2/link-server/LinkServerDialog.jsx +492 -0
  64. package/apps/studio/client/v2/link-server/LinkServerHost.jsx +42 -0
  65. package/apps/studio/client/v2/link-server/link-server-api.js +142 -0
  66. package/apps/studio/client/v2/link-server/link-server-model.js +438 -0
  67. package/apps/studio/client/v2/link-server/link-server.css +109 -0
  68. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +31 -86
  69. package/apps/studio/client/v2/onboarding/onboarding-model.js +1 -18
  70. package/apps/studio/client/v2/search/search-keywords.js +3 -2
  71. package/apps/studio/client/v2/settings/account.jsx +4 -2
  72. package/apps/studio/client/v2/settings/advanced-section.jsx +245 -148
  73. package/apps/studio/client/v2/settings/connection-row.jsx +3 -59
  74. package/apps/studio/client/v2/settings/connections-section.jsx +118 -425
  75. package/apps/studio/client/v2/settings/general-section.jsx +138 -43
  76. package/apps/studio/client/v2/settings/project-sync-settings.jsx +4 -3
  77. package/apps/studio/client/v2/settings/reset-section.jsx +14 -3
  78. package/apps/studio/client/v2/settings/settings-card.jsx +142 -0
  79. package/apps/studio/client/v2/settings/settings-cards.js +220 -0
  80. package/apps/studio/client/v2/settings/settings-handlers.js +7 -6
  81. package/apps/studio/client/v2/settings/settings-model.js +91 -31
  82. package/apps/studio/client/v2/settings/settings-sheet.jsx +25 -6
  83. package/apps/studio/client/v2/settings/settings.css +374 -64
  84. package/apps/studio/client/v2/settings/this-project-card.jsx +730 -0
  85. package/apps/studio/client/v2/settings/this-project-model.js +172 -0
  86. package/apps/studio/client/v2/settings/use-connections.js +3 -2
  87. package/apps/studio/client/v2/settings/use-open-card.js +37 -0
  88. package/apps/studio/client/v2/shell/connection-state.js +197 -0
  89. package/apps/studio/client/v2/shell/menu-runner.js +7 -2
  90. package/apps/studio/client/v2/shell/occlusion-insets.js +37 -9
  91. package/apps/studio/client/v2/shell/project-account-bus.js +36 -0
  92. package/apps/studio/client/v2/shell/project-account-card.jsx +357 -148
  93. package/apps/studio/client/v2/shell/project-account-model.js +272 -149
  94. package/apps/studio/client/v2/shell/project-account-toast.js +66 -0
  95. package/apps/studio/client/v2/shell/project-account.css +237 -0
  96. package/apps/studio/client/v2/shell/share-cluster-host.jsx +166 -83
  97. package/apps/studio/client/v2/shell/shell-parity.js +3 -2
  98. package/apps/studio/client/v2/shell/shell-parity.json +40 -26
  99. package/apps/studio/client/v2/shell/use-account.js +2 -0
  100. package/apps/studio/client/v2/shell/use-occluded-insets.js +13 -3
  101. package/apps/studio/client/v2/signin/use-signin.js +1 -1
  102. package/apps/studio/cloud/endpoints.ts +29 -4
  103. package/apps/studio/collab/room.ts +21 -7
  104. package/apps/studio/dist/client.bundle.js +886 -886
  105. package/apps/studio/dist/comment-mount.js +2 -2
  106. package/apps/studio/dist/styles.css +1 -1
  107. package/apps/studio/exporters/ghostscript.ts +78 -1
  108. package/apps/studio/exporters/pdf-fonts.ts +31 -4
  109. package/apps/studio/generation/jobs.ts +6 -0
  110. package/apps/studio/home/accounts.ts +30 -11
  111. package/apps/studio/home/cloud.ts +6 -1
  112. package/apps/studio/home/hub-health.ts +76 -0
  113. package/apps/studio/home/routes.ts +9 -3
  114. package/apps/studio/http.ts +14 -2
  115. package/apps/studio/migrate/hub.ts +8 -1
  116. package/apps/studio/routes/agent.ts +6 -2
  117. package/apps/studio/routes/hub-link-folder.ts +334 -0
  118. package/apps/studio/routes/hub-signin.ts +78 -1
  119. package/apps/studio/routes/index.ts +4 -0
  120. package/apps/studio/routes/project-undo.ts +10 -0
  121. package/apps/studio/routes/sync.ts +22 -4
  122. package/apps/studio/server.ts +25 -0
  123. package/apps/studio/shell/api-key.ts +11 -0
  124. package/apps/studio/shell/cli-yield.ts +48 -11
  125. package/apps/studio/sync/accepted-cold-start.ts +144 -8
  126. package/apps/studio/sync/action-stage.ts +18 -1
  127. package/apps/studio/sync/ctl-heal.ts +58 -0
  128. package/apps/studio/sync/file-ledger.ts +38 -4
  129. package/apps/studio/sync/file-plane.ts +226 -19
  130. package/apps/studio/sync/held-deletes.ts +86 -5
  131. package/apps/studio/sync/hub-link.ts +8 -0
  132. package/apps/studio/sync/index.ts +68 -4
  133. package/apps/studio/sync/link-consent.ts +22 -75
  134. package/apps/studio/sync/link-survey.ts +252 -0
  135. package/apps/studio/sync/local-kernel.ts +16 -1
  136. package/apps/studio/sync/seed-progress.ts +12 -0
  137. package/apps/studio/sync/source-recovery.ts +18 -2
  138. package/apps/studio/sync/status.ts +11 -1
  139. package/apps/studio/sync/writer-registry.ts +5 -0
  140. package/apps/studio/whats-new.json +36 -0
  141. package/cli/commands/design.mjs +74 -16
  142. package/cli/lib/bash-guard.mjs +23 -4
  143. package/cli/lib/confine-read.mjs +2 -0
  144. package/cli/lib/design-help.gen.mjs +15 -2
  145. package/cli/lib/design-hook.mjs +1 -1
  146. package/cli/lib/desktop-locate.mjs +36 -8
  147. package/cli/lib/studio-locate.mjs +8 -2
  148. package/cli/lib/sub-verbs.mjs +13 -1
  149. package/package.json +9 -8
  150. package/apps/studio/client/home/HomeAccounts.jsx +0 -262
  151. package/apps/studio/client/v2/onboarding/HubSheet.jsx +0 -212
  152. package/apps/studio/client/v2/shell/account-card-model.js +0 -114
  153. package/apps/studio/client/v2/shell/account-card.jsx +0 -189
@@ -453,26 +453,29 @@
453
453
  },
454
454
  {
455
455
  "testid": "cloud-account",
456
- "section": "connections"
456
+ "section": "general",
457
+ "conditional": true
457
458
  },
458
459
  {
459
- "testid": "settings-github",
460
- "section": "connections"
460
+ "testid": "settings-hub-address",
461
+ "section": "general",
462
+ "conditional": true
461
463
  },
462
464
  {
463
- "testid": "settings-ai-keys",
464
- "section": "connections"
465
+ "testid": "settings-team-server-add",
466
+ "section": "general",
467
+ "conditional": true
465
468
  },
466
469
  {
467
- "testid": "figma-connect-card",
470
+ "testid": "settings-github",
468
471
  "section": "connections"
469
472
  },
470
473
  {
471
- "testid": "settings-hub-address",
474
+ "testid": "settings-ai-keys",
472
475
  "section": "connections"
473
476
  },
474
477
  {
475
- "testid": "settings-team-server-add",
478
+ "testid": "figma-connect-card",
476
479
  "section": "connections"
477
480
  },
478
481
  {
@@ -517,19 +520,23 @@
517
520
  },
518
521
  {
519
522
  "testid": "sync-setting-syncFiles",
520
- "section": "advanced"
523
+ "section": "general",
524
+ "conditional": true
521
525
  },
522
526
  {
523
527
  "testid": "sync-setting-syncFiles",
524
- "section": "advanced"
528
+ "section": "general",
529
+ "conditional": true
525
530
  },
526
531
  {
527
532
  "testid": "sync-setting-firstAnchor",
528
- "section": "advanced"
533
+ "section": "general",
534
+ "conditional": true
529
535
  },
530
536
  {
531
537
  "testid": "sync-ownership-adopt",
532
- "section": "advanced"
538
+ "section": "general",
539
+ "conditional": true
533
540
  },
534
541
  {
535
542
  "testid": "settings-runtime",
@@ -727,7 +734,7 @@
727
734
  "nav.home": "Back to Home is for desktop and cloud only",
728
735
  "project.pull-copy": "Pull a local copy… is for desktop only",
729
736
  "project.share-github": "Share on GitHub… is for desktop only",
730
- "account.switch": "Sign in as another account… is for desktop and cloud only",
737
+ "account.switch": "Switch account… is for desktop and cloud only",
731
738
  "ai.chat": "AI chat is for desktop and cloud only"
732
739
  }
733
740
  },
@@ -841,26 +848,29 @@
841
848
  },
842
849
  {
843
850
  "testid": "cloud-account",
844
- "section": "connections"
851
+ "section": "general",
852
+ "conditional": true
845
853
  },
846
854
  {
847
- "testid": "settings-github",
848
- "section": "connections"
855
+ "testid": "settings-hub-address",
856
+ "section": "general",
857
+ "conditional": true
849
858
  },
850
859
  {
851
- "testid": "settings-ai-keys",
852
- "section": "connections"
860
+ "testid": "settings-team-server-add",
861
+ "section": "general",
862
+ "conditional": true
853
863
  },
854
864
  {
855
- "testid": "figma-connect-card",
865
+ "testid": "settings-github",
856
866
  "section": "connections"
857
867
  },
858
868
  {
859
- "testid": "settings-hub-address",
869
+ "testid": "settings-ai-keys",
860
870
  "section": "connections"
861
871
  },
862
872
  {
863
- "testid": "settings-team-server-add",
873
+ "testid": "figma-connect-card",
864
874
  "section": "connections"
865
875
  },
866
876
  {
@@ -901,19 +911,23 @@
901
911
  },
902
912
  {
903
913
  "testid": "sync-setting-syncFiles",
904
- "section": "advanced"
914
+ "section": "general",
915
+ "conditional": true
905
916
  },
906
917
  {
907
918
  "testid": "sync-setting-syncFiles",
908
- "section": "advanced"
919
+ "section": "general",
920
+ "conditional": true
909
921
  },
910
922
  {
911
923
  "testid": "sync-setting-firstAnchor",
912
- "section": "advanced"
924
+ "section": "general",
925
+ "conditional": true
913
926
  },
914
927
  {
915
928
  "testid": "sync-ownership-adopt",
916
- "section": "advanced"
929
+ "section": "general",
930
+ "conditional": true
917
931
  },
918
932
  {
919
933
  "testid": "settings-runtime",
@@ -1926,7 +1940,7 @@
1926
1940
  "import.figma": "Import from Figma… needs edit rights",
1927
1941
  "import.brand": "Import a brand… needs edit rights",
1928
1942
  "video.assemble": "Assemble clips into a video needs edit rights",
1929
- "account.switch": "Sign in as another account… is for desktop and cloud only",
1943
+ "account.switch": "Switch account… is for desktop and cloud only",
1930
1944
  "select.all-annotations": "Select all annotations needs edit rights",
1931
1945
  "ai.chat": "AI chat is for desktop and cloud only",
1932
1946
  "sync.resync": "Resync now needs edit rights"
@@ -31,6 +31,8 @@ export function useAccount(enabled) {
31
31
  // 2.0.5 W4 — the project account card's kind: the cloud address and this folder's link
32
32
  cloudUrl: typeof j?.url === 'string' ? j.url : '',
33
33
  linkedHub: j?.linkedHub ?? null,
34
+ // 2.1.1 T2 — where the project lives: { kept } | { kept: false, folder }
35
+ place: j?.place && typeof j.place === 'object' ? j.place : null,
34
36
  }));
35
37
  })
36
38
  .catch(() => {
@@ -5,7 +5,12 @@
5
5
  import { useEffect, useRef } from 'react';
6
6
  import { postToCanvas } from '../../../bridge/dgn-protocol.ts';
7
7
  import { setShellInsets } from './insets-now.js';
8
- import { createInsetsPump, measureShellInsets, seedOnLadder } from './occlusion-insets.js';
8
+ import {
9
+ createInsetsPump,
10
+ measureShellInsets,
11
+ measureShellTopBand,
12
+ seedOnLadder,
13
+ } from './occlusion-insets.js';
9
14
 
10
15
  /** V2-4.3b — the live pump's synchronous flush, for the mode lane (insets before `set-mode`). A no-op
11
16
  * until the hook has mounted. */
@@ -28,13 +33,18 @@ export function useOccludedInsets({ bodyRef, iframesRef, presenting, layoutKey }
28
33
  const frameEl = () => body.querySelector(':scope > .main');
29
34
  const measure = () =>
30
35
  measureShellInsets(frameEl(), body, { presenting: presentingRef.current });
36
+ // #217 — the free top band, so the canvas's top-centre pill sits between the islands, not under them
37
+ const measureBand = () =>
38
+ measureShellTopBand(frameEl(), body, { presenting: presentingRef.current });
31
39
  const frames = () => [...(iframesRef.current?.values() ?? [])];
32
40
  const pump = createInsetsPump({
33
41
  measure,
34
- send(seq, insets, to) {
42
+ measureBand,
43
+ send(seq, insets, to, topBand) {
35
44
  setShellInsets(insets); // P8 C5: shell surfaces that centre on the free canvas read the same value
36
45
  const targets = to ? [to] : frames().map((f) => f.contentWindow);
37
- for (const win of targets) postToCanvas(win, 'occluded-insets', { seq, insets }, '*');
46
+ const msg = topBand ? { seq, insets, topBand } : { seq, insets };
47
+ for (const win of targets) postToCanvas(win, 'occluded-insets', msg, '*');
38
48
  },
39
49
  schedule: (fn) => requestAnimationFrame(fn),
40
50
  cancel: (h) => cancelAnimationFrame(h),
@@ -58,7 +58,7 @@ export function useCloudSignIn({ native, onSignedIn, now = Date.now }) {
58
58
  };
59
59
  let profile;
60
60
  try {
61
- profile = await signInPrepare(opts.forInvite);
61
+ profile = await signInPrepare(opts.forInvite, opts.profile);
62
62
  } catch (e) {
63
63
  fail(wordsOf(e));
64
64
  return;
@@ -30,7 +30,7 @@ import { browserDoorOf } from '../client/v2/cloud/browser-door.js';
30
30
  import { asFormat, formatToKeep } from '../format.ts';
31
31
  import { deleteHubCredential, saveHubCredential } from '../sync/hub-link.ts';
32
32
  import { getHubRecord, getHubToken, normalizeUrl } from '../sync/hubs-config.ts';
33
- import { deleteProjectLink, linksPath, recordProjectLink } from '../sync/link-consent.ts';
33
+ import { deleteProjectLink, linksPath, normHub, recordProjectLink } from '../sync/link-consent.ts';
34
34
  import { boundCloudToken, cloudConfigPath } from './config-path.ts';
35
35
 
36
36
  /**
@@ -238,6 +238,24 @@ interface Ctx {
238
238
  };
239
239
  }
240
240
 
241
+ /**
242
+ * 2.1.1 T2 — where the project at `repoRoot` lives: `{ kept: true }` for a copy Maude keeps (the app
243
+ * bound it to a server: `MAUDE_APP_BOUND_HUB`, set by the desktop shell per spawn, never by a repo),
244
+ * else `{ kept: false, folder }` — the folder, with the home directory as `~`.
245
+ */
246
+ export function placeOf(
247
+ repoRoot: string,
248
+ env: Record<string, string | undefined> = process.env
249
+ ): { kept: true } | { kept: false; folder: string } {
250
+ if (normHub(env.MAUDE_APP_BOUND_HUB)) return { kept: true };
251
+ const home = env.HOME || '';
252
+ const folder =
253
+ home && (repoRoot === home || repoRoot.startsWith(home.endsWith(sep) ? home : home + sep))
254
+ ? `~${repoRoot.slice(home.replace(/[\\/]+$/, '').length)}`
255
+ : repoRoot;
256
+ return { kept: false, folder };
257
+ }
258
+
241
259
  export function createCloudEndpoints(ctx: Ctx) {
242
260
  const cfgFile = () => ctx.cloudConfigPath ?? cloudConfigPath();
243
261
  /** gate-b-sec4 — the per-Mac link record, beside the same profile's hubs.json. */
@@ -269,6 +287,10 @@ export function createCloudEndpoints(ctx: Ctx) {
269
287
  url: file ? file.url : cloudUrl(),
270
288
  project: basename(ctx.paths.repoRoot),
271
289
  linkedHub: readLinkedHub(),
290
+ // 2.1.1 T2 — where the project lives (canvas 17 · ac-model): a copy Maude keeps for a
291
+ // server the APP bound it to (`MAUDE_APP_BOUND_HUB`, which a repo cannot set), else the
292
+ // person's own folder, home-abbreviated. Main origin only, like the rest of this answer.
293
+ place: placeOf(ctx.paths.repoRoot),
272
294
  },
273
295
  };
274
296
  },
@@ -763,20 +785,23 @@ export function createCloudEndpoints(ctx: Ctx) {
763
785
  * opened (attacker pass 2026-08-04, B2). A stored hub credential for that
764
786
  * address is the corroboration, because only a real sign-in writes one.
765
787
  */
766
- function readLinkedHub(): { url: string; credentialed: boolean } | null {
788
+ function readLinkedHub(): { url: string; credentialed: boolean; confirmed: boolean } | null {
767
789
  try {
768
790
  const cfg = JSON.parse(readFileSync(join(ctx.paths.designRoot, 'config.json'), 'utf8'));
769
791
  const url = cfg?.linkedHub?.url;
770
792
  if (typeof url !== 'string' || !url) return null;
771
793
  let credentialed = false;
772
794
  // gate-b-sec4 — a link this Mac never made vouches for nothing and is sent nothing.
773
- if (ctx.unconfirmedHub) return { url, credentialed: false };
795
+ // 2.1.1 — and the page hears so (`confirmed: false`). `confirmed` comes from THIS Mac's link
796
+ // record (the boot verdict that parked the claim), never from the repo, so an address this Mac
797
+ // never confirmed is never worded as a sign-in to repair.
798
+ if (ctx.unconfirmedHub) return { url, credentialed: false, confirmed: false };
774
799
  try {
775
800
  credentialed = !!getHubToken(normalizeUrl(url));
776
801
  } catch {
777
802
  /* unreadable credential store → treat as uncorroborated */
778
803
  }
779
- return { url, credentialed };
804
+ return { url, credentialed, confirmed: true };
780
805
  } catch {
781
806
  return null; // absent/malformed → simply not linked
782
807
  }
@@ -254,21 +254,35 @@ export function createRoom(slug: string, callbacks: RoomCallbacks): Room {
254
254
  }, DEBOUNCE_MS);
255
255
  }
256
256
 
257
+ // #216 — the flush on its way. A caller that flushes to READ what the room holds (⌘Z's stack read)
258
+ // waits for it: `dirty` is cleared as a flush starts, so a second call used to return while the
259
+ // first was still projecting the board.
260
+ let writing: Promise<void> | null = null;
261
+
257
262
  async function flush(): Promise<void> {
263
+ if (writing) await writing;
258
264
  if (!dirty || destroyed) return;
259
265
  dirty = false;
260
266
  if (flushTimer) {
261
267
  clearTimeout(flushTimer);
262
268
  flushTimer = null;
263
269
  }
270
+ const run = (async () => {
271
+ try {
272
+ await callbacks.persistJson(slug, doc);
273
+ await callbacks.persistBinary(slug, Y.encodeStateAsUpdate(doc));
274
+ } catch (err) {
275
+ // Re-arm so the next mutation retries. Loud-log; persistence loss is a
276
+ // user-visible bug if it stays silent.
277
+ dirty = true;
278
+ console.error(`[collab/${slug}] flush failed:`, err);
279
+ }
280
+ })();
281
+ writing = run;
264
282
  try {
265
- await callbacks.persistJson(slug, doc);
266
- await callbacks.persistBinary(slug, Y.encodeStateAsUpdate(doc));
267
- } catch (err) {
268
- // Re-arm so the next mutation retries. Loud-log; persistence loss is a
269
- // user-visible bug if it stays silent.
270
- dirty = true;
271
- console.error(`[collab/${slug}] flush failed:`, err);
283
+ await run;
284
+ } finally {
285
+ if (writing === run) writing = null;
272
286
  }
273
287
  }
274
288