@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
@@ -0,0 +1,120 @@
1
+ // client/v2/ai/BackgroundStrip.jsx — issue #177: "Running in the background".
2
+ //
3
+ // AI can leave work running after its reply ends: subagents it launched, a command left running. The
4
+ // strip sits between the conversation and the composer and says what is still running, one line per
5
+ // task with its time, so a quiet stretch never reads as "nothing is happening":
6
+ //
7
+ // one task ● Review the Pricing canvas · Agent 0:42
8
+ // several ● 3 agents working 1:12 ▸ (expands to one row each)
9
+ //
10
+ // A task that ends shows "Finished" for a few seconds (background-model.js KEEP_FINISHED_MS), then goes;
11
+ // the strip goes with the last one. The counts are announced politely; the ticking clock never is.
12
+
13
+ import { useEffect, useState } from 'react';
14
+ import { StIcon } from '../../shell/icons.jsx';
15
+ import {
16
+ kindWord,
17
+ pruneFinished,
18
+ rowElapsed,
19
+ rowLabel,
20
+ runningCount,
21
+ stripElapsed,
22
+ summaryText,
23
+ trackBackground,
24
+ } from './background-model.js';
25
+
26
+ /** The strip's items for a connection: folded from its task snapshots, ticking while there are any. */
27
+ export function useBackgroundItems(conn) {
28
+ const [items, setItems] = useState([]);
29
+ const [now, setNow] = useState(() => Date.now());
30
+ useEffect(() => {
31
+ if (!conn?.onBackgroundTasks) return undefined;
32
+ return conn.onBackgroundTasks((tasks) => {
33
+ const at = Date.now();
34
+ setNow(at);
35
+ setItems((prev) => trackBackground(prev, tasks, at));
36
+ });
37
+ }, [conn]);
38
+ const any = items.length > 0;
39
+ useEffect(() => {
40
+ if (!any) return undefined;
41
+ const id = setInterval(() => {
42
+ const at = Date.now();
43
+ setNow(at);
44
+ setItems((prev) => pruneFinished(prev, at));
45
+ }, 1000);
46
+ return () => clearInterval(id);
47
+ }, [any]);
48
+ return { items, now };
49
+ }
50
+
51
+ function Row({ item, now }) {
52
+ const done = item.state === 'finished';
53
+ const time = rowElapsed(item, now);
54
+ return (
55
+ <li
56
+ className={`ai-bg-row${done ? ' is-done' : ''}`}
57
+ data-testid={`ai-background-row-${item.id}`}
58
+ data-state={item.state}
59
+ >
60
+ <span className="ai-bg-dot" aria-hidden="true" />
61
+ <span className="ai-bg-name">{rowLabel(item)}</span>
62
+ <span className="ai-bg-kind">{done ? 'Finished' : kindWord(item.kind)}</span>
63
+ {time ? <span className="ai-bg-time">{time}</span> : null}
64
+ </li>
65
+ );
66
+ }
67
+
68
+ export function BackgroundStrip({ conn }) {
69
+ const { items, now } = useBackgroundItems(conn);
70
+ const [open, setOpen] = useState(false);
71
+ if (!items.length) return null;
72
+ const working = runningCount(items) > 0;
73
+ const many = items.length > 1;
74
+ const summary = summaryText(items);
75
+ return (
76
+ <section
77
+ className={`ai-bg${working ? ' is-working' : ''}`}
78
+ data-testid="ai-background"
79
+ data-working={working ? 'true' : 'false'}
80
+ aria-label="Running in the background"
81
+ >
82
+ <div className="ai-sr-only" role="status" aria-live="polite">
83
+ {summary}
84
+ </div>
85
+ {many ? (
86
+ <>
87
+ <button
88
+ type="button"
89
+ className="ai-bg-head"
90
+ data-testid="ai-background-toggle"
91
+ aria-expanded={open}
92
+ onClick={() => setOpen((v) => !v)}
93
+ >
94
+ <span className="ai-bg-dot" aria-hidden="true" />
95
+ <span className="ai-bg-name" data-testid="ai-background-summary">
96
+ {summary}
97
+ </span>
98
+ {stripElapsed(items, now) ? (
99
+ <span className="ai-bg-time">{stripElapsed(items, now)}</span>
100
+ ) : null}
101
+ <span className={`ai-bg-chev${open ? ' is-open' : ''}`} aria-hidden="true">
102
+ <StIcon name="chevron-right" size={12} />
103
+ </span>
104
+ </button>
105
+ {open ? (
106
+ <ul className="ai-bg-list" data-testid="ai-background-list">
107
+ {items.map((item) => (
108
+ <Row key={item.id} item={item} now={now} />
109
+ ))}
110
+ </ul>
111
+ ) : null}
112
+ </>
113
+ ) : (
114
+ <ul className="ai-bg-list ai-bg-list--one" data-testid="ai-background-list">
115
+ <Row item={items[0]} now={now} />
116
+ </ul>
117
+ )}
118
+ </section>
119
+ );
120
+ }
@@ -9,10 +9,11 @@
9
9
  import { useCallback, useEffect, useState } from 'react';
10
10
 
11
11
  import { stoppedLine, stoppedRunFor } from './stopped.js';
12
+ import { servedFetch } from '../shell/served-routes.js';
12
13
 
13
14
  async function fetchMine() {
14
15
  try {
15
- const r = await fetch('/_api/ai/runs', { cache: 'no-store' });
16
+ const r = await servedFetch('/_api/ai/runs', { cache: 'no-store' });
16
17
  if (!r.ok) return null;
17
18
  const j = await r.json();
18
19
  return Array.isArray(j?.mine) ? j.mine : null;
@@ -288,12 +288,96 @@
288
288
  color: var(--fg-0);
289
289
  }
290
290
 
291
+ /* ── Issue #177: "Running in the background" — work AI left running after its reply ── */
292
+ .ai-bg {
293
+ flex: none;
294
+ margin: 0 var(--space-3) var(--space-2);
295
+ border-radius: var(--radius-md);
296
+ background: var(--bg-2);
297
+ font-size: var(--type-xs);
298
+ color: var(--fg-1);
299
+ }
300
+ .ai-bg-head,
301
+ .ai-bg-row {
302
+ display: flex;
303
+ align-items: center;
304
+ gap: var(--space-2);
305
+ min-width: 0;
306
+ padding: var(--space-1) var(--space-2);
307
+ }
308
+ .ai-bg-head {
309
+ width: 100%;
310
+ border: 0;
311
+ border-radius: var(--radius-md);
312
+ background: none;
313
+ color: inherit;
314
+ font: inherit;
315
+ text-align: start;
316
+ cursor: pointer;
317
+ }
318
+ .ai-bg-head:hover {
319
+ background: var(--bg-3);
320
+ }
321
+ .ai-bg-list {
322
+ margin: 0;
323
+ padding: 0 0 var(--space-1);
324
+ list-style: none;
325
+ }
326
+ .ai-bg-list--one {
327
+ padding: 0;
328
+ }
329
+ .ai-bg-dot {
330
+ flex: none;
331
+ width: 6px;
332
+ height: 6px;
333
+ border-radius: 50%;
334
+ background: var(--fg-2);
335
+ }
336
+ .ai-bg.is-working .ai-bg-head .ai-bg-dot,
337
+ .ai-bg-row:not(.is-done) .ai-bg-dot {
338
+ background: var(--spark);
339
+ animation: ai-working-pulse 1600ms var(--ease-out, ease-out) infinite;
340
+ }
341
+ .ai-bg-name {
342
+ flex: 1;
343
+ min-width: 0;
344
+ overflow: hidden;
345
+ color: var(--fg-0);
346
+ font-weight: var(--w-medium);
347
+ text-overflow: ellipsis;
348
+ white-space: nowrap;
349
+ }
350
+ .ai-bg-row.is-done .ai-bg-name {
351
+ color: var(--fg-1);
352
+ font-weight: var(--w-regular);
353
+ }
354
+ .ai-bg-kind {
355
+ flex: none;
356
+ color: var(--fg-2);
357
+ }
358
+ .ai-bg-time {
359
+ flex: none;
360
+ color: var(--fg-2);
361
+ font-variant-numeric: tabular-nums;
362
+ }
363
+ .ai-bg-chev {
364
+ display: grid;
365
+ flex: none;
366
+ color: var(--fg-2);
367
+ transition: transform var(--dur-flip, 120ms) var(--ease-out, ease-out);
368
+ }
369
+ .ai-bg-chev.is-open {
370
+ transform: rotate(90deg);
371
+ }
372
+
291
373
  @media (prefers-reduced-motion: reduce) {
292
- .ai-working-spark {
293
- animation: none;
374
+ .ai-working-spark,
375
+ .ai-bg-dot {
376
+ animation: none !important;
294
377
  }
295
378
  .ai-act,
296
- .ai-fold-ch {
379
+ .ai-fold-ch,
380
+ .ai-bg-chev {
297
381
  transition-duration: 1ms;
298
382
  }
299
383
  }
@@ -0,0 +1,113 @@
1
+ // client/v2/ai/background-model.js — issue #177: the "Running in the background" strip's model.
2
+ //
3
+ // The server sends this chat's live background tasks as `{t:'background', tasks}` (acp/background-tasks.ts):
4
+ // the WHOLE set, every time it changes — a subagent the AI launched, a command it left running. A task
5
+ // that drops out of the set has ended; the snapshot does not say how, so the row says "Finished", never
6
+ // "Done" or "Failed". A finished row stays a few seconds so the end is seen, then goes.
7
+ //
8
+ // Pure: no React, no DOM. BackgroundStrip.jsx renders it.
9
+
10
+ /** How long a finished row stays on the strip. */
11
+ export const KEEP_FINISHED_MS = 8000;
12
+ const MAX_ITEMS = 50;
13
+ const KINDS = new Set(['agent', 'command', 'other']);
14
+
15
+ /** The server's list, checked: unknown shapes dropped, strings bounded (the frame is data, not trusted shape). */
16
+ export function cleanTasks(raw) {
17
+ if (!Array.isArray(raw)) return [];
18
+ const out = [];
19
+ for (const t of raw) {
20
+ if (out.length >= MAX_ITEMS) break;
21
+ if (!t || typeof t.id !== 'string' || !t.id) continue;
22
+ out.push({
23
+ id: t.id.slice(0, 128),
24
+ kind: KINDS.has(t.kind) ? t.kind : 'other',
25
+ label: typeof t.label === 'string' ? t.label.slice(0, 120) : '',
26
+ since: Number.isFinite(t.since) ? t.since : null,
27
+ });
28
+ }
29
+ return out;
30
+ }
31
+
32
+ /**
33
+ * Fold a new task list into the strip's items. Running tasks keep their start; a running item missing
34
+ * from `tasks` becomes finished at `now`; finished items older than KEEP_FINISHED_MS are dropped.
35
+ * Running rows first (oldest first), then finished ones.
36
+ */
37
+ export function trackBackground(prev, tasks, now = Date.now()) {
38
+ const live = new Map(tasks.map((t) => [t.id, t]));
39
+ const before = new Map(prev.map((i) => [i.id, i]));
40
+ const running = tasks.map((t) => ({
41
+ id: t.id,
42
+ kind: t.kind,
43
+ label: t.label,
44
+ since: t.since ?? before.get(t.id)?.since ?? now,
45
+ state: 'running',
46
+ }));
47
+ const finished = [];
48
+ for (const i of prev) {
49
+ if (live.has(i.id)) continue;
50
+ if (i.state === 'running') finished.push({ ...i, state: 'finished', endedAt: now });
51
+ else if (now - i.endedAt < KEEP_FINISHED_MS) finished.push(i);
52
+ }
53
+ running.sort((a, b) => a.since - b.since);
54
+ return [...running, ...finished];
55
+ }
56
+
57
+ /** Drop finished rows past their time; the same array when nothing changed. */
58
+ export function pruneFinished(items, now = Date.now()) {
59
+ const next = items.filter((i) => i.state !== 'finished' || now - i.endedAt < KEEP_FINISHED_MS);
60
+ return next.length === items.length ? items : next;
61
+ }
62
+
63
+ export function runningCount(items) {
64
+ return items.filter((i) => i.state === 'running').length;
65
+ }
66
+
67
+ const count = (n, one, many) => `${n} ${n === 1 ? one : many}`;
68
+
69
+ /** "3 agents working" · "1 agent working · 1 command running" · "Finished" when nothing runs. */
70
+ export function summaryText(items) {
71
+ const run = items.filter((i) => i.state === 'running');
72
+ if (!run.length) return 'Finished';
73
+ const agents = run.filter((i) => i.kind === 'agent').length;
74
+ const commands = run.filter((i) => i.kind === 'command').length;
75
+ const other = run.length - agents - commands;
76
+ const parts = [];
77
+ if (agents) parts.push(`${count(agents, 'agent', 'agents')} working`);
78
+ if (commands) parts.push(`${count(commands, 'command', 'commands')} running`);
79
+ if (other) parts.push(`${count(other, 'task', 'tasks')} running`);
80
+ return parts.join(' · ');
81
+ }
82
+
83
+ /** What a row is: "Agent" · "Command" · "Task". */
84
+ export function kindWord(kind) {
85
+ return kind === 'agent' ? 'Agent' : kind === 'command' ? 'Command' : 'Task';
86
+ }
87
+
88
+ /** A row's name; an empty label reads as its kind. */
89
+ export function rowLabel(item) {
90
+ return item.label || kindWord(item.kind);
91
+ }
92
+
93
+ /** m:ss (h:mm:ss past an hour); null under a second. */
94
+ export function elapsedText(ms) {
95
+ if (!Number.isFinite(ms) || ms < 1000) return null;
96
+ const s = Math.floor(ms / 1000);
97
+ const h = Math.floor(s / 3600);
98
+ const m = Math.floor((s % 3600) / 60);
99
+ const ss = String(s % 60).padStart(2, '0');
100
+ return h ? `${h}:${String(m).padStart(2, '0')}:${ss}` : `${m}:${ss}`;
101
+ }
102
+
103
+ /** A row's time: how long it has run, or how long it ran. */
104
+ export function rowElapsed(item, now = Date.now()) {
105
+ return elapsedText((item.state === 'finished' ? item.endedAt : now) - item.since);
106
+ }
107
+
108
+ /** The strip's time: since the oldest running task started. */
109
+ export function stripElapsed(items, now = Date.now()) {
110
+ const run = items.filter((i) => i.state === 'running');
111
+ if (!run.length) return null;
112
+ return elapsedText(now - Math.min(...run.map((i) => i.since)));
113
+ }
@@ -10,6 +10,7 @@
10
10
  // reload. It only ever counts YOUR chats on THIS Mac (`needsYou` is mine-only by construction).
11
11
 
12
12
  import { useEffect, useSyncExternalStore } from 'react';
13
+ import { servedFetch } from '../shell/served-routes.js';
13
14
 
14
15
  let local = new Map(); // chatId -> number of open questions
15
16
  let server = 0;
@@ -83,7 +84,7 @@ export function startNeedsYouFeed({
83
84
  if (stopped || inflight) return;
84
85
  inflight = true;
85
86
  try {
86
- const res = await fetchImpl('/_api/ai/runs');
87
+ const res = await servedFetch('/_api/ai/runs', undefined, fetchImpl);
87
88
  if (!res.ok) return;
88
89
  const body = await res.json();
89
90
  if (!stopped && typeof body?.needsYou === 'number') setServerNeedsYou(body.needsYou);
@@ -10,6 +10,8 @@
10
10
  // Undo is the run's own action: "one AI run = one version = one step" (V2-1.5). The stack is read
11
11
  // for the entry carrying this `runId`, so a person's later edits never get undone with it.
12
12
 
13
+ import { fetchIfServed, servedFetch } from '../shell/served-routes.js';
14
+
13
15
  const JSON_HEADERS = { 'content-type': 'application/json' };
14
16
 
15
17
  async function json(res) {
@@ -50,7 +52,7 @@ export async function keepGoingRun(runId, fetchImpl = globalThis.fetch) {
50
52
  /** This chat's runs (YOURS), for the panel that opened after they started. [] when unreachable. */
51
53
  export async function fetchChatRuns(chatId, fetchImpl = globalThis.fetch) {
52
54
  try {
53
- const res = await fetchImpl('/_api/ai/runs');
55
+ const res = await servedFetch('/_api/ai/runs', undefined, fetchImpl);
54
56
  if (!res.ok) return [];
55
57
  const body = await json(res);
56
58
  const mine = Array.isArray(body?.mine) ? body.mine : [];
@@ -68,8 +70,10 @@ async function stackFor(run, designRel, fetchImpl) {
68
70
  if (!canvas) return { ok: false, reason: 'not-found' };
69
71
  let res;
70
72
  try {
71
- res = await fetchImpl(
72
- `/_api/project/undo-stack?canvas=${encodeURIComponent(canvasPath(designRel, canvas))}`
73
+ res = await fetchIfServed(
74
+ `/_api/project/undo-stack?canvas=${encodeURIComponent(canvasPath(designRel, canvas))}`,
75
+ undefined,
76
+ fetchImpl
73
77
  );
74
78
  } catch {
75
79
  return { ok: false, reason: 'unreachable' };
@@ -9,6 +9,7 @@
9
9
 
10
10
  import { useSyncExternalStore } from 'react';
11
11
  import { EMPTY_RUNS, finishedArtboards, normalizeRuns } from './runs-model.js';
12
+ import { servedFetch } from '../shell/served-routes.js';
12
13
 
13
14
  export const RUNS_EVENT = 'maude:ai-runs';
14
15
  const DONE_MS = 6000;
@@ -37,7 +38,7 @@ export function createRunsStore({ fetchImpl, target = globalThis.window, setTime
37
38
 
38
39
  async function read() {
39
40
  try {
40
- const res = await doFetch('/_api/ai/runs', { cache: 'no-store' });
41
+ const res = await servedFetch('/_api/ai/runs', { cache: 'no-store' }, doFetch);
41
42
  if (!res.ok) return;
42
43
  const view = normalizeRuns(await res.json());
43
44
  // a reply older than what we hold is a late answer to an earlier question
@@ -14,6 +14,8 @@
14
14
  // "Start a vote…" is a shell gesture (⌘K, the artboard menu routed through the shell's own handlers). No React, no DOM: `fetchImpl` / `now` / `setTimer` are
15
15
  // injected, so it is unit-tested without a browser.
16
16
 
17
+ import { fetchIfServed } from '../shell/served-routes.js';
18
+
17
19
  /** The words (CONTRACT §3–§4). */
18
20
  export const VOTE_WORDS = {
19
21
  title: 'Start a vote',
@@ -157,11 +159,15 @@ export function resultPlace(artboards, targets) {
157
159
 
158
160
  async function call(fetchImpl, method, url, body) {
159
161
  try {
160
- const r = await fetchImpl(url, {
161
- method,
162
- headers: { 'content-type': 'application/json' },
163
- ...(body !== undefined ? { body: JSON.stringify(body) } : {}),
164
- });
162
+ const r = await fetchIfServed(
163
+ url,
164
+ {
165
+ method,
166
+ headers: { 'content-type': 'application/json' },
167
+ ...(body !== undefined ? { body: JSON.stringify(body) } : {}),
168
+ },
169
+ fetchImpl
170
+ );
165
171
  return { status: r.status, data: await r.json().catch(() => null) };
166
172
  } catch {
167
173
  return { status: 0, data: null };
@@ -30,6 +30,7 @@ import { INDEX_CHANGED_EVENT } from '../canvases/use-canvas-index.js';
30
30
  import { nativeSave } from '../export/native-save.js';
31
31
  import { dispatchCanvasOp } from '../left-panel/left-panel-bus.js';
32
32
  import { ASK_AI_MAX } from '../search/search-env.js';
33
+ import { fetchIfServed } from '../shell/served-routes.js';
33
34
 
34
35
  /** canvas file → (rel → item): what the studio last said about each canvas. The relink gate and the
35
36
  * Inspector's absent-picture box read it; nothing else does. */
@@ -224,9 +225,11 @@ export function createAssetStateLane(deps) {
224
225
  async function ask(canvas) {
225
226
  let res;
226
227
  try {
227
- res = await fetchImpl(`/_api/asset-state?canvas=${encodeURIComponent(canvas)}`, {
228
- headers: { accept: 'application/json' },
229
- });
228
+ res = await fetchIfServed(
229
+ `/_api/asset-state?canvas=${encodeURIComponent(canvas)}`,
230
+ { headers: { accept: 'application/json' } },
231
+ fetchImpl
232
+ );
230
233
  } catch {
231
234
  return null;
232
235
  }
@@ -1,6 +1,6 @@
1
1
  // client/v2/assets/assets-bus.js — how the registry reaches the mounted Assets tab (S8.12).
2
2
  //
3
- // `assets.place` (↵) and `assets.details` (⌘I) are shell actions whose state lives in the panel: which tile is picked,
3
+ // `assets.place` (↵), `assets.details` (⌘I) and `assets.spotlight` (Space) are shell actions whose state lives in the panel: which tile is picked,
4
4
  // where the selected artboard is. The shell's one key listener and the menu runner call `runAssetsAction(id)`; the
5
5
  // panel binds itself here while it is mounted and runs the SAME functions its tile menu runs, so a key, the menu and the
6
6
  // right-click row are one code path.
@@ -9,7 +9,7 @@
9
9
  // is picked AND keyboard focus is inside the tab. A tile still picked while focus moved to the canvas or a toolbar
10
10
  // button must leave ↵ to whatever has focus.
11
11
 
12
- /** @type {{ place: () => void, details: () => void, trash: () => void, generate?: () => void, addLink?: () => void, describe?: () => void, describeStop?: () => void, tileSelected: () => boolean } | null} */
12
+ /** @type {{ place: () => void, details: () => void, spotlight?: () => void, trash: () => void, generate?: () => void, addLink?: () => void, describe?: () => void, describeStop?: () => void, tileSelected: () => boolean } | null} */
13
13
  let bound = null;
14
14
 
15
15
  /** The panel binds itself on mount. @returns the unbind. */
@@ -60,7 +60,7 @@ export function takeAddLinkRequest() {
60
60
  }
61
61
 
62
62
  /**
63
- * Run `assets.place` / `assets.details` / `assets.trash` on the picked tile, or `assets.generate` (the ask).
63
+ * Run `assets.place` / `assets.details` / `assets.spotlight` / `assets.trash` on the picked tile, or `assets.generate` (the ask).
64
64
  * @returns whether a mounted panel took it. `assets.generate` with no panel mounted is held for the next mount.
65
65
  */
66
66
  export function runAssetsAction(id) {
@@ -98,11 +98,13 @@ export function runAssetsAction(id) {
98
98
  ? bound?.place
99
99
  : id === 'assets.details'
100
100
  ? bound?.details
101
- : id === 'assets.trash'
102
- ? bound?.trash
103
- : id === 'assets.rename'
104
- ? bound?.rename
105
- : null;
101
+ : id === 'assets.spotlight'
102
+ ? bound?.spotlight
103
+ : id === 'assets.trash'
104
+ ? bound?.trash
105
+ : id === 'assets.rename'
106
+ ? bound?.rename
107
+ : null;
106
108
  if (!fn) return false;
107
109
  fn();
108
110
  return true;
@@ -41,6 +41,7 @@ export function BrowseView({
41
41
  onChange,
42
42
  onPick,
43
43
  onMenu,
44
+ onOpen = undefined,
44
45
  onBack,
45
46
  onClear,
46
47
  onPlace,
@@ -152,6 +153,7 @@ export function BrowseView({
152
153
  pickCircle
153
154
  onPick={(path, e, isMenu) => onPick(ids, path, e, isMenu)}
154
155
  onMenu={onMenu}
156
+ onOpen={onOpen}
155
157
  />
156
158
  ))}
157
159
  </div>
@@ -10,6 +10,7 @@ import { useCallback, useEffect, useRef, useState } from 'react';
10
10
  import { StIcon } from '../../shell/icons.jsx';
11
11
  import { crumbsOf, filesWords, useDsLibrary } from './ds-library.js';
12
12
  import { placeAsset, SELECT_ARTBOARD_LINE } from './place-asset.js';
13
+ import { AssetSpotlight } from './spotlight.jsx';
13
14
  import { AssetTile } from './tile.jsx';
14
15
 
15
16
  /** "Placed the photo in Fotky ze zápasu." — the design system keeps the picture; nothing is copied. */
@@ -37,6 +38,8 @@ export function DsLibraryView({
37
38
  const [query, setQuery] = useState('');
38
39
  const [picked, setPicked] = useState(null);
39
40
  const [err, setErr] = useState('');
41
+ // 2.0.4 (#191) — the tile open large: the path showing; ← → walk the files listed now, in order
42
+ const [spot, setSpot] = useState(null);
40
43
  const rootRef = useRef(null);
41
44
  const sentinel = useRef(null);
42
45
  const alive = useRef(true);
@@ -96,8 +99,30 @@ export function DsLibraryView({
96
99
  [readOnly, rows, placeTarget, placeLabel, onRecord, toast]
97
100
  );
98
101
 
102
+ const spotIndex = spot ? rows.findIndex((r) => r.path === spot) : -1;
103
+ const focusTile = (path) => {
104
+ const tile = Array.from(rootRef.current?.querySelectorAll?.('[data-asset]') ?? []).find(
105
+ (el) => el.dataset.asset === path
106
+ );
107
+ tile?.focus?.({ preventScroll: true });
108
+ };
109
+ const closeSpotlight = () => {
110
+ if (spot) focusTile(spot);
111
+ setSpot(null);
112
+ };
113
+ const openSpotlight = (path) => {
114
+ if (byPath.has(path)) setSpot(path);
115
+ };
116
+ // the same rows the tile has in this view: Place, for a file that can be one
117
+ const spotAsset = spotIndex >= 0 ? rows[spotIndex] : null;
118
+ const spotRows =
119
+ spotAsset && !readOnly && spotAsset.placeable && ['image', 'video'].includes(spotAsset.kind)
120
+ ? [{ id: 'place', label: placeLabel ? `Place in ${placeLabel}` : 'Place', keys: '↵' }]
121
+ : [];
122
+
99
123
  if (apiRef)
100
124
  apiRef.current = {
125
+ spotlight: () => (picked ? openSpotlight(picked) : undefined),
101
126
  place: () => (picked ? place(picked) : undefined),
102
127
  tileSelected: () => !!picked && !!rootRef.current?.contains(document.activeElement),
103
128
  };
@@ -212,6 +237,7 @@ export function DsLibraryView({
212
237
  setPicked(p);
213
238
  setErr('');
214
239
  }}
240
+ onOpen={openSpotlight}
215
241
  onMenu={() => {}}
216
242
  />
217
243
  ))}
@@ -258,6 +284,27 @@ export function DsLibraryView({
258
284
  {byPath.get(picked)?.name}
259
285
  </p>
260
286
  ) : null}
287
+ {spotAsset ? (
288
+ <AssetSpotlight
289
+ items={rows}
290
+ index={spotIndex}
291
+ urlOf={(p) => p}
292
+ rows={spotRows}
293
+ onIndex={(i) => {
294
+ const a = rows[i];
295
+ if (!a) return;
296
+ setSpot(a.path);
297
+ setPicked(a.path);
298
+ setErr('');
299
+ }}
300
+ onClose={closeSpotlight}
301
+ onRow={(id) => {
302
+ const path = spot;
303
+ setSpot(null);
304
+ if (id === 'place' && path) void place(path);
305
+ }}
306
+ />
307
+ ) : null}
261
308
  </div>
262
309
  );
263
310
  }