@1agh/maude 2.0.3 → 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 (143) 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/bin/_png-playwright.mjs +10 -1
  14. package/apps/studio/bin/_pw-launch.mjs +14 -0
  15. package/apps/studio/bin/_thumbs-playwright.mjs +4 -1
  16. package/apps/studio/boot-progress.ts +31 -0
  17. package/apps/studio/canvas-build-sandbox.ts +275 -42
  18. package/apps/studio/canvas-build-worker.ts +10 -0
  19. package/apps/studio/canvas-create.ts +24 -0
  20. package/apps/studio/canvas-module-cache.ts +93 -0
  21. package/apps/studio/canvas-source/errors.ts +39 -0
  22. package/apps/studio/canvas-source/waiting.ts +290 -0
  23. package/apps/studio/client/actions/shell-key-handlers.js +5 -0
  24. package/apps/studio/client/app.jsx +19 -9
  25. package/apps/studio/client/github.js +23 -3
  26. package/apps/studio/client/home/home-api.js +30 -19
  27. package/apps/studio/client/hooks/use-git-actions.jsx +2 -1
  28. package/apps/studio/client/hooks/use-shell-core.jsx +3 -0
  29. package/apps/studio/client/hooks/use-tabs.jsx +64 -35
  30. package/apps/studio/client/index-loader.ts +23 -3
  31. package/apps/studio/client/panels/ChatPanel.jsx +22 -37
  32. package/apps/studio/client/panels/DiffView.jsx +314 -248
  33. package/apps/studio/client/panels/TeamProjects.jsx +119 -69
  34. package/apps/studio/client/panels/acp-runtime.js +25 -0
  35. package/apps/studio/client/panels/chat-finish.js +66 -0
  36. package/apps/studio/client/shell/frame-cap.js +53 -0
  37. package/apps/studio/client/shell/viewport.jsx +9 -0
  38. package/apps/studio/client/styles/_index.css +2 -0
  39. package/apps/studio/client/tree/tree.jsx +48 -21
  40. package/apps/studio/client/v2/ai/BackgroundStrip.jsx +120 -0
  41. package/apps/studio/client/v2/ai/StoppedDivider.jsx +2 -1
  42. package/apps/studio/client/v2/ai/ai-run.css +87 -3
  43. package/apps/studio/client/v2/ai/background-model.js +113 -0
  44. package/apps/studio/client/v2/ai/needs-you-store.js +2 -1
  45. package/apps/studio/client/v2/ai/run-api.js +7 -3
  46. package/apps/studio/client/v2/ai/runs-store.js +2 -1
  47. package/apps/studio/client/v2/annotations/vote-store.js +11 -5
  48. package/apps/studio/client/v2/assets/asset-state-lane.js +6 -3
  49. package/apps/studio/client/v2/assets/assets-bus.js +10 -8
  50. package/apps/studio/client/v2/assets/browse-view.jsx +2 -0
  51. package/apps/studio/client/v2/assets/ds-library-view.jsx +47 -0
  52. package/apps/studio/client/v2/assets/spotlight-model.js +75 -0
  53. package/apps/studio/client/v2/assets/spotlight.css +153 -0
  54. package/apps/studio/client/v2/assets/spotlight.jsx +199 -0
  55. package/apps/studio/client/v2/assets/tile-menu.jsx +3 -1
  56. package/apps/studio/client/v2/assets/tile.jsx +3 -0
  57. package/apps/studio/client/v2/assets/use-assets.js +2 -1
  58. package/apps/studio/client/v2/canvases/canvases-panel.jsx +13 -2
  59. package/apps/studio/client/v2/canvases/covers.js +11 -5
  60. package/apps/studio/client/v2/canvases/folder-ask.js +139 -0
  61. package/apps/studio/client/v2/canvases/folder-dialogs.jsx +150 -0
  62. package/apps/studio/client/v2/canvases/trash-canvas.js +10 -2
  63. package/apps/studio/client/v2/canvases/trash-queue.js +152 -0
  64. package/apps/studio/client/v2/canvases/use-canvas-index.js +42 -18
  65. package/apps/studio/client/v2/canvases/use-pins.js +2 -1
  66. package/apps/studio/client/v2/code/canvas-error-card.jsx +70 -5
  67. package/apps/studio/client/v2/code/canvas-waiting-card.jsx +128 -0
  68. package/apps/studio/client/v2/code/canvas-waiting.js +164 -0
  69. package/apps/studio/client/v2/code/code.css +67 -0
  70. package/apps/studio/client/v2/code/use-canvas-source.js +19 -4
  71. package/apps/studio/client/v2/create/NameDialog.jsx +4 -2
  72. package/apps/studio/client/v2/create/name-dialog.css +10 -0
  73. package/apps/studio/client/v2/ds/advanced-host.jsx +5 -2
  74. package/apps/studio/client/v2/ds/make-host.jsx +5 -2
  75. package/apps/studio/client/v2/ds/off-system-host.jsx +5 -2
  76. package/apps/studio/client/v2/ds/truth-host.jsx +5 -2
  77. package/apps/studio/client/v2/empty/arriving.jsx +29 -12
  78. package/apps/studio/client/v2/empty/empty-host.jsx +8 -2
  79. package/apps/studio/client/v2/empty/not-local.jsx +31 -1
  80. package/apps/studio/client/v2/empty/use-empty-canvas.js +10 -1
  81. package/apps/studio/client/v2/export/last-finished.js +2 -1
  82. package/apps/studio/client/v2/history/git-model.js +18 -4
  83. package/apps/studio/client/v2/history/git-parts.jsx +60 -42
  84. package/apps/studio/client/v2/history/history.css +6 -0
  85. package/apps/studio/client/v2/left-panel/assets-panel.jsx +87 -10
  86. package/apps/studio/client/v2/left-panel/use-trash.js +2 -1
  87. package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +100 -33
  88. package/apps/studio/client/v2/onboarding/HubSheet.jsx +51 -83
  89. package/apps/studio/client/v2/onboarding/onboarding-model.js +10 -6
  90. package/apps/studio/client/v2/present/order-notes-artboards.js +2 -1
  91. package/apps/studio/client/v2/search/search-recent.js +3 -1
  92. package/apps/studio/client/v2/search/search-remote.js +6 -4
  93. package/apps/studio/client/v2/settings/connections-model.js +1 -1
  94. package/apps/studio/client/v2/shell/menu-runner.js +1 -0
  95. package/apps/studio/client/v2/shell/occlusion-insets.js +14 -2
  96. package/apps/studio/client/v2/shell/recovery-store.js +2 -1
  97. package/apps/studio/client/v2/shell/served-routes.js +120 -0
  98. package/apps/studio/client/v2/shell/share-cluster-host.jsx +2 -1
  99. package/apps/studio/client/v2/shell/shell-activity.js +19 -0
  100. package/apps/studio/client/v2/shell/use-occluded-insets.js +3 -0
  101. package/apps/studio/client/v2/sync-states/conflict-card.jsx +7 -2
  102. package/apps/studio/client/v2/undo/use-undo-projection.jsx +3 -1
  103. package/apps/studio/cloud/endpoints.ts +23 -1
  104. package/apps/studio/dist/client.bundle.js +977 -981
  105. package/apps/studio/dist/styles.css +1 -1
  106. package/apps/studio/editing/minimap-context.tsx +3 -3
  107. package/apps/studio/editing/page-activity.ts +251 -0
  108. package/apps/studio/editing/rotate-handle.tsx +9 -5
  109. package/apps/studio/editing/sticky-name.tsx +4 -4
  110. package/apps/studio/history/restore-artboard-action.ts +40 -0
  111. package/apps/studio/home/hub.ts +77 -175
  112. package/apps/studio/home/routes.ts +47 -8
  113. package/apps/studio/http.ts +117 -66
  114. package/apps/studio/index-flight.ts +40 -0
  115. package/apps/studio/managed-projects.ts +52 -24
  116. package/apps/studio/migrate/hub.ts +7 -1
  117. package/apps/studio/routes/canvas-source.ts +44 -2
  118. package/apps/studio/routes/history.ts +28 -5
  119. package/apps/studio/routes/hub-signin.ts +115 -0
  120. package/apps/studio/routes/index.ts +4 -0
  121. package/apps/studio/routes/table.ts +7 -0
  122. package/apps/studio/routes/trash.ts +3 -0
  123. package/apps/studio/server.ts +11 -0
  124. package/apps/studio/sync/accepted-cold-start.ts +26 -3
  125. package/apps/studio/sync/accepted-link.ts +9 -4
  126. package/apps/studio/sync/code-module-consent.ts +74 -0
  127. package/apps/studio/sync/file-ledger.ts +35 -0
  128. package/apps/studio/sync/file-plane.ts +443 -77
  129. package/apps/studio/sync/hub-browser-signin.ts +377 -0
  130. package/apps/studio/sync/hub-text-undo.ts +30 -10
  131. package/apps/studio/sync/index.ts +73 -11
  132. package/apps/studio/sync/projection.ts +44 -2
  133. package/apps/studio/sync/pull-pacer.ts +160 -0
  134. package/apps/studio/sync/pull-priority.ts +119 -0
  135. package/apps/studio/sync/seed-progress.ts +47 -3
  136. package/apps/studio/sync/transaction-client.ts +71 -6
  137. package/apps/studio/sync/workspace-signin.ts +6 -256
  138. package/apps/studio/sync/writer-registry.ts +5 -1
  139. package/apps/studio/video-links-overlay.tsx +3 -2
  140. package/apps/studio/whats-new.json +54 -0
  141. package/cli/lib/design-help.gen.mjs +1 -1
  142. package/cli/lib/workspace-plan.mjs +14 -0
  143. package/package.json +8 -8
@@ -41,7 +41,7 @@ const modeNow = () => shellMode.get().mode;
41
41
 
42
42
  export function EmptyHost() {
43
43
  const {
44
- shellCore: { activePath, cfg, iframesRef, syncStatus, viewerMode },
44
+ shellCore: { activePath, cfg, iframesRef, loadingPath, syncStatus, viewerMode },
45
45
  } = useShellStore();
46
46
  const canvasOpen = !!activePath && activePath !== SYSTEM_TAB;
47
47
  const mode = useSyncExternalStore(shellMode.subscribe, modeNow, modeNow);
@@ -59,8 +59,14 @@ export function EmptyHost() {
59
59
  canvasOrigin: cfg?.canvasOrigin,
60
60
  });
61
61
 
62
+ // #204 — the shell's own "this canvas is still loading" (cleared on `canvas-rendered`): no invitation
63
+ // over a canvas that has not finished drawing, and a load starts with no count from before.
64
+ const canvasLoading = !!loadingPath && loadingPath === activePath;
65
+ useEffect(() => {
66
+ if (loadingPath) lane.loadStarted(loadingPath);
67
+ }, [lane, loadingPath]);
62
68
  const model = canvasOpen
63
- ? emptyCanvasModel({ count, mode, canEdit, online, claude, canAsk })
69
+ ? emptyCanvasModel({ count, mode, canEdit, online, claude, canAsk, loading: canvasLoading })
64
70
  : null;
65
71
  // rc3-h (#182): a run of yours on this empty canvas — the ghost where the first artboard lands, not the invitation
66
72
  const { view: runsView } = useAiRuns();
@@ -65,6 +65,36 @@ const askAvailability = (path, fetchImpl) =>
65
65
  .then((r) => (r.ok ? r.json() : null))
66
66
  .then((body) => body?.canvas?.state ?? 'unknown');
67
67
 
68
+ // #204 R — one ask per canvas per OPEN, not per render: a tab that flips between canvases (or a viewport
69
+ // that mounts again) asked on every flip. An open shares the ask in flight for its path and reuses an
70
+ // answer younger than OPEN_REUSE_MS. Keyed by the fetch it went through (tests inject their own).
71
+ export const OPEN_REUSE_MS = 1000;
72
+ const DEFAULT_FETCH = {};
73
+ let asks = new WeakMap();
74
+
75
+ function askOnOpen(path, fetchImpl) {
76
+ const key = fetchImpl || DEFAULT_FETCH;
77
+ let byPath = asks.get(key);
78
+ if (!byPath) {
79
+ byPath = new Map();
80
+ asks.set(key, byPath);
81
+ }
82
+ const hit = byPath.get(path);
83
+ if (hit && (hit.pending || Date.now() - hit.at < OPEN_REUSE_MS)) return hit.answer;
84
+ const entry = { at: Date.now(), pending: true, answer: null };
85
+ entry.answer = askAvailability(path, fetchImpl).finally(() => {
86
+ entry.pending = false;
87
+ entry.at = Date.now();
88
+ });
89
+ byPath.set(path, entry);
90
+ return entry.answer;
91
+ }
92
+
93
+ /** Tests only: forget every recent ask. */
94
+ export function resetAvailabilityAsks() {
95
+ asks = new WeakMap();
96
+ }
97
+
68
98
  /**
69
99
  * One canvas's availability, asked once per path (and again when `stamp` changes — the tab's reload key).
70
100
  * A canvas that is `arriving` is asked again every `recheckMs` until it is here (no flicker: the answer
@@ -82,7 +112,7 @@ export function useCanvasAvailability(
82
112
  if (!path) return;
83
113
  let alive = true;
84
114
  setState(null);
85
- askAvailability(path, fetchImpl)
115
+ askOnOpen(path, fetchImpl)
86
116
  .then((s) => alive && setState(s))
87
117
  .catch(() => alive && setState('unknown'));
88
118
  return () => {
@@ -41,12 +41,15 @@ export function hubAway(syncStatus) {
41
41
  * Which empty-canvas situation applies — or null (nothing to show).
42
42
  *
43
43
  * @param {{ count: number|null|undefined, mode: string, canEdit: boolean, online: boolean,
44
- * claude: 'present'|'absent'|'unknown', canAsk: boolean }} f
44
+ * claude: 'present'|'absent'|'unknown', canAsk: boolean, loading?: boolean }} f
45
45
  * `count` is what the CANVAS reported (null until it has: no flash while it loads). `canEdit` false =
46
46
  * Can view / Can comment: no create affordance at all. `canAsk`: the AI chat exists here (desktop app).
47
47
  */
48
48
  export function emptyCanvasModel(f) {
49
49
  if (f.count !== 0) return null;
50
+ // #204 — only for a canvas KNOWN to be empty once its load has finished: a 0 said while the canvas is
51
+ // still loading (before its artboards mount) put the invitation over artboards drawn a moment later.
52
+ if (f.loading) return null;
50
53
  if (f.mode !== 'edit') return null;
51
54
  if (!f.canEdit) return null;
52
55
  const offline = f.online === false;
@@ -170,6 +173,12 @@ export function createEmptyLane(deps) {
170
173
  switched() {
171
174
  set({ count: countOf(), hint: null });
172
175
  },
176
+ /** #204 — a canvas started (re)loading: what its last document said about it is not about the next. */
177
+ loadStarted(path) {
178
+ if (!path || !counts.has(path)) return;
179
+ counts.delete(path);
180
+ set({ ...state, count: countOf() });
181
+ },
173
182
  /** A canvas left the project / was closed. */
174
183
  forget(path) {
175
184
  counts.delete(path);
@@ -4,6 +4,7 @@
4
4
 
5
5
  import { useEffect, useState } from 'react';
6
6
  import { indexMeta } from '../canvases/tree-model.js';
7
+ import { fetchIfServed } from '../shell/served-routes.js';
7
8
 
8
9
  /** @returns ms, or null (no index, no such canvas, or the sheet is closed) */
9
10
  export function useLastFinishedAt({ open, activePath, designRel, fetchImpl }) {
@@ -17,7 +18,7 @@ export function useLastFinishedAt({ open, activePath, designRel, fetchImpl }) {
17
18
  const doFetch = fetchImpl || ((...a) => fetch(...a));
18
19
  (async () => {
19
20
  try {
20
- const r = await doFetch('/_api/index', { cache: 'no-store' });
21
+ const r = await fetchIfServed('/_api/index', { cache: 'no-store' }, doFetch);
21
22
  if (!r.ok || cancelled) return;
22
23
  const snapshot = await r.json();
23
24
  const row = indexMeta(snapshot, designRel).get(activePath);
@@ -318,11 +318,25 @@ export function unitCheck(unit, unchecked) {
318
318
  return on === 0 ? 'none' : on === unit.paths.length ? 'all' : 'some';
319
319
  }
320
320
 
321
- /** The words of the discard confirm. */
321
+ /**
322
+ * The words of the discard ask (the shell's own yes/no dialog — `window.confirm` always answers no in the
323
+ * desktop app): the question names the file, the line under it says it can't be undone.
324
+ */
325
+ export function discardAsk(unit) {
326
+ return {
327
+ title: unit.supporting.length
328
+ ? `Discard your changes to “${unit.name}” and its supporting files?`
329
+ : `Discard your changes to “${unit.name}”?`,
330
+ body: "This can't be undone.",
331
+ confirm: GIT_WORDS.discard,
332
+ busy: 'Discarding…',
333
+ };
334
+ }
335
+
336
+ /** The same ask as one sentence. */
322
337
  export function discardConfirm(unit) {
323
- return unit.supporting.length
324
- ? `Discard your changes to “${unit.name}” and its supporting files? This can't be undone.`
325
- : `Discard your changes to “${unit.name}”? This can't be undone.`;
338
+ const a = discardAsk(unit);
339
+ return `${a.title} ${a.body}`;
326
340
  }
327
341
 
328
342
  // ── "Changed in this version" ──────────────────────────────────────────────────────────────────────────────
@@ -5,11 +5,12 @@
5
5
 
6
6
  import { useEffect, useRef, useState } from 'react';
7
7
  import { StIcon } from '../../shell/icons.jsx';
8
+ import { ConfirmAskDialog } from '../canvases/folder-dialogs.jsx';
8
9
  import { useModalFocus } from '../shell/modal-focus.js';
9
10
  import {
10
11
  GIT_WORDS as W,
11
12
  chatGuardCopy,
12
- discardConfirm,
13
+ discardAsk,
13
14
  saveState,
14
15
  slugifyBranch,
15
16
  unitCheck,
@@ -123,6 +124,9 @@ export function Banner({ banner, busy, onGetLatest, onDismiss }) {
123
124
 
124
125
  /** "Not in a version yet": one row per canvas (its sidecars travel with it), Compare, Discard. */
125
126
  export function UnsavedList({ units, canWrite, busy, onOpen, onCompare, onDiscard }) {
127
+ // Discard asks in the shell's own dialog: `window.confirm` always answers no in the desktop app.
128
+ const [asking, setAsking] = useState(null);
129
+ const ask = asking ? discardAsk(asking) : null;
126
130
  if (!units.length)
127
131
  return (
128
132
  <p className="vh-git-none" data-testid="vh-git-notyet">
@@ -130,51 +134,65 @@ export function UnsavedList({ units, canWrite, busy, onOpen, onCompare, onDiscar
130
134
  </p>
131
135
  );
132
136
  return (
133
- <ul className="vh-git-ul" data-testid="vh-git-notyet" aria-label={W.notYet}>
134
- {units.map((u) => (
135
- <li className="vh-git-unit" key={u.key}>
136
- <Badge kind={u.badge} title={u.badgeTitle} />
137
- <button
138
- type="button"
139
- className="vh-git-file"
140
- title={u.path}
141
- onClick={() => onOpen?.(u.path)}
142
- >
143
- <span className="vh-git-fname">{u.name}</span>
144
- <span className="vh-git-fpath">
145
- {u.supporting.length ? `${u.path} · +${u.supporting.length} supporting` : u.path}
146
- </span>
147
- </button>
148
- {u.comparable && onCompare ? (
149
- <button
150
- type="button"
151
- className="icon-btn"
152
- data-testid="git-compare"
153
- title={W.compareFile}
154
- aria-label={`${W.compareFile}: ${u.name}`}
155
- onClick={() => onCompare(u.path)}
156
- >
157
- <StIcon name="eye" size={13} />
158
- </button>
159
- ) : null}
160
- {canWrite ? (
137
+ <>
138
+ <ul className="vh-git-ul" data-testid="vh-git-notyet" aria-label={W.notYet}>
139
+ {units.map((u) => (
140
+ <li className="vh-git-unit" key={u.key}>
141
+ <Badge kind={u.badge} title={u.badgeTitle} />
161
142
  <button
162
143
  type="button"
163
- className="btn btn--ghost btn--sm"
164
- data-testid="git-discard"
165
- disabled={!!busy}
166
- aria-label={`${W.discard} changes to ${u.name}`}
167
- onClick={() => {
168
- if (!window.confirm(discardConfirm(u))) return;
169
- onDiscard(u);
170
- }}
144
+ className="vh-git-file"
145
+ title={u.path}
146
+ onClick={() => onOpen?.(u.path)}
171
147
  >
172
- {W.discard}
148
+ <span className="vh-git-fname">{u.name}</span>
149
+ <span className="vh-git-fpath">
150
+ {u.supporting.length ? `${u.path} · +${u.supporting.length} supporting` : u.path}
151
+ </span>
173
152
  </button>
174
- ) : null}
175
- </li>
176
- ))}
177
- </ul>
153
+ {u.comparable && onCompare ? (
154
+ <button
155
+ type="button"
156
+ className="icon-btn"
157
+ data-testid="git-compare"
158
+ title={W.compareFile}
159
+ aria-label={`${W.compareFile}: ${u.name}`}
160
+ onClick={() => onCompare(u.path)}
161
+ >
162
+ <StIcon name="eye" size={13} />
163
+ </button>
164
+ ) : null}
165
+ {canWrite ? (
166
+ <button
167
+ type="button"
168
+ className="btn btn--ghost btn--sm"
169
+ data-testid="git-discard"
170
+ disabled={!!busy}
171
+ aria-label={`${W.discard} changes to ${u.name}`}
172
+ onClick={() => setAsking(u)}
173
+ >
174
+ {W.discard}
175
+ </button>
176
+ ) : null}
177
+ </li>
178
+ ))}
179
+ </ul>
180
+ {ask ? (
181
+ <ConfirmAskDialog
182
+ over
183
+ title={ask.title}
184
+ body={ask.body}
185
+ confirm={ask.confirm}
186
+ busyLabel={ask.busy}
187
+ onConfirm={() => {
188
+ const u = asking;
189
+ setAsking(null);
190
+ onDiscard(u);
191
+ }}
192
+ onCancel={() => setAsking(null)}
193
+ />
194
+ ) : null}
195
+ </>
178
196
  );
179
197
  }
180
198
 
@@ -509,6 +509,12 @@
509
509
  flex: none;
510
510
  }
511
511
 
512
+ /* a failed Restore or merge, said inside the sheet (replaces window.alert) */
513
+ .dv-err {
514
+ margin: 0 var(--space-5) var(--space-3);
515
+ flex: none;
516
+ }
517
+
512
518
  .dv-note {
513
519
  color: var(--fg-2);
514
520
  font-size: var(--type-xs);
@@ -43,13 +43,15 @@ import { AssetDetails } from '../assets/details.jsx';
43
43
  import { GenerateAsk } from '../assets/generate-ask.jsx';
44
44
  import { COPY_FAILED_LINE, copyAssetImage } from '../assets/copy-asset.js';
45
45
  import { KindsChip } from '../assets/kinds-chip.jsx';
46
- import { filterKind, GROUP_CAP, libraryFootWords } from '../assets/library-foot.js';
46
+ import { filterKind, libraryFootWords } from '../assets/library-foot.js';
47
47
  import { runMeta, runTitle, splitGenerated, useGenerated } from '../assets/generated.js';
48
48
  import { splitJustAdded } from '../assets/just-added.js';
49
49
  import { placeAsset, placedWords, SELECT_ARTBOARD_LINE } from '../assets/place-asset.js';
50
50
  import { ARRIVAL_LINES, addingLine, linkName } from '../assets/import-lines.js';
51
51
  import { toastArrivals } from '../assets/import-toast.js';
52
52
  import { SeenLine } from '../assets/search-marks.jsx';
53
+ import { AssetSpotlight } from '../assets/spotlight.jsx';
54
+ import { groupShown, narrowOrder, spotlightRows } from '../assets/spotlight-model.js';
53
55
  import { AssetTile } from '../assets/tile.jsx';
54
56
  import { AssetTileMenu, tileMenuItems } from '../assets/tile-menu.jsx';
55
57
  import { ConfirmTrash, NotCountedNote, TidyFoot, tidyModel } from '../assets/tidy.jsx';
@@ -183,6 +185,8 @@ export function AssetsPanel({
183
185
  const [picked, setPicked] = useState(null);
184
186
  const [menu, setMenu] = useState(null);
185
187
  const [details, setDetails] = useState(null);
188
+ // 2.0.4 (#191) — the tile opened large ({ path, order }): `order` is the tiles ← → walks, fixed when it opened
189
+ const [spot, setSpot] = useState(null);
186
190
  // S8.13 — the wide Browse view (null = the narrow tab), the Not used filter, the confirm sheet and the Undo line
187
191
  const [browse, setBrowse] = useState(null);
188
192
  const [notUsedOnly, setNotUsedOnly] = useState(false);
@@ -366,6 +370,17 @@ export function AssetsPanel({
366
370
  }, [query, describe.hits, shown, byPath, notUsedOnly, hasUsage]);
367
371
  useAssetAnswers(); // the bars on tiles follow what the studio last said about each open canvas
368
372
  const url = (p) => `/${designRel}/${p}`;
373
+ // 2.0.4 (#191) — a double-click (or Space on the picked tile, `assets.spotlight`) opens the tile large. ← → walk the tiles
374
+ // the tab draws now: the wide Browse view's order when it is open, else the groups as the narrow tab shows them.
375
+ const openSpotlight = (path) => {
376
+ if (!byPath.has(path)) return;
377
+ setMenu(null);
378
+ const order =
379
+ browse && assets
380
+ ? browseOrder(assets, browse)
381
+ : narrowOrder(groups, seen, { uncapped: notUsedOnly && hasUsage });
382
+ setSpot({ path, order: order.includes(path) ? order : [path] });
383
+ };
369
384
  const renderTile = (a, o = undefined) => (
370
385
  <AssetTile
371
386
  key={a.path}
@@ -376,6 +391,7 @@ export function AssetsPanel({
376
391
  canDrag={!readOnly}
377
392
  onPick={setPicked}
378
393
  onMenu={openMenu}
394
+ onOpen={openSpotlight}
379
395
  uploading={assetUploadOf(a.path)}
380
396
  />
381
397
  );
@@ -583,6 +599,7 @@ export function AssetsPanel({
583
599
  place,
584
600
  placeMany,
585
601
  showDetails,
602
+ openSpotlight,
586
603
  trashSelection,
587
604
  startRename,
588
605
  readOnly,
@@ -607,6 +624,15 @@ export function AssetsPanel({
607
624
  l.showDetails(one);
608
625
  } else if (l.picked) l.showDetails(l.picked);
609
626
  },
627
+ // 2.0.4 (#191) — Space on the picked tile: the same window a double-click opens
628
+ spotlight: () => {
629
+ const l = live.current;
630
+ if (l.sourceDs) dsApi.current?.spotlight();
631
+ else {
632
+ const one = l.browse ? l.browsePicked()[0] : l.picked;
633
+ if (one) l.openSpotlight(one);
634
+ }
635
+ },
610
636
  rename: () => {
611
637
  const l = live.current;
612
638
  const one = l.browse ? l.browsePicked()[0] : l.picked;
@@ -659,14 +685,14 @@ export function AssetsPanel({
659
685
  const menuItems = menu
660
686
  ? tileMenuItems(menu.asset, { readOnly, placeLabel, count: menuCount })
661
687
  : [];
662
- const onMenuSelect = (id) => {
663
- const path = menu?.asset.path;
664
- setMenu(null);
665
- if (!path) return;
688
+ // the tile menu's rows and the spotlight's: one function (`single`: the spotlight acts on the one picture it shows)
689
+ const runTileAction = (id, path, { single = false } = {}) => {
666
690
  if (id === 'place') {
667
- if (browse && browse.selected.has(path) && browse.selected.size > 1)
691
+ if (!single && browse && browse.selected.has(path) && browse.selected.size > 1)
668
692
  void placeMany(browsePicked());
669
693
  else void place(path);
694
+ } else if (id === 'spotlight') {
695
+ openSpotlight(path);
670
696
  } else if (id === 'details') {
671
697
  setBrowse(null);
672
698
  showDetails(path);
@@ -677,6 +703,48 @@ export function AssetsPanel({
677
703
  } else if (id === 'rename') startRename(path);
678
704
  else if (id === 'trash') trashSelection(path);
679
705
  };
706
+ const onMenuSelect = (id) => {
707
+ const path = menu?.asset.path;
708
+ setMenu(null);
709
+ if (path) runTileAction(id, path);
710
+ };
711
+
712
+ // ── 2.0.4 (#191): the spotlight ────────────────────────────────────────────────────────────────────────────────
713
+ const spotItems = spot ? spot.order.map((p) => byPath.get(p)).filter(Boolean) : [];
714
+ const spotIndex = spot ? spotItems.findIndex((a) => a.path === spot.path) : -1;
715
+ // the tile the window was showing takes focus back (esc, the button and a click outside all end here)
716
+ const focusTile = (path) => {
717
+ const tile = Array.from(document.querySelectorAll('[data-testid="assets-tile"]')).find(
718
+ (el) => el.dataset.asset === path && el.getClientRects().length > 0
719
+ );
720
+ tile?.focus?.({ preventScroll: true });
721
+ };
722
+ const closeSpotlight = () => {
723
+ const path = spot?.path;
724
+ if (path) focusTile(path);
725
+ setSpot(null);
726
+ };
727
+ // stepping moves the pick with it, so what ↵ places and ⌘I opens is the picture you were looking at
728
+ const stepSpotlight = (i) => {
729
+ const a = spotItems[i];
730
+ if (!a) return;
731
+ setSpot((cur) => (cur ? { ...cur, path: a.path } : cur));
732
+ if (browse) patchBrowse({ ...pickTile(spot.order, browse, a.path, {}) });
733
+ else setPicked(a.path);
734
+ };
735
+ const spotRows =
736
+ spotIndex >= 0
737
+ ? spotlightRows(
738
+ tileMenuItems(spotItems[spotIndex], { readOnly, placeLabel, count: 1 }).filter(
739
+ (r) => r.id !== 'spotlight'
740
+ )
741
+ )
742
+ : [];
743
+ const runSpotRow = (id) => {
744
+ const path = spotItems[spotIndex]?.path;
745
+ setSpot(null);
746
+ if (path) runTileAction(id, path, { single: true });
747
+ };
680
748
 
681
749
  const detailed = details ? byPath.get(details) : null;
682
750
  // Not used, narrowed by the search: the numbers on the foot are what is listed, so "Move N" moves what is shown
@@ -1154,10 +1222,7 @@ export function AssetsPanel({
1154
1222
  </div>
1155
1223
  ) : (
1156
1224
  <div className="lp-grid">
1157
- {(g.kind === 'added' || (notUsedOnly && hasUsage)
1158
- ? g.items
1159
- : g.items.slice(0, GROUP_CAP)
1160
- ).map(renderTile)}
1225
+ {groupShown(g, { uncapped: notUsedOnly && hasUsage }).map(renderTile)}
1161
1226
  </div>
1162
1227
  )}
1163
1228
  </section>
@@ -1238,6 +1303,7 @@ export function AssetsPanel({
1238
1303
  onChange={patchBrowse}
1239
1304
  onPick={onBrowsePick}
1240
1305
  onMenu={openMenu}
1306
+ onOpen={openSpotlight}
1241
1307
  onBack={() => setBrowse(null)}
1242
1308
  onClear={() => patchBrowse({ ...NOTHING_PICKED })}
1243
1309
  onPlace={(paths) => void placeMany(paths)}
@@ -1257,6 +1323,17 @@ export function AssetsPanel({
1257
1323
  />
1258
1324
  ) : null}
1259
1325
  <AssetTileMenu state={menu} items={menuItems} onSelect={onMenuSelect} onClose={closeMenu} />
1326
+ {spot && spotIndex >= 0 ? (
1327
+ <AssetSpotlight
1328
+ items={spotItems}
1329
+ index={spotIndex}
1330
+ urlOf={url}
1331
+ rows={spotRows}
1332
+ onIndex={stepSpotlight}
1333
+ onClose={closeSpotlight}
1334
+ onRow={runSpotRow}
1335
+ />
1336
+ ) : null}
1260
1337
  </div>
1261
1338
  );
1262
1339
  }
@@ -17,6 +17,7 @@
17
17
  import { useCallback, useEffect, useRef, useState } from 'react';
18
18
 
19
19
  import { trashClearRequest, trashRestoreRequest } from '../../../history/surface-requests.ts';
20
+ import { fetchIfServed } from '../shell/served-routes.js';
20
21
 
21
22
  /** The app shell relays the bus's `trash:changed { seq }` as this window event. */
22
23
  export const TRASH_CHANGED_EVENT = 'maude:trash-changed';
@@ -32,7 +33,7 @@ export function visibleTrash(j) {
32
33
  /** Today's per-Mac list (`/_api/sync/trash`): "Kept on this Mac". Null when the route refuses. */
33
34
  export async function fetchTrash(fetchImpl = fetch) {
34
35
  try {
35
- const r = await fetchImpl('/_api/sync/trash');
36
+ const r = await fetchIfServed('/_api/sync/trash', undefined, fetchImpl);
36
37
  if (!r.ok) return null;
37
38
  const j = await r.json();
38
39
  return j && Array.isArray(j.entries) ? visibleTrash(j) : null;
@@ -3,16 +3,18 @@
3
3
  // shell command a sheet's button runs. Each sheet is a view (exported from ./index.js for S11.14), so Settings ›
4
4
  // Connections mounts the same sheets with its own wiring.
5
5
  //
6
- // hub → /_home/hub/{test,prepare,join} then Home's own open of the managed copy (a tab);
7
- // `join` (S6.11b) redeems a hub invite ("Invite link or key")
6
+ // hub → /_home/hub/test; Sign in (#204 K2) → /_home/hub/signin/start, the shell opens the hub's
7
+ // own page (`open_team_server_signin`; with an invite, the hub's invite page), poll until
8
+ // the browser came back, then /_home/hub/prepare and Home's own open of the managed copy
8
9
  // folder-github → the shell's folder picker (`open_project_folder`); "From GitHub" (S6.10) → Rust's
9
10
  // github_repos / home_github_sign_in / github_clone / github_create, then `open_project({root})`
10
11
  // ai → /_home/ai/{status,connect} (install Claude Code, then the browser sign-in)
11
12
  // cli → /_home/cli/{status,install} (a link to the bundled maude; the plugin when claude is there)
12
13
  // figma → the target project opens with the `import-figma` intent (Q8)
13
14
  //
14
- // No credential reaches a log or comes back into the page: the hub password is posted once from the sheet's
15
- // own state and emptied; the AI sign-in is the person's browser; nothing here stores a token.
15
+ // No credential reaches a log or comes back into the page: the app owns no team-server password (the hub's
16
+ // own page in the browser takes it, issue #204); the AI sign-in is the person's browser; nothing here stores
17
+ // a token.
16
18
 
17
19
  import { useCallback, useEffect, useRef, useState } from 'react';
18
20
 
@@ -21,12 +23,15 @@ import {
21
23
  aiStatus,
22
24
  cliInstall,
23
25
  cliStatus,
24
- hubJoin,
25
26
  hubPrepare,
27
+ hubSignInCancel,
28
+ hubSignInPoll,
29
+ hubSignInStart,
26
30
  hubTest,
27
31
  inShell,
28
32
  openProject,
29
33
  openProjectFolder,
34
+ openTeamServerSignIn,
30
35
  shellListen,
31
36
  } from '../../home/home-api.js';
32
37
  import { useGithubSegment } from './GithubSegment.jsx';
@@ -180,6 +185,95 @@ function FigmaHost({ target, onClose, startFigma }) {
180
185
  return <FigmaSheet target={target} busy={busy} error={error} onImport={go} onCancel={onClose} />;
181
186
  }
182
187
 
188
+ /** How often Home asks whether the browser came back (the hub's code lives a minute). */
189
+ export const HUB_POLL_MS = 1500;
190
+
191
+ /**
192
+ * #204 K2 — the hub sheet's host: Sign in opens the hub's own page and waits for the browser to come back to
193
+ * Home's server; Cancel forgets the attempt (a late return then changes nothing). `pollMs` is a test seam.
194
+ */
195
+ function HubHost({ onClose, profile, openPrepared, pollMs = HUB_POLL_MS }) {
196
+ const attempt = useRef(null); // { id, stop: (r) => void }
197
+ useEffect(
198
+ () => () => {
199
+ const a = attempt.current;
200
+ attempt.current = null;
201
+ if (a) {
202
+ a.stop({ ok: false, cancelled: true });
203
+ void hubSignInCancel(a.id);
204
+ }
205
+ },
206
+ []
207
+ );
208
+
209
+ const waitForBrowser = (id) =>
210
+ new Promise((resolve) => {
211
+ let timer = null;
212
+ const stop = (r) => {
213
+ clearTimeout(timer);
214
+ resolve(r);
215
+ };
216
+ attempt.current = { id, stop };
217
+ const tick = async () => {
218
+ const p = await hubSignInPoll(id);
219
+ if (attempt.current?.id !== id) return; // cancelled meanwhile
220
+ if (p.json?.pending) {
221
+ timer = setTimeout(tick, pollMs);
222
+ return;
223
+ }
224
+ attempt.current = null;
225
+ stop(
226
+ p.ok && p.json?.ok && p.json.url
227
+ ? { ok: true, url: p.json.url }
228
+ : { ok: false, error: p.json?.error || HUB_WORDS.unreachable }
229
+ );
230
+ };
231
+ timer = setTimeout(tick, 0); // the first ask at once, then every pollMs
232
+ });
233
+
234
+ return (
235
+ <HubSheet
236
+ onCancel={onClose}
237
+ onTest={async (url) => {
238
+ const r = await hubTest(url);
239
+ return r.json?.ok
240
+ ? { ok: true, version: r.json.version ?? null }
241
+ : { ok: false, error: r.json?.error || HUB_WORDS.unreachable };
242
+ }}
243
+ onSignIn={async ({ url, invite, onWaiting }) => {
244
+ const s = await hubSignInStart(profile, url, invite);
245
+ if (!s.ok || !s.json?.ok)
246
+ return { ok: false, error: s.json?.error || HUB_WORDS.unreachable };
247
+ const id = s.json.id;
248
+ const opened = await openTeamServerSignIn(s.json.signInUrl);
249
+ if (opened !== 'ok') {
250
+ void hubSignInCancel(id);
251
+ return {
252
+ ok: false,
253
+ error: opened === 'refused' ? HUB_WORDS.refused : HUB_WORDS.noBrowser,
254
+ };
255
+ }
256
+ onWaiting();
257
+ const done = await waitForBrowser(id);
258
+ if (!done.ok) return done;
259
+ const r = await hubPrepare(profile, done.url);
260
+ if (!r.ok || !r.json?.ok)
261
+ return { ok: false, error: r.json?.error || HUB_WORDS.unreachable };
262
+ await openPrepared(r, r.json.name, profile);
263
+ onClose();
264
+ return { ok: true };
265
+ }}
266
+ onAbortSignIn={() => {
267
+ const a = attempt.current;
268
+ attempt.current = null;
269
+ if (!a) return;
270
+ void hubSignInCancel(a.id);
271
+ a.stop({ ok: false, cancelled: true });
272
+ }}
273
+ />
274
+ );
275
+ }
276
+
183
277
  /**
184
278
  * @param {{ open: string|null, onClose: () => void, profile: string, target?: object|null,
185
279
  * openPrepared: (prep: object, name: string, profile: string) => Promise<unknown>,
@@ -199,34 +293,7 @@ export function AdvancedSheets({
199
293
  github = null,
200
294
  }) {
201
295
  if (open === 'hub')
202
- return (
203
- <HubSheet
204
- onCancel={onClose}
205
- onTest={async (url) => {
206
- const r = await hubTest(url);
207
- return r.json?.ok
208
- ? { ok: true, version: r.json.version ?? null }
209
- : { ok: false, error: r.json?.error || HUB_WORDS.unreachable };
210
- }}
211
- onConnect={async ({ url, email, password }) => {
212
- const r = await hubPrepare(profile, url, email || password ? { email, password } : null);
213
- if (!r.ok || !r.json?.ok)
214
- return { ok: false, error: r.json?.error || HUB_WORDS.unreachable };
215
- await openPrepared(r, r.json.name, profile);
216
- onClose();
217
- return { ok: true };
218
- }}
219
- // S6.11b — "Invite link or key": the hub's own invite redeem, then the same open
220
- onJoin={async ({ url, token, email, password }) => {
221
- const r = await hubJoin(profile, url, { token, email, password });
222
- if (!r.ok || !r.json?.ok)
223
- return { ok: false, error: r.json?.error || HUB_WORDS.unreachable };
224
- await openPrepared(r, r.json.name, profile);
225
- onClose();
226
- return { ok: true };
227
- }}
228
- />
229
- );
296
+ return <HubHost onClose={onClose} profile={profile} openPrepared={openPrepared} />;
230
297
  if (open === 'folder-github')
231
298
  return (
232
299
  <FolderHost onClose={onClose} openFolder={openFolder} profile={profile} github={github} />