@1agh/maude 2.0.3 → 2.0.6

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 (242) hide show
  1. package/README.md +6 -5
  2. package/apps/hub/src/project-transactions/kernel.mjs +10 -1
  3. package/apps/studio/access/filters.ts +12 -5
  4. package/apps/studio/access/known-canvases.ts +24 -1
  5. package/apps/studio/access/refused-inputs.ts +89 -0
  6. package/apps/studio/access/request.ts +0 -1
  7. package/apps/studio/acp/adapter-stderr.ts +43 -13
  8. package/apps/studio/acp/background-tasks.ts +155 -0
  9. package/apps/studio/acp/bridge.ts +44 -5
  10. package/apps/studio/acp/connected-fact.ts +15 -4
  11. package/apps/studio/acp/index.ts +14 -5
  12. package/apps/studio/actions/agents.ts +10 -0
  13. package/apps/studio/actions/defs/app.ts +12 -0
  14. package/apps/studio/actions/defs/view.ts +12 -0
  15. package/apps/studio/actions.manifest.json +25 -1
  16. package/apps/studio/actions.parity.json +13 -1
  17. package/apps/studio/annotations/ui/element-node.tsx +139 -54
  18. package/apps/studio/annotations/ui/lod.tsx +1 -1
  19. package/apps/studio/annotations/ui/text-style.ts +1 -1
  20. package/apps/studio/annotations-layer.tsx +0 -12
  21. package/apps/studio/api.ts +73 -24
  22. package/apps/studio/artboard-live-gate.tsx +267 -0
  23. package/apps/studio/artboard-live.ts +336 -0
  24. package/apps/studio/artboard-webgl.ts +668 -0
  25. package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
  26. package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
  27. package/apps/studio/bin/_canvas-reasons.mjs +34 -0
  28. package/apps/studio/bin/_ds-check-live.mjs +37 -0
  29. package/apps/studio/bin/_ds-check.mjs +4 -1
  30. package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
  31. package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
  32. package/apps/studio/bin/_import-asset.mjs +2 -1
  33. package/apps/studio/bin/_perf-probe.mjs +2 -1
  34. package/apps/studio/bin/_png-playwright.mjs +10 -1
  35. package/apps/studio/bin/_pw-launch.mjs +14 -0
  36. package/apps/studio/bin/_studio-verb.mjs +24 -3
  37. package/apps/studio/bin/_thumb-blank.mjs +70 -0
  38. package/apps/studio/bin/_thumb-cover.mjs +35 -0
  39. package/apps/studio/bin/_thumbs-playwright.mjs +93 -13
  40. package/apps/studio/bin/ds-check.sh +5 -1
  41. package/apps/studio/bin/perf.sh +11 -1
  42. package/apps/studio/bin/server-up.sh +7 -2
  43. package/apps/studio/bin/smoke.sh +19 -0
  44. package/apps/studio/boot-progress.ts +31 -0
  45. package/apps/studio/canvas-build-sandbox.ts +275 -42
  46. package/apps/studio/canvas-build-worker.ts +10 -0
  47. package/apps/studio/canvas-create.ts +24 -0
  48. package/apps/studio/canvas-lib.tsx +131 -12
  49. package/apps/studio/canvas-module-cache.ts +93 -0
  50. package/apps/studio/canvas-source/errors.ts +39 -0
  51. package/apps/studio/canvas-source/waiting.ts +290 -0
  52. package/apps/studio/client/actions/shell-key-handlers.js +5 -0
  53. package/apps/studio/client/app.jsx +19 -9
  54. package/apps/studio/client/canvas-url.js +13 -0
  55. package/apps/studio/client/github.js +23 -3
  56. package/apps/studio/client/home/HomeAccounts.jsx +262 -0
  57. package/apps/studio/client/home/Shelves.jsx +4 -3
  58. package/apps/studio/client/home/home-accounts-model.js +121 -0
  59. package/apps/studio/client/home/home-api.js +36 -19
  60. package/apps/studio/client/home/home-app.jsx +141 -40
  61. package/apps/studio/client/home/home-model.js +172 -6
  62. package/apps/studio/client/home/home.css +169 -5
  63. package/apps/studio/client/home/shell-mode.js +8 -1
  64. package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
  65. package/apps/studio/client/hooks/use-project-data.jsx +2 -0
  66. package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
  67. package/apps/studio/client/hooks/use-tabs.jsx +64 -35
  68. package/apps/studio/client/index-loader.ts +23 -3
  69. package/apps/studio/client/panels/ChatPanel.jsx +49 -57
  70. package/apps/studio/client/panels/CreateProject.jsx +19 -5
  71. package/apps/studio/client/panels/DiffView.jsx +314 -248
  72. package/apps/studio/client/panels/TeamProjects.jsx +119 -69
  73. package/apps/studio/client/panels/acp-runtime.js +25 -0
  74. package/apps/studio/client/panels/caps-cache.js +46 -0
  75. package/apps/studio/client/panels/chat-finish.js +66 -0
  76. package/apps/studio/client/shell/frame-cap.js +53 -0
  77. package/apps/studio/client/shell/viewport.jsx +45 -8
  78. package/apps/studio/client/styles/_index.css +2 -0
  79. package/apps/studio/client/tree/tree.jsx +48 -21
  80. package/apps/studio/client/v2/access/access-client.js +2 -0
  81. package/apps/studio/client/v2/access/access-host.jsx +12 -1
  82. package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
  83. package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
  84. package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
  85. package/apps/studio/client/v2/ai/Composer.jsx +27 -10
  86. package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
  87. package/apps/studio/client/v2/ai/ai-run.css +87 -3
  88. package/apps/studio/client/v2/ai/background-model.js +113 -0
  89. package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
  90. package/apps/studio/client/v2/ai/run-api.js +7 -3
  91. package/apps/studio/client/v2/ai/runs-store.js +2 -1
  92. package/apps/studio/client/v2/annotations/vote-store.js +11 -5
  93. package/apps/studio/client/v2/assets/asset-state-lane.js +6 -3
  94. package/apps/studio/client/v2/assets/assets-bus.js +10 -8
  95. package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
  96. package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
  97. package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
  98. package/apps/studio/client/v2/assets/spotlight.css +153 -0
  99. package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
  100. package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
  101. package/apps/studio/client/v2/assets/tile.jsx +3 -0
  102. package/apps/studio/client/v2/assets/use-assets.js +2 -1
  103. package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
  104. package/apps/studio/client/v2/canvases/covers.js +11 -5
  105. package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
  106. package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
  107. package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
  108. package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
  109. package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
  110. package/apps/studio/client/v2/canvases/use-pins.js +2 -1
  111. package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
  112. package/apps/studio/client/v2/code/canvas-imports-card.jsx +15 -14
  113. package/apps/studio/client/v2/code/canvas-imports-words.js +44 -0
  114. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
  115. package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
  116. package/apps/studio/client/v2/code/code-bus.js +5 -0
  117. package/apps/studio/client/v2/code/code.css +67 -0
  118. package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
  119. package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
  120. package/apps/studio/client/v2/create/name-dialog.css +10 -0
  121. package/apps/studio/client/v2/ds/advanced-host.jsx +11 -23
  122. package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
  123. package/apps/studio/client/v2/ds/library-host.jsx +45 -45
  124. package/apps/studio/client/v2/ds/make-host.jsx +13 -12
  125. package/apps/studio/client/v2/ds/off-system-host.jsx +18 -16
  126. package/apps/studio/client/v2/ds/review-host.jsx +7 -1
  127. package/apps/studio/client/v2/ds/truth-host.jsx +15 -14
  128. package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
  129. package/apps/studio/client/v2/empty/arriving.jsx +29 -12
  130. package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
  131. package/apps/studio/client/v2/empty/not-local.jsx +31 -1
  132. package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
  133. package/apps/studio/client/v2/export/last-finished.js +2 -1
  134. package/apps/studio/client/v2/history/branch-actions.js +13 -9
  135. package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
  136. package/apps/studio/client/v2/history/git-model.js +21 -5
  137. package/apps/studio/client/v2/history/git-parts.jsx +76 -43
  138. package/apps/studio/client/v2/history/history.css +6 -0
  139. package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
  140. package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
  141. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
  142. package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
  143. package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
  144. package/apps/studio/client/v2/presence/faces.jsx +42 -14
  145. package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
  146. package/apps/studio/client/v2/search/search-recent.js +3 -1
  147. package/apps/studio/client/v2/search/search-remote.js +6 -4
  148. package/apps/studio/client/v2/settings/connections-model.js +1 -1
  149. package/apps/studio/client/v2/shell/account-card.jsx +10 -4
  150. package/apps/studio/client/v2/shell/canvas-crash-guard.js +137 -0
  151. package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
  152. package/apps/studio/client/v2/shell/menu-runner.js +12 -0
  153. package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
  154. package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
  155. package/apps/studio/client/v2/shell/project-account-model.js +182 -0
  156. package/apps/studio/client/v2/shell/recovery-store.js +2 -1
  157. package/apps/studio/client/v2/shell/served-routes.js +120 -0
  158. package/apps/studio/client/v2/shell/share-cluster-host.jsx +139 -11
  159. package/apps/studio/client/v2/shell/share-cluster.css +58 -0
  160. package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
  161. package/apps/studio/client/v2/shell/shell-activity.js +19 -0
  162. package/apps/studio/client/v2/shell/team-switch.js +94 -0
  163. package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
  164. package/apps/studio/client/v2/shell/use-account.js +8 -1
  165. package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
  166. package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
  167. package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
  168. package/apps/studio/cloud/endpoints.ts +23 -1
  169. package/apps/studio/collab/persistence.ts +9 -1
  170. package/apps/studio/collab/registry.ts +32 -0
  171. package/apps/studio/collab/room.ts +8 -0
  172. package/apps/studio/config-reload-wire.ts +53 -0
  173. package/apps/studio/dist/client.bundle.js +1098 -1102
  174. package/apps/studio/dist/styles.css +1 -1
  175. package/apps/studio/ds/board/specimen.tsx +12 -1
  176. package/apps/studio/ds/canvas-cli.ts +58 -2
  177. package/apps/studio/ds/check.ts +26 -1
  178. package/apps/studio/ds/cli.ts +7 -3
  179. package/apps/studio/ds/convert.ts +34 -6
  180. package/apps/studio/ds/ds-verb.ts +13 -0
  181. package/apps/studio/ds/post-build.ts +38 -0
  182. package/apps/studio/ds/upgrade-apply.ts +27 -5
  183. package/apps/studio/ds/upgrade-cli.ts +22 -2
  184. package/apps/studio/ds/upgrade-prove.ts +198 -15
  185. package/apps/studio/ds/upgrade-stage.ts +4 -1
  186. package/apps/studio/editing/minimap-context.tsx +3 -3
  187. package/apps/studio/editing/page-activity.ts +251 -0
  188. package/apps/studio/editing/rotate-handle.tsx +9 -5
  189. package/apps/studio/editing/sticky-name.tsx +4 -4
  190. package/apps/studio/history/restore-artboard-action.ts +40 -0
  191. package/apps/studio/history/trash.ts +6 -0
  192. package/apps/studio/home/accounts.ts +87 -0
  193. package/apps/studio/home/hub.ts +77 -175
  194. package/apps/studio/home/index-reader.ts +24 -2
  195. package/apps/studio/home/routes.ts +66 -8
  196. package/apps/studio/http.ts +131 -68
  197. package/apps/studio/index-flight.ts +40 -0
  198. package/apps/studio/managed-projects.ts +52 -24
  199. package/apps/studio/migrate/hub.ts +7 -1
  200. package/apps/studio/routes/canvas-source.ts +44 -2
  201. package/apps/studio/routes/ds-convert.ts +18 -0
  202. package/apps/studio/routes/history.ts +28 -5
  203. package/apps/studio/routes/hub-signin.ts +115 -0
  204. package/apps/studio/routes/index.ts +4 -0
  205. package/apps/studio/routes/table.ts +7 -0
  206. package/apps/studio/routes/trash.ts +19 -1
  207. package/apps/studio/server.ts +19 -10
  208. package/apps/studio/sync/accepted-cold-start.ts +54 -16
  209. package/apps/studio/sync/accepted-link.ts +9 -4
  210. package/apps/studio/sync/asset-push.ts +146 -23
  211. package/apps/studio/sync/asset-state.ts +3 -2
  212. package/apps/studio/sync/code-module-consent.ts +74 -0
  213. package/apps/studio/sync/file-ledger.ts +35 -0
  214. package/apps/studio/sync/file-membership.ts +28 -3
  215. package/apps/studio/sync/file-plane.ts +483 -86
  216. package/apps/studio/sync/file-pull.ts +304 -33
  217. package/apps/studio/sync/hub-browser-signin.ts +377 -0
  218. package/apps/studio/sync/hub-link.ts +1 -2
  219. package/apps/studio/sync/hub-text-undo.ts +30 -10
  220. package/apps/studio/sync/index.ts +381 -161
  221. package/apps/studio/sync/journal-client.ts +94 -5
  222. package/apps/studio/sync/pending-deletes.ts +100 -0
  223. package/apps/studio/sync/projection.ts +121 -14
  224. package/apps/studio/sync/pull-pacer.ts +160 -0
  225. package/apps/studio/sync/pull-priority.ts +119 -0
  226. package/apps/studio/sync/seed-progress.ts +58 -3
  227. package/apps/studio/sync/status.ts +3 -1
  228. package/apps/studio/sync/transaction-client.ts +71 -6
  229. package/apps/studio/sync/workspace-signin.ts +6 -256
  230. package/apps/studio/sync/writer-registry.ts +5 -1
  231. package/apps/studio/thumbs/service.ts +12 -2
  232. package/apps/studio/thumbs/validate.ts +7 -0
  233. package/apps/studio/ui-prefs-migrate.ts +4 -0
  234. package/apps/studio/video-comp.tsx +23 -0
  235. package/apps/studio/video-links-overlay.tsx +3 -2
  236. package/apps/studio/whats-new.json +126 -0
  237. package/cli/lib/bash-guard.mjs +13 -1
  238. package/cli/lib/design-help.gen.mjs +1 -1
  239. package/cli/lib/design-hook.mjs +20 -0
  240. package/cli/lib/studio-locate.mjs +35 -10
  241. package/cli/lib/workspace-plan.mjs +14 -0
  242. package/package.json +8 -8
@@ -0,0 +1,290 @@
1
+ // What a canvas is still waiting for — 2.0.4 task B (decision `v2-204-canvas-waiting-from-ledger`).
2
+ //
3
+ // A canvas that imports a file this Mac does not hold yet cannot load: its import walk finds nothing
4
+ // at the path, the frame is refused, and the old card said "<Canvas> can't be drawn right now" — on a
5
+ // second Mac doing a 1.5 h first sync, while the file was simply still coming (or held back by the
6
+ // code-module consent). This module answers WHY, from two things the server already has:
7
+ //
8
+ // 1. the canvas's import closure, walked on disk (the same specifier rules as the access closure,
9
+ // `relativeImportGroups`): every relative import of the canvas and of what it imports, and
10
+ // which of them resolve to nothing here;
11
+ // 2. the file plane's ledger (the doručenka, `sync/file-ledger.ts`), which knows per path whether
12
+ // the hub offered it (`remoteHash`), whether it is held (`stuck` / `refused`) and why.
13
+ //
14
+ // Per missing import: `{ rel, state: 'downloading' | 'waiting' | 'refused', reason? }`. `reason` is
15
+ // one of OUR words (`WaitingReason`) — never the ledger's `reason` text, which can embed a snippet of
16
+ // a hub error body (`failureReason()`), so a hub cannot put sentences on this card. Plus how far the
17
+ // canvas got (`need: { here, total }` files) and the whole project's first sync (`progress:
18
+ // { delivered, total }`, the same fold the sync status reports — `computeSeedProgress`).
19
+ //
20
+ // A READ: no file content leaves here (only design-root-relative paths), nothing is written, the hub
21
+ // is never asked. An import that is missing and that the ledger does not explain (sync converged, the
22
+ // hub never had it) is a genuine mistake in the code — it is not reported, and the ordinary error card
23
+ // stays.
24
+ //
25
+ // The ledger is read from its own file (`<designRoot>/_state/file-ledger/<hubId>.json`, which the file
26
+ // plane persists for "tests and the panel"), so this needs no handle on the live runtime. It is
27
+ // runtime state of THIS Mac (DDR-115: `_state/` never syncs), and even a planted one only steers which
28
+ // of our own words appear for paths the canvas itself imports.
29
+
30
+ import { readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
31
+ import path from 'node:path';
32
+
33
+ import { relativeImportGroups } from '../access/closure.ts';
34
+ import { isUnderOrEqual } from '../path-containment.ts';
35
+ import type { LedgerRow } from '../sync/file-ledger.ts';
36
+ import { classifyProjectFile } from '../sync/file-membership.ts';
37
+ import { computeSeedProgress } from '../sync/seed-progress.ts';
38
+
39
+ export type WaitingState = 'downloading' | 'waiting' | 'refused';
40
+
41
+ /** Our own words for why a file is held. The card turns each into a sentence. */
42
+ export type WaitingReason =
43
+ /** A code module (.ts/.js) from a hub this Mac has not accepted shared code from. */
44
+ | 'code-consent'
45
+ /** Over the file plane's size ceiling — it never moves. */
46
+ | 'too-large'
47
+ /** The workspace's upload allowance is spent for now. */
48
+ | 'quota'
49
+ /** The workspace refused it for good. */
50
+ | 'refused'
51
+ /** A try failed; the plane tries again by itself. */
52
+ | 'retrying'
53
+ /** Something references it and no peer has shared it yet. */
54
+ | 'not-shared';
55
+
56
+ export interface WaitingFile {
57
+ /** design-root-relative */
58
+ rel: string;
59
+ state: WaitingState;
60
+ reason?: WaitingReason;
61
+ }
62
+
63
+ export interface CanvasWaiting {
64
+ /** Refused first, then downloading, then waiting; at most `MAX_WAITING_FILES`. */
65
+ files: WaitingFile[];
66
+ /** How many more are missing past `files`. */
67
+ more: number;
68
+ /** The files this canvas needs: the canvas, what it imports (transitively), the missing ones. */
69
+ need: { here: number; total: number };
70
+ /** The whole project's sync: files delivered of files tracked. Null when not asked for. */
71
+ progress: { delivered: number; total: number } | null;
72
+ }
73
+
74
+ /** What the module reads of the ledger. */
75
+ export interface LedgerView {
76
+ rows: Record<string, LedgerRow>;
77
+ /** How far through the journal this Mac has read; 0 = the first read has not landed. */
78
+ cursor: number;
79
+ }
80
+
81
+ /** Files named in an answer (the card shows five). */
82
+ export const MAX_WAITING_FILES = 20;
83
+ /** The walk stops after this many files (no canvas comes near it). */
84
+ const MAX_WALK = 400;
85
+ /** A ledger file larger than this is not parsed (5 041 rows is ~2 MB). */
86
+ const MAX_LEDGER_BYTES = 64 * 1024 * 1024;
87
+ /** Files whose text can import something. */
88
+ const SCAN_RE = /\.(tsx|ts|jsx|js|mjs|cjs|css)$/i;
89
+
90
+ /**
91
+ * The file plane's own sentence for a code module it will not land (`sync/file-plane.ts`, the
92
+ * receive half of the code-module gate). Matched EXACTLY and only together with our own
93
+ * classification of the path — `test/canvas-waiting.test.ts` holds it equal to the plane's text.
94
+ */
95
+ export const CODE_CONSENT_REASON =
96
+ 'code modules replicate only from an owner-vouched or loopback hub';
97
+
98
+ // ── the ledger, from disk ───────────────────────────────────────────────────────────────────────
99
+
100
+ let ledgerMemo: { key: string; view: LedgerView | null } | null = null;
101
+
102
+ /**
103
+ * The newest ledger under `<designRoot>/_state/file-ledger/` (one per hub; a relinked project keeps
104
+ * the old hub's file beside it), or null when this project has none — not linked, a cell, or the
105
+ * first pass has not flushed yet. Re-parsed only when the file changes.
106
+ */
107
+ export function readLedgerView(designRoot: string): LedgerView | null {
108
+ const dir = path.join(designRoot, '_state', 'file-ledger');
109
+ let newest: { file: string; mtimeMs: number; size: number } | null = null;
110
+ try {
111
+ for (const name of readdirSync(dir)) {
112
+ if (!name.endsWith('.json')) continue;
113
+ const file = path.join(dir, name);
114
+ const st = statSync(file);
115
+ if (!st.isFile() || st.size > MAX_LEDGER_BYTES) continue;
116
+ if (!newest || st.mtimeMs > newest.mtimeMs)
117
+ newest = { file, mtimeMs: st.mtimeMs, size: st.size };
118
+ }
119
+ } catch {
120
+ return null;
121
+ }
122
+ if (!newest) return null;
123
+ const key = `${newest.file}:${newest.mtimeMs}:${newest.size}`;
124
+ if (ledgerMemo?.key === key) return ledgerMemo.view;
125
+ let view: LedgerView | null = null;
126
+ try {
127
+ const data = JSON.parse(readFileSync(newest.file, 'utf8')) as {
128
+ rows?: unknown;
129
+ cursor?: unknown;
130
+ };
131
+ if (data && typeof data.rows === 'object' && data.rows !== null && !Array.isArray(data.rows))
132
+ view = {
133
+ rows: data.rows as Record<string, LedgerRow>,
134
+ cursor: typeof data.cursor === 'number' && Number.isFinite(data.cursor) ? data.cursor : 0,
135
+ };
136
+ } catch {
137
+ view = null;
138
+ }
139
+ ledgerMemo = { key, view };
140
+ return view;
141
+ }
142
+
143
+ // ── the walk ────────────────────────────────────────────────────────────────────────────────────
144
+
145
+ /** A regular file at `abs`, held inside the design root (symlinks resolved), or false. */
146
+ function isHereFile(abs: string, rootReal: string): boolean {
147
+ try {
148
+ const real = realpathSync(abs);
149
+ return isUnderOrEqual(real, rootReal) && statSync(real).isFile();
150
+ } catch {
151
+ return false;
152
+ }
153
+ }
154
+
155
+ const relOf = (designRoot: string, abs: string) =>
156
+ path.relative(designRoot, abs).split(path.sep).join('/');
157
+
158
+ /**
159
+ * The canvas's import closure on disk: the files that are here, and every import that resolves to
160
+ * none of its candidates (one candidate list per specifier, design-root-relative).
161
+ */
162
+ export function walkCanvasImports(
163
+ designRoot: string,
164
+ canvasAbs: string
165
+ ): { here: string[]; missing: string[][] } {
166
+ const root = path.resolve(designRoot);
167
+ let rootReal: string;
168
+ try {
169
+ rootReal = realpathSync(root);
170
+ } catch {
171
+ return { here: [], missing: [] };
172
+ }
173
+ const here: string[] = [];
174
+ const missing: string[][] = [];
175
+ const seen = new Set<string>();
176
+ const missingSeen = new Set<string>();
177
+ const queue = [path.resolve(canvasAbs)];
178
+ while (queue.length && seen.size < MAX_WALK) {
179
+ const abs = queue.shift() as string;
180
+ if (seen.has(abs)) continue;
181
+ seen.add(abs);
182
+ if (!isHereFile(abs, rootReal)) continue;
183
+ here.push(relOf(root, abs));
184
+ if (!SCAN_RE.test(abs)) continue;
185
+ let text: string;
186
+ try {
187
+ text = readFileSync(abs, 'utf8');
188
+ } catch {
189
+ continue;
190
+ }
191
+ for (const group of relativeImportGroups(text, abs, root)) {
192
+ if (!group.length) continue; // points outside the design root: not ours to explain
193
+ const found = group.find((c) => isHereFile(c, rootReal));
194
+ if (found) {
195
+ if (!seen.has(found)) queue.push(found);
196
+ continue;
197
+ }
198
+ const rels = group.map((c) => relOf(root, c));
199
+ const key = rels.join('\n');
200
+ if (missingSeen.has(key)) continue;
201
+ missingSeen.add(key);
202
+ missing.push(rels);
203
+ }
204
+ }
205
+ return { here, missing };
206
+ }
207
+
208
+ // ── one missing import, explained ───────────────────────────────────────────────────────────────
209
+
210
+ /** The name to show for an import the ledger has no row for: the one candidate, or the base. */
211
+ function shownRel(group: string[]): string {
212
+ if (group.length === 1) return group[0] as string;
213
+ const tsx = group.find((r) => r.endsWith('.tsx'));
214
+ return tsx ? tsx.slice(0, -'.tsx'.length) : (group[0] as string);
215
+ }
216
+
217
+ /** Why `rel` (a ledger row) is not here, in our words — or null when the ledger does not explain it. */
218
+ export function explainRow(rel: string, row: LedgerRow, syncing: boolean): WaitingFile | null {
219
+ switch (row.state) {
220
+ case 'refused':
221
+ if (row.blockedClass === 'unreachable') return { rel, state: 'waiting', reason: 'retrying' };
222
+ return {
223
+ rel,
224
+ state: 'refused',
225
+ reason:
226
+ row.blockedClass === 'too-large'
227
+ ? 'too-large'
228
+ : row.blockedClass === 'quota'
229
+ ? 'quota'
230
+ : 'refused',
231
+ };
232
+ case 'stuck':
233
+ // the receive half of the code-module gate: only OUR sentence AND our own class of the path
234
+ if (row.reason === CODE_CONSENT_REASON && classifyProjectFile(rel) === 'code-module')
235
+ return { rel, state: 'refused', reason: 'code-consent' };
236
+ return { rel, state: 'waiting', reason: 'retrying' };
237
+ case 'referenced-but-unoffered':
238
+ return { rel, state: 'waiting', reason: 'not-shared' };
239
+ default:
240
+ break;
241
+ }
242
+ if (typeof row.remoteHash === 'string' && row.remoteHash) return { rel, state: 'downloading' };
243
+ // the hub has not offered it (or said it has none): only a sync still under way explains that
244
+ return syncing ? { rel, state: 'waiting' } : null;
245
+ }
246
+
247
+ function explainGroup(group: string[], ledger: LedgerView, syncing: boolean): WaitingFile | null {
248
+ const rows = group
249
+ .map((rel) => [rel, Object.hasOwn(ledger.rows, rel) ? ledger.rows[rel] : undefined] as const)
250
+ .filter((e): e is readonly [string, LedgerRow] => !!e[1] && typeof e[1] === 'object');
251
+ // the candidate the hub offered wins; else any row; else none
252
+ const best = rows.find(([, r]) => typeof r.remoteHash === 'string' && r.remoteHash) ?? rows[0];
253
+ if (best) return explainRow(best[0], best[1], syncing);
254
+ return syncing ? { rel: shownRel(group), state: 'waiting' } : null;
255
+ }
256
+
257
+ const RANK: Record<WaitingState, number> = { refused: 0, downloading: 1, waiting: 2 };
258
+
259
+ /**
260
+ * What `canvasAbs` is waiting for, or null when nothing it imports is missing for a reason the sync
261
+ * explains (then the ordinary error card is the truth). `project: false` leaves out the project's
262
+ * totals (a canvas-only session learns nothing about the rest of the project).
263
+ */
264
+ export function canvasWaiting(opts: {
265
+ designRoot: string;
266
+ canvasAbs: string;
267
+ ledger: LedgerView | null;
268
+ project?: boolean;
269
+ now?: number;
270
+ }): CanvasWaiting | null {
271
+ const { ledger } = opts;
272
+ if (!ledger) return null;
273
+ const walk = walkCanvasImports(opts.designRoot, opts.canvasAbs);
274
+ if (!walk.missing.length) return null;
275
+ const seed = computeSeedProgress({ rows: ledger.rows, now: opts.now ?? Date.now() });
276
+ const syncing = ledger.cursor === 0 || seed.remaining > 0;
277
+ const explained: WaitingFile[] = [];
278
+ for (const group of walk.missing) {
279
+ const w = explainGroup(group, ledger, syncing);
280
+ if (w) explained.push(w);
281
+ }
282
+ if (!explained.length) return null;
283
+ explained.sort((a, b) => RANK[a.state] - RANK[b.state] || a.rel.localeCompare(b.rel));
284
+ return {
285
+ files: explained.slice(0, MAX_WAITING_FILES),
286
+ more: Math.max(0, explained.length - MAX_WAITING_FILES),
287
+ need: { here: walk.here.length, total: walk.here.length + walk.missing.length },
288
+ progress: opts.project === false ? null : { delivered: seed.delivered, total: seed.tracked },
289
+ };
290
+ }
@@ -180,6 +180,11 @@ export const SHELL_KEY_HANDLERS = {
180
180
  e.preventDefault();
181
181
  runAssetsAction('assets.details');
182
182
  },
183
+ // 2.0.4 (#191) — Space on a picked tile: the same window a double-click opens
184
+ 'assets.spotlight': (_d, { event: e }) => {
185
+ e.preventDefault();
186
+ runAssetsAction('assets.spotlight');
187
+ },
183
188
  // S8.16 — ← → on a selected picture with other takes: the neighbouring take in its place (image.replace, one undo step)
184
189
  'image.next-take': (d, { event: e }) => {
185
190
  e.preventDefault();
@@ -232,6 +232,7 @@ import { ExportDialog, downloadCapturedBlob } from './dialogs/export-dialog.jsx'
232
232
  import { Sidebar } from './tree/tree.jsx';
233
233
  import { CornerIcons } from './v2/shell/corner-icons.jsx';
234
234
  import ShellErrorBoundary from './v2/shell/shell-error-boundary.jsx';
235
+ import { expectServedFrom, setServedFrom } from './v2/shell/served-routes.js';
235
236
  import { cutCopyPaste, createMenuHandlers, menuRunner } from './v2/shell/menu-runner.js';
236
237
  import DiagnosticsHost from './v2/diagnostics/diagnostics-host.jsx';
237
238
  import { useDiagnosticsMenu } from './v2/diagnostics/use-diagnostics-menu.js';
@@ -3477,8 +3478,12 @@ function ShellTree() {
3477
3478
  /^r\d+$/.test(version || '') ? Number(version.slice(1)) : NaN
3478
3479
  )
3479
3480
  : await gitDiscard([file]);
3480
- if (res?.ok) setDiffTarget(null);
3481
- else window.alert(res?.error || 'Could not restore that version. Try again.');
3481
+ if (res?.ok) {
3482
+ setDiffTarget(null);
3483
+ return res;
3484
+ }
3485
+ // The sheet says why, inside itself (DiffView): `window.alert` shows nothing in the desktop app.
3486
+ return { ok: false, error: res?.error || 'Could not restore that version. Try again.' };
3482
3487
  }}
3483
3488
  onResolve={async (choice) => {
3484
3489
  // phase-28 (E3): apply the chosen side via /_api/git/resolve, which
@@ -3488,11 +3493,12 @@ function ShellTree() {
3488
3493
  const res = await gitResolveConflict(choice);
3489
3494
  if (res.ok) {
3490
3495
  setDiffTarget(null);
3491
- } else {
3492
- window.alert(
3493
- res.error || 'Could not finish the merge. Get the latest again, then retry.'
3494
- );
3496
+ return res;
3495
3497
  }
3498
+ return {
3499
+ ok: false,
3500
+ error: res.error || 'Could not finish the merge. Get the latest again, then retry.',
3501
+ };
3496
3502
  }}
3497
3503
  />
3498
3504
  )}
@@ -3602,12 +3608,16 @@ else {
3602
3608
  // S11.13 (Gate 0 D20) — the 1.x preferences move to their v2 homes once per origin, before the
3603
3609
  // first v2 home is read (a second boot is a no-op without a request). Bounded: a slow server
3604
3610
  // never holds the first paint, and a failure leaves the 1.x keys where they are.
3611
+ // #204 R — the shell's pollers mount before `/_config` answers; they wait for it (bounded) so a
3612
+ // workspace cell is never asked a route it withholds on the way up. Home is no cell: it says so at once.
3613
+ expectServedFrom();
3605
3614
  const migrated = migrateAtBoot().catch(() => {});
3606
3615
  Promise.race([migrated, new Promise((r) => setTimeout(r, 1500))]).then(() =>
3607
- bootShellMode((mode) =>
3616
+ bootShellMode((mode) => {
3617
+ if (mode === 'home') setServedFrom(null);
3608
3618
  root.render(
3609
3619
  <ShellErrorBoundary>{mode === 'home' ? <HomeApp /> : <App />}</ShellErrorBoundary>
3610
- )
3611
- )
3620
+ );
3621
+ })
3612
3622
  );
3613
3623
  }
@@ -255,6 +255,16 @@ export function canvasImportsOf(cfg, p) {
255
255
  return Array.isArray(list) ? list.filter((x) => typeof x === 'string' && x) : null;
256
256
  }
257
257
 
258
+ /**
259
+ * 2.0.5 (#205) — the design-root files `p`'s BUILT module was refused for (it inlined a file another canvas
260
+ * owns), from the index's `canvasRefusedInputs`, or `null` when none is on record.
261
+ */
262
+ export function canvasRefusedOf(cfg, p) {
263
+ const list = cfg?.canvasRefusedInputs?.[p];
264
+ const names = Array.isArray(list) ? list.filter((x) => typeof x === 'string' && x) : [];
265
+ return names.length ? names : null;
266
+ }
267
+
258
268
  export function canvasUrl(p, cfg, opts) {
259
269
  if (!p.endsWith('.tsx')) return urlOf(p);
260
270
  const designRel = (cfg?.designRel || '.design').replace(/^\/+|\/+$/g, '');
@@ -286,6 +296,9 @@ export function canvasUrl(p, cfg, opts) {
286
296
  // Phase 27 (E2) — DiffView renders a CLEAN canvas (no editor chrome: toolbar,
287
297
  // world minimap, devtools) so the before/after is just the design.
288
298
  if (opts?.hideChrome) params.set('hide-chrome', '1');
299
+ // 2.0.5 — the too-heavy card's "Show visible artboards only": the canvas mounts only the artboards near the
300
+ // viewport (artboard-live.ts `light`). A capture (`hide-chrome`) ignores it and renders everything.
301
+ if (opts?.light) params.set('artboard-live', 'light');
289
302
  // Cloud Phase 25 C2 — the linked hub vouched a viewer role at sign-in
290
303
  // (`/_config.readOnly`), so the canvas boots read-only: edit tools and
291
304
  // mutating interactions are ABSENT from the iframe chrome (read-only-mode.ts
@@ -132,10 +132,10 @@ export const hubLink = (body) =>
132
132
 
133
133
  // ── managed team projects (plan T21/T22) ───────────────────────────────────────
134
134
  /**
135
- * Sign in / hold the credential and describe a team project, so its own copy can
135
+ * Describe a team project from the credential this computer holds, so its own copy can
136
136
  * be created without choosing a folder. body: { kind: 'cloud', projectId } |
137
- * { kind: 'handoff', code, claimedProject } | { kind: 'hub', url, email, password }
138
- * | { kind: 'known-hub', url }.
137
+ * { kind: 'handoff', code, claimedProject } | { kind: 'known-hub', url }. A body carrying an
138
+ * email or password is refused with a 400 (issue #204: sign in on the team server's own page).
139
139
  */
140
140
  export const prepareProject = (body) =>
141
141
  api('/_api/projects/prepare', { method: 'POST', body: JSON.stringify(body) });
@@ -147,6 +147,26 @@ export const managedProjectOpen = (p) =>
147
147
  name: p.name || p.projectId,
148
148
  canvasGroups: p.canvasGroups || [],
149
149
  });
150
+ /**
151
+ * Issue #204 — open a team server's own sign-in page (`/studio/signin?client=desktop…`, built by
152
+ * `/_api/hub-signin/start`) in the browser. In the app Rust opens exactly that page shape and only
153
+ * with this tab's own return address (external_link.rs `open_team_server_signin`); in a plain
154
+ * browser it is a new tab. Resolves 'ok' | 'refused' | 'failed'.
155
+ */
156
+ export function openTeamServerSignIn(url) {
157
+ if (isNativeApp()) {
158
+ return invoke('open_team_server_signin', { url }).then(
159
+ () => 'ok',
160
+ (e) => (/Refusing/i.test(String(e)) ? 'refused' : 'failed')
161
+ );
162
+ }
163
+ try {
164
+ window.open(url, '_blank', 'noopener');
165
+ return Promise.resolve('ok');
166
+ } catch {
167
+ return Promise.resolve('failed');
168
+ }
169
+ }
150
170
  /** The team projects this computer keeps a copy of, most recent first. */
151
171
  // Outside the app there are no managed copies — and invoke() throws synchronously there, which a
152
172
  // caller's `.catch()` never sees (the P8 sweep: Settings › Add a team server… crashed the browser shell).