@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,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 };