@1agh/maude 2.0.0-rc.2 → 2.0.0

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 (76) hide show
  1. package/apps/studio/acp/login-state.ts +3 -2
  2. package/apps/studio/actions/defs/chat.ts +4 -1
  3. package/apps/studio/actions.manifest.json +1 -1
  4. package/apps/studio/bridge/dgn-protocol.ts +13 -0
  5. package/apps/studio/canvas-lib.tsx +7 -0
  6. package/apps/studio/client/export-lane.js +4 -2
  7. package/apps/studio/client/hooks/use-canvas-bridge.jsx +6 -0
  8. package/apps/studio/client/panels/ChatPanel.jsx +10 -2
  9. package/apps/studio/client/panels/acp-runtime.js +14 -0
  10. package/apps/studio/client/system/system-view.jsx +6 -2
  11. package/apps/studio/client/tree-row-menu.jsx +4 -0
  12. package/apps/studio/client/v2/ai/Advanced.jsx +23 -7
  13. package/apps/studio/client/v2/ai/AttachMenu.jsx +4 -0
  14. package/apps/studio/client/v2/ai/ChatList.jsx +7 -1
  15. package/apps/studio/client/v2/ai/ConnectSheet.jsx +75 -4
  16. package/apps/studio/client/v2/ai/NeedsYouSlot.jsx +42 -8
  17. package/apps/studio/client/v2/ai/NotReady.jsx +24 -3
  18. package/apps/studio/client/v2/ai/RunList.jsx +4 -0
  19. package/apps/studio/client/v2/ai/RunSurface.jsx +14 -4
  20. package/apps/studio/client/v2/ai/ScopeChip.jsx +4 -0
  21. package/apps/studio/client/v2/ai/Working.jsx +13 -1
  22. package/apps/studio/client/v2/ai/activity-line.js +390 -0
  23. package/apps/studio/client/v2/ai/activity-store.js +45 -0
  24. package/apps/studio/client/v2/ai/advanced-model.js +62 -12
  25. package/apps/studio/client/v2/ai/ai-list-advanced.css +7 -0
  26. package/apps/studio/client/v2/ai/ai-run.css +19 -0
  27. package/apps/studio/client/v2/ai/ai-send.js +6 -2
  28. package/apps/studio/client/v2/ai/connect-flow.js +29 -8
  29. package/apps/studio/client/v2/ai/needs-you.css +18 -0
  30. package/apps/studio/client/v2/ai/ring-relay.js +11 -1
  31. package/apps/studio/client/v2/ai/use-activity-line.js +81 -0
  32. package/apps/studio/client/v2/annotations/templates-panel.jsx +4 -0
  33. package/apps/studio/client/v2/assets/kinds-chip.jsx +1 -1
  34. package/apps/studio/client/v2/assets/place-asset.js +20 -1
  35. package/apps/studio/client/v2/assets/tile-menu.jsx +1 -1
  36. package/apps/studio/client/v2/canvases/canvases-panel.jsx +5 -1
  37. package/apps/studio/client/v2/canvases/row-menu.jsx +4 -2
  38. package/apps/studio/client/v2/ds/review.css +2 -0
  39. package/apps/studio/client/v2/empty/ai-drafting.jsx +78 -0
  40. package/apps/studio/client/v2/empty/empty-host.jsx +17 -0
  41. package/apps/studio/client/v2/empty/empty.css +98 -0
  42. package/apps/studio/client/v2/export/advanced/render.jsx +5 -2
  43. package/apps/studio/client/v2/export/export-copy.js +11 -4
  44. package/apps/studio/client/v2/export/export-sheet.jsx +6 -2
  45. package/apps/studio/client/v2/export/exports-model.js +13 -0
  46. package/apps/studio/client/v2/export/exports-panel.jsx +4 -2
  47. package/apps/studio/client/v2/export/job-row.jsx +4 -0
  48. package/apps/studio/client/v2/export/other-formats.jsx +7 -1
  49. package/apps/studio/client/v2/export/sections/batch-model.js +3 -2
  50. package/apps/studio/client/v2/export/sections/batch.jsx +20 -4
  51. package/apps/studio/client/v2/inspector/sections/colour-popover.jsx +4 -0
  52. package/apps/studio/client/v2/inspector/token-chip.jsx +4 -0
  53. package/apps/studio/client/v2/kinds/SizePicker.jsx +4 -0
  54. package/apps/studio/client/v2/presence/faces.jsx +4 -0
  55. package/apps/studio/client/v2/share/role-menu.jsx +7 -1
  56. package/apps/studio/client/v2/share/share-model.js +20 -1
  57. package/apps/studio/client/v2/share/share-sheet.jsx +6 -4
  58. package/apps/studio/client/v2/shell/account-card.jsx +7 -1
  59. package/apps/studio/client/v2/shell/canvas-pointer.js +21 -0
  60. package/apps/studio/client/v2/shell/mode-switch.jsx +4 -0
  61. package/apps/studio/client/v2/shell/project-pill.jsx +4 -0
  62. package/apps/studio/client/v2/shell/save-status.js +10 -1
  63. package/apps/studio/client/v2/shell/share-cluster-host.jsx +2 -0
  64. package/apps/studio/client/v2/shell/share-cluster.jsx +6 -1
  65. package/apps/studio/client/v2/shell/use-dismiss-outside.js +14 -6
  66. package/apps/studio/client/v2/timeline/joins/transition-picker.jsx +7 -1
  67. package/apps/studio/client/v2/undo/undo-history.jsx +7 -1
  68. package/apps/studio/cloud/endpoints.ts +31 -1
  69. package/apps/studio/dist/client.bundle.js +921 -921
  70. package/apps/studio/dist/comment-mount.js +1 -1
  71. package/apps/studio/dist/styles.css +1 -1
  72. package/apps/studio/editing/canvas-pointer.ts +29 -0
  73. package/apps/studio/routes/cloud-move.ts +7 -4
  74. package/apps/studio/video-play-overlay.tsx +67 -12
  75. package/apps/studio/whats-new.json +43 -16
  76. package/package.json +8 -8
@@ -125,9 +125,13 @@ export async function relayAiSend(island, d, env = {}) {
125
125
  }
126
126
 
127
127
  let field = composerField(island);
128
- if (d.newChat) {
128
+ // rc3-f (issue #181): while Claude is not connected the header draws no New chat (chat-header.jsx). The open
129
+ // chat then IS the place for the sentence when its field is empty — waiting for a New chat that never comes
130
+ // dropped a Home prompt on a fresh Mac. A draft the person is typing is still never overwritten.
131
+ const newBtn = d.newChat ? island.querySelector('[data-testid="ai-chat-new"]') : null;
132
+ if (d.newChat && newBtn) {
129
133
  const before = field;
130
- island.querySelector('[data-testid="ai-chat-new"]')?.click();
134
+ newBtn.click();
131
135
  field = await until(() => {
132
136
  const f = composerField(island);
133
137
  return f && f !== before ? f : null;
@@ -5,6 +5,10 @@
5
5
  // connectClaude({ fetchImpl, sleep, signal, onPhase }) → { ok: true } | { ok: false, reason }
6
6
  //
7
7
  // Phases: 'installing' · 'waiting' (for the browser). Cancel = abort the signal (the sign-in is withdrawn).
8
+ // `onPhase(phase, info)`: for 'installing', `info.startedAt` (ms) is when the install began — the server's own
9
+ // clock when it says so, so a sheet that joins a running install shows the real elapsed time.
10
+ // rc3-f (issue #181): a click while an install already runs JOINS it (the server answers 409 "already in
11
+ // progress"); it is never a dead-end error.
8
12
  // Pure of React so test/v2-ai-needs-you.test.ts drives it with a scripted fetch.
9
13
 
10
14
  const SIGNIN_POLL_MS = 2000;
@@ -38,21 +42,38 @@ export async function connectClaude({
38
42
  if (first?.status === 'present' && !force) return { ok: true };
39
43
 
40
44
  if (first?.action === 'install' && !force) {
41
- onPhase('installing');
45
+ const installState = () =>
46
+ fetchImpl('/_api/claude/install-status')
47
+ .then(json)
48
+ .catch(() => null);
49
+ const startedAtOf = (state) =>
50
+ typeof state?.startedAt === 'number' && Number.isFinite(state.startedAt)
51
+ ? state.startedAt
52
+ : now();
42
53
  const started = await post('/_api/claude/install');
43
- if (!started?.ok)
44
- return { ok: false, reason: started?.reason || 'Could not start the installer.' };
54
+ let startedAt = now();
55
+ if (!started?.ok) {
56
+ // Already running (an earlier click, another window, a sheet that was closed): join it.
57
+ const state = await installState();
58
+ if (state?.phase !== 'running')
59
+ return { ok: false, reason: started?.reason || 'Could not start the installer.' };
60
+ startedAt = startedAtOf(state);
61
+ }
62
+ onPhase('installing', { startedAt });
45
63
  let deadline = now() + INSTALL_MAX_MS;
46
64
  for (;;) {
47
65
  if (cancelled()) return { ok: false, reason: 'cancelled' };
48
- if (now() > deadline) return { ok: false, reason: 'Install is taking longer than expected.' };
49
- const state = await fetchImpl('/_api/claude/install-status')
50
- .then(json)
51
- .catch(() => null);
66
+ if (now() > deadline)
67
+ return {
68
+ ok: false,
69
+ reason: 'Could not tell how the Claude Code install is going. Try again.',
70
+ };
71
+ const state = await installState();
52
72
  if (state?.phase === 'running')
53
73
  deadline = now() + INSTALL_MAX_MS; // progressing: never cut off
54
74
  else if (state?.phase === 'done') {
55
- if (!state.ok) return { ok: false, reason: state.reason || 'Install failed.' };
75
+ if (!state.ok)
76
+ return { ok: false, reason: state.reason || 'Claude Code did not install. Try again.' };
56
77
  break;
57
78
  }
58
79
  await sleep(INSTALL_POLL_MS);
@@ -520,6 +520,24 @@
520
520
  font-size: var(--type-xs);
521
521
  color: var(--status-error-text);
522
522
  }
523
+ /* rc3-f: the setup's live status line (what runs, how long, what is next) */
524
+ .ai-conn-b .ai-conn-prog {
525
+ padding: var(--space-2) var(--space-3);
526
+ border-radius: var(--radius-md);
527
+ background: var(--spark-muted);
528
+ font-size: var(--type-xs);
529
+ line-height: var(--lh-xs);
530
+ color: var(--fg-1);
531
+ }
532
+ .ai-conn-prog strong {
533
+ color: var(--fg-0);
534
+ font-weight: var(--w-semibold);
535
+ font-variant-numeric: tabular-nums;
536
+ }
537
+ .ai-conn-step {
538
+ display: block;
539
+ color: var(--fg-2);
540
+ }
523
541
  .ai-conn-a {
524
542
  display: flex;
525
543
  justify-content: flex-end;
@@ -30,6 +30,8 @@ import {
30
30
  ringsFor,
31
31
  } from './runs-model.js';
32
32
  import { getRunsStore } from './runs-store.js';
33
+ import { targetRings } from './activity-line.js';
34
+ import { getActivityStore } from './activity-store.js';
33
35
 
34
36
  const FRAME = 'iframe[data-testid="canvas-frame"]';
35
37
 
@@ -37,6 +39,8 @@ export function createRingsLane({
37
39
  store,
38
40
  // S5.15 — "Made by AI" (made-by-ai.js): settled rings that last until the next person's change
39
41
  madeByAi = getMadeByAiStore(),
42
+ // rc3-h (#182) — the artboard the chat's in-flight edit names, ringed before the write lands
43
+ activity = getActivityStore(),
40
44
  doc = globalThis.document,
41
45
  win = globalThis.window,
42
46
  } = {}) {
@@ -54,7 +58,11 @@ export function createRingsLane({
54
58
  if (!origin) return;
55
59
  const { view, done } = store.getSnapshot();
56
60
  const file = frame.getAttribute('data-path') || frame.dataset?.path || '';
57
- const artboards = mergeRings(ringsFor(view, { activeCanvas: file }), {
61
+ const live = {
62
+ ...targetRings(activity?.get?.(), file),
63
+ ...ringsFor(view, { activeCanvas: file }),
64
+ };
65
+ const artboards = mergeRings(live, {
58
66
  ...madeByAiRings(madeByAi?.getSnapshot(), file),
59
67
  ...doneRings(Object.keys(done)),
60
68
  });
@@ -116,6 +124,7 @@ export function createRingsLane({
116
124
  }
117
125
  const unsub = store.subscribe(onTick);
118
126
  const unsubMade = madeByAi?.subscribe(tellAll);
127
+ const unsubActivity = activity?.subscribe?.(tellAll);
119
128
  const onMessage = (e) => {
120
129
  const dgn = e.data?.dgn;
121
130
  if (dgn !== 'loaded' && dgn !== 'canvas-rendered') return;
@@ -133,6 +142,7 @@ export function createRingsLane({
133
142
  clearTimeout(expiryTimer);
134
143
  unsub();
135
144
  unsubMade?.();
145
+ unsubActivity?.();
136
146
  win?.removeEventListener?.('message', onMessage);
137
147
  };
138
148
  }
@@ -0,0 +1,81 @@
1
+ // client/v2/ai/use-activity-line.js — rc3-h (#182): feeds the chat's live stream into the activity line
2
+ // (activity-line.js) and re-renders only when what it shows changes — a waiting swap, the idle fallback, a
3
+ // new announcement. While `live` is false the line is empty and the canvas target is let go.
4
+
5
+ import { useEffect, useRef, useState } from 'react';
6
+ import { createActivityLine } from './activity-line.js';
7
+ import { getActivityStore } from './activity-store.js';
8
+
9
+ const EMPTY = { text: null, step: null, target: null, announce: null };
10
+ const sameView = (a, b) =>
11
+ a.text === b.text &&
12
+ a.step === b.step &&
13
+ a.target === b.target &&
14
+ (a.announce?.id ?? null) === (b.announce?.id ?? null);
15
+
16
+ /**
17
+ * @param {{ onTurnFrame?: (fn: (frame: any) => void) => () => void } | null} conn
18
+ * @param {boolean} live a turn or run of this chat is working
19
+ * @param {{ designRel?: string, labels?: Map<string, Array<{id: string, label: string}>>, store?: any,
20
+ * now?: () => number }} [o]
21
+ */
22
+ export function useActivityLine(conn, live, o = {}) {
23
+ const { designRel = '.design', labels = null } = o;
24
+ const store = o.store ?? getActivityStore();
25
+ const now = o.now ?? Date.now;
26
+ const lineRef = useRef(null);
27
+ if (!lineRef.current) lineRef.current = createActivityLine();
28
+ const ctxRef = useRef(null);
29
+ ctxRef.current = { designRel, labelsFor: (f) => labels?.get?.(f) ?? [] };
30
+ const liveRef = useRef(live);
31
+ liveRef.current = live;
32
+ const [view, setView] = useState(EMPTY);
33
+ const [wake, setWake] = useState(0);
34
+ const viewRef = useRef(EMPTY);
35
+
36
+ const publish = () => {
37
+ const v = liveRef.current ? lineRef.current.view(now()) : EMPTY;
38
+ if (!sameView(v, viewRef.current)) {
39
+ viewRef.current = v;
40
+ setView(v);
41
+ }
42
+ store.set(liveRef.current ? v.target : null);
43
+ };
44
+ const publishRef = useRef(publish);
45
+ publishRef.current = publish;
46
+
47
+ useEffect(() => {
48
+ if (!conn?.onTurnFrame) return undefined;
49
+ return conn.onTurnFrame((frame) => {
50
+ if (frame?.t === 'update') lineRef.current.feed(frame.update, now(), ctxRef.current);
51
+ publishRef.current();
52
+ setWake((n) => n + 1);
53
+ });
54
+ }, [conn, now]);
55
+
56
+ // a run that ended, failed or was stopped: forget it all
57
+ useEffect(() => {
58
+ if (!live) lineRef.current.reset();
59
+ publishRef.current();
60
+ }, [live]);
61
+
62
+ // wake when the view changes by itself (a waiting swap, the idle fallback, an announcement)
63
+ // biome-ignore lint/correctness/useExhaustiveDependencies: `wake` re-arms the timer after every event
64
+ useEffect(() => {
65
+ if (!live) return undefined;
66
+ const at = lineRef.current.nextAt(now());
67
+ if (at === null) return undefined;
68
+ const id = setTimeout(
69
+ () => {
70
+ publishRef.current();
71
+ setWake((n) => n + 1);
72
+ },
73
+ Math.max(16, at - now())
74
+ );
75
+ return () => clearTimeout(id);
76
+ }, [live, wake, view, now]);
77
+
78
+ useEffect(() => () => store.set(null), [store]);
79
+
80
+ return view;
81
+ }
@@ -19,6 +19,7 @@ import { useEffect, useRef, useState } from 'react';
19
19
  import { TEMPLATES } from '../../../annotations/templates.ts';
20
20
  import { v2Scope } from './v2-scope.js';
21
21
  import { reasonProps } from '../access/disabled-reason.js';
22
+ import { onCanvasPointer } from '../shell/canvas-pointer.js';
22
23
 
23
24
  /** The columns of the tile grid (canvas 15 `.an-tpl-g`). */
24
25
  export const TEMPLATE_COLUMNS = 4;
@@ -118,9 +119,12 @@ export default function TemplatesPanel({
118
119
  const onBlur = () => onClose();
119
120
  document.addEventListener('pointerdown', onDown, true);
120
121
  window.addEventListener('blur', onBlur);
122
+ // rc3 r4-12 — a press in the canvas, told over the dgn bridge (WebKit gives this window no blur for it)
123
+ const offCanvas = onCanvasPointer(onBlur);
121
124
  return () => {
122
125
  document.removeEventListener('pointerdown', onDown, true);
123
126
  window.removeEventListener('blur', onBlur);
127
+ offCanvas();
124
128
  };
125
129
  }, [anchor, onClose]);
126
130
 
@@ -34,7 +34,7 @@ export function KindsChip({ value, onChange }) {
34
34
  document.addEventListener('keydown', onKey, true);
35
35
  return () => document.removeEventListener('keydown', onKey, true);
36
36
  }, [open]);
37
- // a click anywhere else closes it — also a click into the canvas (another origin), which only blurs this window
37
+ // a click anywhere else closes it — also a click into the canvas (another origin, told over the dgn bridge)
38
38
  useDismissOutside(open, root, () => setOpen(false));
39
39
  return (
40
40
  <span className="lp-kinds" ref={root}>
@@ -22,6 +22,22 @@ const SAID = {
22
22
  invalid: 'Not placed. That picture does not fit there; try another.',
23
23
  };
24
24
 
25
+ // rc3 walk (r4-2) — a video dropped onto a photo was refused as a "picture". The refusal names what was dropped: a
26
+ // video (the extensions the shell previews as video, client/shell/util.js PREVIEW_KIND_RULES), or neutrally for a mix.
27
+ const VIDEO_PATH = /\.(mp4|webm|mov|m4v)$/i;
28
+ const INVALID_VIDEO = 'Not placed. That video does not fit there; try another.';
29
+ const INVALID_MIXED = 'Not placed. That does not fit there; try another.';
30
+
31
+ /** The words for a refusal `code`, for the files `list` that were being placed. */
32
+ export function refusalWords(code, list = []) {
33
+ if (code === 'invalid' && list.length) {
34
+ const videos = list.filter((p) => typeof p === 'string' && VIDEO_PATH.test(p)).length;
35
+ if (videos === list.length) return INVALID_VIDEO;
36
+ if (videos > 0) return INVALID_MIXED;
37
+ }
38
+ return SAID[code];
39
+ }
40
+
25
41
  /**
26
42
  * "Placed 6 photos in Fotky ze zápasu. They're in Assets too." — the line a placement says (12 · ia-placed). The same words
27
43
  * the drop says (`editing/finder-drop-model.ts` placedLine; pinned equal in p8-c9-assets.test.tsx), kept here so the shell
@@ -100,7 +116,10 @@ export async function placeAsset(req, opts = {}) {
100
116
  created: Array.isArray(body.created) ? body.created : [],
101
117
  };
102
118
  }
103
- return { ok: false, message: SAID[body?.code] ?? body?.message ?? 'Not placed; try again.' };
119
+ return {
120
+ ok: false,
121
+ message: refusalWords(body?.code, list) ?? body?.message ?? 'Not placed; try again.',
122
+ };
104
123
  }
105
124
 
106
125
  /**
@@ -75,7 +75,7 @@ export function AssetTileMenu({ state, items, onSelect, onClose }) {
75
75
  document.addEventListener('keydown', onKey, true);
76
76
  return () => document.removeEventListener('keydown', onKey, true);
77
77
  }, [state, onClose]);
78
- // a click anywhere else closes it — also a click into the canvas (another origin), which only blurs this window
78
+ // a click anywhere else closes it — also a click into the canvas (another origin, told over the dgn bridge)
79
79
  useDismissOutside(!!state, ref, () => onClose());
80
80
 
81
81
  if (!state) return null;
@@ -23,6 +23,7 @@ import { useFold } from '../fold/use-fold.js';
23
23
  import { KindChips } from '../kinds/KindChips.jsx';
24
24
  import { countByKind, isFilterKind, noCanvasesOfKind } from '../kinds/kind-filter-model.js';
25
25
  import { clearKindFilter, useKindFilter } from '../kinds/kind-filter-store.js';
26
+ import { onCanvasPointer } from '../shell/canvas-pointer.js';
26
27
  import { nativeDoors } from '../shell/native-doors.js';
27
28
  import { PANEL_NONE_FOOT, PanelNoCanvases } from '../create/empty-project.jsx';
28
29
  import { AskButton, Empty } from '../empty/index.js';
@@ -389,15 +390,18 @@ export function CanvasesPanel({
389
390
  setSortMenu(null);
390
391
  if (e.type === 'keydown') sortButton()?.focus();
391
392
  };
392
- // a click into the canvas (another origin) never reaches this document; it only blurs the window
393
+ // a click into the canvas (another origin) never reaches this document: the canvas tells the shell over the dgn
394
+ // bridge (rc3 r4-12 — the packaged app's WebKit gives no window blur for it); Chromium also blurs the window
393
395
  const away = () => setSortMenu(null);
394
396
  document.addEventListener('pointerdown', close);
395
397
  document.addEventListener('keydown', close);
396
398
  window.addEventListener('blur', away);
399
+ const offCanvas = onCanvasPointer(away);
397
400
  return () => {
398
401
  document.removeEventListener('pointerdown', close);
399
402
  document.removeEventListener('keydown', close);
400
403
  window.removeEventListener('blur', away);
404
+ offCanvas();
401
405
  };
402
406
  }, [sortMenu]);
403
407
  // opening it takes the focus into the menu (the checked choice), so the keys have somewhere to land
@@ -82,8 +82,10 @@ export function CanvasRowMenu({ state, items, targets, onSelect, onPick, onClose
82
82
  document.addEventListener('keydown', onKey, true);
83
83
  return () => document.removeEventListener('keydown', onKey, true);
84
84
  }, [state, view, onClose]);
85
- // a click anywhere else closes it — also a click into the canvas (another origin), which only blurs this window
86
- useDismissOutside(!!state, ref, () => onClose());
85
+ // a click anywhere else closes it — also a click into the canvas (another origin), which tells the shell over the
86
+ // dgn bridge (rc3 r4-12: the packaged app's WebKit gives no window blur for it). The focus stays where the click
87
+ // put it — handing it back to ⋯ would take it out of the canvas the person just clicked; esc still gives it back.
88
+ useDismissOutside(!!state, ref, () => onClose(false));
87
89
 
88
90
  if (!state) return null;
89
91
  const style = placed
@@ -71,6 +71,8 @@
71
71
 
72
72
  .sv-header .sv-title {
73
73
  flex: 1 1 auto;
74
+ /* the empty state's heading is an <h1> (rc3 r4-7) */
75
+ margin: 0;
74
76
  }
75
77
 
76
78
  .sv-ds-picker {
@@ -0,0 +1,78 @@
1
+ // client/v2/empty/ai-drafting.jsx — rc3-h (#182): an EMPTY canvas reacts the moment a run of yours starts on it.
2
+ //
3
+ // Before AI writes anything the empty canvas used to keep inviting "Ask AI for a first draft" while the run worked
4
+ // — nothing moved for a minute. Now the invitation steps aside for the board's ghost (01 cf-ai-drafting: a dashed
5
+ // spark outline, "Mobile — next"): where the first artboard will land, "AI is drafting…" above it, and the AI
6
+ // cursor on it (_kit `aiCursor`, the spark arrow). It goes when the run ends, fails or is stopped, and when the real
7
+ // artboard lands (the canvas counts one). Shell-side over the canvas pane, like the empty-canvas card it replaces:
8
+ // no message into the untrusted canvas, no route.
9
+ //
10
+ // Decorative (`aria-hidden`): the AI chat's working line + its polite region say the same words to a screen reader.
11
+ // Reduced motion: the pulse and the cursor's drift stop; the ghost and the cursor stay.
12
+
13
+ import { ownRunWorkingOn, TAG_NEEDS_YOU } from '../ai/runs-model.js';
14
+ import { SparkGlyph } from './ask-button.jsx';
15
+
16
+ export const DRAFTING_LABEL = 'AI is drafting…';
17
+
18
+ const LIVE = new Set(['starting', 'running']);
19
+
20
+ /**
21
+ * `null`, or what the ghost says. A run of yours is working on THIS canvas (its scope or a lease, or an edit
22
+ * that names it) and the canvas has reported no artboards (`count` 0 — null while it has not said: no flash).
23
+ *
24
+ * @param {{ view: any, activePath: string|null, designRel?: string, count: number|null|undefined,
25
+ * target?: { file: string, artboard: string, label: string, adding?: boolean } | null }} f
26
+ * @returns {{ label: string, waiting: boolean } | null}
27
+ */
28
+ export function draftingPresence(f) {
29
+ if (f.count !== 0 || !f.activePath) return null;
30
+ const designRel = f.designRel || '.design';
31
+ const mine = (f.view?.mine || []).filter((r) => LIVE.has(r?.state) || r?.state === 'needs-you');
32
+ if (!mine.length) return null;
33
+ const named = !!f.target && f.target.file === f.activePath;
34
+ if (!ownRunWorkingOn(f.view, f.activePath, designRel) && !named) return null;
35
+ const working = mine.some((r) => LIVE.has(r.state));
36
+ if (!working) return { label: TAG_NEEDS_YOU, waiting: true };
37
+ const adding =
38
+ named && f.target.adding && f.target.label ? `AI is drawing ${f.target.label}` : null;
39
+ return { label: adding || DRAFTING_LABEL, waiting: false };
40
+ }
41
+
42
+ /** The ghost, the label above it and the AI cursor, centred on the free canvas (`centre`, px from the left). */
43
+ export function AiDrafting({ label, centre, waiting = false }) {
44
+ return (
45
+ <div className="es-host" style={{ '--es-cx': `${centre}px` }}>
46
+ <div
47
+ className="es-aid"
48
+ data-testid="ai-drafting"
49
+ data-waiting={waiting ? 'true' : undefined}
50
+ aria-hidden="true"
51
+ >
52
+ <span className="es-aid-l" data-testid="ai-drafting-label">
53
+ <SparkGlyph size={10} />
54
+ {label}
55
+ </span>
56
+ <span className="es-aid-ghost" data-testid="ai-drafting-ghost">
57
+ <span className="es-aid-page">
58
+ <i />
59
+ <i />
60
+ <i />
61
+ </span>
62
+ </span>
63
+ <span className="es-aid-cur" data-testid="ai-drafting-cursor">
64
+ <svg width="14" height="16" viewBox="0 0 14 16" aria-hidden="true">
65
+ <path
66
+ d="M1 1l11 6.2-4.7 1.3L5.6 14z"
67
+ fill="currentColor"
68
+ stroke="var(--bg-0)"
69
+ strokeWidth="1"
70
+ strokeLinejoin="round"
71
+ />
72
+ </svg>
73
+ <span className="es-aid-cur-l">AI</span>
74
+ </span>
75
+ </div>
76
+ </div>
77
+ );
78
+ }
@@ -18,6 +18,9 @@ import { menuRunner } from '../shell/menu-runner.js';
18
18
  import { insetsNow } from '../shell/insets-now.js';
19
19
  import { shellMode } from '../shell/use-canvas-mode-lane.js';
20
20
  import { freeCentre } from './free-centre.js';
21
+ import { useActivityTarget } from '../ai/activity-store.js';
22
+ import { useAiRuns } from '../ai/runs-store.js';
23
+ import { AiDrafting, draftingPresence } from './ai-drafting.jsx';
21
24
  import { AllTrashed } from './all-trashed.jsx';
22
25
  import { ArtboardHint, HINT_SIZE } from './artboard-hint.jsx';
23
26
  import { EmptyCanvas } from './empty-canvas.jsx';
@@ -59,6 +62,18 @@ export function EmptyHost() {
59
62
  const model = canvasOpen
60
63
  ? emptyCanvasModel({ count, mode, canEdit, online, claude, canAsk })
61
64
  : null;
65
+ // rc3-h (#182): a run of yours on this empty canvas — the ghost where the first artboard lands, not the invitation
66
+ const { view: runsView } = useAiRuns();
67
+ const target = useActivityTarget();
68
+ const drafting = canvasOpen
69
+ ? draftingPresence({
70
+ view: runsView,
71
+ activePath,
72
+ designRel: cfg?.designRel || '.design',
73
+ count,
74
+ target,
75
+ })
76
+ : null;
62
77
 
63
78
  // P8 C5 (05 es-all-trashed): a canvas whose every artboard is in the Trash says that, not "Your canvas is
64
79
  // ready." — the card (S11.5) reads the shared Trash itself and tells us when it is on screen.
@@ -132,6 +147,8 @@ export function EmptyHost() {
132
147
  );
133
148
 
134
149
  const showHint = !!hint && !!placement && canEdit && mode === 'edit' && !model;
150
+ if (drafting)
151
+ return <AiDrafting label={drafting.label} centre={centre} waiting={drafting.waiting} />;
135
152
  if (!model && !showHint && !trashWatch) return null;
136
153
  return (
137
154
  <>
@@ -437,4 +437,102 @@
437
437
  line-height: var(--lh-xs);
438
438
  color: var(--fg-2);
439
439
  }
440
+
441
+ /* ─── rc3-h (issue 182): an empty canvas while AI drafts on it (01 cf-ai-drafting's ghost + the _kit AI cursor) ─── */
442
+ .es-aid {
443
+ position: absolute;
444
+ left: var(--es-cx, 50%);
445
+ top: 45%;
446
+ translate: -50% -50%;
447
+ width: min(400px, calc(100% - var(--space-8)));
448
+ aspect-ratio: 16 / 10;
449
+ }
450
+ .es-aid-ghost {
451
+ position: absolute;
452
+ inset: 0;
453
+ border: 1.5px dashed var(--spark);
454
+ border-radius: var(--radius-xs);
455
+ background: var(--spark-muted);
456
+ }
457
+ /* the page lines are faint: the wrapper holds the opacity, the pulse animates the lines inside it */
458
+ .es-aid-page {
459
+ position: absolute;
460
+ inset: 0;
461
+ opacity: 0.2;
462
+ }
463
+ .es-aid-ghost i {
464
+ position: absolute;
465
+ left: 10%;
466
+ display: block;
467
+ height: 7%;
468
+ border-radius: var(--radius-xs);
469
+ background: var(--spark);
470
+ }
471
+ .es-aid-ghost i:nth-child(1) {
472
+ top: 14%;
473
+ width: 46%;
474
+ }
475
+ .es-aid-ghost i:nth-child(2) {
476
+ top: 28%;
477
+ width: 30%;
478
+ height: 5%;
479
+ }
480
+ .es-aid-ghost i:nth-child(3) {
481
+ top: 46%;
482
+ right: 10%;
483
+ height: 38%;
484
+ }
485
+ .es-aid-l {
486
+ position: absolute;
487
+ left: 0;
488
+ bottom: calc(100% + var(--space-1));
489
+ display: inline-flex;
490
+ align-items: center;
491
+ gap: var(--space-1);
492
+ max-width: 100%;
493
+ overflow: hidden;
494
+ font-size: var(--type-xs);
495
+ font-weight: var(--w-medium);
496
+ color: var(--spark-text);
497
+ white-space: nowrap;
498
+ text-overflow: ellipsis;
499
+ }
500
+ .es-aid-cur {
501
+ position: absolute;
502
+ left: 74%;
503
+ top: 62%;
504
+ display: inline-flex;
505
+ align-items: flex-start;
506
+ color: var(--spark);
507
+ }
508
+ .es-aid-cur-l {
509
+ margin: 12px 0 0 -2px;
510
+ padding: 0 var(--space-1);
511
+ border-radius: var(--radius-xs);
512
+ background: var(--spark);
513
+ color: var(--bg-0);
514
+ font-size: var(--type-xs);
515
+ font-weight: var(--w-semibold, 600);
516
+ line-height: var(--lh-xs);
517
+ }
518
+ @media (prefers-reduced-motion: no-preference) {
519
+ .es-aid:not([data-waiting]) .es-aid-ghost i {
520
+ animation: v2-empty-pulse calc(var(--dur-panel) * 6) var(--ease-in-out) infinite alternate;
521
+ }
522
+ .es-aid:not([data-waiting]) .es-aid-cur {
523
+ animation: es-aid-drift calc(var(--dur-panel) * 8) var(--ease-in-out) infinite alternate;
524
+ }
525
+ }
526
+ [data-reduced-motion="true"] .es-aid-ghost i,
527
+ [data-reduced-motion="true"] .es-aid-cur {
528
+ animation: none;
529
+ }
530
+ @keyframes es-aid-drift {
531
+ from {
532
+ translate: 0 0;
533
+ }
534
+ to {
535
+ translate: -56px -26px;
536
+ }
537
+ }
440
538
  }
@@ -21,9 +21,12 @@ import { LANES, renderStatus } from './model.js';
21
21
 
22
22
  export function RenderPart({ spec, exportLane, video, setAdv }) {
23
23
  const status = renderStatus(exportLane);
24
+ // rc3-i — "Suggest each time · always the cloud · always this Mac" and "always export on this Mac" are the
25
+ // desktop's: a cloud tab renders where its workspace does, so it is told only the service and its state
26
+ const workspace = exportLane !== 'local';
24
27
  return (
25
28
  <section className="ex-advp" data-testid="export-adv-render" aria-label={RENDER_TITLE}>
26
- {video ? (
29
+ {video && !workspace ? (
27
30
  <>
28
31
  <Row k={RENDER_VIDEO}>
29
32
  <Select
@@ -41,7 +44,7 @@ export function RenderPart({ spec, exportLane, video, setAdv }) {
41
44
  <Note>{RENDER_NOTE_VIDEO}</Note>
42
45
  </>
43
46
  ) : null}
44
- <Note>{RENDER_NOTE_IMAGES}</Note>
47
+ {workspace ? null : <Note>{RENDER_NOTE_IMAGES}</Note>}
45
48
  <span className="ex-kv">
46
49
  <span>{RENDER_SERVICE}</span>
47
50
  <span className="ex-mono" data-testid="export-adv-render-service">
@@ -143,16 +143,23 @@ function secondsWords(seconds) {
143
143
  return `about ${Math.round(seconds / 60)} min`;
144
144
  }
145
145
 
146
- /** "21 files · about 140 MB · about 20 seconds on this Mac". */
147
- export function estimateWords({ files, bytes, seconds, lane }, { pdfPages = null } = {}) {
148
- const where = lane === 'cloud' ? 'in the cloud' : 'on this Mac';
146
+ /**
147
+ * "21 files · about 140 MB · about 20 seconds on this Mac".
148
+ * `workspace` = a cloud tab (a browser on a cell): nothing runs on a Mac there, so the time names the cloud or no
149
+ * place at all (rc3-i — the callouts' rule: same words, minus the part that is false there).
150
+ */
151
+ export function estimateWords(
152
+ { files, bytes, seconds, lane },
153
+ { pdfPages = null, workspace = false } = {}
154
+ ) {
155
+ const where = lane === 'cloud' ? ' in the cloud' : workspace ? '' : ' on this Mac';
149
156
  return [
150
157
  // 09 ex-print: one print PDF says its pages — "1 PDF · 2 pages", not "1 file"
151
158
  pdfPages && files === 1
152
159
  ? `1 PDF · ${pdfPages} ${pdfPages === 1 ? 'page' : 'pages'}`
153
160
  : `${files} ${files === 1 ? 'file' : 'files'}`,
154
161
  `about ${bytesWords(bytes)}`,
155
- `${secondsWords(seconds)} ${where}`,
162
+ `${secondsWords(seconds)}${where}`,
156
163
  ].join(' · ');
157
164
  }
158
165