@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
@@ -11,7 +11,7 @@
11
11
 
12
12
  import { useThread, useThreadRuntime } from '@assistant-ui/react';
13
13
  import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
14
- import { activityLabel } from '../../panels/acp-runtime.js';
14
+ import { isSubagentTool } from '../../panels/acp-runtime.js';
15
15
  import { sendToAskAI } from '../search/search-env.js';
16
16
  import { focusComposer } from './panel-focus.js';
17
17
  import { ResultCard } from './Result.jsx';
@@ -43,7 +43,9 @@ import { useBoardLabels } from './RunList.jsx';
43
43
  import { shortArtboardName } from './scope.js';
44
44
  import { runCardFor } from './run-cards.js';
45
45
  import './video/cards.jsx';
46
- import { RunLiveRegion, useRunClock, WorkingLine } from './Working.jsx';
46
+ import { ActivityLiveRegion, RunLiveRegion, useRunClock, WorkingLine } from './Working.jsx';
47
+ import { workingLineParts } from './activity-line.js';
48
+ import { useActivityLine } from './use-activity-line.js';
47
49
  import { useChatRuns } from './use-chat-runs.js';
48
50
  import { setAnswered, setResultShown } from './result-shown.js';
49
51
 
@@ -92,6 +94,13 @@ export function RunSurface({ conn, chatId, tools = [], artboards = [], designRel
92
94
  const elapsed = useRunClock(run?.startedAt, showWorking);
93
95
  // S5.18 G2: a run that ran on a copy says so, with the artboard that was busy
94
96
  const boardLabels = useBoardLabels(designRel, 0);
97
+ // rc3-h (#182) — the ONE line says what AI is doing now, from the live stream (activity-line.js)
98
+ const activity = useActivityLine(conn, live, { designRel, labels: boardLabels });
99
+ const line = workingLineParts({
100
+ headline: workingText(run),
101
+ activity,
102
+ subagents: tools.filter(isSubagentTool).length,
103
+ });
95
104
  const copyLine = run?.copyOf
96
105
  ? copyDividerText(run, {
97
106
  name: shortArtboardName(
@@ -211,6 +220,7 @@ export function RunSurface({ conn, chatId, tools = [], artboards = [], designRel
211
220
  return (
212
221
  <>
213
222
  <RunLiveRegion message={message} />
223
+ {showWorking ? <ActivityLiveRegion announce={activity.announce} /> : null}
214
224
  {copyLine && (showWorking || showResult) ? (
215
225
  <p className="ai-copy-rule" data-testid="ai-copy-divider">
216
226
  {copyLine}
@@ -219,8 +229,8 @@ export function RunSurface({ conn, chatId, tools = [], artboards = [], designRel
219
229
  {kindCard('top')}
220
230
  {showWorking ? (
221
231
  <WorkingLine
222
- text={workingText(run)}
223
- step={tools.length ? activityLabel(tools) : ''}
232
+ text={line.text}
233
+ step={line.step}
224
234
  elapsed={elapsed}
225
235
  onStop={onStop}
226
236
  stopping={stopping}
@@ -10,6 +10,7 @@
10
10
  import { useCallback, useEffect, useId, useRef, useState } from 'react';
11
11
  import { StIcon } from '../../shell/icons.jsx';
12
12
  import { scopeLabel, scopeMenu, scopeNames, scopeTitle, toggleArtboard } from './scope.js';
13
+ import { onCanvasPointer } from '../shell/canvas-pointer.js';
13
14
 
14
15
  export function ScopeChip({
15
16
  scope,
@@ -49,9 +50,12 @@ export function ScopeChip({
49
50
  };
50
51
  document.addEventListener('pointerdown', onDown);
51
52
  document.addEventListener('keydown', onKey, true);
53
+ // rc3 r4-12 — a press in the canvas closes it too (told over the dgn bridge; it never reaches this document)
54
+ const offCanvas = onCanvasPointer(() => close(false));
52
55
  return () => {
53
56
  document.removeEventListener('pointerdown', onDown);
54
57
  document.removeEventListener('keydown', onKey, true);
58
+ offCanvas();
55
59
  };
56
60
  }, [open, close]);
57
61
 
@@ -35,7 +35,7 @@ export function WorkingLine({ text, step, elapsed, onStop, stopping = false }) {
35
35
  <Spark size={14} />
36
36
  </span>
37
37
  <span className="ai-working-txt">
38
- <span className="ai-working-main" data-testid="ai-working-text">
38
+ <span className="ai-working-main" data-testid="ai-working-text" key={text}>
39
39
  {text}
40
40
  </span>
41
41
  {step || elapsed ? (
@@ -72,3 +72,15 @@ export function RunLiveRegion({ message }) {
72
72
  </div>
73
73
  );
74
74
  }
75
+
76
+ /**
77
+ * rc3-h (#182) — the working line changes with what AI does; this sibling region reads a changed line out at most
78
+ * once per 10 s (activity-line.js ANNOUNCE_GAP_MS), never the clock. `announce` is `{ id, text }`.
79
+ */
80
+ export function ActivityLiveRegion({ announce }) {
81
+ return (
82
+ <div className="ai-sr-only" role="status" aria-live="polite" data-testid="ai-activity-live">
83
+ {announce?.text ? <span key={announce.id}>{announce.text}</span> : null}
84
+ </div>
85
+ );
86
+ }
@@ -0,0 +1,390 @@
1
+ // client/v2/ai/activity-line.js — rc3-h (issue #182): the AI chat's ONE line that says what AI is doing right now.
2
+ //
3
+ // The chat already receives the agent's real stream (`{t:'update', update}` — tool calls with kind / locations /
4
+ // rawInput, the plan, thought and reply chunks). This module turns each event into a short present-tense line in
5
+ // product voice ("AI is reading Kanban", "AI is drawing Sprint board", "AI is thinking") and keeps the line calm:
6
+ //
7
+ // · a new phrase waits until the last one has been up SWAP_MS (a burst shows only its newest, no flicker);
8
+ // · after IDLE_MS with no event and nothing in flight the line falls back (`text: null` — the caller shows the
9
+ // run's own headline, "AI is working");
10
+ // · the polite live region hears a changed phrase at most once per ANNOUNCE_GAP_MS.
11
+ //
12
+ // What it never shows: a path, a command line, the model's prose. Names come from a file name or an artboard's
13
+ // `label` (a name, capped) — the canvas is untrusted (DDR-054), so nothing longer than a name leaves it. A plan
14
+ // step is shown only when it opens with a verb the `doing` table knows (decision v2-p8-c6-doing-from-ask); any
15
+ // other plan text becomes "AI is on step 2 of 5".
16
+ //
17
+ // Pure: no React, no DOM. use-activity-line.js feeds it from the connection and renders `view(now)`.
18
+
19
+ import { doingOf } from '../../../ai/run-doing.ts';
20
+
21
+ export const SWAP_MS = 1000;
22
+ export const IDLE_MS = 8000;
23
+ export const ANNOUNCE_GAP_MS = 10_000;
24
+ const NAME_MAX = 48;
25
+
26
+ /** One line of a name: control characters out, whitespace collapsed, capped at a word with an ellipsis. */
27
+ export function cleanName(s, max = NAME_MAX) {
28
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: stripping control characters is the point
29
+ const t = String(s ?? '').replace(/[\u0000-\u001f\u007f-\u009f​-‏‪-‮]/g, ' ');
30
+ const one = t.replace(/\s+/g, ' ').trim();
31
+ if (one.length <= max) return one;
32
+ const cut = one.slice(0, max - 1);
33
+ const sp = cut.lastIndexOf(' ');
34
+ return `${(sp > max / 2 ? cut.slice(0, sp) : cut).trimEnd()}…`;
35
+ }
36
+
37
+ /** The design-root-relative path of `p` (absolute or repo-relative), or null when it is not under the root. */
38
+ export function designPath(p, designRel = '.design') {
39
+ if (typeof p !== 'string' || !p) return null;
40
+ const norm = p.replace(/\\/g, '/');
41
+ const root = String(designRel || '.design').replace(/^\/+|\/+$/g, '');
42
+ let rel = null;
43
+ if (norm.startsWith(`${root}/`)) rel = norm.slice(root.length + 1);
44
+ else {
45
+ const at = norm.lastIndexOf(`/${root}/`);
46
+ if (at >= 0) rel = norm.slice(at + root.length + 2);
47
+ }
48
+ if (!rel || rel.split('/').some((seg) => seg === '..' || seg === '')) return null;
49
+ return rel;
50
+ }
51
+
52
+ /** "ui/Kanban board.tsx" → "Kanban board". */
53
+ export function canvasName(rel) {
54
+ const base =
55
+ String(rel ?? '')
56
+ .split('/')
57
+ .pop() ?? '';
58
+ return cleanName(
59
+ base.replace(/\.(?:tsx|jsx|ts|js|html|svg|meta\.json|annotations\.json|css)$/i, '')
60
+ );
61
+ }
62
+
63
+ /** The `<DCArtboard>` tags in a piece of canvas source: `{ id, label }` per tag, in order. */
64
+ export function artboardsIn(text) {
65
+ const out = [];
66
+ if (typeof text !== 'string' || !text) return out;
67
+ const re = /<DCArtboard\b([^>]*)>/g;
68
+ for (let m = re.exec(text); m && out.length < 50; m = re.exec(text)) {
69
+ const attrs = m[1];
70
+ const id = attrs.match(/\bid=(["'])([^"']{1,128})\1/)?.[2];
71
+ if (!id) continue;
72
+ const label = attrs.match(/\blabel=(["'])([^"']{0,200})\1/)?.[2] ?? '';
73
+ out.push({ id, label });
74
+ }
75
+ return out;
76
+ }
77
+
78
+ const humanize = (id) =>
79
+ cleanName(
80
+ String(id)
81
+ .replace(/[-_]+/g, ' ')
82
+ .replace(/^\w/, (c) => c.toUpperCase())
83
+ );
84
+
85
+ /** `maude design <verb>` → the verb's plain words. Not a maude verb → null. */
86
+ const VERB_WORDS = {
87
+ screenshot: 'AI is checking how it looks',
88
+ 'visual-sanity': 'AI is checking how it looks',
89
+ smoke: 'AI is checking the canvases',
90
+ 'canvas-rects': 'AI is measuring the canvas',
91
+ 'canvas-errors': 'AI is checking the canvas for errors',
92
+ 'canvas-source': 'AI is reading the canvas',
93
+ 'read-annotations': 'AI is reading the notes',
94
+ annotate: 'AI is adding notes',
95
+ 'canvas-edit': 'AI is editing the canvas',
96
+ place: 'AI is placing it on the canvas',
97
+ 'layout-check': 'AI is checking the layout',
98
+ 'draw-build': 'AI is drawing a vector',
99
+ 'draw-proof': 'AI is checking the drawing',
100
+ 'svg-optimize': 'AI is tidying the drawing',
101
+ 'ds-check': 'AI is checking the design system',
102
+ 'import-tokens': 'AI is bringing in the design tokens',
103
+ 'import-asset': 'AI is bringing in a file',
104
+ 'import-figma': 'AI is bringing in the Figma file',
105
+ 'import-brand': 'AI is bringing in the brand',
106
+ 'fetch-asset': 'AI is fetching an image',
107
+ generate: 'AI is generating media',
108
+ export: 'AI is exporting',
109
+ handoff: 'AI is preparing the handoff',
110
+ 'photo-adjust': 'AI is adjusting the photo',
111
+ 'photo-bg-remove': 'AI is removing the background',
112
+ captions: 'AI is writing captions',
113
+ transcribe: 'AI is listening to the audio',
114
+ 'transcribe-local': 'AI is listening to the audio',
115
+ beats: 'AI is finding the beats',
116
+ 'cut-words': 'AI is cutting the video',
117
+ 'cut-to-beat': 'AI is cutting the video',
118
+ 'reel-place': 'AI is placing the clips',
119
+ 'probe-footage': 'AI is looking at the footage',
120
+ 'ingest-footage': 'AI is looking at the footage',
121
+ 'smart-frames': 'AI is looking at the footage',
122
+ 'audio-search': 'AI is looking for music',
123
+ 'to-lottie': 'AI is exporting the animation',
124
+ prep: 'AI is getting ready',
125
+ 'bootstrap-check': 'AI is getting ready',
126
+ 'server-up': 'AI is getting ready',
127
+ 'runtime-health': 'AI is getting ready',
128
+ 'ensure-browser': 'AI is getting ready',
129
+ open: 'AI is opening a canvas',
130
+ index: 'AI is looking through the canvases',
131
+ status: 'AI is looking through the canvases',
132
+ assets: 'AI is looking through the assets',
133
+ logs: 'AI is reading the logs',
134
+ check: 'AI is checking the project',
135
+ };
136
+
137
+ export function verbWords(command) {
138
+ if (typeof command !== 'string') return null;
139
+ const m = command.match(/(?:^|[\s;&|(])maude\s+design\s+([a-z][a-z-]{0,40})/);
140
+ if (!m) return null;
141
+ return VERB_WORDS[m[1]] ?? 'AI is working on the canvas';
142
+ }
143
+
144
+ const isSubagent = (u) => {
145
+ const n = u?._meta?.claudeCode?.toolName;
146
+ return n === 'Task' || n === 'Agent';
147
+ };
148
+
149
+ function pathOf(u) {
150
+ const raw = u?.rawInput && typeof u.rawInput === 'object' ? u.rawInput : null;
151
+ for (const c of [raw?.file_path, raw?.abs_path, raw?.path, raw?.notebook_path])
152
+ if (typeof c === 'string' && c) return c;
153
+ const loc = Array.isArray(u?.locations)
154
+ ? u.locations.find((l) => typeof l?.path === 'string')
155
+ : null;
156
+ return loc?.path ?? null;
157
+ }
158
+
159
+ const SOURCE_RE = /\.(?:tsx|jsx)$/i;
160
+
161
+ function readPhrase(u, ctx) {
162
+ const rel = designPath(pathOf(u), ctx.designRel);
163
+ if (!rel) return pathOf(u) ? 'AI is reading the project files' : 'AI is reading';
164
+ if (rel.startsWith('system/')) return 'AI is reading the design system';
165
+ if (SOURCE_RE.test(rel) || /\.(?:meta|annotations)\.json$/i.test(rel))
166
+ return `AI is reading ${canvasName(rel)}`;
167
+ return 'AI is reading the project';
168
+ }
169
+
170
+ function editPhrase(u, ctx) {
171
+ const rel = designPath(pathOf(u), ctx.designRel);
172
+ if (!rel) return { text: pathOf(u) ? 'AI is editing a project file' : 'AI is editing' };
173
+ if (rel.startsWith('system/')) return { text: 'AI is updating the design system' };
174
+ const name = canvasName(rel);
175
+ if (/\.meta\.json$/i.test(rel)) return { text: `AI is arranging ${name}` };
176
+ if (/\.css$/i.test(rel)) return { text: `AI is styling ${name}` };
177
+ if (!SOURCE_RE.test(rel)) return { text: 'AI is editing the project' };
178
+ const file = `${String(ctx.designRel || '.design').replace(/\/+$/, '')}/${rel}`;
179
+ const raw = u?.rawInput && typeof u.rawInput === 'object' ? u.rawInput : {};
180
+ const next = typeof raw.content === 'string' ? raw.content : (raw.new_string ?? '');
181
+ const prev = typeof raw.old_string === 'string' ? raw.old_string : '';
182
+ const known = new Map(
183
+ (ctx.labelsFor?.(file) ?? []).filter((b) => b?.id).map((b) => [b.id, b.label])
184
+ );
185
+ const before = new Set(artboardsIn(prev).map((a) => a.id));
186
+ const inNext = artboardsIn(next);
187
+ const added = inNext.filter((a) => !before.has(a.id) && !known.has(a.id));
188
+ if (added.length === 1) {
189
+ const label = cleanName(added[0].label) || humanize(added[0].id);
190
+ return {
191
+ text: `AI is drawing ${label}`,
192
+ target: { file, artboard: added[0].id, label, adding: true },
193
+ };
194
+ }
195
+ if (added.length > 1) return { text: `AI is drawing ${added.length} artboards` };
196
+ const touched = [...artboardsIn(prev), ...inNext].find((a) => known.has(a.id));
197
+ if (touched) {
198
+ const label = cleanName(known.get(touched.id) || touched.label) || humanize(touched.id);
199
+ return { text: `AI is editing ${label}`, target: { file, artboard: touched.id, label } };
200
+ }
201
+ const ids = new Set(String(next).match(/data-cd-id=["'][^"']{1,128}["']/g) ?? []);
202
+ if (ids.size >= 2) return { text: `AI is editing ${ids.size} elements` };
203
+ return { text: `AI is editing ${name}` };
204
+ }
205
+
206
+ function planPhrase(u) {
207
+ const entries = Array.isArray(u?.entries)
208
+ ? u.entries.filter((e) => e && typeof e === 'object')
209
+ : [];
210
+ if (!entries.length) return null;
211
+ let i = entries.findIndex((e) => e.status === 'in_progress');
212
+ if (i < 0) i = entries.findIndex((e) => e.status !== 'completed');
213
+ if (i < 0) return null;
214
+ const step = `Step ${i + 1} of ${entries.length}`;
215
+ const doing = doingOf(typeof entries[i].content === 'string' ? entries[i].content : '');
216
+ return { text: doing ? `AI is ${doing}` : `AI is on step ${i + 1} of ${entries.length}`, step };
217
+ }
218
+
219
+ /**
220
+ * One ACP `session/update` → `{ text, target?, step? }`, or null when it says nothing new (bookkeeping, a
221
+ * completion). `ctx = { designRel, labelsFor(repoRelFile) → [{id,label}] }`.
222
+ */
223
+ export function phraseFor(u, ctx = {}) {
224
+ if (!u || typeof u !== 'object') return null;
225
+ switch (u.sessionUpdate) {
226
+ case 'agent_thought_chunk':
227
+ return { text: 'AI is thinking' };
228
+ case 'agent_message_chunk':
229
+ return u.content?.type === 'text' && u.content.text ? { text: 'AI is replying' } : null;
230
+ case 'plan':
231
+ return planPhrase(u);
232
+ case 'tool_call':
233
+ break;
234
+ case 'tool_call_update':
235
+ // a pending call's details can arrive on its first update; a completion says nothing new
236
+ if (u.status === 'completed' || u.status === 'failed' || !u.kind) return null;
237
+ break;
238
+ default:
239
+ return null;
240
+ }
241
+ if (isSubagent(u)) return { text: 'AI is asking a helper' };
242
+ switch (u.kind) {
243
+ case 'read':
244
+ return { text: readPhrase(u, ctx) };
245
+ case 'edit':
246
+ return editPhrase(u, ctx);
247
+ case 'search':
248
+ return { text: 'AI is searching the project' };
249
+ case 'execute':
250
+ return { text: verbWords(u.rawInput?.command) ?? 'AI is running a step' };
251
+ case 'fetch':
252
+ return { text: 'AI is reading the web' };
253
+ case 'think':
254
+ return { text: 'AI is thinking' };
255
+ case 'delete':
256
+ return { text: 'AI is removing a file' };
257
+ case 'move':
258
+ return { text: 'AI is moving a file' };
259
+ default:
260
+ return null;
261
+ }
262
+ }
263
+
264
+ /**
265
+ * The line over time. `feed(update, now, ctx)` takes each event; `view(now)` is what to draw:
266
+ * `{ text: string|null, step: string|null, target, announce: {id, text}|null }` (`text: null` = fall back to the
267
+ * run's headline). `nextAt(now)` is when the view next changes by itself (a waiting swap, the idle fallback, an
268
+ * announcement), or null.
269
+ */
270
+ export function createActivityLine({
271
+ swapMs = SWAP_MS,
272
+ idleMs = IDLE_MS,
273
+ announceGapMs = ANNOUNCE_GAP_MS,
274
+ } = {}) {
275
+ let shown = null; // { text, step, target, at }
276
+ let pending = null; // { text, step, target }
277
+ let lastEventAt = null;
278
+ let step = null;
279
+ const open = new Map(); // toolCallId → target|null
280
+ let announced = null; // { id, text, at }
281
+ let seq = 0;
282
+
283
+ const reset = () => {
284
+ shown = null;
285
+ pending = null;
286
+ lastEventAt = null;
287
+ step = null;
288
+ open.clear();
289
+ announced = null;
290
+ };
291
+
292
+ function feed(u, now, ctx = {}) {
293
+ if (!u || typeof u !== 'object') return;
294
+ lastEventAt = now;
295
+ if (
296
+ u.sessionUpdate === 'tool_call_update' &&
297
+ (u.status === 'completed' || u.status === 'failed')
298
+ ) {
299
+ open.delete(u.toolCallId);
300
+ // its target lets go now: the write landed (or did not)
301
+ if (shown?.target && !hasTarget(shown.target)) shown = { ...shown, target: null };
302
+ if (pending?.target && !hasTarget(pending.target)) pending = { ...pending, target: null };
303
+ return;
304
+ }
305
+ const p = phraseFor(u, ctx);
306
+ if (u.sessionUpdate === 'tool_call' && u.toolCallId) open.set(u.toolCallId, p?.target ?? null);
307
+ if (!p) return;
308
+ if (p.step) step = p.step;
309
+ const next = { text: p.text, step: p.step ?? null, target: p.target ?? null };
310
+ if (!shown) shown = { ...next, at: now };
311
+ else if (shown.text === next.text && !pending) shown = { ...shown, target: next.target };
312
+ else pending = next;
313
+ }
314
+
315
+ function hasTarget(t) {
316
+ for (const v of open.values())
317
+ if (v && v.file === t.file && v.artboard === t.artboard) return true;
318
+ return false;
319
+ }
320
+
321
+ function settle(now) {
322
+ if (pending && (!shown || now - shown.at >= swapMs)) {
323
+ shown = { ...pending, at: now };
324
+ pending = null;
325
+ }
326
+ const quiet = !open.size && !pending && lastEventAt !== null && now - lastEventAt >= idleMs;
327
+ if (quiet && shown && shown.text !== null)
328
+ shown = { text: null, step: null, target: null, at: now };
329
+ }
330
+
331
+ function view(now) {
332
+ settle(now);
333
+ const text = shown?.text ?? null;
334
+ if (text && text !== announced?.text && (!announced || now - announced.at >= announceGapMs)) {
335
+ seq += 1;
336
+ announced = { id: seq, text, at: now };
337
+ }
338
+ return {
339
+ text,
340
+ step: text ? step : null,
341
+ target: shown?.target ?? null,
342
+ announce: announced ? { id: announced.id, text: announced.text } : null,
343
+ };
344
+ }
345
+
346
+ function nextAt(now) {
347
+ const at = [];
348
+ if (pending && shown) at.push(shown.at + swapMs);
349
+ if (!open.size && lastEventAt !== null && shown?.text) at.push(lastEventAt + idleMs);
350
+ if (shown?.text && announced && shown.text !== announced.text)
351
+ at.push(announced.at + announceGapMs);
352
+ const future = at.filter((t) => t >= now);
353
+ return future.length ? Math.min(...future) : null;
354
+ }
355
+
356
+ return { feed, view, nextAt, reset };
357
+ }
358
+
359
+ /**
360
+ * What the working line draws: the live phrase (or the run's headline when there is none), and under it the
361
+ * plan step, else the person's own ask when the line has moved on from it ("Drawing a calm landing page"), and how
362
+ * many helpers run. `headline` is run-model's `workingText(run)`.
363
+ */
364
+ export function workingLineParts({ headline, activity, subagents = 0 }) {
365
+ const head = headline || 'AI is working';
366
+ const text = activity?.text || head;
367
+ const ask =
368
+ activity?.text && head !== 'AI is working' && head !== text
369
+ ? head.replace(/^AI is\s+/i, '').replace(/^\w/, (c) => c.toUpperCase())
370
+ : '';
371
+ const helpers =
372
+ subagents > 0 ? `${subagents} ${subagents === 1 ? 'helper' : 'helpers'} working` : '';
373
+ const step = [activity?.step || ask, helpers].filter(Boolean).join(' · ');
374
+ return { text, step };
375
+ }
376
+
377
+ /**
378
+ * The ring the canvas wears for an in-flight edit that names one of its artboards (`ai-runs` shape), before the
379
+ * write lands and the run's own lease ring arrives. An artboard still being ADDED has nothing to ring yet (the
380
+ * canvas marks it itself when it lands). `file` is the frame's repo-relative path.
381
+ */
382
+ export function targetRings(target, file) {
383
+ if (!target || target.adding || !file || target.file !== file) return {};
384
+ const id = typeof target.artboard === 'string' ? target.artboard : '';
385
+ if (!id || id.length > 128) return {};
386
+ const label = cleanName(target.label || id);
387
+ return {
388
+ [id]: { state: 'running', who: 'you', tag: `AI is editing ${label}`.slice(0, 120), waiting: 0 },
389
+ };
390
+ }
@@ -0,0 +1,45 @@
1
+ // client/v2/ai/activity-store.js — rc3-h (#182): what the chat's activity line knows that the canvas can use.
2
+ //
3
+ // One value per tab: the artboard the AI's in-flight edit names (`{ file, artboard, label, adding? }`, file
4
+ // repo-relative), or null. use-activity-line.js writes it from the live stream; the ring relay
5
+ // (ring-relay.js) marks that artboard the moment the edit starts — before the write lands and the run's
6
+ // lease arrives — and the empty canvas's drafting ghost (empty/ai-drafting.jsx) takes the name of an
7
+ // artboard being added. Names only (an index label or a capped `label`), never a path or the model's words.
8
+
9
+ import { useSyncExternalStore } from 'react';
10
+
11
+ export function createActivityStore() {
12
+ let target = null;
13
+ const subs = new Set();
14
+ const same = (a, b) =>
15
+ a === b ||
16
+ (!!a &&
17
+ !!b &&
18
+ a.file === b.file &&
19
+ a.artboard === b.artboard &&
20
+ a.label === b.label &&
21
+ !!a.adding === !!b.adding);
22
+ return {
23
+ get: () => target,
24
+ set(next) {
25
+ const t = next && typeof next === 'object' ? next : null;
26
+ if (same(t, target)) return;
27
+ target = t;
28
+ for (const fn of [...subs]) fn();
29
+ },
30
+ subscribe(fn) {
31
+ subs.add(fn);
32
+ return () => subs.delete(fn);
33
+ },
34
+ };
35
+ }
36
+
37
+ let shared = null;
38
+ export function getActivityStore() {
39
+ if (!shared) shared = createActivityStore();
40
+ return shared;
41
+ }
42
+
43
+ export function useActivityTarget(store = getActivityStore()) {
44
+ return useSyncExternalStore(store.subscribe, store.get, store.get);
45
+ }
@@ -19,7 +19,7 @@ export const ADVANCED_WHERE = 'AI chat panel › Advanced';
19
19
  * to and focuses. Open in terminal and Copy transcript are registry actions that already existed (S5.7).
20
20
  */
21
21
  export const ADVANCED_ROWS = Object.freeze([
22
- { row: 'ask-before', action: 'chat.advanced.ask-before', label: 'Ask before' },
22
+ { row: 'ask-before', action: 'chat.advanced.ask-before', label: 'Permissions' },
23
23
  { row: 'model', action: 'chat.advanced.model', label: 'Model' },
24
24
  { row: 'effort', action: 'chat.advanced.effort', label: 'Effort' },
25
25
  { row: 'fast', action: 'chat.advanced.fast-mode', label: 'Fast mode' },
@@ -36,27 +36,75 @@ export const rowDomId = (row) => `ai-adv-${row}`;
36
36
 
37
37
  // ── modes in plain words ─────────────────────────────────────────────────────────────────────────
38
38
 
39
- /** Claude Code's mode ids → what AI may do (03 `ai-adv-edges`). Order = the order the menu lists them. */
39
+ /**
40
+ * Claude Code's mode ids → what AI may do (03 `ai-adv-edges`; rc3-g, issue #181 C). Order = the order the menu
41
+ * lists them. Each entry: id · label · group · hint · risky.
42
+ * - The LABEL reads alone — it is all the closed row shows ("Permissions: Edit freely, ask before commands"),
43
+ * so it never leans on a heading or on the row's name.
44
+ * - The HINT is one line under the closed row: what AI may do WITHOUT asking, and what it still asks.
45
+ * - RISKY marks the one mode with no checks at all; it says so in its label, its group and its hint.
46
+ */
40
47
  const MODE_WORDS = [
41
- ['default', 'Replace or move to the trash', 'asks'],
42
- ['auto', 'When unsure', 'asks'],
43
- ['acceptEdits', 'Nothing — change freely', 'asks'],
44
- ['plan', 'Suggest only', 'nochange'],
45
- ['dontAsk', 'Skip what needs asking', 'nochange'],
46
- ['bypassPermissions', 'Skip every check', 'free'],
48
+ [
49
+ 'default',
50
+ 'Ask before every change',
51
+ 'asks',
52
+ 'AI asks before it changes a canvas, replaces or deletes a file, or runs a command.',
53
+ false,
54
+ ],
55
+ [
56
+ 'auto',
57
+ 'Ask only when unsure',
58
+ 'asks',
59
+ 'AI decides what is safe to do and asks when it is unsure.',
60
+ false,
61
+ ],
62
+ [
63
+ 'acceptEdits',
64
+ 'Edit freely, ask before commands',
65
+ 'asks',
66
+ 'AI changes canvases and files in this project without asking. It still asks before running a command.',
67
+ false,
68
+ ],
69
+ [
70
+ 'plan',
71
+ 'Suggest only',
72
+ 'nochange',
73
+ 'AI changes nothing. It only suggests what it would do.',
74
+ false,
75
+ ],
76
+ [
77
+ 'dontAsk',
78
+ 'Skip what needs asking',
79
+ 'nochange',
80
+ 'AI never asks. Anything that would need a yes is skipped.',
81
+ false,
82
+ ],
83
+ [
84
+ 'bypassPermissions',
85
+ 'Skip every check — risky',
86
+ 'free',
87
+ 'No checks at all. AI runs commands and changes files, also outside this project, without asking.',
88
+ true,
89
+ ],
47
90
  ];
48
- const WORDS = new Map(MODE_WORDS.map(([id, label, group], i) => [id, { label, group, order: i }]));
91
+ const WORDS = new Map(
92
+ MODE_WORDS.map(([id, label, group, hint, risky], i) => [
93
+ id,
94
+ { label, group, hint, risky, order: i },
95
+ ])
96
+ );
49
97
 
50
98
  export const MODE_GROUP_LABEL = Object.freeze({
51
- asks: 'AI asks before…',
99
+ asks: 'AI asks first',
52
100
  nochange: 'AI changes nothing',
53
- free: '',
101
+ free: 'No safety net',
54
102
  });
55
103
 
56
104
  /**
57
105
  * The modes the SESSION offers, in plain words. The agent decides which it offers; the rest stay hidden
58
106
  * ("Skip every check" shows only where the agent allows it). An id Maude has no words for keeps the agent's
59
- * own name rather than vanishing.
107
+ * own name (and its own description as the hint) rather than vanishing.
60
108
  */
61
109
  export function modeOptions(modes) {
62
110
  const list = modes?.availableModes ?? [];
@@ -70,6 +118,8 @@ export function modeOptions(modes) {
70
118
  group: w?.group ?? 'asks',
71
119
  order: w?.order ?? 100,
72
120
  description: m.description ?? '',
121
+ hint: w?.hint ?? m.description ?? '',
122
+ risky: w?.risky ?? false,
73
123
  };
74
124
  })
75
125
  .sort((a, b) => a.order - b.order);
@@ -496,6 +496,13 @@
496
496
  line-height: var(--lh-xs);
497
497
  color: var(--fg-2);
498
498
  }
499
+ /* rc3-g: the mode that skips every check says so in the warning colour, not just in grey. */
500
+ .ai-adv-hint[data-risky] {
501
+ color: var(--status-error-text);
502
+ }
503
+ .ai-adv-select[data-risky] {
504
+ box-shadow: inset 0 0 0 1px var(--status-error-text);
505
+ }
499
506
  .ai-adv-val {
500
507
  font-size: var(--type-xs);
501
508
  color: var(--fg-2);
@@ -31,6 +31,25 @@
31
31
  }
32
32
  .ai-working-main {
33
33
  overflow-wrap: anywhere;
34
+ /* rc3-h (issue 182): one line — a long name ends in an ellipsis instead of growing the row */
35
+ display: block;
36
+ overflow: hidden;
37
+ text-overflow: ellipsis;
38
+ white-space: nowrap;
39
+ }
40
+ /* a new phrase (the span re-mounts on change) eases in; reduced motion: just the text change */
41
+ @media (prefers-reduced-motion: no-preference) {
42
+ .ai-working-main {
43
+ animation: ai-working-swap var(--dur-flip) var(--ease-out, ease-out);
44
+ }
45
+ }
46
+ @keyframes ai-working-swap {
47
+ from {
48
+ opacity: 0.35;
49
+ }
50
+ to {
51
+ opacity: 1;
52
+ }
34
53
  }
35
54
  .ai-step {
36
55
  color: var(--fg-1);