@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
@@ -81,25 +81,26 @@ export function registerCanvasThemeSystem(ds: { name: string; themeDefault: stri
81
81
  /** The registered design system's name, or null on a canvas with none. */
82
82
  export const getCanvasThemeSystemName = (): string | null => store().dsName;
83
83
 
84
- /** Remember the pick for this canvas on this Mac (best-effort, fire-and-forget like the camera). */
84
+ /**
85
+ * Remember the pick for this canvas on this Mac. The canvas writes nothing itself: its origin may PATCH only `layout`
86
+ * and `viewport` (routes/canvas-origin.ts), so its own `canvasTheme` PATCH was refused. It tells the studio
87
+ * `theme-pick`, and the shell writes `canvasTheme` into the view file for the canvas it has open, on the main origin
88
+ * (client/v2/shell/pages-pick.js) — the Canvas | Pages path. Outside the studio window nothing is remembered.
89
+ */
85
90
  function persist(mode: CanvasTheme): void {
86
- if (typeof window === 'undefined' || typeof fetch === 'undefined') return;
91
+ if (typeof window === 'undefined' || window.parent === window) return;
87
92
  // an embed, a Present follower and a past version are not the designer's own view (read-only-mode.ts)
88
93
  if (!persistsCanvasMeta()) return;
89
94
  const w = window as unknown as MetaWindow;
90
- const file = typeof w.__canvas_meta_file__ === 'string' ? w.__canvas_meta_file__ : null;
91
- if (!file) return;
92
95
  // keep the page-load snapshot current, so a soft remount reads the pick back (DDR-138)
93
96
  if (w.__canvas_meta__ && typeof w.__canvas_meta__ === 'object')
94
97
  w.__canvas_meta__.canvasTheme = mode;
95
98
  w.__maude_last_meta_self_write_at = Date.now();
96
- fetch('/_api/canvas-meta', {
97
- method: 'PATCH',
98
- headers: { 'content-type': 'application/json' },
99
- body: JSON.stringify({ file, patch: { canvasTheme: mode } }),
100
- }).catch((err) => {
101
- console.warn('[canvas-theme] persist failed:', err);
102
- });
99
+ try {
100
+ window.parent.postMessage({ dgn: 'theme-pick', v: 1, theme: mode }, '*');
101
+ } catch {
102
+ /* detached */
103
+ }
103
104
  }
104
105
 
105
106
  /** Show `mode` on every artboard. `persist: false` is a preview — nothing is remembered. */
@@ -237,6 +237,7 @@ import { cutCopyPaste, createMenuHandlers, menuRunner } from './v2/shell/menu-ru
237
237
  import DiagnosticsHost from './v2/diagnostics/diagnostics-host.jsx';
238
238
  import { useDiagnosticsMenu } from './v2/diagnostics/use-diagnostics-menu.js';
239
239
  import { menuCtx, moveDestinations } from './v2/shell/project-menu-model.js';
240
+ import { usePagesView } from './v2/shell/use-canvas-mode-lane.js';
240
241
  import { useProjectSwitcher } from './panels/RepoBranchSwitcher.jsx';
241
242
  import { ProjectPill } from './v2/shell/project-pill.jsx';
242
243
  import { AskSelectionHost } from './v2/ai/AskSelectionHost.jsx';
@@ -1895,6 +1896,7 @@ function ShellProjectPill() {
1895
1896
  const activeRel = activePath ? normalizeOpenPath(activePath, cfg?.designRel) : null;
1896
1897
  const activeRole = sessionRole(cfg, activeRel);
1897
1898
  const activeObserver = observerOn(cfg, activeRel);
1899
+ const pagesOn = usePagesView();
1898
1900
  const ctx = useMemo(
1899
1901
  () =>
1900
1902
  menuCtx({
@@ -1907,6 +1909,8 @@ function ShellProjectPill() {
1907
1909
  // S3.8 — Copy presentation link reads both: a cloud-linked desktop, and the network up.
1908
1910
  linkedHub: !!cloudLinkedHub?.url,
1909
1911
  online,
1912
+ // 2.0.7 B2 — the active canvas shows Pages (Preview / Present greyed, paging on)
1913
+ pagesView: pagesOn,
1910
1914
  }),
1911
1915
  [
1912
1916
  native,
@@ -1917,6 +1921,7 @@ function ShellProjectPill() {
1917
1921
  presentMode,
1918
1922
  cloudLinkedHub?.url,
1919
1923
  online,
1924
+ pagesOn,
1920
1925
  ]
1921
1926
  );
1922
1927
  // V2-4.8a: the megaphone's unseen dot, as a word on the Help row; and no "Back to Home" in a hub that
@@ -1960,6 +1965,7 @@ function ShellProjectPill() {
1960
1965
  'view.exports': exportCenter.panelOpen,
1961
1966
  'history.open': changesOpen,
1962
1967
  'present.canvas': presentMode,
1968
+ 'view.pages': pagesOn,
1963
1969
  },
1964
1970
  }),
1965
1971
  [
@@ -1984,6 +1990,7 @@ function ShellProjectPill() {
1984
1990
  exportCenter.panelOpen,
1985
1991
  changesOpen,
1986
1992
  presentMode,
1993
+ pagesOn,
1987
1994
  ]
1988
1995
  );
1989
1996
  const previewing = usePreviewMode();
@@ -265,6 +265,16 @@ export function canvasRefusedOf(cfg, p) {
265
265
  return names.length ? names : null;
266
266
  }
267
267
 
268
+ /**
269
+ * 2.0.7 — the imports of `p` that resolve to no file in the project (its frame is refused before it builds),
270
+ * from the index's `canvasMissingImports`, or `null` when none is on record.
271
+ */
272
+ export function canvasMissingOf(cfg, p) {
273
+ const list = cfg?.canvasMissingImports?.[p];
274
+ const names = Array.isArray(list) ? list.filter((x) => typeof x === 'string' && x) : [];
275
+ return names.length ? names : null;
276
+ }
277
+
268
278
  export function canvasUrl(p, cfg, opts) {
269
279
  if (!p.endsWith('.tsx')) return urlOf(p);
270
280
  const designRel = (cfg?.designRel || '.design').replace(/^\/+|\/+$/g, '');
@@ -371,7 +381,19 @@ export function canvasUrl(p, cfg, opts) {
371
381
  // against. Unknown DS (single-DS / legacy / default-DS canvas) → `ds0`, which
372
382
  // keeps the historical behavior byte-for-byte. DDR-093.
373
383
  const uiDsName = !specMatch ? (opts?.ds ?? cfg?.canvasDesignSystems?.[p]) : null;
374
- const uiDsEntry = uiDsName ? cfg?.designSystems?.find((d) => d.name === uiDsName) : null;
384
+ // 2.0.7 — a system the config does not list (a cell's config.json never syncs) still owns the
385
+ // canvases in its own folder: the server names it (`ds-resolver` `folderSystemOf`), and only a
386
+ // canvas inside `system/<that name>/` gets that folder's files — a name never invents a path.
387
+ const uiDsEntry = uiDsName
388
+ ? (cfg?.designSystems?.find((d) => d.name === uiDsName) ??
389
+ (rel.startsWith(`system/${uiDsName}/`) && !/^[._]/.test(uiDsName)
390
+ ? {
391
+ name: uiDsName,
392
+ path: `system/${uiDsName}`,
393
+ tokensCssRel: `system/${uiDsName}/colors_and_type.css`,
394
+ }
395
+ : null))
396
+ : null;
375
397
  const uiDs = uiDsEntry || ds0;
376
398
  // Resolve tokens path. For a specimen, prefer the matching DS's tokensCssRel
377
399
  // (fall back to the `system/<ds>/colors_and_type.css` convention). Otherwise
@@ -24,3 +24,37 @@ export async function probeCanvasOrigin(canvasOrigin, fetchImpl = fetch) {
24
24
  return 'server';
25
25
  }
26
26
  }
27
+
28
+ /** 2.0.7 (#2) — how often a loading canvas whose build is still running is asked about again. */
29
+ export const BUILDING_RECHECK_MS = 15000;
30
+
31
+ /**
32
+ * The loading cap's question (2.0.7, #2): is this canvas still being built? A cold design system on a
33
+ * team server can need longer than the cap, and its frame now waits for the build (`importWhenBuilt`
34
+ * in _shell.html) — so while the server says `building`, the cap answers `building` and the studio
35
+ * keeps the loading screen instead of raising "can't be drawn right now" over a build that is fine.
36
+ * Otherwise the origin probe's answer, as before: `compile` (the origin is up, the canvas never drew)
37
+ * or `server`. Same-origin `/_api/canvas-errors`, the route the card itself reads.
38
+ */
39
+ export async function loadCapVerdict({ path, canvasOrigin, fetchImpl = fetch }) {
40
+ try {
41
+ const r = await fetchImpl(`/_api/canvas-errors?canvas=${encodeURIComponent(path)}`, {
42
+ cache: 'no-store',
43
+ });
44
+ if (r.ok) {
45
+ const j = await r.json();
46
+ if (j && j.building === true && !(j.errors && j.errors.length)) return 'building';
47
+ }
48
+ } catch {
49
+ /* no answer — the origin probe decides */
50
+ }
51
+ return probeCanvasOrigin(canvasOrigin, fetchImpl);
52
+ }
53
+
54
+ /**
55
+ * The reason the load-failure card names when the server recorded none (2.0.7): which wait ran out.
56
+ * `no-shell` — the canvas frame never started; `slow` — it started and never drew.
57
+ */
58
+ export function capReason(shellAlive) {
59
+ return shellAlive ? 'slow' : 'no-shell';
60
+ }
@@ -24,7 +24,7 @@ import { shellToast, totalCounts } from '../shell/util.js';
24
24
  import { assetTileSelected } from '../v2/assets/assets-bus.js';
25
25
  import { selectionHasTakes } from '../v2/assets/takes.js';
26
26
  import { keyOutcome } from '../v2/shell/role-gate.js';
27
- import { ROLE_DENIAL } from '../v2/shell/use-canvas-mode-lane.js';
27
+ import { ROLE_DENIAL, shellMode } from '../v2/shell/use-canvas-mode-lane.js';
28
28
  import { installFocusRescue } from '../v2/shell/modal-focus.js';
29
29
  import { useAnnotationPrefsLane } from '../v2/shell/use-annotation-prefs.js';
30
30
  import { singleKeysStore, useSingleKeysLane } from '../v2/shell/use-single-keys.js';
@@ -54,6 +54,8 @@ function shellState(d) {
54
54
  assetTileSelected: assetTileSelected(),
55
55
  // S8.16: the one selected picture has other takes — ← → step them (image.next-take / image.prev-take)
56
56
  selectionHasTakes: selectionHasTakes(sel, d.activePath),
57
+ // 2.0.7 B2: the active canvas shows Pages — ⌥⌘P and the Present keys are off (greyed, the key swallowed)
58
+ pagesView: shellMode.get().pages === true,
57
59
  };
58
60
  }
59
61
 
@@ -1338,7 +1338,7 @@ export function useCanvasBridge({
1338
1338
  // page it names is the open canvas (the frame is the proof, not the `file` it claims), and the
1339
1339
  // next `loaded` (Reload canvas) retires it.
1340
1340
  if (m.dgn === 'canvas-failed' && activePath)
1341
- setCanvasError({ path: activePath, kind: 'compile' });
1341
+ setCanvasError({ path: activePath, kind: 'compile', reason: 'frame' });
1342
1342
  }
1343
1343
  } else if (m.dgn === 'loaded' && m.file) {
1344
1344
  stampFollowRef.current.bump(); // a reloaded canvas carries the file's ids (stamp-follow.js)
@@ -22,7 +22,9 @@ import { menuRunner } from '../v2/shell/menu-runner.js';
22
22
  import { panelAvailable as panelAvailableIn } from '../v2/shell/panel-availability.js';
23
23
  import { keyHint, menuCtx, menuPaletteRows } from '../v2/shell/project-menu-model.js';
24
24
  import { roleRefuses } from '../v2/shell/role-gate.js';
25
- import { ROLE_DENIAL } from '../v2/shell/use-canvas-mode-lane.js';
25
+ import { ROLE_DENIAL, usePagesArtboard, usePagesView } from '../v2/shell/use-canvas-mode-lane.js';
26
+ import { artboardInView } from '../v2/left-panel/left-panel-model.js';
27
+ import { useLayersTreeRequest } from '../v2/layers/layers-request.js';
26
28
  import { bindPaletteEnv, sendToAskAI } from '../v2/search/search-env.js';
27
29
  import { desktopProjectsEnv } from '../v2/search/search-projects.js';
28
30
  import { actionSearchRows, settingsSearchRows } from '../v2/search/search-model.js';
@@ -334,6 +336,19 @@ export function usePaletteAndPanels({
334
336
  const clipRowsVersion = useClipRowsVersion(); // S7.16 — the clips of the video on the timeline, by name
335
337
  // p8-v1-drop — the systems offered "Bring it up to the schema" (the Canvases panel publishes them)
336
338
  const dsUpgradeOffers = useSyncExternalStore(onUpgradeOffers, upgradeOffersKey, upgradeOffersKey);
339
+ const pagesOn = usePagesView(); // 2.0.7 B2 — Preview / Present greyed, Next / Previous page on
340
+ const pagesAt = usePagesArtboard(); // 2.0.7 polish — the artboard on the page: the left panel marks it
341
+ // 2.0.7 fix (decision `v2-207-layers-current`) — Layers marks the artboard you are on and draws only its tree; a
342
+ // tree in hand for another artboard (late, or re-posted by the canvas) is answered by asking again for this one
343
+ const layersOnArtboard = artboardInView({ selected, activePath, pagesAt });
344
+ useLayersTreeRequest({
345
+ activePath,
346
+ want: layersOnArtboard,
347
+ have: layersTree ? (layersTree.artboardId ?? null) : null,
348
+ post: postToActiveCanvas,
349
+ delay: 400,
350
+ skip: activePath === SYSTEM_TAB,
351
+ });
337
352
  const paletteActions = useMemo(() => {
338
353
  const run = {
339
354
  'canvas.new': () => openNewCanvasDialog(),
@@ -389,6 +404,7 @@ export function usePaletteAndPanels({
389
404
  linkedHub: !!cloudLinkedHub?.url,
390
405
  // p8-v1-drop — "Bring it up to the schema" is a ⌘K row while a system is below Conformant
391
406
  dsUpgradeOffered: dsUpgradeOffers !== '',
407
+ pagesView: pagesOn,
392
408
  });
393
409
  // V2-4 gate (design blocker 6): a row's key is the registry's live chord in this shell, written by
394
410
  // `formatChord` (⌥⇧⌘), or none — never v1's display string (New canvas "N" was Sticky's key, the
@@ -466,6 +482,7 @@ export function usePaletteAndPanels({
466
482
  return [...v1, ...menuRows, ...leftRows, ...searchRows];
467
483
  }, [
468
484
  dsUpgradeOffers,
485
+ pagesOn,
469
486
  cfg.cloud,
470
487
  viewerMode,
471
488
  activePath,
@@ -639,11 +656,9 @@ export function usePaletteAndPanels({
639
656
  onDuplicateCanvas={duplicateCanvasReq}
640
657
  onDeleteFile={deleteFileReq}
641
658
  onCopyLink={copyCanvasLink}
642
- // S1.3 — the artboard in view on the open canvas, so the jump list can highlight it
643
- activeArtboard={(() => {
644
- const sel = Array.isArray(selected) ? selected[0] : selected;
645
- return sel && sel.file === activePath ? (sel.artboardId ?? null) : null;
646
- })()}
659
+ // S1.3 — the artboard in view on the open canvas, so the jump list can highlight it (2.0.7 polish: in
660
+ // Pages, the artboard on the page)
661
+ activeArtboard={artboardInView({ selected, activePath, pagesAt })}
647
662
  onRefresh={refreshTree}
648
663
  onToggleShowHidden={() => menuRunner.run('view.hidden-files')}
649
664
  refreshing={treeRefreshing}
@@ -793,6 +808,8 @@ export function usePaletteAndPanels({
793
808
  // gate-b-polish3 — Layers by artboard: the open canvas's artboards, its name, a row selects one
794
809
  layersBoards={id === 'layers' && activeCanvasFile ? boardLabels.get(activePath) : null}
795
810
  layersCanvasName={activeCanvasFile ? displayName(basename(activeCanvasFile)) : ''}
811
+ // 2.0.7 fix — the artboard you are on (the page in Pages, else the selection's): Layers marks it
812
+ layersArtboard={layersOnArtboard}
796
813
  onSelectArtboard={(artboardId) => postToActiveCanvas({ dgn: 'select-by-id', artboardId })}
797
814
  onSelectBySelector={(selector) =>
798
815
  postToActiveCanvas({ dgn: 'select-by-selector', v: 1, selector })
@@ -5,7 +5,12 @@ import { syncAnnotationsHiddenToast } from './annotations-hidden-toast.js';
5
5
  import { acceptFromCanvas } from '../../bridge/dgn-protocol.ts';
6
6
  import { persistUiPrefs, shellToast } from '../shell/util.js';
7
7
  import { installDropGuard } from '../shell/drop-guard.js';
8
- import { togglePresentCanvas, usePresentMode } from '../v2/shell/use-canvas-mode-lane.js';
8
+ import {
9
+ togglePresentCanvas,
10
+ usePagesArtboard,
11
+ usePresentMode,
12
+ } from '../v2/shell/use-canvas-mode-lane.js';
13
+ import { layersArtboardOf, useLayersTreeRequest } from '../v2/layers/layers-request.js';
9
14
  import {
10
15
  ANNOT_STORE,
11
16
  LAYERS_MODE_STORE,
@@ -662,13 +667,16 @@ export function usePhotoAndTimeline({
662
667
  // the tree for the viewport-active artboard whenever it (or the canvas)
663
668
  // changes, so Layers work in browse mode with no selection at all. Small
664
669
  // debounce — the active-artboard signal can flicker during a fast pan.
665
- useEffect(() => {
666
- if (!activePath || activePath === SYSTEM_TAB || !canvasActiveArtboard) return;
667
- const t = setTimeout(() => {
668
- postToActiveCanvas({ dgn: 'request-layers', artboardId: canvasActiveArtboard });
669
- }, 250);
670
- return () => clearTimeout(t);
671
- }, [activePath, canvasActiveArtboard, postToActiveCanvas]);
670
+ // 2.0.7 fix (decision `v2-207-layers-current`) — asked for the artboard the person is ON (the page in Pages, else
671
+ // the selection's artboard, else the one in view), the same one Layers marks: a Layers pick or a page turn used to
672
+ // leave the tree — and the mark — on the artboard nearest the viewport centre.
673
+ const pagesAt = usePagesArtboard();
674
+ useLayersTreeRequest({
675
+ activePath,
676
+ want: layersArtboardOf({ selected, activePath, pagesAt, inView: canvasActiveArtboard }),
677
+ post: postToActiveCanvas,
678
+ skip: activePath === SYSTEM_TAB,
679
+ });
672
680
 
673
681
  // feature-4 T7b — locked layer keys (`"<cdId>:<index>"`, per-user, per-canvas
674
682
  // via view.json). Toggling PATCHes the FULL set (replace semantics) + pushes
@@ -24,8 +24,14 @@ export function useProjectData({
24
24
  const loadTree = useCallback(() => treeLoaderRef.current?.reload() ?? Promise.resolve(), []);
25
25
  useEffect(() => {
26
26
  const loader = createIndexLoader({
27
- read: async (signal) => {
28
- const r = await fetch('/_index-data', { signal, cache: 'no-store' });
27
+ // #207 — `fresh`: the last answer was a previous run's copy (`indexStale`); this one waits
28
+ // for the server's own build. `partial`: on the first open ever (no copy) the bare listing may
29
+ // answer first (`indexPartial`, also `indexStale`): the tree is drawn, the details follow.
30
+ read: async (signal, { fresh } = { fresh: false }) => {
31
+ const r = await fetch(fresh ? '/_index-data?fresh=1' : '/_index-data?partial=1', {
32
+ signal,
33
+ cache: 'no-store',
34
+ });
29
35
  if (!r.ok)
30
36
  throw Object.assign(new Error(`Project index request failed: ${r.status}`), {
31
37
  status: r.status,
@@ -37,6 +43,7 @@ export function useProjectData({
37
43
  }));
38
44
  return { data, built };
39
45
  },
46
+ isStale: ({ data }) => data?.indexStale === true,
40
47
  apply: ({ data, built }) => {
41
48
  setProject(data.project || 'Design');
42
49
  setGroups(built);
@@ -65,6 +72,8 @@ export function useProjectData({
65
72
  canvasImportsCanvases: data.canvasImportsCanvases ?? {},
66
73
  // 2.0.5 (#205) — canvases whose built module was refused for a file another canvas owns.
67
74
  canvasRefusedInputs: data.canvasRefusedInputs ?? {},
75
+ // 2.0.7 — canvases with an import that resolves to no file: the stage names it (viewport.jsx).
76
+ canvasMissingImports: data.canvasMissingImports ?? {},
68
77
  }));
69
78
  },
70
79
  onError: (error) => {
@@ -1,7 +1,7 @@
1
1
  // hooks/use-shell-core.jsx — moved verbatim out of client/app.jsx (Maude v2 plan V2-0.2, move-only split).
2
2
 
3
3
  import { editScopeQuery } from './edit-scope-query.js';
4
- import { probeCanvasOrigin } from './canvas-origin-probe.js';
4
+ import { BUILDING_RECHECK_MS, capReason, loadCapVerdict } from './canvas-origin-probe.js';
5
5
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
6
6
  import {
7
7
  layersTreeOf,
@@ -448,18 +448,28 @@ export function useShellCore({}) {
448
448
  // without anything being wrong, so the cap stretches instead of calling it a
449
449
  // failure. The shell reports a real build error itself (`canvas-failed`).
450
450
  const shellAlive = !!loadingPath && loadedPath === loadingPath;
451
+ // 2.0.7 (#2) — and while the server says the canvas is still BUILDING, the cap waits on (re-asking
452
+ // every BUILDING_RECHECK_MS): a cold design system on a team server can need more than the cap, and
453
+ // its frame waits for the build. When the card does show, it carries which wait ran out (`reason`).
451
454
  useEffect(() => {
452
455
  if (!loadingPath) return;
453
456
  const path = loadingPath;
454
- const cap = setTimeout(
455
- async () => {
456
- const kind = await probeCanvasOrigin(cfg?.canvasOrigin);
457
- setCanvasError({ path, kind });
457
+ let gone = false;
458
+ let cap;
459
+ const arm = (ms) => {
460
+ cap = setTimeout(async () => {
461
+ const kind = await loadCapVerdict({ path, canvasOrigin: cfg?.canvasOrigin });
462
+ if (gone) return;
463
+ if (kind === 'building') return arm(BUILDING_RECHECK_MS);
464
+ setCanvasError({ path, kind, reason: capReason(shellAlive) });
458
465
  setLoadingPath((p) => (p === path ? null : p));
459
- },
460
- shellAlive ? 60000 : 15000
461
- );
462
- return () => clearTimeout(cap);
466
+ }, ms);
467
+ };
468
+ arm(shellAlive ? 60000 : 15000);
469
+ return () => {
470
+ gone = true;
471
+ clearTimeout(cap);
472
+ };
463
473
  }, [loadingPath, shellAlive, cfg?.canvasOrigin]);
464
474
  // WHO IS SAVING THIS PROJECT — one expression, read by every surface that
465
475
  // would otherwise offer to save it, poll for it, or badge it (DDR-218, widened
@@ -1,31 +1,45 @@
1
- /** One project-index request at a time, with automatic transient recovery. */
1
+ /**
2
+ * One project-index request at a time, with automatic recovery from a real error.
3
+ *
4
+ * #207 — a request that is still pending is never aborted and never asked again: the server keeps
5
+ * every request for the index on ONE build (index-cache.ts), so a client timeout only threw the
6
+ * answer away and showed "taking a while — trying again…" on a project whose files are all local
7
+ * (StudyFi: 13 s per build, a 10 s client timeout). Only a failed request (an error status, a
8
+ * dropped connection) is retried, with a backoff.
9
+ *
10
+ * A previous run's copy (`isStale`) is drawn at once and then asked for again with `fresh`, which
11
+ * the server answers once its own build is done.
12
+ */
2
13
  export function createIndexLoader<T>({
3
14
  read,
4
15
  apply,
5
16
  onError,
17
+ isStale,
6
18
  retryDelayMs = 500,
7
19
  maxRetryDelayMs = 5000,
8
- timeoutMs = 10000,
9
- maxTimeoutMs = 120000,
20
+ staleRetryMs = 250,
21
+ maxStaleRetryMs = 2000,
10
22
  }: {
11
- read: (signal: AbortSignal) => Promise<T>;
23
+ read: (signal: AbortSignal, opts: { fresh: boolean }) => Promise<T>;
12
24
  apply: (value: T) => void;
13
25
  onError: (error: unknown) => void;
26
+ /** The answer is a previous run's copy: draw it, then ask for a fresh one. */
27
+ isStale?: (value: T) => boolean;
14
28
  retryDelayMs?: number;
15
29
  maxRetryDelayMs?: number;
16
- timeoutMs?: number;
17
- maxTimeoutMs?: number;
30
+ staleRetryMs?: number;
31
+ maxStaleRetryMs?: number;
18
32
  }) {
19
33
  let disposed = false;
20
34
  let dirty = false;
21
35
  let failures = 0;
22
- // #204 — a large index on a small cell answered after the fixed timeout, so it was aborted and
23
- // asked again forever (each retry another full build on the server). Each timeout in a row
24
- // doubles the next one's patience, up to `maxTimeoutMs`; any answer resets it.
25
- let timeoutsInARow = 0;
36
+ // A fresh answer is owed (the last one drawn was a copy); how many copies in a row.
37
+ let wantFresh = false;
38
+ let staleInARow = 0;
26
39
  // #204 — nothing drawn yet: the first answer is drawn even if a refresh is already queued behind
27
40
  // it (a materialising project asks for one per arriving file, so "only the freshest" was never).
28
41
  let appliedOnce = false;
42
+ let appliedReal = false;
29
43
  let pending: Promise<void> | null = null;
30
44
  let retryTimer: ReturnType<typeof setTimeout> | undefined;
31
45
  let controller: AbortController | undefined;
@@ -39,26 +53,33 @@ export function createIndexLoader<T>({
39
53
  cancelRetry();
40
54
  const current = new AbortController();
41
55
  controller = current;
42
- let timedOut = false;
43
- const patience = Math.min(maxTimeoutMs, timeoutMs * 2 ** Math.min(timeoutsInARow, 10));
44
- const timeout = setTimeout(() => {
45
- timedOut = true;
46
- current.abort();
47
- }, patience);
48
56
  try {
49
- const value = await read(current.signal);
50
- timeoutsInARow = 0;
57
+ const value = await read(current.signal, { fresh: wantFresh });
58
+ const stale = isStale?.(value) === true;
51
59
  // A mutation/refresh requested a newer index during this read. Do not
52
60
  // briefly restore the older tree; the next request serves all waiters —
53
61
  // unless there is no tree at all yet (#204): then this one is drawn.
54
62
  if (!disposed && (!dirty || !appliedOnce)) {
55
- apply(value);
63
+ // A copy never replaces a real answer already drawn.
64
+ if (!(stale && appliedReal)) apply(value);
56
65
  appliedOnce = true;
66
+ if (!stale) appliedReal = true;
57
67
  }
58
68
  failures = 0;
69
+ if (stale && !disposed) {
70
+ // Ask again for the real one. A server that honours `fresh` answers once its build is
71
+ // done; one that does not (an older server) is asked again with a backoff.
72
+ wantFresh = true;
73
+ const delay = Math.min(maxStaleRetryMs, staleRetryMs * 2 ** Math.min(staleInARow++, 10));
74
+ retryTimer = setTimeout(() => {
75
+ void reload();
76
+ }, delay);
77
+ } else {
78
+ wantFresh = false;
79
+ staleInARow = 0;
80
+ }
59
81
  } catch (error) {
60
82
  if (disposed) return;
61
- if (timedOut) timeoutsInARow++;
62
83
  onError(error);
63
84
  const status = (error as { status?: number } | null)?.status;
64
85
  if (status == null || status === 408 || status === 429 || status >= 500) {
@@ -68,7 +89,6 @@ export function createIndexLoader<T>({
68
89
  }, delay);
69
90
  }
70
91
  } finally {
71
- clearTimeout(timeout);
72
92
  if (controller === current) controller = undefined;
73
93
  }
74
94
  }
@@ -20,7 +20,7 @@ import { isFilterKind } from '../v2/kinds/kind-filter-model.js';
20
20
  import { useKindFilter } from '../v2/kinds/kind-filter-store.js';
21
21
  import { artboardCounts } from '../v2/kinds/layers-kind-model.js';
22
22
  import { LayersAdvanced } from '../v2/left-panel/layers-advanced.jsx';
23
- import { ArtboardLayers, currentBoard } from '../v2/layers/artboard-layers.jsx';
23
+ import { ArtboardLayers, currentBoard, treeOfBoard } from '../v2/layers/artboard-layers.jsx';
24
24
  import { timelineSelectionElement, useTimelineSelection } from '../v2/timeline/selection.js';
25
25
  import '../v2/inspector/sections/index.js'; // S2.3: the Position · Size · Layout bodies register themselves
26
26
 
@@ -161,6 +161,9 @@ export function InspectorPanel({
161
161
  // gate-b-polish3 — the open canvas's artboards ({ id, label, kind }), its name, and how a row selects one
162
162
  layersBoards = null,
163
163
  layersCanvasName = '',
164
+ // 2.0.7 fix (decision `v2-207-layers-current`) — the artboard the person is on (`artboardInView`: the page in
165
+ // Pages, else the selection's artboard on this canvas); Layers marks it and draws only its tree under it
166
+ layersArtboard = null,
164
167
  onSelectArtboard,
165
168
  // S11.9 — Layers › Advanced › Select by selector: posts `select-by-selector {selector}` to the open canvas.
166
169
  onSelectBySelector,
@@ -551,16 +554,27 @@ export function InspectorPanel({
551
554
  const el = Array.isArray(selected) ? selected[0] : selected;
552
555
  // gate-b-polish3 (08 · ak-mixed-fit / 14) — the Layers tab by artboard: every artboard a row (kind glyph +
553
556
  // label), the tree of the one you are in nested under it. No artboard list known → the tree alone.
557
+ // 2.0.7 fix (decision `v2-207-layers-current`): the marked row is the artboard you are on, and only THAT artboard's
558
+ // tree is drawn under it — a tree that is late or for another artboard leaves the row busy until its own lands.
559
+ const markedBoard = currentBoard({
560
+ boards: layersBoards ?? [],
561
+ onBoard: layersArtboard,
562
+ selectedArtboard: el?.artboardId ?? null,
563
+ treeArtboard: layersTree?.artboardId ?? emptyBoard?.artboardId ?? null,
564
+ });
565
+ const layersShown = treeOfBoard(layersTree, markedBoard);
566
+ const layersPending = !!markedBoard && !layersShown;
567
+ // 2.0.7 (decision `v2-207-pages-stale-selection`) — the selection's own layer path (the fallback for an empty
568
+ // tree) may be drawn under the marked row only when the selection is on that artboard: under "NOVÝ v3 · A1" it
569
+ // drew a path ending in another artboard (`article[data-dc-screen="spine-home-entry"]`).
570
+ const selOnMarked = !markedBoard || el?.artboardId === markedBoard;
554
571
  const byArtboard = (inner) => (
555
572
  <ArtboardLayers
556
573
  boards={layersBoards}
557
574
  canvasName={layersCanvasName}
558
575
  count={artboardCount}
559
- current={currentBoard({
560
- boards: layersBoards ?? [],
561
- treeArtboard: layersTree?.artboardId ?? emptyBoard?.artboardId ?? null,
562
- selectedArtboard: el?.artboardId ?? null,
563
- })}
576
+ current={markedBoard}
577
+ pending={layersPending}
564
578
  onPick={onSelectArtboard}
565
579
  >
566
580
  {inner}
@@ -721,16 +735,23 @@ export function InspectorPanel({
721
735
  </div>
722
736
  ) : effTab === 'layers' &&
723
737
  emptyBoard &&
724
- layersTree?.artboardId === emptyBoard.artboardId &&
725
- !layersTree?.nodes?.length ? (
738
+ layersShown?.artboardId === emptyBoard.artboardId &&
739
+ !layersShown?.nodes?.length ? (
726
740
  byArtboard(<LayersEmpty artboard={emptyBoard.label} />)
727
- ) : effTab === 'layers' && layersBoards?.length && !el && !layersTree?.nodes?.length ? (
741
+ ) : effTab === 'layers' && layersPending ? (
742
+ // the artboard you are on is marked; its own tree is on its way (never another artboard's in its place)
728
743
  byArtboard(null)
729
- ) : !el && !(effTab === 'layers' && layersTree?.nodes?.length) && (dsTruth || dsSystem) ? (
744
+ ) : effTab === 'layers' &&
745
+ layersBoards?.length &&
746
+ (!el || !selOnMarked) &&
747
+ !layersShown?.nodes?.length ? (
748
+ // the marked artboard's tree is empty: nothing under its row (never another artboard's path in its place)
749
+ byArtboard(null)
750
+ ) : !el && !(effTab === 'layers' && layersShown?.nodes?.length) && (dsTruth || dsSystem) ? (
730
751
  // c7 · 13 truth shots: a waiting review is the whole empty place — the system block (Which way changes flow,
731
752
  // Advanced) is what it shows when nothing else is waiting (advanced.jsx header)
732
753
  <>{dsTruth || dsSystem}</>
733
- ) : !el && !(effTab === 'layers' && layersTree?.nodes?.length) ? (
754
+ ) : !el && !(effTab === 'layers' && layersShown?.nodes?.length) ? (
734
755
  <div className="sh-rp-empty">
735
756
  {/* <p> wrapper — sh-rp-empty is a flex column, bare text nodes +
736
757
  kbd would stack as stretched flex items. */}
@@ -738,7 +759,7 @@ export function InspectorPanel({
738
759
  </div>
739
760
  ) : effTab === 'layers' ? (
740
761
  byArtboard(
741
- layersTree?.nodes?.length ? (
762
+ layersShown?.nodes?.length ? (
742
763
  <>
743
764
  {/* gate-b-polish3 — the key strip is no longer default chrome (README: no dev chrome in the
744
765
  default view); the same words ride on the tree as its tooltip and its accessible description. */}
@@ -753,7 +774,7 @@ export function InspectorPanel({
753
774
  ref={layerTreeRef}
754
775
  onKeyDown={onTreeKeyDown}
755
776
  >
756
- {withSlot(layersTree.nodes, layersSlot).map((n, ni) => (
777
+ {withSlot(layersShown.nodes, layersSlot).map((n, ni) => (
757
778
  <LayerRow
758
779
  key={`${n.id}:${n.index}`}
759
780
  node={n}
@@ -795,7 +816,7 @@ export function InspectorPanel({
795
816
  {reorderMsg}
796
817
  </div>
797
818
  </>
798
- ) : el && Array.isArray(el.dom_path) && el.dom_path.length ? (
819
+ ) : el && selOnMarked && Array.isArray(el.dom_path) && el.dom_path.length ? (
799
820
  el.dom_path.map((node, i) => (
800
821
  <div
801
822
  key={i}