@1agh/maude 2.0.2 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/README.md +6 -5
  2. package/apps/studio/access/request.ts +0 -1
  3. package/apps/studio/acp/adapter-stderr.ts +43 -13
  4. package/apps/studio/acp/background-tasks.ts +155 -0
  5. package/apps/studio/acp/bridge.ts +44 -5
  6. package/apps/studio/acp/connected-fact.ts +15 -4
  7. package/apps/studio/acp/index.ts +14 -5
  8. package/apps/studio/actions/agents.ts +5 -0
  9. package/apps/studio/actions/defs/view.ts +12 -0
  10. package/apps/studio/actions.manifest.json +13 -1
  11. package/apps/studio/actions.parity.json +7 -1
  12. package/apps/studio/api.ts +31 -24
  13. package/apps/studio/asset-placeholder.tsx +157 -62
  14. package/apps/studio/bin/_png-playwright.mjs +10 -1
  15. package/apps/studio/bin/_pw-launch.mjs +14 -0
  16. package/apps/studio/bin/_thumbs-playwright.mjs +4 -1
  17. package/apps/studio/boot-progress.ts +31 -0
  18. package/apps/studio/bridge/dgn-protocol.ts +34 -4
  19. package/apps/studio/canvas-build-sandbox.ts +275 -42
  20. package/apps/studio/canvas-build-worker.ts +10 -0
  21. package/apps/studio/canvas-create.ts +24 -0
  22. package/apps/studio/canvas-module-cache.ts +93 -0
  23. package/apps/studio/canvas-source/errors.ts +39 -0
  24. package/apps/studio/canvas-source/waiting.ts +290 -0
  25. package/apps/studio/client/actions/shell-key-handlers.js +5 -0
  26. package/apps/studio/client/app.jsx +22 -9
  27. package/apps/studio/client/github.js +23 -3
  28. package/apps/studio/client/home/home-api.js +30 -19
  29. package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
  30. package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
  31. package/apps/studio/client/hooks/use-tabs.jsx +64 -35
  32. package/apps/studio/client/index-loader.ts +23 -3
  33. package/apps/studio/client/panels/ChatPanel.jsx +22 -37
  34. package/apps/studio/client/panels/DiffView.jsx +314 -248
  35. package/apps/studio/client/panels/TeamProjects.jsx +119 -69
  36. package/apps/studio/client/panels/acp-runtime.js +25 -0
  37. package/apps/studio/client/panels/chat-finish.js +66 -0
  38. package/apps/studio/client/shell/frame-cap.js +53 -0
  39. package/apps/studio/client/shell/viewport.jsx +9 -0
  40. package/apps/studio/client/styles/_index.css +2 -0
  41. package/apps/studio/client/tree/tree.jsx +48 -21
  42. package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
  43. package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
  44. package/apps/studio/client/v2/ai/ai-run.css +87 -3
  45. package/apps/studio/client/v2/ai/background-model.js +113 -0
  46. package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
  47. package/apps/studio/client/v2/ai/run-api.js +7 -3
  48. package/apps/studio/client/v2/ai/runs-store.js +2 -1
  49. package/apps/studio/client/v2/annotations/vote-store.js +11 -5
  50. package/apps/studio/client/v2/assets/asset-state-lane.js +176 -8
  51. package/apps/studio/client/v2/assets/assets-bus.js +10 -8
  52. package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
  53. package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
  54. package/apps/studio/client/v2/assets/missing-frame.jsx +8 -4
  55. package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
  56. package/apps/studio/client/v2/assets/spotlight.css +153 -0
  57. package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
  58. package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
  59. package/apps/studio/client/v2/assets/tile.jsx +3 -0
  60. package/apps/studio/client/v2/assets/use-assets.js +2 -1
  61. package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
  62. package/apps/studio/client/v2/canvases/covers.js +11 -5
  63. package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
  64. package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
  65. package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
  66. package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
  67. package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
  68. package/apps/studio/client/v2/canvases/use-pins.js +2 -1
  69. package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
  70. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
  71. package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
  72. package/apps/studio/client/v2/code/code.css +67 -0
  73. package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
  74. package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
  75. package/apps/studio/client/v2/create/name-dialog.css +10 -0
  76. package/apps/studio/client/v2/ds/advanced-host.jsx +5 -2
  77. package/apps/studio/client/v2/ds/make-host.jsx +5 -2
  78. package/apps/studio/client/v2/ds/off-system-host.jsx +5 -2
  79. package/apps/studio/client/v2/ds/truth-host.jsx +5 -2
  80. package/apps/studio/client/v2/empty/arriving.jsx +29 -12
  81. package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
  82. package/apps/studio/client/v2/empty/not-local.jsx +31 -1
  83. package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
  84. package/apps/studio/client/v2/export/last-finished.js +2 -1
  85. package/apps/studio/client/v2/export/native-save.js +44 -0
  86. package/apps/studio/client/v2/history/git-model.js +18 -4
  87. package/apps/studio/client/v2/history/git-parts.jsx +60 -42
  88. package/apps/studio/client/v2/history/history.css +6 -0
  89. package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
  90. package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
  91. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
  92. package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
  93. package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
  94. package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
  95. package/apps/studio/client/v2/search/search-recent.js +3 -1
  96. package/apps/studio/client/v2/search/search-remote.js +6 -4
  97. package/apps/studio/client/v2/settings/connections-model.js +1 -1
  98. package/apps/studio/client/v2/shell/menu-runner.js +1 -0
  99. package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
  100. package/apps/studio/client/v2/shell/recovery-store.js +2 -1
  101. package/apps/studio/client/v2/shell/served-routes.js +120 -0
  102. package/apps/studio/client/v2/shell/share-cluster-host.jsx +2 -1
  103. package/apps/studio/client/v2/shell/shell-activity.js +19 -0
  104. package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
  105. package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
  106. package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
  107. package/apps/studio/cloud/endpoints.ts +23 -1
  108. package/apps/studio/dist/client.bundle.js +798 -801
  109. package/apps/studio/dist/comment-mount.js +2 -2
  110. package/apps/studio/dist/styles.css +1 -1
  111. package/apps/studio/ds-assets.ts +138 -48
  112. package/apps/studio/editing/minimap-context.tsx +3 -3
  113. package/apps/studio/editing/page-activity.ts +251 -0
  114. package/apps/studio/editing/rotate-handle.tsx +9 -5
  115. package/apps/studio/editing/sticky-name.tsx +4 -4
  116. package/apps/studio/history/restore-artboard-action.ts +40 -0
  117. package/apps/studio/home/hub.ts +77 -175
  118. package/apps/studio/home/routes.ts +47 -8
  119. package/apps/studio/http.ts +117 -66
  120. package/apps/studio/index-flight.ts +40 -0
  121. package/apps/studio/managed-projects.ts +52 -24
  122. package/apps/studio/migrate/hub.ts +7 -1
  123. package/apps/studio/routes/asset-state.ts +12 -0
  124. package/apps/studio/routes/canvas-source.ts +44 -2
  125. package/apps/studio/routes/ds-assets.ts +8 -0
  126. package/apps/studio/routes/history.ts +28 -5
  127. package/apps/studio/routes/hub-signin.ts +115 -0
  128. package/apps/studio/routes/index.ts +4 -0
  129. package/apps/studio/routes/table.ts +7 -0
  130. package/apps/studio/routes/trash.ts +3 -0
  131. package/apps/studio/server.ts +11 -0
  132. package/apps/studio/sync/accepted-cold-start.ts +26 -3
  133. package/apps/studio/sync/accepted-link.ts +9 -4
  134. package/apps/studio/sync/asset-push.ts +8 -1
  135. package/apps/studio/sync/asset-state.ts +27 -2
  136. package/apps/studio/sync/code-module-consent.ts +74 -0
  137. package/apps/studio/sync/file-ledger.ts +35 -0
  138. package/apps/studio/sync/file-plane.ts +479 -84
  139. package/apps/studio/sync/hub-browser-signin.ts +377 -0
  140. package/apps/studio/sync/hub-text-undo.ts +30 -10
  141. package/apps/studio/sync/index.ts +73 -11
  142. package/apps/studio/sync/lfs-pointer.ts +137 -0
  143. package/apps/studio/sync/projection.ts +44 -2
  144. package/apps/studio/sync/pull-pacer.ts +160 -0
  145. package/apps/studio/sync/pull-priority.ts +119 -0
  146. package/apps/studio/sync/seed-progress.ts +47 -3
  147. package/apps/studio/sync/transaction-client.ts +71 -6
  148. package/apps/studio/sync/workspace-signin.ts +6 -256
  149. package/apps/studio/sync/writer-registry.ts +5 -1
  150. package/apps/studio/video-links-overlay.tsx +3 -2
  151. package/apps/studio/whats-new.json +63 -0
  152. package/cli/lib/design-help.gen.mjs +1 -1
  153. package/cli/lib/workspace-plan.mjs +14 -0
  154. package/package.json +8 -8
@@ -0,0 +1,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';
@@ -3098,6 +3099,9 @@ function ShellTree() {
3098
3099
  const relink = useRelinkSheet({ canEdit: !viewerMode });
3099
3100
  useAssetStateLane({
3100
3101
  onRelink: relink.onRelink,
3102
+ // 2.0.3 — a Git LFS placeholder's Fix with AI / Copy prompt: where the error card offers Ask AI.
3103
+ askAiAvailable: isNativeApp() && !cfg?.readOnly,
3104
+ designRel: cfg?.designRel || cfg?.designRoot || '.design',
3101
3105
  syncStatus,
3102
3106
  wsConnected,
3103
3107
  canvasOrigin: () => cfg?.canvasOrigin || window.location.origin,
@@ -3474,8 +3478,12 @@ function ShellTree() {
3474
3478
  /^r\d+$/.test(version || '') ? Number(version.slice(1)) : NaN
3475
3479
  )
3476
3480
  : await gitDiscard([file]);
3477
- if (res?.ok) setDiffTarget(null);
3478
- 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.' };
3479
3487
  }}
3480
3488
  onResolve={async (choice) => {
3481
3489
  // phase-28 (E3): apply the chosen side via /_api/git/resolve, which
@@ -3485,11 +3493,12 @@ function ShellTree() {
3485
3493
  const res = await gitResolveConflict(choice);
3486
3494
  if (res.ok) {
3487
3495
  setDiffTarget(null);
3488
- } else {
3489
- window.alert(
3490
- res.error || 'Could not finish the merge. Get the latest again, then retry.'
3491
- );
3496
+ return res;
3492
3497
  }
3498
+ return {
3499
+ ok: false,
3500
+ error: res.error || 'Could not finish the merge. Get the latest again, then retry.',
3501
+ };
3493
3502
  }}
3494
3503
  />
3495
3504
  )}
@@ -3599,12 +3608,16 @@ else {
3599
3608
  // S11.13 (Gate 0 D20) — the 1.x preferences move to their v2 homes once per origin, before the
3600
3609
  // first v2 home is read (a second boot is a no-op without a request). Bounded: a slow server
3601
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();
3602
3614
  const migrated = migrateAtBoot().catch(() => {});
3603
3615
  Promise.race([migrated, new Promise((r) => setTimeout(r, 1500))]).then(() =>
3604
- bootShellMode((mode) =>
3616
+ bootShellMode((mode) => {
3617
+ if (mode === 'home') setServedFrom(null);
3605
3618
  root.render(
3606
3619
  <ShellErrorBoundary>{mode === 'home' ? <HomeApp /> : <App />}</ShellErrorBoundary>
3607
- )
3608
- )
3620
+ );
3621
+ })
3609
3622
  );
3610
3623
  }
@@ -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).
@@ -130,27 +130,38 @@ export const signInOpenBrowser = (userCode, state) =>
130
130
  shellInvoke('home_cloud_sign_in_open', { userCode, state });
131
131
  /** After the Home server stored the credential: Rust records the account → the profile it landed in. */
132
132
  export const signInDone = (profile) => shellInvoke('home_cloud_signed_in', { profile });
133
- // S6.9 — the Advanced sheets' routes (S6.6). Nothing here keeps or logs what it carries: the hub
134
- // password is posted once, in the body, and the answer never contains it.
133
+ // S6.9 — the Advanced sheets' routes (S6.6). Issue #204 K2: Home takes no team-server password —
134
+ // Sign in (and an invite) opens the hub's own page in the browser, and Home's server waits for the
135
+ // browser to come back (home/hub.ts). Nothing here keeps or logs what it carries.
135
136
  /** "Test connection": one tokenless GET /health on the server → `{ok, reachable, url, version}`. */
136
137
  export const hubTest = (url) => post('/_home/hub/test', { url });
137
- /** "Connect": `creds` ({email, password}) signs in; without it, a hub this Mac already holds a sign-in for. */
138
- export const hubPrepare = (profile, url, creds) =>
139
- post('/_home/hub/prepare', {
140
- profile,
141
- url,
142
- ...(creds ? { email: creds.email, password: creds.password } : {}),
143
- });
144
- /** S6.11b — "Invite link or key": redeem a hub invite (the hub's POST /join) → the same answer as
145
- * `hubPrepare`. The invite key, email and password ride this one POST body, never a URL or a log. */
146
- export const hubJoin = (profile, url, invite) =>
147
- post('/_home/hub/join', {
148
- profile,
149
- url,
150
- token: invite?.token,
151
- email: invite?.email,
152
- password: invite?.password,
153
- });
138
+ /** The project on a team server THIS profile is signed in to → the managed copy to open. */
139
+ export const hubPrepare = (profile, url) => post('/_home/hub/prepare', { profile, url });
140
+ /** #204 K2 — a sign-in (with `invite`, an invite accept) on the hub's own page →
141
+ * `{ok, id, signInUrl}` | `{ok:false, error, reason?}` (`reason: 'needs-update'` for a hub < 2.0.4). */
142
+ export const hubSignInStart = (profile, url, invite) =>
143
+ post('/_home/hub/signin/start', { profile, url, ...(invite ? { invite } : {}) });
144
+ /** → `{ok, pending}` | `{ok, url, user}` | `{ok:false, error}`. */
145
+ export const hubSignInPoll = (id) => post('/_home/hub/signin/poll', { id });
146
+ export const hubSignInCancel = (id) => post('/_home/hub/signin/cancel', { id });
147
+ /**
148
+ * Open the hub's page `hubSignInStart` answered. In the app Rust opens exactly that page shape, back
149
+ * to the Home origin only (external_link.rs `open_team_server_signin`); in a plain browser it is a
150
+ * new tab. Resolves 'ok' | 'refused' | 'failed'.
151
+ */
152
+ export function openTeamServerSignIn(url) {
153
+ if (inShell())
154
+ return shellInvoke('open_team_server_signin', { url }).then(
155
+ () => 'ok',
156
+ (e) => (/Refusing/i.test(String(e)) ? 'refused' : 'failed')
157
+ );
158
+ try {
159
+ window.open(url, '_blank', 'noopener');
160
+ return Promise.resolve('ok');
161
+ } catch {
162
+ return Promise.resolve('failed');
163
+ }
164
+ }
154
165
  /** Claude readiness →`{available, claudeInstalled, reason, install:{phase,ok?,reason?}, signinInFlight}`. */
155
166
  export const aiStatus = () => homeFetch('/_home/ai/status');
156
167
  /** step: 'install' | 'signin' | 'cancel'. */
@@ -219,7 +219,8 @@ export function useGitActions({
219
219
  setProjectHistoryRefresh((version) => version + 1);
220
220
  return result;
221
221
  }
222
- return { ok: false, error: result?.error };
222
+ // F14 — a refused restore's own line ("…a change on this Mac that isn't saved…") is the words
223
+ return { ok: false, error: result?.line || result?.error };
223
224
  }, []);
224
225
 
225
226
  // Repo-relative path → M/A/D/U badge for the tree (paths match: both the tree
@@ -59,6 +59,7 @@ import {
59
59
  import { useThemeAuto } from '../v2/settings/theme-auto.js';
60
60
  import { canvasTargetOrigin } from '../v2/kinds/kind-dim-relay.js';
61
61
  import { viewerModeOn } from '../v2/access/access-client.js';
62
+ import { setServedFrom } from '../v2/shell/served-routes.js';
62
63
 
63
64
  export function useShellCore({}) {
64
65
  const [groups, setGroups] = useState([]);
@@ -507,6 +508,8 @@ export function useShellCore({}) {
507
508
  fetch('/_config')
508
509
  .then((r) => r.json())
509
510
  .then((data) => {
511
+ // #204 — a workspace cell serves no desktop-only route: the pollers stop asking them
512
+ setServedFrom(data);
510
513
  const designRel = (data.designRoot || '.design').replace(/^\/+|\/+$/g, '');
511
514
  // Functional merge — the `/_config` and `/_index-data` fetches race, and
512
515
  // the latter contributes `canvasDesignSystems` (DDR-093). A full-replace