@1agh/maude 2.0.2 → 2.0.4

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 (154) hide show
  1. package/README.md +6 -5
  2. package/apps/studio/access/request.ts +0 -1
  3. package/apps/studio/acp/adapter-stderr.ts +43 -13
  4. package/apps/studio/acp/background-tasks.ts +155 -0
  5. package/apps/studio/acp/bridge.ts +44 -5
  6. package/apps/studio/acp/connected-fact.ts +15 -4
  7. package/apps/studio/acp/index.ts +14 -5
  8. package/apps/studio/actions/agents.ts +5 -0
  9. package/apps/studio/actions/defs/view.ts +12 -0
  10. package/apps/studio/actions.manifest.json +13 -1
  11. package/apps/studio/actions.parity.json +7 -1
  12. package/apps/studio/api.ts +31 -24
  13. package/apps/studio/asset-placeholder.tsx +157 -62
  14. package/apps/studio/bin/_png-playwright.mjs +10 -1
  15. package/apps/studio/bin/_pw-launch.mjs +14 -0
  16. package/apps/studio/bin/_thumbs-playwright.mjs +4 -1
  17. package/apps/studio/boot-progress.ts +31 -0
  18. package/apps/studio/bridge/dgn-protocol.ts +34 -4
  19. package/apps/studio/canvas-build-sandbox.ts +275 -42
  20. package/apps/studio/canvas-build-worker.ts +10 -0
  21. package/apps/studio/canvas-create.ts +24 -0
  22. package/apps/studio/canvas-module-cache.ts +93 -0
  23. package/apps/studio/canvas-source/errors.ts +39 -0
  24. package/apps/studio/canvas-source/waiting.ts +290 -0
  25. package/apps/studio/client/actions/shell-key-handlers.js +5 -0
  26. package/apps/studio/client/app.jsx +22 -9
  27. package/apps/studio/client/github.js +23 -3
  28. package/apps/studio/client/home/home-api.js +30 -19
  29. package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
  30. package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
  31. package/apps/studio/client/hooks/use-tabs.jsx +64 -35
  32. package/apps/studio/client/index-loader.ts +23 -3
  33. package/apps/studio/client/panels/ChatPanel.jsx +22 -37
  34. package/apps/studio/client/panels/DiffView.jsx +314 -248
  35. package/apps/studio/client/panels/TeamProjects.jsx +119 -69
  36. package/apps/studio/client/panels/acp-runtime.js +25 -0
  37. package/apps/studio/client/panels/chat-finish.js +66 -0
  38. package/apps/studio/client/shell/frame-cap.js +53 -0
  39. package/apps/studio/client/shell/viewport.jsx +9 -0
  40. package/apps/studio/client/styles/_index.css +2 -0
  41. package/apps/studio/client/tree/tree.jsx +48 -21
  42. package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
  43. package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
  44. package/apps/studio/client/v2/ai/ai-run.css +87 -3
  45. package/apps/studio/client/v2/ai/background-model.js +113 -0
  46. package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
  47. package/apps/studio/client/v2/ai/run-api.js +7 -3
  48. package/apps/studio/client/v2/ai/runs-store.js +2 -1
  49. package/apps/studio/client/v2/annotations/vote-store.js +11 -5
  50. package/apps/studio/client/v2/assets/asset-state-lane.js +176 -8
  51. package/apps/studio/client/v2/assets/assets-bus.js +10 -8
  52. package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
  53. package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
  54. package/apps/studio/client/v2/assets/missing-frame.jsx +8 -4
  55. package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
  56. package/apps/studio/client/v2/assets/spotlight.css +153 -0
  57. package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
  58. package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
  59. package/apps/studio/client/v2/assets/tile.jsx +3 -0
  60. package/apps/studio/client/v2/assets/use-assets.js +2 -1
  61. package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
  62. package/apps/studio/client/v2/canvases/covers.js +11 -5
  63. package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
  64. package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
  65. package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
  66. package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
  67. package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
  68. package/apps/studio/client/v2/canvases/use-pins.js +2 -1
  69. package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
  70. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
  71. package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
  72. package/apps/studio/client/v2/code/code.css +67 -0
  73. package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
  74. package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
  75. package/apps/studio/client/v2/create/name-dialog.css +10 -0
  76. package/apps/studio/client/v2/ds/advanced-host.jsx +5 -2
  77. package/apps/studio/client/v2/ds/make-host.jsx +5 -2
  78. package/apps/studio/client/v2/ds/off-system-host.jsx +5 -2
  79. package/apps/studio/client/v2/ds/truth-host.jsx +5 -2
  80. package/apps/studio/client/v2/empty/arriving.jsx +29 -12
  81. package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
  82. package/apps/studio/client/v2/empty/not-local.jsx +31 -1
  83. package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
  84. package/apps/studio/client/v2/export/last-finished.js +2 -1
  85. package/apps/studio/client/v2/export/native-save.js +44 -0
  86. package/apps/studio/client/v2/history/git-model.js +18 -4
  87. package/apps/studio/client/v2/history/git-parts.jsx +60 -42
  88. package/apps/studio/client/v2/history/history.css +6 -0
  89. package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
  90. package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
  91. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
  92. package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
  93. package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
  94. package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
  95. package/apps/studio/client/v2/search/search-recent.js +3 -1
  96. package/apps/studio/client/v2/search/search-remote.js +6 -4
  97. package/apps/studio/client/v2/settings/connections-model.js +1 -1
  98. package/apps/studio/client/v2/shell/menu-runner.js +1 -0
  99. package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
  100. package/apps/studio/client/v2/shell/recovery-store.js +2 -1
  101. package/apps/studio/client/v2/shell/served-routes.js +120 -0
  102. package/apps/studio/client/v2/shell/share-cluster-host.jsx +2 -1
  103. package/apps/studio/client/v2/shell/shell-activity.js +19 -0
  104. package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
  105. package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
  106. package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
  107. package/apps/studio/cloud/endpoints.ts +23 -1
  108. package/apps/studio/dist/client.bundle.js +798 -801
  109. package/apps/studio/dist/comment-mount.js +2 -2
  110. package/apps/studio/dist/styles.css +1 -1
  111. package/apps/studio/ds-assets.ts +138 -48
  112. package/apps/studio/editing/minimap-context.tsx +3 -3
  113. package/apps/studio/editing/page-activity.ts +251 -0
  114. package/apps/studio/editing/rotate-handle.tsx +9 -5
  115. package/apps/studio/editing/sticky-name.tsx +4 -4
  116. package/apps/studio/history/restore-artboard-action.ts +40 -0
  117. package/apps/studio/home/hub.ts +77 -175
  118. package/apps/studio/home/routes.ts +47 -8
  119. package/apps/studio/http.ts +117 -66
  120. package/apps/studio/index-flight.ts +40 -0
  121. package/apps/studio/managed-projects.ts +52 -24
  122. package/apps/studio/migrate/hub.ts +7 -1
  123. package/apps/studio/routes/asset-state.ts +12 -0
  124. package/apps/studio/routes/canvas-source.ts +44 -2
  125. package/apps/studio/routes/ds-assets.ts +8 -0
  126. package/apps/studio/routes/history.ts +28 -5
  127. package/apps/studio/routes/hub-signin.ts +115 -0
  128. package/apps/studio/routes/index.ts +4 -0
  129. package/apps/studio/routes/table.ts +7 -0
  130. package/apps/studio/routes/trash.ts +3 -0
  131. package/apps/studio/server.ts +11 -0
  132. package/apps/studio/sync/accepted-cold-start.ts +26 -3
  133. package/apps/studio/sync/accepted-link.ts +9 -4
  134. package/apps/studio/sync/asset-push.ts +8 -1
  135. package/apps/studio/sync/asset-state.ts +27 -2
  136. package/apps/studio/sync/code-module-consent.ts +74 -0
  137. package/apps/studio/sync/file-ledger.ts +35 -0
  138. package/apps/studio/sync/file-plane.ts +479 -84
  139. package/apps/studio/sync/hub-browser-signin.ts +377 -0
  140. package/apps/studio/sync/hub-text-undo.ts +30 -10
  141. package/apps/studio/sync/index.ts +73 -11
  142. package/apps/studio/sync/lfs-pointer.ts +137 -0
  143. package/apps/studio/sync/projection.ts +44 -2
  144. package/apps/studio/sync/pull-pacer.ts +160 -0
  145. package/apps/studio/sync/pull-priority.ts +119 -0
  146. package/apps/studio/sync/seed-progress.ts +47 -3
  147. package/apps/studio/sync/transaction-client.ts +71 -6
  148. package/apps/studio/sync/workspace-signin.ts +6 -256
  149. package/apps/studio/sync/writer-registry.ts +5 -1
  150. package/apps/studio/video-links-overlay.tsx +3 -2
  151. package/apps/studio/whats-new.json +63 -0
  152. package/cli/lib/design-help.gen.mjs +1 -1
  153. package/cli/lib/workspace-plan.mjs +14 -0
  154. package/package.json +8 -8
@@ -0,0 +1,164 @@
1
+ // client/v2/code/canvas-waiting.js — 2.0.4 task B + #189: the words for a canvas that can't load for a
2
+ // reason that is NOT a mistake in its code. The data half; canvas-waiting-card.jsx and
3
+ // canvas-error-card.jsx only draw it.
4
+ //
5
+ // waiting files it imports haven't reached this Mac yet (first sync) — "<Canvas> is still downloading."
6
+ // refused a file it imports is held back (code from a hub this Mac hasn't accepted, too big, …)
7
+ // buildFailure the build stopped on the app's side (engine unavailable, timed out, imports refused)
8
+ // building the build is still running on the server (2.0.4 task P) — not a failure
9
+ //
10
+ // The server answers with its own state and reason WORDS (`canvas-source/waiting.ts`,
11
+ // `canvas-source/errors.ts` `BuildFailure`); anything else is dropped here, so no hub text and no
12
+ // build text is ever drawn. File names are drawn as text nodes only.
13
+
14
+ const STATES = new Set(['downloading', 'waiting', 'refused']);
15
+ const REASONS = new Set([
16
+ 'code-consent',
17
+ 'too-large',
18
+ 'quota',
19
+ 'refused',
20
+ 'retrying',
21
+ 'not-shared',
22
+ ]);
23
+ const FAILURES = new Set(['engine', 'timed-out', 'memory', 'imports-refused']);
24
+
25
+ /** Names the card lists before "and N more". */
26
+ export const SHOWN_FILES = 5;
27
+
28
+ const count = (v) => (Number.isFinite(v) && v > 0 ? Math.floor(v) : 0);
29
+
30
+ /** The server's `waiting` → the card's shape, or null (nothing it waits for). */
31
+ export function normalizeWaiting(w) {
32
+ if (!w || typeof w !== 'object' || !Array.isArray(w.files)) return null;
33
+ const files = w.files
34
+ .filter((f) => f && typeof f.rel === 'string' && f.rel && STATES.has(f.state))
35
+ .map((f) => ({
36
+ rel: f.rel.slice(0, 512),
37
+ state: f.state,
38
+ ...(REASONS.has(f.reason) ? { reason: f.reason } : {}),
39
+ }));
40
+ if (!files.length) return null;
41
+ const need =
42
+ w.need && count(w.need.total) > 0
43
+ ? { here: Math.min(count(w.need.here), count(w.need.total)), total: count(w.need.total) }
44
+ : null;
45
+ const progress =
46
+ w.progress && count(w.progress.total) > 0
47
+ ? {
48
+ delivered: Math.min(count(w.progress.delivered), count(w.progress.total)),
49
+ total: count(w.progress.total),
50
+ }
51
+ : null;
52
+ return { files, more: count(w.more), need, progress };
53
+ }
54
+
55
+ /** The server's `buildFailure` → `{ class, count? }`, or null. */
56
+ export function normalizeBuildFailure(b) {
57
+ if (!b || typeof b !== 'object' || !FAILURES.has(b.class)) return null;
58
+ return b.class === 'imports-refused'
59
+ ? { class: b.class, count: count(b.count) }
60
+ : { class: b.class };
61
+ }
62
+
63
+ /** `ui/_uniform-template.ts` → `_uniform-template.ts`. */
64
+ export const baseName = (rel) =>
65
+ String(rel ?? '')
66
+ .split('/')
67
+ .pop() || String(rel ?? '');
68
+
69
+ /** "5,041" — counts read the same on every Mac. */
70
+ export const num = (n) => count(n).toLocaleString('en-US');
71
+
72
+ /** Refused outranks waiting: the first held file decides the card, or null when nothing is held. */
73
+ export function refusedFile(waiting) {
74
+ return waiting?.files.find((f) => f.state === 'refused') ?? null;
75
+ }
76
+
77
+ /** The card's title. */
78
+ export function waitingTitle(name, waiting) {
79
+ return refusedFile(waiting)
80
+ ? `${name} can't open on this Mac yet.`
81
+ : `${name} is still downloading.`;
82
+ }
83
+
84
+ /** The card's sentence under the title: what happened · what is safe · what comes next. */
85
+ export function waitingBody(waiting) {
86
+ const held = refusedFile(waiting);
87
+ if (!held)
88
+ return "Some of its files haven't reached this Mac yet. Nothing is lost. The canvas opens by itself when they arrive.";
89
+ const file = baseName(held.rel);
90
+ switch (held.reason) {
91
+ case 'code-consent':
92
+ return `This Mac hasn't accepted shared code from this project (${file}). Nothing is lost. To allow it, link this folder to the project again and accept shared code when asked.`;
93
+ case 'too-large':
94
+ return `${file} is too big to sync, so it can't reach this Mac. Nothing is lost.`;
95
+ case 'quota':
96
+ return `This project's upload allowance is used up for now, so ${file} hasn't reached this Mac. Nothing is lost; it arrives once the allowance resets.`;
97
+ default:
98
+ return `The project's server refused ${file}, so it can't reach this Mac. Nothing is lost.`;
99
+ }
100
+ }
101
+
102
+ /** The quiet note beside one listed file (none for a plain download). */
103
+ export function fileNote(f) {
104
+ if (f.state === 'refused') return 'held back';
105
+ if (f.reason === 'retrying') return 'retrying';
106
+ if (f.reason === 'not-shared') return 'not shared yet';
107
+ if (f.state === 'waiting') return 'waiting';
108
+ return '';
109
+ }
110
+
111
+ /** "3 of 5 files" for the canvas's bar. */
112
+ export function needLabel(need) {
113
+ return need
114
+ ? `${num(need.here)} of ${num(need.total)} ${need.total === 1 ? 'file' : 'files'}`
115
+ : '';
116
+ }
117
+
118
+ /** "Project sync: 5,029 of 5,041 files". */
119
+ export function projectLabel(progress) {
120
+ return progress
121
+ ? `Project sync: ${num(progress.delivered)} of ${num(progress.total)} ${progress.total === 1 ? 'file' : 'files'}`
122
+ : '';
123
+ }
124
+
125
+ /** How many names past the first five ("and 3 more"). */
126
+ export function moreCount(waiting) {
127
+ return Math.max(0, (waiting?.files.length ?? 0) - SHOWN_FILES) + (waiting?.more ?? 0);
128
+ }
129
+
130
+ // ── 2.0.4 task P: a build that is still running ──────────────────────────────────────────────────
131
+
132
+ /** The Design system canvas: `system/<ds>/design-system.tsx` (designRoot- or repo-relative). */
133
+ const DS_BOARD_RE = /(?:^|\/)system\/[^/]+\/design-system\.tsx$/;
134
+
135
+ /** The building card's title: the design system by its role, any other canvas by its name. */
136
+ export function buildingTitle(canvas, name) {
137
+ return DS_BOARD_RE.test(String(canvas ?? ''))
138
+ ? 'Building the design system…'
139
+ : `Building ${name}…`;
140
+ }
141
+
142
+ export const BUILDING_BODY =
143
+ "This can take a minute on a big project. Nothing is lost. The canvas opens by itself when it's ready.";
144
+
145
+ // ── #189: a build that stopped on the app's side ─────────────────────────────────────────────────
146
+
147
+ export const BUILD_FAILURE_BODY =
148
+ "It couldn't be built, and the cause is on the app's side, not in its code. Nothing is lost.";
149
+
150
+ /** The reason class under Show details, in words. */
151
+ export function buildFailureReason(b) {
152
+ switch (b?.class) {
153
+ case 'engine':
154
+ return 'The build engine is unavailable';
155
+ case 'timed-out':
156
+ return 'The build timed out';
157
+ case 'memory':
158
+ return 'The build ran out of memory';
159
+ case 'imports-refused':
160
+ return `${num(b.count)} ${b.count === 1 ? 'import' : 'imports'} refused`;
161
+ default:
162
+ return '';
163
+ }
164
+ }
@@ -360,6 +360,73 @@
360
360
  user-select: none;
361
361
  }
362
362
 
363
+ /* 2.0.4 — the waiting card (canvas-waiting-card.jsx): the same frame, a calm icon, the bar of 05 es-arriving */
364
+ .v2-err-ic--calm {
365
+ color: var(--fg-1);
366
+ }
367
+ .v2-err-prog {
368
+ display: flex;
369
+ flex-direction: column;
370
+ gap: var(--space-1);
371
+ padding-left: 48px;
372
+ }
373
+ .v2-err-bar {
374
+ display: block;
375
+ height: 4px;
376
+ border-radius: var(--radius-pill);
377
+ background: var(--bg-4);
378
+ overflow: hidden;
379
+ }
380
+ .v2-err-bar i {
381
+ display: block;
382
+ height: 100%;
383
+ border-radius: var(--radius-pill);
384
+ background: var(--accent);
385
+ }
386
+ .v2-err-prog-l {
387
+ font-size: var(--type-xs);
388
+ color: var(--fg-1);
389
+ font-variant-numeric: tabular-nums;
390
+ }
391
+ .v2-err-files {
392
+ display: flex;
393
+ flex-direction: column;
394
+ gap: var(--space-1);
395
+ padding-left: 48px;
396
+ }
397
+ .v2-err-files-h {
398
+ font-size: var(--type-xs);
399
+ color: var(--fg-2);
400
+ }
401
+ .v2-err-files-l {
402
+ margin: 0;
403
+ padding: 0;
404
+ list-style: none;
405
+ display: flex;
406
+ flex-direction: column;
407
+ gap: 2px;
408
+ }
409
+ .v2-err-file {
410
+ display: flex;
411
+ align-items: baseline;
412
+ gap: var(--space-2);
413
+ min-width: 0;
414
+ font-size: var(--type-xs);
415
+ color: var(--fg-0);
416
+ }
417
+ .v2-err-file-n {
418
+ min-width: 0;
419
+ overflow: hidden;
420
+ text-overflow: ellipsis;
421
+ white-space: nowrap;
422
+ font-family: var(--font-mono);
423
+ }
424
+ .v2-err-file-s,
425
+ .v2-err-file--more {
426
+ flex: none;
427
+ color: var(--fg-2);
428
+ }
429
+
363
430
  /* The viewport slot the card sits in (client/shell/viewport.jsx keeps `.sh-canvas-error` and its testid). */
364
431
  .sh-canvas-error--v2 {
365
432
  overflow: auto;
@@ -17,6 +17,7 @@
17
17
 
18
18
  import { useEffect, useRef, useState } from 'react';
19
19
  import { LAST_GOOD, restoreRequest } from '../../../history/surface-requests.ts';
20
+ import { normalizeBuildFailure, normalizeWaiting } from './canvas-waiting.js';
20
21
  import { splitLines } from './highlight.js';
21
22
 
22
23
  export const SOURCE_ROUTE = '/_api/canvas-source';
@@ -94,7 +95,7 @@ export async function fetchCanvasSource(canvas, { fetchImpl = (...a) => fetch(..
94
95
  }
95
96
  }
96
97
 
97
- /** @returns {Promise<{status:'ok', error:object|null} | {status:'view-only'|'refused'|'missing'|'error'}>} */
98
+ /** @returns {Promise<{status:'ok', error:object|null, waiting:object|null, buildFailure:object|null, building:boolean} |{status:'view-only'|'refused'|'missing'|'error'}>} */
98
99
  export async function fetchCanvasError(canvas, { fetchImpl = (...a) => fetch(...a) } = {}) {
99
100
  try {
100
101
  const res = await fetchImpl(`${ERRORS_ROUTE}?canvas=${encodeURIComponent(canvas)}`, {
@@ -102,7 +103,15 @@ export async function fetchCanvasError(canvas, { fetchImpl = (...a) => fetch(...
102
103
  });
103
104
  const body = await readJson(res);
104
105
  if (!res.ok || !body || !Array.isArray(body.errors)) return failure(res, body);
105
- return { status: 'ok', error: normalizeError(body.errors[0]) };
106
+ return {
107
+ status: 'ok',
108
+ error: normalizeError(body.errors[0]),
109
+ // 2.0.4 — files it is still waiting for; #189 — why its build stopped outside its code
110
+ waiting: normalizeWaiting(body.waiting),
111
+ buildFailure: normalizeBuildFailure(body.buildFailure),
112
+ // 2.0.4 task P — its build is still running on the server (not a failure)
113
+ building: body.building === true,
114
+ };
106
115
  } catch {
107
116
  return { status: 'error' };
108
117
  }
@@ -246,9 +255,12 @@ export async function goBackToLastGood(canvas, { fetchImpl = (...a) => fetch(...
246
255
  line: typeof body?.line === 'string' ? clip(body.line, 120) : 'Went back.',
247
256
  };
248
257
  }
258
+ // The server's own line first: a 409 is also "this canvas has a change on this Mac that isn't
259
+ // saved" / "still saving" (F14), not only "no earlier version".
249
260
  return {
250
261
  ok: false,
251
262
  line:
263
+ (typeof body?.line === 'string' && body.line ? clip(body.line, 120) : null) ??
252
264
  GO_BACK_WORDS[res.status] ??
253
265
  "Couldn't go back just now. The canvas is as it was. Try again.",
254
266
  };
@@ -280,15 +292,18 @@ export function useCanvasSource({ canvas, enabled = true, stamp, fetchImpl } = {
280
292
  }
281
293
 
282
294
  /** The canvas's current error (or null) while `enabled`. */
283
- export function useCanvasError({ canvas, enabled = true, stamp, fetchImpl } = {}) {
295
+ export function useCanvasError({ canvas, enabled = true, stamp, quiet = false, fetchImpl } = {}) {
284
296
  const [state, setState] = useState({ status: 'loading' });
285
297
  const fetchRef = useRef(fetchImpl);
286
298
  fetchRef.current = fetchImpl;
299
+ const quietRef = useRef(quiet);
300
+ quietRef.current = quiet;
287
301
  // biome-ignore lint/correctness/useExhaustiveDependencies: `stamp` is the "try again" signal
288
302
  useEffect(() => {
289
303
  if (!enabled || !canvas) return undefined;
290
304
  let cancelled = false;
291
- setState({ status: 'loading' });
305
+ // `quiet`: a re-ask keeps the answer on screen until the new one comes (the waiting card's watch)
306
+ setState((s) => (quietRef.current && s.status === 'ok' ? s : { status: 'loading' }));
292
307
  fetchCanvasError(canvas, { fetchImpl: fetchRef.current }).then((r) => {
293
308
  if (!cancelled) setState(r);
294
309
  });
@@ -8,13 +8,15 @@ import { useModalFocus } from '../shell/modal-focus.js';
8
8
 
9
9
  /**
10
10
  * @param {{ title: string, label: string, initial: string, confirm?: string, busy?: boolean, error?: string,
11
- * onSubmit: (name: string) => void, onCancel: () => void }} props
11
+ * busyLabel?: string, onSubmit: (name: string) => void, onCancel: () => void }} props
12
+ * #195 — the tree's folder asks reuse this dialog ("Rename folder", "Renaming…").
12
13
  */
13
14
  export default function NameDialog({
14
15
  title,
15
16
  label,
16
17
  initial,
17
18
  confirm = 'Create',
19
+ busyLabel = 'Creating…',
18
20
  busy = false,
19
21
  error = '',
20
22
  onSubmit,
@@ -86,7 +88,7 @@ export default function NameDialog({
86
88
  disabled={busy || !name}
87
89
  data-testid="name-dialog-create"
88
90
  >
89
- {busy ? 'Creating…' : confirm}
91
+ {busy ? busyLabel : confirm}
90
92
  </button>
91
93
  </div>
92
94
  </form>
@@ -10,6 +10,10 @@
10
10
  place-items: center;
11
11
  background: var(--scrim, rgb(0 0 0 / 0.32));
12
12
  }
13
+ /* a yes/no ask opened from inside another modal sheet (.sh-scrim is 9000; banners keep 9100) */
14
+ .nd-scrim--over {
15
+ z-index: 9050;
16
+ }
13
17
  .nd-dialog {
14
18
  width: min(380px, calc(100vw - 32px));
15
19
  display: flex;
@@ -23,6 +27,12 @@
23
27
  font-weight: var(--w-semibold);
24
28
  color: var(--fg-0);
25
29
  }
30
+ /* #195 — the tree's yes/no asks ("Move “2026” to the trash?") say one line under the title */
31
+ .nd-body {
32
+ margin: 0;
33
+ font-size: var(--type-sm);
34
+ color: var(--fg-1);
35
+ }
26
36
  .nd-err {
27
37
  margin: 0;
28
38
  font-size: var(--type-sm);
@@ -18,6 +18,8 @@
18
18
  // The system comes from the canvas the person has open, never from a message.
19
19
 
20
20
  import { useEffect, useRef } from 'react';
21
+ import { pacedInterval } from '../../../editing/page-activity.ts';
22
+ import { shellActivity } from '../shell/shell-activity.js';
21
23
  import { dispatchCanvasOp } from '../left-panel/left-panel-bus.js';
22
24
  import { menuRunner } from '../shell/menu-runner.js';
23
25
  import { nativeDoors } from '../shell/native-doors.js';
@@ -210,14 +212,15 @@ export function DsAdvancedHost({
210
212
  });
211
213
 
212
214
  refresh({ withBoard: true });
213
- const timer = setInterval(() => refresh(), pollMs);
215
+ // 2.0.4: at pace while the window is used, slower while it is only looked at, not at all while hidden
216
+ const stopPoll = pacedInterval(() => refresh(), pollMs, shellActivity());
214
217
  const onVisible = () => {
215
218
  if (document.visibilityState === 'visible') refresh({ withBoard: true });
216
219
  };
217
220
  document.addEventListener('visibilitychange', onVisible);
218
221
  return () => {
219
222
  dead = true;
220
- clearInterval(timer);
223
+ stopPoll();
221
224
  document.removeEventListener('visibilitychange', onVisible);
222
225
  setAdvancedActions(null);
223
226
  setAdvanced(null);
@@ -30,6 +30,8 @@ import {
30
30
  systemLabelFor,
31
31
  systemNameFor,
32
32
  } from './make-model.js';
33
+ import { pacedInterval } from '../../../editing/page-activity.ts';
34
+ import { shellActivity } from '../shell/shell-activity.js';
33
35
  import { DsMakeSheet } from './make-sheet.jsx';
34
36
  import { finishMaking, makeSystem, readMakeState, uploadLogo } from './make-write.js';
35
37
  import { finishedMaking } from './switch-bus.js';
@@ -189,10 +191,11 @@ export function DsMakeHost({ cfg, activePath, toast, frameFor, fetchImpl, pollMs
189
191
  }
190
192
  };
191
193
  look();
192
- const t = setInterval(look, pollMs ?? MAKE_POLL_MS);
194
+ // 2.0.4: at pace while the window is used, slower while it is only looked at, not at all while hidden
195
+ const stopPoll = pacedInterval(look, pollMs ?? MAKE_POLL_MS, shellActivity());
193
196
  return () => {
194
197
  off = true;
195
- clearInterval(t);
198
+ stopPoll();
196
199
  };
197
200
  }, [ds, pollMs]);
198
201
 
@@ -12,6 +12,8 @@ import { useCallback, useEffect, useRef, useState } from 'react';
12
12
  import { canvasDsSystem } from '../../canvas-url.js';
13
13
  import { EDGE_WORDS, findingKey, nextFinding } from './edge-model.js';
14
14
  import { addColourNow, fetchOffSystem, applyNearestNow } from './edge-write.js';
15
+ import { pacedInterval } from '../../../editing/page-activity.ts';
16
+ import { shellActivity } from '../shell/shell-activity.js';
15
17
  import { OffSystemQuestion } from './off-system.jsx';
16
18
  import { openCanvasRel } from './switch-host.jsx';
17
19
 
@@ -62,11 +64,12 @@ export function DsOffSystemHost({
62
64
  };
63
65
  refreshRef.current = refresh;
64
66
  const first = setTimeout(refresh, firstMs);
65
- const t = setInterval(refresh, pollMs);
67
+ // 2.0.4: at pace while the window is used, slower while it is only looked at, not at all while hidden
68
+ const stopPoll = pacedInterval(refresh, pollMs, shellActivity());
66
69
  return () => {
67
70
  dead = true;
68
71
  clearTimeout(first);
69
- clearInterval(t);
72
+ stopPoll();
70
73
  refreshRef.current = null;
71
74
  };
72
75
  }, [canvas, pollMs, firstMs]);
@@ -16,6 +16,8 @@
16
16
  // canvas is on screen (the server only offers a review after its 5 s quiet window, so a faster read gains nothing).
17
17
 
18
18
  import { useEffect, useRef } from 'react';
19
+ import { pacedInterval } from '../../../editing/page-activity.ts';
20
+ import { shellActivity } from '../shell/shell-activity.js';
19
21
  import { contrastLine } from './contrast.js';
20
22
  import { fetchBoard } from './token-write.js';
21
23
  import { getTruth, setTruth, setTruthActions } from './truth-store.js';
@@ -212,7 +214,8 @@ export function DsTruthHost({
212
214
  });
213
215
 
214
216
  refresh();
215
- const timer = setInterval(refresh, pollMs);
217
+ // 2.0.4: at pace while the window is used, slower while it is only looked at, not at all while hidden
218
+ const stopPoll = pacedInterval(refresh, pollMs, shellActivity());
216
219
  const onVisible = () => {
217
220
  if (document.visibilityState === 'visible') refresh();
218
221
  };
@@ -227,7 +230,7 @@ export function DsTruthHost({
227
230
  window.addEventListener('message', onLoaded);
228
231
  return () => {
229
232
  dead = true;
230
- clearInterval(timer);
233
+ stopPoll();
231
234
  document.removeEventListener('visibilitychange', onVisible);
232
235
  window.removeEventListener('message', onLoaded);
233
236
  setTruthActions(null);
@@ -118,8 +118,22 @@ async function readAvailability(fetchImpl) {
118
118
  * Mount once in the Canvases panel. `groups` is the panel's index (its change re-asks, throttled).
119
119
  * @param {{ groups: object[], designRel: string, fetchImpl?: typeof fetch }} o
120
120
  */
121
+ // #204 R — the cadence is the PAGE's, not a mount's. It lived in the hook's useRef, so a panel that mounted
122
+ // again started with no "last asked" and asked at once: a remounting panel asked once per mount, however
123
+ // fast (the report: ~100 in a few seconds against a cell). The last answer, the request in flight and when
124
+ // it was asked are kept here; a mount draws the last answer at once and asks only when the gap allows.
125
+ const poll = { model: null, carried: new Map(), inFlight: false, last: 0 };
126
+
127
+ /** Tests only: forget the page's last answer and when it was asked. */
128
+ export function resetArrivingPoll() {
129
+ poll.model = null;
130
+ poll.carried = new Map();
131
+ poll.inFlight = false;
132
+ poll.last = 0;
133
+ }
134
+
121
135
  export function useArrivingRows({ groups, designRel, fetchImpl }) {
122
- const state = useRef({ model: null, carried: new Map(), inFlight: false, last: 0, timer: null });
136
+ const state = useRef({ timer: null });
123
137
  const indexed = useRef(new Set());
124
138
  indexed.current = indexedPaths(groups, designRel);
125
139
 
@@ -127,12 +141,12 @@ export function useArrivingRows({ groups, designRel, fetchImpl }) {
127
141
  const s = state.current;
128
142
  let alive = true;
129
143
  const publish = () => {
130
- const out = arrivingSlots(s.model, {
144
+ const out = arrivingSlots(poll.model, {
131
145
  indexed: indexed.current,
132
- carried: s.carried,
146
+ carried: poll.carried,
133
147
  localOnly,
134
148
  });
135
- s.carried = out.carried;
149
+ poll.carried = out.carried;
136
150
  setGhostRows('sync', out.ghosts);
137
151
  setFootSlot('arriving', out.foot);
138
152
  };
@@ -141,23 +155,26 @@ export function useArrivingRows({ groups, designRel, fetchImpl }) {
141
155
  s.timer = setTimeout(ask, Math.max(ms, MIN_GAP_MS));
142
156
  };
143
157
  async function ask() {
144
- if (!alive || s.inFlight) return;
145
- const since = Date.now() - s.last;
158
+ if (!alive) return;
159
+ // another mount's read is out: its answer lands in `poll`; look again after the gap
160
+ if (poll.inFlight) return schedule(MIN_GAP_MS);
161
+ const since = Date.now() - poll.last;
146
162
  if (since < MIN_GAP_MS) return schedule(MIN_GAP_MS - since);
147
- s.inFlight = true;
148
- s.last = Date.now();
163
+ poll.inFlight = true;
164
+ poll.last = Date.now();
149
165
  const model = await readAvailability(fetchImpl);
150
- s.inFlight = false;
151
- if (!alive) return;
166
+ poll.inFlight = false;
152
167
  // A failed read keeps the last answer (never "nothing is coming" because one request failed).
153
- if (model) s.model = model;
168
+ if (model) poll.model = model;
169
+ if (!alive) return;
154
170
  publish();
155
- schedule(NEXT_MS[s.model?.phase] ?? NEXT_MS.complete);
171
+ schedule(NEXT_MS[poll.model?.phase] ?? NEXT_MS.complete);
156
172
  }
157
173
  s.ask = ask;
158
174
  s.publish = publish;
159
175
  const onLocalOnly = () => publish();
160
176
  localOnlyListeners.add(onLocalOnly);
177
+ if (poll.model) publish();
161
178
  void ask();
162
179
  return () => {
163
180
  alive = false;
@@ -41,7 +41,7 @@ const modeNow = () => shellMode.get().mode;
41
41
 
42
42
  export function EmptyHost() {
43
43
  const {
44
- shellCore: { activePath, cfg, iframesRef, syncStatus, viewerMode },
44
+ shellCore: { activePath, cfg, iframesRef, loadingPath, syncStatus, viewerMode },
45
45
  } = useShellStore();
46
46
  const canvasOpen = !!activePath && activePath !== SYSTEM_TAB;
47
47
  const mode = useSyncExternalStore(shellMode.subscribe, modeNow, modeNow);
@@ -59,8 +59,14 @@ export function EmptyHost() {
59
59
  canvasOrigin: cfg?.canvasOrigin,
60
60
  });
61
61
 
62
+ // #204 — the shell's own "this canvas is still loading" (cleared on `canvas-rendered`): no invitation
63
+ // over a canvas that has not finished drawing, and a load starts with no count from before.
64
+ const canvasLoading = !!loadingPath && loadingPath === activePath;
65
+ useEffect(() => {
66
+ if (loadingPath) lane.loadStarted(loadingPath);
67
+ }, [lane, loadingPath]);
62
68
  const model = canvasOpen
63
- ? emptyCanvasModel({ count, mode, canEdit, online, claude, canAsk })
69
+ ? emptyCanvasModel({ count, mode, canEdit, online, claude, canAsk, loading: canvasLoading })
64
70
  : null;
65
71
  // rc3-h (#182): a run of yours on this empty canvas — the ghost where the first artboard lands, not the invitation
66
72
  const { view: runsView } = useAiRuns();
@@ -65,6 +65,36 @@ const askAvailability = (path, fetchImpl) =>
65
65
  .then((r) => (r.ok ? r.json() : null))
66
66
  .then((body) => body?.canvas?.state ?? 'unknown');
67
67
 
68
+ // #204 R — one ask per canvas per OPEN, not per render: a tab that flips between canvases (or a viewport
69
+ // that mounts again) asked on every flip. An open shares the ask in flight for its path and reuses an
70
+ // answer younger than OPEN_REUSE_MS. Keyed by the fetch it went through (tests inject their own).
71
+ export const OPEN_REUSE_MS = 1000;
72
+ const DEFAULT_FETCH = {};
73
+ let asks = new WeakMap();
74
+
75
+ function askOnOpen(path, fetchImpl) {
76
+ const key = fetchImpl || DEFAULT_FETCH;
77
+ let byPath = asks.get(key);
78
+ if (!byPath) {
79
+ byPath = new Map();
80
+ asks.set(key, byPath);
81
+ }
82
+ const hit = byPath.get(path);
83
+ if (hit && (hit.pending || Date.now() - hit.at < OPEN_REUSE_MS)) return hit.answer;
84
+ const entry = { at: Date.now(), pending: true, answer: null };
85
+ entry.answer = askAvailability(path, fetchImpl).finally(() => {
86
+ entry.pending = false;
87
+ entry.at = Date.now();
88
+ });
89
+ byPath.set(path, entry);
90
+ return entry.answer;
91
+ }
92
+
93
+ /** Tests only: forget every recent ask. */
94
+ export function resetAvailabilityAsks() {
95
+ asks = new WeakMap();
96
+ }
97
+
68
98
  /**
69
99
  * One canvas's availability, asked once per path (and again when `stamp` changes — the tab's reload key).
70
100
  * A canvas that is `arriving` is asked again every `recheckMs` until it is here (no flicker: the answer
@@ -82,7 +112,7 @@ export function useCanvasAvailability(
82
112
  if (!path) return;
83
113
  let alive = true;
84
114
  setState(null);
85
- askAvailability(path, fetchImpl)
115
+ askOnOpen(path, fetchImpl)
86
116
  .then((s) => alive && setState(s))
87
117
  .catch(() => alive && setState('unknown'));
88
118
  return () => {
@@ -41,12 +41,15 @@ export function hubAway(syncStatus) {
41
41
  * Which empty-canvas situation applies — or null (nothing to show).
42
42
  *
43
43
  * @param {{ count: number|null|undefined, mode: string, canEdit: boolean, online: boolean,
44
- * claude: 'present'|'absent'|'unknown', canAsk: boolean }} f
44
+ * claude: 'present'|'absent'|'unknown', canAsk: boolean, loading?: boolean }} f
45
45
  * `count` is what the CANVAS reported (null until it has: no flash while it loads). `canEdit` false =
46
46
  * Can view / Can comment: no create affordance at all. `canAsk`: the AI chat exists here (desktop app).
47
47
  */
48
48
  export function emptyCanvasModel(f) {
49
49
  if (f.count !== 0) return null;
50
+ // #204 — only for a canvas KNOWN to be empty once its load has finished: a 0 said while the canvas is
51
+ // still loading (before its artboards mount) put the invitation over artboards drawn a moment later.
52
+ if (f.loading) return null;
50
53
  if (f.mode !== 'edit') return null;
51
54
  if (!f.canEdit) return null;
52
55
  const offline = f.online === false;
@@ -170,6 +173,12 @@ export function createEmptyLane(deps) {
170
173
  switched() {
171
174
  set({ count: countOf(), hint: null });
172
175
  },
176
+ /** #204 — a canvas started (re)loading: what its last document said about it is not about the next. */
177
+ loadStarted(path) {
178
+ if (!path || !counts.has(path)) return;
179
+ counts.delete(path);
180
+ set({ ...state, count: countOf() });
181
+ },
173
182
  /** A canvas left the project / was closed. */
174
183
  forget(path) {
175
184
  counts.delete(path);
@@ -4,6 +4,7 @@
4
4
 
5
5
  import { useEffect, useState } from 'react';
6
6
  import { indexMeta } from '../canvases/tree-model.js';
7
+ import { fetchIfServed } from '../shell/served-routes.js';
7
8
 
8
9
  /** @returns ms, or null (no index, no such canvas, or the sheet is closed) */
9
10
  export function useLastFinishedAt({ open, activePath, designRel, fetchImpl }) {
@@ -17,7 +18,7 @@ export function useLastFinishedAt({ open, activePath, designRel, fetchImpl }) {
17
18
  const doFetch = fetchImpl || ((...a) => fetch(...a));
18
19
  (async () => {
19
20
  try {
20
- const r = await doFetch('/_api/index', { cache: 'no-store' });
21
+ const r = await fetchIfServed('/_api/index', { cache: 'no-store' }, doFetch);
21
22
  if (!r.ok || cancelled) return;
22
23
  const snapshot = await r.json();
23
24
  const row = indexMeta(snapshot, designRel).get(activePath);