@1agh/maude 2.0.6 → 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 (177) hide show
  1. package/apps/studio/access/closure.ts +156 -16
  2. package/apps/studio/access/filters.ts +27 -0
  3. package/apps/studio/actions/agents.ts +54 -0
  4. package/apps/studio/actions/ctx.ts +3 -0
  5. package/apps/studio/actions/defs/sync.ts +13 -0
  6. package/apps/studio/actions/defs/view.ts +59 -3
  7. package/apps/studio/actions/keymap.gen.ts +35 -0
  8. package/apps/studio/actions/menu.ts +2 -0
  9. package/apps/studio/actions/types.ts +3 -1
  10. package/apps/studio/actions.manifest.json +136 -1
  11. package/apps/studio/actions.parity.json +25 -1
  12. package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
  13. package/apps/studio/annotations/ui/ride.ts +2 -1
  14. package/apps/studio/annotations-context-toolbar.tsx +5 -4
  15. package/apps/studio/annotations-layer.tsx +4 -3
  16. package/apps/studio/api.ts +383 -128
  17. package/apps/studio/artboard-activity-overlay.tsx +4 -4
  18. package/apps/studio/artboard-ai-copies.tsx +4 -4
  19. package/apps/studio/artboard-freeze.ts +108 -0
  20. package/apps/studio/artboard-live-gate.tsx +414 -45
  21. package/apps/studio/artboard-live.ts +526 -31
  22. package/apps/studio/artboard-placeholder.ts +197 -0
  23. package/apps/studio/artboard-still-raster.ts +485 -0
  24. package/apps/studio/artboard-still-warmup.ts +221 -0
  25. package/apps/studio/artboard-still.ts +1188 -0
  26. package/apps/studio/artboard-webgl.ts +2 -1
  27. package/apps/studio/asset-placeholder.tsx +237 -132
  28. package/apps/studio/asset-upload-bars.tsx +4 -4
  29. package/apps/studio/bin/_perf-probe-open.mjs +364 -0
  30. package/apps/studio/bin/_perf-shared.mjs +12 -7
  31. package/apps/studio/bin/_pw-launch.mjs +26 -1
  32. package/apps/studio/bin/perf.sh +19 -0
  33. package/apps/studio/bridge/dgn-protocol.ts +35 -0
  34. package/apps/studio/canvas-build-sandbox.ts +69 -13
  35. package/apps/studio/canvas-camera.ts +90 -0
  36. package/apps/studio/canvas-comment-mount.tsx +9 -9
  37. package/apps/studio/canvas-lib.tsx +160 -34
  38. package/apps/studio/canvas-pages-view.tsx +465 -0
  39. package/apps/studio/canvas-pages.ts +305 -0
  40. package/apps/studio/canvas-rows.ts +62 -0
  41. package/apps/studio/canvas-shell.tsx +62 -16
  42. package/apps/studio/canvas-theme-icons.tsx +41 -0
  43. package/apps/studio/canvas-theme-pill.tsx +15 -6
  44. package/apps/studio/canvas-theme.ts +12 -11
  45. package/apps/studio/client/app.jsx +7 -0
  46. package/apps/studio/client/canvas-url.js +23 -1
  47. package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
  48. package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
  49. package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
  50. package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
  51. package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
  52. package/apps/studio/client/hooks/use-project-data.jsx +11 -2
  53. package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
  54. package/apps/studio/client/index-loader.ts +41 -21
  55. package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
  56. package/apps/studio/client/shell/viewport.jsx +32 -16
  57. package/apps/studio/client/tree/tree.jsx +17 -0
  58. package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
  59. package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
  60. package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
  61. package/apps/studio/client/v2/code/canvas-imports-card.jsx +7 -3
  62. package/apps/studio/client/v2/code/canvas-imports-words.js +16 -0
  63. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
  64. package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
  65. package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
  66. package/apps/studio/client/v2/code/code-consent.js +67 -0
  67. package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
  68. package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
  69. package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
  70. package/apps/studio/client/v2/layers/layers-request.js +49 -0
  71. package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
  72. package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
  73. package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
  74. package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
  75. package/apps/studio/client/v2/shell/canvas-crash-guard.js +40 -5
  76. package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
  77. package/apps/studio/client/v2/shell/floating-panels.css +37 -1
  78. package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
  79. package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
  80. package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
  81. package/apps/studio/client/v2/shell/pages-pick.js +49 -0
  82. package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
  83. package/apps/studio/client/v2/shell/share-cluster-host.jsx +3 -1
  84. package/apps/studio/client/v2/shell/shell-parity.json +8 -0
  85. package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
  86. package/apps/studio/comments-overlay.tsx +12 -11
  87. package/apps/studio/config-reload-wire.ts +4 -1
  88. package/apps/studio/config.schema.json +6 -0
  89. package/apps/studio/context.ts +37 -1
  90. package/apps/studio/dist/client.bundle.js +720 -720
  91. package/apps/studio/dist/comment-mount.js +2 -2
  92. package/apps/studio/dist/styles.css +1 -1
  93. package/apps/studio/ds/board/board.css +6 -0
  94. package/apps/studio/ds/board/ds-bar.tsx +21 -3
  95. package/apps/studio/ds/board/specimen.tsx +6 -3
  96. package/apps/studio/ds/board/template.ts +39 -19
  97. package/apps/studio/ds/cli.ts +7 -1
  98. package/apps/studio/ds/component-list.ts +2 -1
  99. package/apps/studio/ds/default.ts +6 -1
  100. package/apps/studio/ds/ds-resolver.ts +58 -8
  101. package/apps/studio/ds/engine.ts +3 -1
  102. package/apps/studio/ds/folder-systems.ts +199 -0
  103. package/apps/studio/ds/pairing-css.ts +2 -1
  104. package/apps/studio/ds/rename.ts +10 -3
  105. package/apps/studio/ds/shell-fallbacks.ts +2 -1
  106. package/apps/studio/ds/upgrade-stage.ts +6 -2
  107. package/apps/studio/editing/ai-point-ring.tsx +4 -4
  108. package/apps/studio/editing/ai-scope-outline.tsx +4 -4
  109. package/apps/studio/editing/align-bar.tsx +4 -4
  110. package/apps/studio/editing/anchor-report.ts +3 -2
  111. package/apps/studio/editing/artboard-handles.tsx +4 -4
  112. package/apps/studio/editing/corner-dots.tsx +4 -4
  113. package/apps/studio/editing/crop-mode.tsx +4 -4
  114. package/apps/studio/editing/drop-chip.tsx +4 -4
  115. package/apps/studio/editing/empty-report.ts +3 -2
  116. package/apps/studio/editing/focus-model.tsx +4 -4
  117. package/apps/studio/editing/gap-bands.tsx +3 -3
  118. package/apps/studio/editing/hold-rings.tsx +4 -4
  119. package/apps/studio/editing/lock-badge.tsx +3 -3
  120. package/apps/studio/editing/long-page.ts +23 -1
  121. package/apps/studio/editing/nudge.tsx +2 -2
  122. package/apps/studio/editing/page-activity.ts +4 -3
  123. package/apps/studio/editing/paste-bar.tsx +4 -4
  124. package/apps/studio/editing/pen/overlay.tsx +4 -3
  125. package/apps/studio/editing/place-freely.tsx +3 -3
  126. package/apps/studio/editing/reorder-slot.tsx +3 -3
  127. package/apps/studio/editing/selection.tsx +4 -4
  128. package/apps/studio/editing/size-ghost.tsx +4 -4
  129. package/apps/studio/editing/tab-order.tsx +4 -4
  130. package/apps/studio/editing/text-in-place.tsx +4 -4
  131. package/apps/studio/editing/undo-preview.tsx +3 -3
  132. package/apps/studio/equal-spacing-handles.tsx +3 -3
  133. package/apps/studio/frame-clock.ts +89 -0
  134. package/apps/studio/http.ts +66 -32
  135. package/apps/studio/index/ds-usage.ts +4 -1
  136. package/apps/studio/index-cache.ts +272 -0
  137. package/apps/studio/inspect-overlay.tsx +4 -3
  138. package/apps/studio/inspect.ts +7 -2
  139. package/apps/studio/link-chip-overlay.tsx +4 -3
  140. package/apps/studio/measure-overlay.tsx +4 -3
  141. package/apps/studio/present/pointer-dot.tsx +3 -2
  142. package/apps/studio/present/present-media.ts +6 -2
  143. package/apps/studio/present/present-stage.tsx +3 -2
  144. package/apps/studio/preview/preview-camera.tsx +3 -2
  145. package/apps/studio/routes/sync.ts +176 -0
  146. package/apps/studio/safe-zones-overlay.tsx +3 -2
  147. package/apps/studio/skip-dirs.ts +103 -47
  148. package/apps/studio/studio-page-host.ts +70 -0
  149. package/apps/studio/sync/code-module-consent.ts +86 -0
  150. package/apps/studio/sync/file-ledger.ts +24 -0
  151. package/apps/studio/sync/file-plane.ts +458 -53
  152. package/apps/studio/sync/held-deletes.ts +230 -0
  153. package/apps/studio/sync/hubs-config.ts +59 -2
  154. package/apps/studio/sync/index.ts +99 -15
  155. package/apps/studio/sync/seed-progress.ts +92 -2
  156. package/apps/studio/sync/settings.ts +36 -1
  157. package/apps/studio/sync/status.ts +15 -1
  158. package/apps/studio/sync/writer-registry.ts +5 -0
  159. package/apps/studio/text-caret.ts +5 -3
  160. package/apps/studio/toolbars/toolbar-rect.ts +3 -2
  161. package/apps/studio/use-annotation-resize.tsx +4 -3
  162. package/apps/studio/use-artboard-drag.tsx +3 -2
  163. package/apps/studio/use-element-resize.tsx +7 -6
  164. package/apps/studio/use-grid-track-handles.tsx +5 -4
  165. package/apps/studio/use-selection-set.tsx +64 -4
  166. package/apps/studio/use-spacing-handles.tsx +7 -6
  167. package/apps/studio/video-comp.tsx +55 -42
  168. package/apps/studio/video-play-overlay.tsx +4 -3
  169. package/apps/studio/whats-new.json +27 -0
  170. package/cli/commands/design.mjs +5 -2
  171. package/cli/commands/hub.mjs +10 -1
  172. package/cli/lib/bash-guard.mjs +14 -0
  173. package/cli/lib/design-help.gen.mjs +1 -1
  174. package/cli/lib/design-link.mjs +42 -17
  175. package/cli/lib/hub-purge.mjs +183 -0
  176. package/package.json +8 -8
  177. package/plugins/design/templates/_shell.html +164 -1
@@ -1,7 +1,13 @@
1
1
  // shell/viewport.jsx — moved verbatim out of client/app.jsx (Maude v2 plan V2-0.2, move-only split).
2
2
 
3
3
  import { useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';
4
- import { canvasFrameCfg, canvasImportsOf, canvasRefusedOf, canvasUrl } from '../canvas-url.js';
4
+ import {
5
+ canvasFrameCfg,
6
+ canvasImportsOf,
7
+ canvasMissingOf,
8
+ canvasRefusedOf,
9
+ canvasUrl,
10
+ } from '../canvas-url.js';
5
11
  import { CompareHost } from '../v2/history/compare-view.jsx';
6
12
  import { useDsPreviewTarget, withDsPreview } from '../v2/ds/preview-mode.js';
7
13
  import { useViewing } from '../v2/history/history-host.jsx';
@@ -30,6 +36,7 @@ import { CanvasDropCatcher, catcherReadOnly } from '../v2/assets/canvas-drop-cat
30
36
  import { framesToMount, noteShown } from './frame-cap.js';
31
37
  import { crashGuard, subscribeCrashGuard } from '../v2/shell/canvas-crash-guard.js';
32
38
  import { TooHeavyCanvas } from '../v2/shell/too-heavy-card.jsx';
39
+ import { OpeningSkeleton } from '../v2/shell/opening-skeleton.jsx';
33
40
 
34
41
  export function Viewport({
35
42
  tabs,
@@ -357,7 +364,9 @@ export function Viewport({
357
364
  Reload canvas
358
365
  </button>
359
366
  </div>
360
- ) : canvasImportsOf(cfg, canvasError.path) || canvasRefusedOf(cfg, canvasError.path) ? (
367
+ ) : canvasImportsOf(cfg, canvasError.path) ||
368
+ canvasRefusedOf(cfg, canvasError.path) ||
369
+ canvasMissingOf(cfg, canvasError.path) ? (
361
370
  // gate-b-c4j — it imports another canvas, so its frame refused the module: say that, not "can't
362
371
  // be drawn" (v2/code/canvas-imports-card.jsx). 2.0.5 (#205): or its built module inlined a file
363
372
  // another canvas owns — the card names that file too.
@@ -365,6 +374,7 @@ export function Viewport({
365
374
  key={`${canvasError.path}#imports`}
366
375
  imports={canvasImportsOf(cfg, canvasError.path)}
367
376
  refused={canvasRefusedOf(cfg, canvasError.path)}
377
+ missing={canvasMissingOf(cfg, canvasError.path)}
368
378
  componentDir={cfg?.newComponentDir}
369
379
  />
370
380
  ) : (
@@ -380,6 +390,7 @@ export function Viewport({
380
390
  onAskAi={(text) => dispatchCanvasOp('ask-ai-fix', canvasError.path, text)}
381
391
  onReload={() => onRetryCanvasLoad?.(canvasError.path)}
382
392
  onNotify={(msg, ok) => shellToast(msg, ok)}
393
+ loadReason={canvasError.reason}
383
394
  />
384
395
  )}
385
396
  </div>
@@ -419,27 +430,32 @@ export function CanvasLoading({ path, cloud }) {
419
430
  return () => clearTimeout(t);
420
431
  }, []);
421
432
  const name = sanitizeDisplayText(basename(path || '').replace(/\.(tsx|jsx|html?)$/i, ''));
433
+ const hint = cloud
434
+ ? 'Still working — the first open of a canvas fetches its images and fonts from cloud storage. It is quicker next time.'
435
+ : 'Still working — large canvases take a moment to build.';
436
+ // 2.0.7 (B1) — every artboard at once, as a skeleton at its final place and size, while the canvas builds
437
+ // and renders (v2/shell/opening-skeleton.js); the card below only while that layout is not known.
438
+ const card = (
439
+ <div className="sh-skel-card">
440
+ <div className="sh-canvas-loading-head">
441
+ <span className="sh-canvas-loading-spinner" aria-hidden="true" />
442
+ <span className="sh-canvas-loading-title">Opening {name}…</span>
443
+ </div>
444
+ <span className="skel sh-skel-thumb" aria-hidden="true" />
445
+ <span className="skel sh-skel-line" style={{ width: '72%' }} aria-hidden="true" />
446
+ <span className="skel sh-skel-line" style={{ width: '46%' }} aria-hidden="true" />
447
+ <div className={'sh-canvas-loading-hint' + (slow ? ' is-shown' : '')}>{hint}</div>
448
+ </div>
449
+ );
422
450
  return (
423
451
  <div
424
452
  className="sh-canvas-loading"
425
453
  role="status"
426
454
  aria-live="polite"
455
+ aria-label={`Opening ${name}…`}
427
456
  data-testid="canvas-loading"
428
457
  >
429
- <div className="sh-skel-card">
430
- <div className="sh-canvas-loading-head">
431
- <span className="sh-canvas-loading-spinner" aria-hidden="true" />
432
- <span className="sh-canvas-loading-title">Opening {name}…</span>
433
- </div>
434
- <span className="skel sh-skel-thumb" aria-hidden="true" />
435
- <span className="skel sh-skel-line" style={{ width: '72%' }} aria-hidden="true" />
436
- <span className="skel sh-skel-line" style={{ width: '46%' }} aria-hidden="true" />
437
- <div className={'sh-canvas-loading-hint' + (slow ? ' is-shown' : '')}>
438
- {cloud
439
- ? 'Still working — the first open of a canvas fetches its images and fonts from cloud storage. It is quicker next time.'
440
- : 'Still working — large canvases take a moment to build.'}
441
- </div>
442
- </div>
458
+ <OpeningSkeleton path={path} fallback={card} note={slow ? hint : null} />
443
459
  </div>
444
460
  );
445
461
  }
@@ -26,6 +26,8 @@ import { CanvasesAdvanced, useAdvancedOpen } from '../v2/left-panel/canvases-adv
26
26
  import { DsPinnedRows, NewCanvasRow, TrashRow } from '../v2/left-panel/canvases-pinned.jsx';
27
27
  import { OPEN_TRASH_EVENT, takeTrashRequest } from '../v2/left-panel/left-panel-bus.js';
28
28
  import { dsPinnedModel, trashRowCount } from '../v2/left-panel/left-panel-model.js';
29
+ import { dsBoardLists } from '../v2/left-panel/ds-boards.js';
30
+ import { useIndexSnapshotNow } from '../v2/canvases/use-canvas-index.js';
29
31
  import { openNewCanvasDialog } from '../v2/create/new-canvas.js';
30
32
  import { systemMenuItems } from '../v2/ds/system-menu.jsx';
31
33
  import { trashedTokenItems } from '../v2/ds/door-write.js';
@@ -914,6 +916,18 @@ export function Sidebar({
914
916
  [groups, dsCfg, dsDesignRel, dsState, onDsAction, readOnly]
915
917
  );
916
918
  const pinnedDs = dsModel.rows;
919
+ // 2.0.7 (B3) — each system row's Design system canvas artboards, from the index the Canvases panel read
920
+ const indexSnap = useIndexSnapshotNow();
921
+ const dsBoards = useMemo(
922
+ () =>
923
+ dsBoardLists(pinnedDs, {
924
+ snapshot: indexSnap,
925
+ designRel: dsDesignRel,
926
+ systems: dsCfg?.designSystems ?? [],
927
+ groups,
928
+ }),
929
+ [pinnedDs, indexSnap, dsDesignRel, dsCfg, groups]
930
+ );
917
931
  // p8-v1-drop — the systems below Conformant are offered "Bring it up" in ⌘K too (client/v2/ds/upgrade-offers.js)
918
932
  useEffect(() => {
919
933
  if (!onDsAction || readOnly) return undefined;
@@ -1405,6 +1419,9 @@ export function Sidebar({
1405
1419
  renaming={renamingDs}
1406
1420
  onRename={(row, label) => onDsAction?.('ds.rename', { ds: row.dsName, label })}
1407
1421
  onRenameDone={() => setRenamingDs(null)}
1422
+ boards={dsBoards}
1423
+ activePath={activePath}
1424
+ activeArtboard={activeArtboard}
1408
1425
  />
1409
1426
  )}
1410
1427
  {/* S1.1 — the canvases, virtualised: Pinned, the project row with Sort, folders with counts.
@@ -280,6 +280,30 @@ export function CanvasesPanel({
280
280
  }
281
281
  }, [activePath, rows, layout]);
282
282
 
283
+ // 2.0.7 polish — the artboard in view moved (Pages' ‹ › and keys turn it, a jump picks it): its row in the open
284
+ // list scrolls into view, once per artboard (a list opened later scrolls to it then)
285
+ const lastBoard = useRef(null);
286
+ useEffect(() => {
287
+ const key = activePath && currentBoard ? `${activePath}#${currentBoard}` : null;
288
+ if (!key) {
289
+ lastBoard.current = null;
290
+ return;
291
+ }
292
+ if (lastBoard.current === key) return;
293
+ const isCur = (r) => r.type === 'board' && r.current;
294
+ let i = rows.findIndex((r) => isCur(r) && !r.inPinned && !r.inRecent);
295
+ if (i < 0) i = rows.findIndex(isCur);
296
+ if (i < 0) return;
297
+ lastBoard.current = key;
298
+ const el = treeRef.current;
299
+ if (!el) return;
300
+ const next = scrollToReveal(rows, layout, i, el.scrollTop, el.clientHeight);
301
+ if (next !== el.scrollTop) {
302
+ el.scrollTop = next;
303
+ setScrollTop(next);
304
+ }
305
+ }, [activePath, currentBoard, rows, layout]);
306
+
283
307
  const setOpen = useCallback((path, v) => expansion?.setOpen(path, v), [expansion]);
284
308
  const toggleJump = useCallback((row) => {
285
309
  setJumpOpen((m) => new Map(m).set(row.path, !row.jumpOpen));
@@ -7,12 +7,34 @@
7
7
  // the panel foot kept "21 artboards" after one was trashed). If the server has
8
8
  // no index (an older server, a cloud tab that does not serve it) the panel is simply without badges.
9
9
 
10
- import { useEffect, useRef, useState } from 'react';
10
+ import { useEffect, useRef, useState, useSyncExternalStore } from 'react';
11
11
  import { fetchIfServed } from '../shell/served-routes.js';
12
12
 
13
13
  /** The shell's relay of the socket's `index-changed { seq, rels }` (client/app.jsx). */
14
14
  export const INDEX_CHANGED_EVENT = 'maude:index-changed';
15
15
 
16
+ // 2.0.7 — the last snapshot the panel read, for the surfaces that need the same rows without asking the
17
+ // server again: the pinned Design system rows (their artboards) and the opening skeletons (artboard sizes).
18
+ let lastSnapshot = null;
19
+ const snapshotSubs = new Set();
20
+ export const indexSnapshotNow = {
21
+ get: () => lastSnapshot,
22
+ subscribe(fn) {
23
+ snapshotSubs.add(fn);
24
+ return () => snapshotSubs.delete(fn);
25
+ },
26
+ };
27
+ /** Publish a snapshot read (tests call it to seed one). */
28
+ export function publishIndexSnapshot(snap) {
29
+ if (snap === lastSnapshot) return;
30
+ lastSnapshot = snap;
31
+ for (const fn of [...snapshotSubs]) fn();
32
+ }
33
+ /** The last index snapshot the Canvases panel read (null until the first answer). */
34
+ export function useIndexSnapshotNow() {
35
+ return useSyncExternalStore(indexSnapshotNow.subscribe, indexSnapshotNow.get, () => null);
36
+ }
37
+
16
38
  export function useCanvasIndex({ stamp, fetchImpl } = {}) {
17
39
  const [snapshot, setSnapshot] = useState(null);
18
40
  const [moved, setMoved] = useState(0);
@@ -55,6 +77,7 @@ export function useCanvasIndex({ stamp, fetchImpl } = {}) {
55
77
  if (!data?.unchanged && Array.isArray(data?.canvases)) {
56
78
  seq.current = data.writer?.seq || 0;
57
79
  setSnapshot(data);
80
+ publishIndexSnapshot(data);
58
81
  }
59
82
  } while (f.again);
60
83
  } catch {
@@ -23,7 +23,7 @@ import { AdvancedFold } from '../fold/advanced-fold.jsx';
23
23
  import { Check, Copy, Spark } from '../ai/icons.jsx';
24
24
  import { INDEX_CHANGED_EVENT } from '../canvases/use-canvas-index.js';
25
25
  import { projectRel } from '../shell/native-doors.js';
26
- import { BUILD_FAILURE_BODY, buildFailureReason } from './canvas-waiting.js';
26
+ import { BUILD_FAILURE_BODY, buildFailureReason, loadReasonWords } from './canvas-waiting.js';
27
27
  import { CanvasBuildingCard, CanvasWaitingCard } from './canvas-waiting-card.jsx';
28
28
  import { registerErrorCard } from './code-bus.js';
29
29
  import {
@@ -152,6 +152,8 @@ export function CanvasErrorCard({
152
152
  askAiAvailable = true,
153
153
  /** #189 — the build stopped outside the code (`{ class, count? }`): no Ask AI, the reason under the fold. */
154
154
  buildFailure = null,
155
+ /** 2.0.7 — which of the studio's waits ran out (`canvasError.reason`), named when nothing else is. */
156
+ loadReason = null,
155
157
  /** The fold starts open (a test / a caller that wants the details up front). */
156
158
  detailsOpen = false,
157
159
  }) {
@@ -274,6 +276,13 @@ export function CanvasErrorCard({
274
276
  {buildFailureReason(buildFailure)}
275
277
  </span>
276
278
  </div>
279
+ ) : loadReasonWords(loadReason) ? (
280
+ <div className="v2-err-row">
281
+ <span className="v2-err-k">Reason</span>
282
+ <span className="v2-err-v" data-testid="canvas-error-load-reason">
283
+ {loadReasonWords(loadReason)}
284
+ </span>
285
+ </div>
277
286
  ) : (
278
287
  <p className="v2-err-none" data-testid="canvas-error-none">
279
288
  No details were reported. Reload the canvas, or ask AI to look.
@@ -388,6 +397,8 @@ export function CanvasLoadFailure({
388
397
  fetchImpl,
389
398
  /** How often the waiting card re-asks (a file landing also re-asks at once). */
390
399
  watchMs = WAITING_WATCH_MS,
400
+ /** 2.0.7 — passed to the card: which wait ran out. */
401
+ loadReason = null,
391
402
  }) {
392
403
  const [stamp, setStamp] = useState(0);
393
404
  const err = useCanvasError({ canvas, stamp, quiet: true, fetchImpl });
@@ -449,7 +460,7 @@ export function CanvasLoadFailure({
449
460
  );
450
461
  }
451
462
  // files it imports haven't reached this Mac, or are held back: not a mistake in its code
452
- if (waiting) return <CanvasWaitingCard canvas={canvas} waiting={waiting} />;
463
+ if (waiting) return <CanvasWaitingCard canvas={canvas} waiting={waiting} fetchImpl={fetchImpl} />;
453
464
  if (building) return <CanvasBuildingCard canvas={canvas} />;
454
465
  return (
455
466
  <>
@@ -466,6 +477,7 @@ export function CanvasLoadFailure({
466
477
  onReload={onReload}
467
478
  onCopy={onCopy}
468
479
  buildFailure={buildFailure}
480
+ loadReason={loadReason}
469
481
  />
470
482
  </>
471
483
  );
@@ -12,12 +12,16 @@
12
12
  // canvas and the index reports them (`canvasRefusedInputs`, canvas-url.js `canvasRefusedOf`): the card names
13
13
  // them too — "This canvas uses <file>, which belongs to another canvas."
14
14
 
15
- import { canvasImportsText } from './canvas-imports-words.js';
15
+ import { canvasImportsText, canvasMissingText } from './canvas-imports-words.js';
16
16
 
17
17
  export { canvasImportsText };
18
18
 
19
- export function CanvasImportsCard({ imports, refused, componentDir }) {
20
- const { title, also, body } = canvasImportsText(imports, componentDir, refused);
19
+ export function CanvasImportsCard({ imports, refused, missing, componentDir }) {
20
+ // 2.0.7 — a canvas whose only trouble is a missing import names that file (canvasMissingText)
21
+ const onlyMissing = !imports?.length && !refused?.length && missing?.length;
22
+ const { title, also, body } = onlyMissing
23
+ ? canvasMissingText(missing)
24
+ : canvasImportsText(imports, componentDir, refused);
21
25
  return (
22
26
  <div className="sh-canvas-error-card" data-testid="canvas-imports-card">
23
27
  <div className="sh-canvas-error-title">{title}</div>
@@ -37,6 +37,22 @@ export function canvasImportsText(imports, componentDir, refused = []) {
37
37
  };
38
38
  }
39
39
 
40
+ /**
41
+ * 2.0.7 — the words for a canvas that imports a file which is not in the project (deleted, renamed, or not on
42
+ * this Mac yet). Its frame is refused before it builds, so without these the card could only say it "didn't
43
+ * finish loading". `missing`: designRoot-relative paths, from the index's `canvasMissingImports`.
44
+ */
45
+ export function canvasMissingText(missing) {
46
+ const names = namesOf(missing);
47
+ return {
48
+ title: names.length
49
+ ? `This canvas imports ${listWords(names)}, which ${names.length > 1 ? 'are' : 'is'} not in the project.`
50
+ : 'This canvas imports a file that is not in the project.',
51
+ also: [],
52
+ body: 'Put the file back, or remove the import, to draw the canvas.',
53
+ };
54
+ }
55
+
40
56
  /** The card's words as plain lines (title, the other reason, what to do) — for a terminal or a report. */
41
57
  export function canvasImportsLines(imports, componentDir, refused = []) {
42
58
  const { title, also, body } = canvasImportsText(imports, componentDir, refused);
@@ -5,14 +5,17 @@
5
5
  // files) · the project's sync (Project sync: 5,029 of 5,041 files) · the names it waits
6
6
  // for (five, then "and N more"). No button: the canvas opens by itself when they land
7
7
  // (CanvasLoadFailure watches and reloads it).
8
- // refused "Uniformy-2027 can't open on this Mac yet." · why, in plain words; for the code consent,
9
- // linking the folder again (the link asks — Settings has no per-hub consent row, and a
10
- // Maude Cloud project opened from Home accepts by itself). No "Ask AI to fix it": AI can't change a
11
- // sync consent, and nothing in the code is wrong.
8
+ // refused "Uniformy-2027 can't open on this Mac yet." · why, in plain words; for the code consent
9
+ // (fix/207) the card's one button, Allow shared code…, opens the confirm sheet (a Maude
10
+ // Cloud project opened from Home accepts by itself). No "Ask AI to fix it": AI can't change
11
+ // a sync consent, and nothing in the code is wrong.
12
12
  //
13
13
  // Same card frame as the broken-canvas card (`.v2-err`); the words are canvas-waiting.js's.
14
14
 
15
+ import { useEffect, useState } from 'react';
15
16
  import { StIcon } from '../../shell/icons.jsx';
17
+ import { readCodeConsent } from './code-consent.js';
18
+ import { CodeConsentSheet } from './code-consent-sheet.jsx';
16
19
  import {
17
20
  BUILDING_BODY,
18
21
  baseName,
@@ -28,9 +31,59 @@ import {
28
31
  } from './canvas-waiting.js';
29
32
  import { canvasTitle } from './use-canvas-source.js';
30
33
 
31
- export function CanvasWaitingCard({ canvas, waiting }) {
34
+ /** fix/207 — the card's one action for held shared code; drawn only where this Mac may answer. */
35
+ function AllowCodeAction({ fetchImpl }) {
36
+ const [consent, setConsent] = useState(null);
37
+ const [open, setOpen] = useState(false);
38
+ const [said, setSaid] = useState('');
39
+ useEffect(() => {
40
+ let live = true;
41
+ readCodeConsent(fetchImpl).then((c) => {
42
+ if (live) setConsent(c);
43
+ });
44
+ return () => {
45
+ live = false;
46
+ };
47
+ }, [fetchImpl]);
48
+ if (said)
49
+ return (
50
+ <p className="v2-err-lg" role="status" data-testid="canvas-waiting-allowed">
51
+ {said}
52
+ </p>
53
+ );
54
+ if (!consent?.changeable || consent.allowed) return null;
55
+ return (
56
+ <div className="v2-err-acts">
57
+ <button
58
+ type="button"
59
+ className="btn btn--primary"
60
+ data-action="sync.allow-code"
61
+ data-testid="canvas-waiting-allow-code"
62
+ onClick={() => setOpen(true)}
63
+ >
64
+ Allow shared code…
65
+ </button>
66
+ {open ? (
67
+ <CodeConsentSheet
68
+ mode="allow"
69
+ host={consent.host}
70
+ fetchImpl={fetchImpl}
71
+ onClose={() => setOpen(false)}
72
+ onDone={(c) => {
73
+ setOpen(false);
74
+ setConsent(c);
75
+ setSaid('Shared code is allowed. The canvas opens once it arrives.');
76
+ }}
77
+ />
78
+ ) : null}
79
+ </div>
80
+ );
81
+ }
82
+
83
+ export function CanvasWaitingCard({ canvas, waiting, fetchImpl = globalThis.fetch }) {
32
84
  const name = canvasTitle(canvas);
33
85
  const held = !!refusedFile(waiting);
86
+ const codeHeld = refusedFile(waiting)?.reason === 'code-consent';
34
87
  const { need, progress } = waiting;
35
88
  const shown = waiting.files.slice(0, SHOWN_FILES);
36
89
  const more = moreCount(waiting);
@@ -54,6 +107,7 @@ export function CanvasWaitingCard({ canvas, waiting }) {
54
107
  <p className="v2-err-d" data-testid="canvas-waiting-body">
55
108
  {waitingBody(waiting)}
56
109
  </p>
110
+ {codeHeld ? <AllowCodeAction fetchImpl={fetchImpl} /> : null}
57
111
  {need && !held ? (
58
112
  <div className="v2-err-prog" data-testid="canvas-waiting-progress">
59
113
  <span
@@ -89,7 +89,8 @@ export function waitingBody(waiting) {
89
89
  const file = baseName(held.rel);
90
90
  switch (held.reason) {
91
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.`;
92
+ // fix/207 — the card carries the answer itself (Allow shared code…), so the sentence names it
93
+ return `This Mac hasn't allowed shared code from this project yet (${file}). Nothing is lost. Allow shared code to open it.`;
93
94
  case 'too-large':
94
95
  return `${file} is too big to sync, so it can't reach this Mac. Nothing is lost.`;
95
96
  case 'quota':
@@ -162,3 +163,19 @@ export function buildFailureReason(b) {
162
163
  return '';
163
164
  }
164
165
  }
166
+
167
+ // ── 2.0.7: the load stopped and the server recorded nothing ──────────────────────────────────────
168
+
169
+ /** Which of the studio's own waits ran out (`canvasError.reason`), in words; '' when unknown. */
170
+ export function loadReasonWords(reason) {
171
+ switch (reason) {
172
+ case 'slow':
173
+ return "It didn't finish opening within a minute";
174
+ case 'no-shell':
175
+ return "Its frame didn't start within 15 seconds";
176
+ case 'frame':
177
+ return 'It stopped loading before it was drawn';
178
+ default:
179
+ return '';
180
+ }
181
+ }
@@ -0,0 +1,87 @@
1
+ // client/v2/code/code-consent-sheet.jsx — fix/207: the confirm sheet for shared code from the
2
+ // project's hub. `mode` 'allow' → "Allow shared code from <host>?" · Allow shared code / Cancel;
3
+ // 'stop' → "Stop allowing shared code from <host>?" · Stop allowing / Cancel. The primary runs
4
+ // `sync.allow-code` / `sync.stop-code` (POST /_api/sync/code-consent/set); `onDone(consent)` gets
5
+ // the server's new answer. Same dialog frame as the design-system sheets (`dsr-*`, review.css).
6
+
7
+ import { useRef, useState } from 'react';
8
+ import { useModalFocus } from '../shell/modal-focus.js';
9
+ import { CONSENT_FAILED, consentWords, requestCodeConsent } from './code-consent.js';
10
+
11
+ export function CodeConsentSheet({
12
+ mode = 'allow',
13
+ host = '',
14
+ onClose,
15
+ onDone,
16
+ fetchImpl = fetch,
17
+ }) {
18
+ const words = consentWords(mode, host);
19
+ const [busy, setBusy] = useState(false);
20
+ const [error, setError] = useState('');
21
+ const cancelRef = useRef(null);
22
+ // Focus starts on Cancel: a yes to running code is pressed on purpose, never by a stray Return.
23
+ const ref = useModalFocus({ onClose, initialRef: cancelRef });
24
+ const go = async () => {
25
+ if (busy) return;
26
+ setBusy(true);
27
+ setError('');
28
+ const r = await requestCodeConsent(mode !== 'stop', fetchImpl);
29
+ if (!r.ok) {
30
+ setBusy(false);
31
+ setError(r.message || CONSENT_FAILED);
32
+ return;
33
+ }
34
+ onDone?.(r.consent);
35
+ };
36
+ return (
37
+ <div className="dsr-scrim" data-testid="code-consent-scrim">
38
+ <div
39
+ ref={ref}
40
+ className="island dsr-dialog"
41
+ role="dialog"
42
+ aria-modal="true"
43
+ aria-labelledby="code-consent-title"
44
+ tabIndex={-1}
45
+ data-testid="code-consent-sheet"
46
+ data-mode={mode}
47
+ >
48
+ <h2 id="code-consent-title" className="dsr-title" data-testid="code-consent-title">
49
+ {words.title}
50
+ </h2>
51
+ <div className="dsr-body">
52
+ {words.lines.map((l) => (
53
+ <p key={l}>{l}</p>
54
+ ))}
55
+ {words.fine ? <p className="dsr-fine">{words.fine}</p> : null}
56
+ {error ? (
57
+ <p className="dsr-err" role="alert" data-testid="code-consent-error">
58
+ {error}
59
+ </p>
60
+ ) : null}
61
+ </div>
62
+ <div className="dsr-acts">
63
+ <button
64
+ ref={cancelRef}
65
+ type="button"
66
+ className="btn"
67
+ disabled={busy}
68
+ data-testid="code-consent-cancel"
69
+ onClick={onClose}
70
+ >
71
+ Cancel
72
+ </button>
73
+ <button
74
+ type="button"
75
+ className="btn btn--primary"
76
+ disabled={busy}
77
+ data-action={mode === 'stop' ? 'sync.stop-code' : 'sync.allow-code'}
78
+ data-testid="code-consent-go"
79
+ onClick={go}
80
+ >
81
+ {words.go}
82
+ </button>
83
+ </div>
84
+ </div>
85
+ </div>
86
+ );
87
+ }
@@ -0,0 +1,67 @@
1
+ // client/v2/code/code-consent.js — fix/207: this Mac's answer to "may the project's hub deliver
2
+ // shared code here?", in words and two fetches.
3
+ //
4
+ // Shared code is the `.ts`/`.js` modules a team adds to a project (helpers, components canvases
5
+ // import). It lands OUTSIDE the canvas sandbox — AI and the maude helpers read it, and canvases run
6
+ // it — so a Mac takes it only once the person says yes (DDR-054). The answer lives in the profile's
7
+ // hubs.json; the studio writes it (`POST /_api/sync/code-consent/set`, the window's own fetch only).
8
+ // Reached from Sync details' held row and the canvas-waiting card; registry actions
9
+ // `sync.allow-code` / `sync.stop-code`.
10
+
11
+ /** The sheet's words for `mode` 'allow' | 'stop', naming the hub by its host (CONTRACT §4). */
12
+ export function consentWords(mode, host) {
13
+ const from = host ? ` from ${host}` : '';
14
+ if (mode === 'stop')
15
+ return {
16
+ title: `Stop allowing shared code${from}?`,
17
+ lines: [
18
+ 'Shared code already on this Mac stays. New or changed shared code from this project waits until you allow it again.',
19
+ 'Canvases that need code that hasn’t arrived can’t open until then.',
20
+ ],
21
+ go: 'Stop allowing',
22
+ };
23
+ return {
24
+ title: `Allow shared code${from}?`,
25
+ lines: [
26
+ 'Shared code is the .ts and .js files the people in this project add to it — helpers and components its canvases import.',
27
+ 'It runs on this Mac, outside the canvas sandbox: canvases run it when they open, and AI and the Maude tools read it. Allow it only if you trust the people who share this project.',
28
+ 'Shared code you deleted on this Mac stays deleted.',
29
+ ],
30
+ fine: 'You can stop allowing it any time in Sync details.',
31
+ go: 'Allow shared code',
32
+ };
33
+ }
34
+
35
+ export const CONSENT_FAILED = 'That didn’t work. Nothing changed on this Mac.';
36
+
37
+ /** GET /_api/sync/code-consent → the view, or null (not syncing, or unreachable). */
38
+ export async function readCodeConsent(fetchImpl = globalThis.fetch) {
39
+ try {
40
+ const r = await fetchImpl('/_api/sync/code-consent', { cache: 'no-store' });
41
+ if (!r.ok) return null;
42
+ const j = await r.json();
43
+ return j && typeof j.consent === 'object' ? j.consent : null;
44
+ } catch {
45
+ return null;
46
+ }
47
+ }
48
+
49
+ /** POST /_api/sync/code-consent/set → { ok: true, consent } | { ok: false, message }. */
50
+ export async function requestCodeConsent(allow, fetchImpl = globalThis.fetch) {
51
+ try {
52
+ const r = await fetchImpl('/_api/sync/code-consent/set', {
53
+ method: 'POST',
54
+ headers: { 'Content-Type': 'application/json' },
55
+ body: JSON.stringify({ allow: allow === true }),
56
+ });
57
+ const j = await r.json().catch(() => ({}));
58
+ if (r.ok && j.ok) return { ok: true, consent: j.consent ?? null };
59
+ const said = typeof j.detail === 'string' ? j.detail : j.message;
60
+ return {
61
+ ok: false,
62
+ message: typeof said === 'string' && said.length <= 200 ? said : CONSENT_FAILED,
63
+ };
64
+ } catch {
65
+ return { ok: false, message: 'Maude isn’t reachable right now.' };
66
+ }
67
+ }