@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
@@ -8,8 +8,11 @@
8
8
  // • Maude Cloud — sign in with the same device flow CloudBar uses, then the
9
9
  // projects your account belongs to. Viewers get the browser, not a dead
10
10
  // Open (the workspace would refuse their edits).
11
- // • Your team's server — its address plus the email and password the team
12
- // gave you (the self-hosted hub's own sign-in).
11
+ // • Your team's server — its address, then "Sign in", which opens the
12
+ // server's OWN sign-in page in the browser (a password, "Sign in with
13
+ // <provider>", whatever that server offers) and comes back with a one-time
14
+ // code (issue #204, decision maude/v2-michal-team-server-signin-via-hub-page).
15
+ // The app has no email or password field for a team server.
13
16
  //
14
17
  // Every path ends in `openTeamProject` / `managedProjectOpen`: the studio holds
15
18
  // the credential and describes the project, the shell creates or reuses the
@@ -27,6 +30,7 @@ import {
27
30
  managedProjectOpen,
28
31
  managedProjectsList,
29
32
  openTeamProject,
33
+ openTeamServerSignIn,
30
34
  } from '../github.js';
31
35
  import { reasonProps } from '../v2/access/disabled-reason.js';
32
36
  import { SIGNIN_WORDS } from '../v2/signin/signin-model.js';
@@ -145,8 +149,8 @@ function ErrorLine({ text }) {
145
149
  );
146
150
  }
147
151
 
148
- // `serverOnly` (V2-4.7a): Settings › Connections › “Add a team server…” opens just the address /
149
- // email / password form — the recents and the cloud list have their own homes. The same form,
152
+ // `serverOnly` (V2-4.7a): Settings › Connections › “Add a team server…” opens just the address +
153
+ // Sign in (issue #204: the server's own page signs you in) — the recents and the cloud list have their own homes. The same form,
150
154
  // the same handler, the same consent path (opening a project still goes through the switch).
151
155
  export default function TeamProjects({ variant = 'door', initialServer = '', serverOnly = false }) {
152
156
  const [recents, setRecents] = useState(null);
@@ -158,7 +162,10 @@ export default function TeamProjects({ variant = 'door', initialServer = '', ser
158
162
  const [projects, setProjects] = useState(null);
159
163
  const [device, setDevice] = useState(null);
160
164
  const [copied, setCopied] = useState(false);
161
- const [hub, setHub] = useState({ url: initialServer, email: '', password: '' });
165
+ const [hub, setHub] = useState({ url: initialServer });
166
+ // Issue #204: a team-server sign-in waiting on the browser — `{ id, url }`.
167
+ const [hubWait, setHubWait] = useState(null);
168
+ const hubPollRef = useRef(null);
162
169
  const [busy, setBusy] = useState(''); // the key of whatever is opening
163
170
  const [opening, setOpening] = useState(''); // display name once the switch started
164
171
  const [err, setErr] = useState('');
@@ -180,6 +187,7 @@ export default function TeamProjects({ variant = 'door', initialServer = '', ser
180
187
  return () => {
181
188
  alive = false;
182
189
  clearInterval(pollRef.current);
190
+ clearInterval(hubPollRef.current);
183
191
  };
184
192
  // eslint-disable-next-line react-hooks/exhaustive-deps
185
193
  }, []);
@@ -276,17 +284,70 @@ export default function TeamProjects({ variant = 'door', initialServer = '', ser
276
284
  const openCloud = (p) =>
277
285
  run(`cloud:${p.id}`, p.name || p.id, () => openTeamProject({ kind: 'cloud', projectId: p.id }));
278
286
 
279
- const openHub = () =>
280
- run('hub', serverLabel(hub.url), () =>
281
- openTeamProject({
282
- kind: 'hub',
283
- url: hub.url.trim(),
284
- email: hub.email.trim(),
285
- password: hub.password,
286
- })
287
- );
287
+ // Issue #204 — "Sign in" opens the team server's own page; this tab's server waits for the
288
+ // browser to come back with a one-time code, stores the sign-in, and then the project opens
289
+ // the way a known server's does (no credential ever passes through this page).
290
+ async function startHubSignIn() {
291
+ if (busy || hubWait) return;
292
+ setErr('');
293
+ const url = hub.url.trim();
294
+ const r = await api('/_api/hub-signin/start', {
295
+ method: 'POST',
296
+ headers: { 'content-type': 'application/json' },
297
+ body: JSON.stringify({ url }),
298
+ });
299
+ if (!r.ok || !r.json?.ok) {
300
+ setErr(r.json?.error || 'The sign-in could not start. Try again.');
301
+ return;
302
+ }
303
+ const id = r.json.id;
304
+ const opened = await openTeamServerSignIn(r.json.signInUrl);
305
+ if (opened !== 'ok') {
306
+ void api('/_api/hub-signin/cancel', {
307
+ method: 'POST',
308
+ headers: { 'content-type': 'application/json' },
309
+ body: JSON.stringify({ id }),
310
+ });
311
+ setErr(
312
+ opened === 'refused'
313
+ ? 'Maude won’t open that address. Check the server address.'
314
+ : 'Maude couldn’t open your browser. Try again.'
315
+ );
316
+ return;
317
+ }
318
+ setHubWait({ id, url });
319
+ clearInterval(hubPollRef.current);
320
+ hubPollRef.current = setInterval(async () => {
321
+ const p = await api('/_api/hub-signin/poll', {
322
+ method: 'POST',
323
+ headers: { 'content-type': 'application/json' },
324
+ body: JSON.stringify({ id }),
325
+ });
326
+ if (p.json?.pending) return;
327
+ clearInterval(hubPollRef.current);
328
+ setHubWait(null);
329
+ if (p.ok && p.json?.ok && p.json.url) {
330
+ const signedIn = p.json.url;
331
+ run('hub', serverLabel(signedIn), () =>
332
+ openTeamProject({ kind: 'known-hub', url: signedIn })
333
+ );
334
+ } else setErr(p.json?.error || 'The sign-in did not finish. Try again.');
335
+ }, 1500);
336
+ }
288
337
 
289
- const canHub = hub.url.trim() && hub.email.trim() && hub.password;
338
+ function cancelHubSignIn() {
339
+ clearInterval(hubPollRef.current);
340
+ const id = hubWait?.id;
341
+ setHubWait(null);
342
+ if (id)
343
+ void api('/_api/hub-signin/cancel', {
344
+ method: 'POST',
345
+ headers: { 'content-type': 'application/json' },
346
+ body: JSON.stringify({ id }),
347
+ });
348
+ }
349
+
350
+ const canHub = !!hub.url.trim();
290
351
 
291
352
  return (
292
353
  <div className={`tp tp--${variant}`} data-testid="team-projects">
@@ -487,7 +548,7 @@ export default function TeamProjects({ variant = 'door', initialServer = '', ser
487
548
  className="ob-form"
488
549
  onSubmit={(e) => {
489
550
  e.preventDefault();
490
- if (canHub && !busy) openHub();
551
+ if (canHub && !busy && !hubWait) void startHubSignIn();
491
552
  }}
492
553
  >
493
554
  <label className="ob-field">
@@ -503,63 +564,52 @@ export default function TeamProjects({ variant = 'door', initialServer = '', ser
503
564
  placeholder="https://design.yourteam.com"
504
565
  aria-label="Server address"
505
566
  data-testid="team-hub-url"
567
+ disabled={!!hubWait}
506
568
  onChange={(e) => setHub((h) => ({ ...h, url: e.target.value }))}
507
569
  />
508
570
  </span>
509
571
  </label>
510
- <label className="ob-field">
511
- <span className="ob-field-label">Email</span>
512
- <span className="ob-field-wrap">
513
- <Icon name="user" size={14} className="ob-field-pre" />
514
- <input
515
- className="input ob-input"
516
- type="email"
517
- autoComplete="username"
518
- value={hub.email}
519
- placeholder="you@yourteam.com"
520
- aria-label="Email"
521
- data-testid="team-hub-email"
522
- onChange={(e) => setHub((h) => ({ ...h, email: e.target.value }))}
523
- />
524
- </span>
525
- </label>
526
- <label className="ob-field">
527
- <span className="ob-field-label">Password</span>
528
- <span className="ob-field-wrap">
529
- <Icon name="key" size={14} className="ob-field-pre" />
530
- <input
531
- className="input ob-input"
532
- type="password"
533
- autoComplete="current-password"
534
- value={hub.password}
535
- aria-label="Password"
536
- data-testid="team-hub-password"
537
- onChange={(e) => setHub((h) => ({ ...h, password: e.target.value }))}
538
- />
539
- </span>
540
- </label>
541
- <div className="ob-form-actions">
542
- <button
543
- type="submit"
544
- className="btn btn--primary"
545
- disabled={!canHub || !!busy}
546
- {...reasonProps(
547
- !canHub || !!busy,
548
- busy ? 'Opening…' : 'Fill in the address, email and password first.'
549
- )}
550
- data-testid="team-hub-open"
551
- >
552
- {busy === 'hub' ? (
553
- <>
554
- <Icon name="spinner" size={15} className="ob-spin" /> Signing in…
555
- </>
556
- ) : (
557
- <>
558
- <Icon name="arrow-right" size={15} /> Sign in and open
559
- </>
560
- )}
561
- </button>
562
- </div>
572
+ {hubWait ? (
573
+ <div className="ob-form-actions" data-testid="team-hub-waiting">
574
+ <span className="gi-dc-status" aria-live="polite">
575
+ <span className="gi-pulse" aria-hidden="true" /> Finish signing in in your browser…
576
+ </span>
577
+ <button
578
+ type="button"
579
+ className="btn btn--ghost"
580
+ onClick={cancelHubSignIn}
581
+ data-testid="team-hub-cancel"
582
+ >
583
+ Cancel
584
+ </button>
585
+ </div>
586
+ ) : (
587
+ <div className="ob-form-actions">
588
+ <button
589
+ type="submit"
590
+ className="btn btn--primary"
591
+ disabled={!canHub || !!busy}
592
+ {...reasonProps(
593
+ !canHub || !!busy,
594
+ busy ? 'Opening…' : 'Fill in the server address first.'
595
+ )}
596
+ data-testid="team-hub-open"
597
+ >
598
+ {busy === 'hub' ? (
599
+ <>
600
+ <Icon name="spinner" size={15} className="ob-spin" /> Opening…
601
+ </>
602
+ ) : (
603
+ <>
604
+ <Icon name="external" size={15} /> Sign in
605
+ </>
606
+ )}
607
+ </button>
608
+ </div>
609
+ )}
610
+ <p className="ob-foot-note">
611
+ Opens your team server’s sign-in page in your browser, then brings you back.
612
+ </p>
563
613
  </form>
564
614
  </section>
565
615
 
@@ -10,6 +10,7 @@ import { recordSent, sentFromChips } from '../v2/ai/sent-attachments.js';
10
10
  import { readMay } from '../v2/ai/ai-may.js';
11
11
  import { mayField, mergeOutbox, newAskId, promptFrame, reduceQueued } from '../v2/ai/ask-frame.js';
12
12
  import { noteAskedAnnotations } from '../v2/ai/ai-offer.js';
13
+ import { cleanTasks } from '../v2/ai/background-model.js';
13
14
 
14
15
  const WS_PATH = '/_ws/acp';
15
16
 
@@ -252,6 +253,17 @@ export function createAcpConnection() {
252
253
  emitBackground();
253
254
  }
254
255
 
256
+ // Issue #177 — the chat's live background tasks (subagents, background commands): the server's
257
+ // `{t:'background', tasks}` snapshot, replaced whole on every change and replayed on attach. Chrome,
258
+ // not turn content — it outlives the turn by design.
259
+ const bgTaskListeners = new Set();
260
+ let bgTasks = [];
261
+ function setBgTasks(next) {
262
+ if (next === bgTasks || (!next.length && !bgTasks.length)) return;
263
+ bgTasks = next;
264
+ for (const fn of bgTaskListeners) fn(bgTasks);
265
+ }
266
+
255
267
  // Connection-problem error card (Task C3) — the bridge `error` frame (a
256
268
  // socket/adapter failure mid-turn) is ALSO thrown from prompt()'s generator
257
269
  // (so assistant-ui's own turn-failed bookkeeping still runs), but a thrown
@@ -307,6 +319,10 @@ export function createAcpConnection() {
307
319
  if (frame.running) setBusy(true);
308
320
  return;
309
321
  }
322
+ if (frame.t === 'background') {
323
+ setBgTasks(cleanTasks(frame.tasks));
324
+ return;
325
+ }
310
326
  if (frame.t === 'ready') {
311
327
  status.ready = true;
312
328
  status.available = frame.available;
@@ -456,6 +472,8 @@ export function createAcpConnection() {
456
472
  ws = null;
457
473
  status.ready = false;
458
474
  emitStatus();
475
+ // The bridge is unreachable: what it ran is unknown until the next attach replays it.
476
+ setBgTasks([]);
459
477
  };
460
478
  sock.onmessage = (e) => {
461
479
  try {
@@ -487,6 +505,13 @@ export function createAcpConnection() {
487
505
  return () => turnFrameListeners.delete(fn);
488
506
  },
489
507
 
508
+ /** Issue #177 — the live background tasks; `fn(list)` now and on every change. */
509
+ onBackgroundTasks(fn) {
510
+ bgTaskListeners.add(fn);
511
+ fn(bgTasks);
512
+ return () => bgTaskListeners.delete(fn);
513
+ },
514
+
490
515
  /** Subscribe to the post-turn-end continuation parts; replays the current tail. */
491
516
  onBackground(fn) {
492
517
  backgroundListeners.add(fn);
@@ -0,0 +1,66 @@
1
+ // When a chat counts as "finished" — the ping behind the AI-finished notification, the Dock badge
2
+ // and the dot in the chat list. Pure state, so it is testable without a socket.
3
+ //
4
+ // A connection replays its CURRENT busy state the moment anyone subscribes (`onBusy` calls the
5
+ // listener with `busy` straight away), so "not busy" alone is not the end of a turn: on every
6
+ // project load that replay used to ping "AI finished" with no AI run at all. A turn ends only on a
7
+ // busy → not-busy change. Background work (a subagent, a task the AI left running) can outlive the
8
+ // turn (claude-agent-acp #773, issue #177): then the ping waits until it drains.
9
+ //
10
+ // Hooks (all optional): dot(on) — the chat's busy dot; aggregate(busy) — this chat's share of the
11
+ // app-wide busy state; finished() — the ping; refresh() — reload the chat list.
12
+ export function createFinishTracker(hooks = {}) {
13
+ const call = (name, ...args) => hooks[name]?.(...args);
14
+ let toolsActive = false; // a tool (e.g. a subagent) is still running
15
+ let tasksActive = false; // a background task is still running
16
+ let bgActive = false; // either of the two
17
+ let busyNow = false; // the prompt turn itself is in flight
18
+ let deferredFinish = false; // a turn (or background work) ended while something still ran
19
+
20
+ const background = () => {
21
+ bgActive = toolsActive || tasksActive;
22
+ call('aggregate', busyNow || bgActive);
23
+ if (deferredFinish && !bgActive && !busyNow) {
24
+ deferredFinish = false;
25
+ call('dot', false);
26
+ call('finished');
27
+ call('refresh');
28
+ }
29
+ };
30
+
31
+ return {
32
+ activity(activeTools) {
33
+ toolsActive = activeTools.length > 0;
34
+ background();
35
+ },
36
+ tasks(list) {
37
+ tasksActive = list.length > 0;
38
+ if (tasksActive && !busyNow) {
39
+ // work started outside a turn (a follow-up the AI began on its own): lit until it ends
40
+ deferredFinish = true;
41
+ call('dot', true);
42
+ }
43
+ background();
44
+ },
45
+ busy(busy) {
46
+ const wasBusy = busyNow;
47
+ busyNow = busy;
48
+ call('aggregate', busyNow || bgActive);
49
+ if (busy) {
50
+ deferredFinish = false; // a new turn supersedes any pending drain ping
51
+ call('dot', true);
52
+ return;
53
+ }
54
+ if (!wasBusy) return; // the subscribe-time replay of an idle chat, not the end of a turn
55
+ // Turn ended. If background work is still draining, keep the dot lit and hold the ping.
56
+ if (bgActive) {
57
+ deferredFinish = true;
58
+ call('refresh');
59
+ } else {
60
+ call('dot', false);
61
+ call('finished');
62
+ call('refresh');
63
+ }
64
+ },
65
+ };
66
+ }
@@ -0,0 +1,53 @@
1
+ // shell/frame-cap.js — Maude 2.0.4 (task O): how many canvas frames the viewport keeps mounted.
2
+ //
3
+ // Every mounted canvas frame is a whole page: its own React, its own canvas runtime and the canvas bundle (~2 MB
4
+ // of script per canvas), plus every picture on it decoded. The viewport mounts one frame per entry in `tabs`, and
5
+ // some roads append to `tabs` without dropping the frame before (a comment jump into another canvas), so a session
6
+ // could keep any number of canvases alive. The cap: the active canvas + the one shown just before it. A frame past
7
+ // the cap unmounts; opening its canvas again loads it afresh — its camera comes back from `_canvas-state` like any
8
+ // open.
9
+
10
+ /** Frames kept mounted at most: the active canvas + 1 most recent. */
11
+ export const FRAME_CAP = 2;
12
+
13
+ /** How many recent canvases are remembered (only the first FRAME_CAP - 1 others are ever mounted). */
14
+ const RECENT_KEEP = 8;
15
+
16
+ /**
17
+ * The recency list with `path` moved to the front (most recent first). Returns the SAME array when `path` is
18
+ * already at the front, so a render that changes nothing allocates nothing.
19
+ * @param {string[]} recent
20
+ * @param {string | null | undefined} path
21
+ * @returns {string[]}
22
+ */
23
+ export function noteShown(recent, path) {
24
+ if (!path || recent[0] === path) return recent;
25
+ return [path, ...recent.filter((p) => p !== path)].slice(0, RECENT_KEEP);
26
+ }
27
+
28
+ /**
29
+ * Which tabs get a mounted frame: the active path, then the most recently shown other open tabs, up to `cap`.
30
+ * Paths in `skip` (views that are not canvas frames, like the Design system tab) are never counted.
31
+ * @param {{ path: string }[]} tabs
32
+ * @param {string | null | undefined} activePath
33
+ * @param {string[]} recent most recent first
34
+ * @param {{ cap?: number, skip?: (path: string) => boolean }} [opts]
35
+ * @returns {Set<string>}
36
+ */
37
+ export function framesToMount(tabs, activePath, recent, opts = {}) {
38
+ const cap = opts.cap ?? FRAME_CAP;
39
+ const skip = opts.skip ?? (() => false);
40
+ const open = new Set(tabs.map((t) => t.path).filter((p) => !skip(p)));
41
+ const keep = new Set();
42
+ if (activePath && open.has(activePath)) keep.add(activePath);
43
+ for (const p of recent) {
44
+ if (keep.size >= cap) break;
45
+ if (open.has(p)) keep.add(p);
46
+ }
47
+ // an open tab never shown yet (none in practice — every tab is opened by showing it) takes a free slot
48
+ for (const p of open) {
49
+ if (keep.size >= cap) break;
50
+ keep.add(p);
51
+ }
52
+ return keep;
53
+ }
@@ -27,6 +27,7 @@ import { insetsNow } from '../v2/shell/insets-now.js';
27
27
  import { normalizeOpenPath } from '../share-link.js';
28
28
  import { framesIsolated, sessionRole } from '../v2/access/access-client.js';
29
29
  import { CanvasDropCatcher, catcherReadOnly } from '../v2/assets/canvas-drop-catcher.jsx';
30
+ import { framesToMount, noteShown } from './frame-cap.js';
30
31
 
31
32
  export function Viewport({
32
33
  tabs,
@@ -154,6 +155,13 @@ export function Viewport({
154
155
  ? 'loading'
155
156
  : 'idle';
156
157
  const soloFrame = framesIsolated(cfg);
158
+ // 2.0.4 (task O) — at most the active canvas frame + the one shown before it stay mounted (frame-cap.js): each
159
+ // frame is a whole page with its own runtime, so an unbounded `tabs` list was an unbounded memory bill.
160
+ const recentRef = useRef([]);
161
+ recentRef.current = noteShown(recentRef.current, activePath);
162
+ const mounted = framesToMount(tabs, activePath, recentRef.current, {
163
+ skip: (p) => p === SYSTEM_TAB,
164
+ });
157
165
  return (
158
166
  // V2-8.7 — the stage IS the page's main landmark (axe landmark-one-main: with no canvas open the shell had none)
159
167
  <main className="viewport sh-stage" data-tour="viewport" data-canvas-state={canvasState}>
@@ -230,6 +238,7 @@ export function Viewport({
230
238
  // p8-secfix-f F1 — sibling frames on the one canvas origin can read each other; a canvas-only
231
239
  // session's frames carry different grants, so only its active canvas is framed (no keep-alive).
232
240
  if (soloFrame && t.path !== activePath) return null;
241
+ if (!mounted.has(t.path)) return null;
233
242
  return (
234
243
  <iframe
235
244
  // The nonce is part of the key ONLY so the #115 Retry can force a
@@ -174,6 +174,8 @@
174
174
  @import url("../v2/assets/describe.css");
175
175
  /* 2.0.2 - the Assets tab Library switch and a design system own library (client/v2/assets/ds-library-view.jsx). */
176
176
  @import url("../v2/assets/ds-library.css");
177
+ /* 2.0.4 - an Assets tile, large: double-click opens it in a window (client/v2/assets/spotlight.jsx). */
178
+ @import url("../v2/assets/spotlight.css");
177
179
  /* Phase 4 gate — the a11y contrast floor (WCAG 1.4.3), utilities layer: wins over shell + components. */
178
180
  @import url("../v2/shell/contrast.css");
179
181
  /* V2-3.3 — the Home page, scoped under `.maude-v2.home-root` (maude-v2 tokens only). */
@@ -17,6 +17,8 @@ import { prefetchPreviewImage } from '../panels/file-preview.jsx';
17
17
  import { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
18
18
  import { useTreeDrag } from '../use-tree-drag.js';
19
19
  import { TreeRowMenu, useRowMenu } from '../tree-row-menu.jsx';
20
+ import { TreeAsk } from '../v2/canvases/folder-dialogs.jsx';
21
+ import { askFailure, checkAskName, FOLDER_ASK_WORDS } from '../v2/canvases/folder-ask.js';
20
22
  import CloudBar from '../panels/CloudBar.jsx';
21
23
  import IdentityBar from '../panels/IdentityBar.jsx';
22
24
  import { CanvasesPanel } from '../v2/canvases/canvases-panel.jsx';
@@ -941,6 +943,23 @@ export function Sidebar({
941
943
  // non-DS canvas group folder (incl. each group's own root) is a valid
942
944
  // "Move to…" destination.
943
945
  const rowMenu = useRowMenu();
946
+ // #195 — the folder and file rows' asks (New folder here, Rename folder, Delete folder, a file's Rename… and
947
+ // Delete): one centered dialog at a time (v2/canvases/folder-dialogs.jsx), never `window.prompt`/`confirm`.
948
+ const [treeAsk, setTreeAsk] = useState(null);
949
+ const closeTreeAsk = useCallback(() => setTreeAsk(null), []);
950
+ const runTreeAsk = useCallback(
951
+ (ask, name) => {
952
+ const label = ask.name ?? ask.path.split('/').pop();
953
+ if (ask.kind === 'new-folder') return onNewFolder(ask.path, name, { quiet: true });
954
+ if (ask.kind === 'rename-folder') return onRenameFolder(ask.path, name, { quiet: true });
955
+ if (ask.kind === 'rename-canvas' || ask.kind === 'rename-file')
956
+ return onRenameCanvas(ask.path, name, { quiet: true });
957
+ if (ask.kind === 'trash-folder') return onDeleteFolder(ask.path, label, { quiet: true });
958
+ if (ask.kind === 'trash-file') return onDeleteFile(ask.path, label, { quiet: true });
959
+ return { ok: false };
960
+ },
961
+ [onNewFolder, onRenameFolder, onRenameCanvas, onDeleteFolder, onDeleteFile]
962
+ );
944
963
  // P8 round 7 — the pinned system row whose name is a field (Rename…, 13 · ds-multi-menu)
945
964
  const [renamingDs, setRenamingDs] = useState(null);
946
965
  const destinations = useMemo(() => {
@@ -997,10 +1016,11 @@ export function Sidebar({
997
1016
  label: 'Rename…',
998
1017
  onSelect: () => {
999
1018
  rowMenu.close();
1000
- const current = displayName(menuExtra.path.split('/').pop());
1001
- const name = window.prompt('Rename canvas to:', current);
1002
- if (name?.trim() && name.trim() !== current)
1003
- onRenameCanvas(menuExtra.path, name.trim());
1019
+ setTreeAsk({
1020
+ kind: 'rename-canvas',
1021
+ path: menuExtra.path,
1022
+ name: displayName(menuExtra.path.split('/').pop()),
1023
+ });
1004
1024
  },
1005
1025
  },
1006
1026
  ]
@@ -1026,12 +1046,11 @@ export function Sidebar({
1026
1046
  label: 'Rename…',
1027
1047
  onSelect: () => {
1028
1048
  rowMenu.close();
1029
- const n = menuExtra.name ?? menuExtra.path.split('/').pop();
1030
- const ext = n.includes('.') ? n.slice(n.lastIndexOf('.')) : '';
1031
- const current = ext ? n.slice(0, -ext.length) : n;
1032
- const name = window.prompt(`Rename ${n} to:`, current);
1033
- if (name?.trim() && name.trim() !== current)
1034
- onRenameCanvas(menuExtra.path, name.trim());
1049
+ setTreeAsk({
1050
+ kind: 'rename-file',
1051
+ path: menuExtra.path,
1052
+ name: menuExtra.name ?? menuExtra.path.split('/').pop(),
1053
+ });
1035
1054
  },
1036
1055
  },
1037
1056
  ]
@@ -1047,7 +1066,11 @@ export function Sidebar({
1047
1066
  destructive: true,
1048
1067
  onSelect: () => {
1049
1068
  rowMenu.close();
1050
- onDeleteFile(menuExtra.path, menuExtra.name ?? menuExtra.path.split('/').pop());
1069
+ setTreeAsk({
1070
+ kind: 'trash-file',
1071
+ path: menuExtra.path,
1072
+ name: menuExtra.name ?? menuExtra.path.split('/').pop(),
1073
+ });
1051
1074
  },
1052
1075
  },
1053
1076
  ]
@@ -1058,10 +1081,10 @@ export function Sidebar({
1058
1081
  {
1059
1082
  id: 'new-folder-here',
1060
1083
  label: 'New folder here',
1084
+ // #195 — asked in the shell's own dialog: `window.prompt` is a no-op in the desktop app
1061
1085
  onSelect: () => {
1062
1086
  rowMenu.close();
1063
- const name = window.prompt('New folder name:');
1064
- if (name?.trim()) onNewFolder(menuExtra.dirPath, name.trim());
1087
+ setTreeAsk({ kind: 'new-folder', path: menuExtra.dirPath });
1065
1088
  },
1066
1089
  },
1067
1090
  {
@@ -1069,10 +1092,7 @@ export function Sidebar({
1069
1092
  label: 'Rename folder',
1070
1093
  onSelect: () => {
1071
1094
  rowMenu.close();
1072
- const current = menuExtra.dirPath.split('/').pop();
1073
- const name = window.prompt('Rename folder to:', current);
1074
- if (name?.trim() && name.trim() !== current)
1075
- onRenameFolder(menuExtra.dirPath, name.trim());
1095
+ setTreeAsk({ kind: 'rename-folder', path: menuExtra.dirPath });
1076
1096
  },
1077
1097
  },
1078
1098
  {
@@ -1081,7 +1101,7 @@ export function Sidebar({
1081
1101
  destructive: true,
1082
1102
  onSelect: () => {
1083
1103
  rowMenu.close();
1084
- onDeleteFolder(menuExtra.dirPath, menuExtra.dirPath.split('/').pop());
1104
+ setTreeAsk({ kind: 'trash-folder', path: menuExtra.dirPath });
1085
1105
  },
1086
1106
  },
1087
1107
  ]
@@ -1118,14 +1138,20 @@ export function Sidebar({
1118
1138
  setNamingErr('');
1119
1139
  if (!defaultFolderParent) {
1120
1140
  setNaming({ ...naming, busy: false });
1121
- setNamingErr('no canvas group to create a folder in');
1141
+ setNamingErr(FOLDER_ASK_WORDS.noGroup);
1142
+ return;
1143
+ }
1144
+ const v = checkAskName({ kind: 'new-folder', path: defaultFolderParent }, name);
1145
+ if (v.kind === 'error') {
1146
+ setNaming({ ...naming, busy: false });
1147
+ setNamingErr(v.error);
1122
1148
  return;
1123
1149
  }
1124
- const res = await onNewFolder(defaultFolderParent, name);
1150
+ const res = await onNewFolder(defaultFolderParent, name, { quiet: true });
1125
1151
  if (res?.ok) cancelNaming();
1126
1152
  else {
1127
1153
  setNaming({ ...naming, busy: false });
1128
- setNamingErr(res?.error || 'Could not make the folder. Nothing was changed.');
1154
+ setNamingErr(askFailure('new-folder', res));
1129
1155
  }
1130
1156
  }, [naming, defaultFolderParent, onNewFolder, cancelNaming]);
1131
1157
 
@@ -1464,6 +1490,7 @@ export function Sidebar({
1464
1490
  destinations={rowMenuDestinations}
1465
1491
  onPickDestination={(dest) => onMoveCanvas(menuExtra.path, dest)}
1466
1492
  />
1493
+ <TreeAsk ask={treeAsk} run={runTreeAsk} onClose={closeTreeAsk} />
1467
1494
  {/* P8 C4: no project switcher here — the project pill is the switcher (RepoBranchSwitcher.jsx). */}
1468
1495
  {/* Cloud Phase 23 C3 — Maude Cloud sign-in + remote-project attach, docked
1469
1496
  above the GitHub identity. Dev-server-backed, so it works in the desktop