@1agh/maude 1.8.1 → 1.9.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 (73) hide show
  1. package/apps/studio/acp/bridge.ts +14 -2
  2. package/apps/studio/acp/probe.ts +51 -1
  3. package/apps/studio/api.ts +19 -4
  4. package/apps/studio/bin/_curl-local.mjs +7 -0
  5. package/apps/studio/bin/annotate.mjs +16 -7
  6. package/apps/studio/bin/read-annotations.mjs +62 -4
  7. package/apps/studio/client/app.jsx +428 -15977
  8. package/apps/studio/client/dialogs/asset-picker.jsx +331 -0
  9. package/apps/studio/client/dialogs/command-palette.jsx +112 -0
  10. package/apps/studio/client/dialogs/export-dialog.jsx +782 -0
  11. package/apps/studio/client/dialogs/help-modal.jsx +324 -0
  12. package/apps/studio/client/dialogs/shortcuts-overlay.jsx +144 -0
  13. package/apps/studio/client/hooks/use-canvas-bridge.jsx +2150 -0
  14. package/apps/studio/client/hooks/use-git-actions.jsx +236 -0
  15. package/apps/studio/client/hooks/use-keyboard-shortcuts.jsx +297 -0
  16. package/apps/studio/client/hooks/use-palette-and-panels.jsx +474 -0
  17. package/apps/studio/client/hooks/use-photo-and-timeline.jsx +901 -0
  18. package/apps/studio/client/hooks/use-project-data.jsx +90 -0
  19. package/apps/studio/client/hooks/use-shell-core.jsx +1212 -0
  20. package/apps/studio/client/hooks/use-tabs.jsx +723 -0
  21. package/apps/studio/client/hooks/use-web-socket.jsx +13 -0
  22. package/apps/studio/client/inspector/artboard-knobs.jsx +456 -0
  23. package/apps/studio/client/inspector/color-picker.jsx +196 -0
  24. package/apps/studio/client/inspector/color.js +92 -0
  25. package/apps/studio/client/inspector/css-knobs.jsx +1720 -0
  26. package/apps/studio/client/inspector/css-vocab.jsx +131 -0
  27. package/apps/studio/client/inspector/ds-tokens.js +90 -0
  28. package/apps/studio/client/inspector/grid-tracks-editor.jsx +97 -0
  29. package/apps/studio/client/inspector/inspect-computed.jsx +68 -0
  30. package/apps/studio/client/inspector/inspector-panel.jsx +769 -0
  31. package/apps/studio/client/inspector/layers.jsx +322 -0
  32. package/apps/studio/client/inspector/selection.js +65 -0
  33. package/apps/studio/client/inspector/token-popover.jsx +301 -0
  34. package/apps/studio/client/menus/menubar.jsx +856 -0
  35. package/apps/studio/client/selection-scope.js +40 -0
  36. package/apps/studio/client/shell/banners.jsx +272 -0
  37. package/apps/studio/client/shell/collapsed-rail.jsx +23 -0
  38. package/apps/studio/client/shell/comments-panel.jsx +177 -0
  39. package/apps/studio/client/shell/constants.js +60 -0
  40. package/apps/studio/client/shell/dock.jsx +131 -0
  41. package/apps/studio/client/shell/icons.jsx +370 -0
  42. package/apps/studio/client/shell/status-bar.jsx +215 -0
  43. package/apps/studio/client/shell/util.js +332 -0
  44. package/apps/studio/client/shell/viewport.jsx +254 -0
  45. package/apps/studio/client/system/system-view.jsx +255 -0
  46. package/apps/studio/client/tree/tree.jsx +1243 -0
  47. package/apps/studio/comments-overlay.tsx +6 -4
  48. package/apps/studio/config.schema.json +5 -0
  49. package/apps/studio/context.ts +13 -0
  50. package/apps/studio/dist/client.bundle.js +1337 -1337
  51. package/apps/studio/dist/comment-mount.js +2 -2
  52. package/apps/studio/exporters/_browser-bundles.ts +21 -2
  53. package/apps/studio/exporters/jobs.ts +75 -15
  54. package/apps/studio/exporters/scope.ts +15 -12
  55. package/apps/studio/format.ts +296 -0
  56. package/apps/studio/http.ts +213 -23
  57. package/apps/studio/server.ts +118 -29
  58. package/apps/studio/sync/accepted-link.ts +6 -0
  59. package/apps/studio/sync/agent.ts +9 -1
  60. package/apps/studio/sync/cold-start-apply.ts +29 -4
  61. package/apps/studio/sync/cold-start.ts +78 -0
  62. package/apps/studio/sync/file-plane.ts +61 -1
  63. package/apps/studio/sync/format-sync.ts +160 -0
  64. package/apps/studio/sync/index.ts +134 -10
  65. package/apps/studio/sync/journal-client.ts +25 -5
  66. package/apps/studio/sync/migrate-seed.ts +8 -1
  67. package/apps/studio/sync/status.ts +2 -0
  68. package/apps/studio/sync/transaction-client.ts +130 -13
  69. package/apps/studio/ui-prefs.ts +95 -10
  70. package/apps/studio/whats-new.json +9 -0
  71. package/apps/studio/ws.ts +19 -4
  72. package/cli/bin/claude-design-server.mjs +0 -0
  73. package/package.json +10 -8
@@ -0,0 +1,856 @@
1
+ // menus/menubar.jsx — moved verbatim out of client/app.jsx (Maude v2 plan V2-0.2, move-only split).
2
+
3
+ import { useEffect } from 'react';
4
+ import { Kbd, StIcon } from '../shell/icons.jsx';
5
+ import { isNativeApp } from '../github.js';
6
+ import { SYSTEM_TAB } from '../shell/constants.js';
7
+ import { basename, displayName } from '../shell/util.js';
8
+ import { ExportBadge } from '../export-center.jsx';
9
+
10
+ // ───────── Menubar (CV-01/CV-08 top chrome) ─────────
11
+ //
12
+ // Replaces the legacy `.header` action-button toolbar. Mirrors the shared
13
+ // Menubar component from .design/ui/Canvas Viewport.html — brand · menus ·
14
+ // status. View dropdown is wired to the panels + zoom that exist today;
15
+ // Presentation Mode stays phase-tagged until it ships.
16
+
17
+ export const MENU_NAMES = ['File', 'Edit', 'View', 'Selection', 'Tools', 'Help'];
18
+
19
+ // Shared close-on-Esc / outside-click effect for the menubar dropdowns.
20
+ export function useDropdownClose(onClose) {
21
+ useEffect(() => {
22
+ function onKey(e) {
23
+ if (e.key === 'Escape') onClose();
24
+ }
25
+ function onDocClick(e) {
26
+ if (!e.target.closest('.st-dropdown, .st-menu')) onClose();
27
+ }
28
+ window.addEventListener('keydown', onKey);
29
+ window.addEventListener('mousedown', onDocClick);
30
+ return () => {
31
+ window.removeEventListener('keydown', onKey);
32
+ window.removeEventListener('mousedown', onDocClick);
33
+ };
34
+ }, [onClose]);
35
+ }
36
+
37
+ export function ViewDropdown({ panels, onToggle, onClose, onZoom, hasCanvas }) {
38
+ useDropdownClose(onClose);
39
+ return (
40
+ <div className="st-dropdown" role="menu" aria-label="View" style={{ left: 152 }}>
41
+ <div className="st-dd-hd">Panels</div>
42
+ {panels.map((p) => (
43
+ <button
44
+ key={p.id}
45
+ type="button"
46
+ role="menuitem"
47
+ className={'st-dd-item' + (p.checked ? ' is-on' : '')}
48
+ aria-disabled={p.disabled ? 'true' : undefined}
49
+ title={p.hint || undefined}
50
+ onClick={() => {
51
+ // Cloud Phase 27 C2 — a row that states an absence still has
52
+ // somewhere to send you. A disabled item with a `href` opens it
53
+ // instead of doing nothing, which is the difference between "this
54
+ // is not available here" and a dead button.
55
+ if (p.disabled) {
56
+ if (p.href) {
57
+ window.open(p.href, '_blank', 'noopener,noreferrer');
58
+ onClose();
59
+ }
60
+ return;
61
+ }
62
+ onToggle(p.id);
63
+ onClose();
64
+ }}
65
+ >
66
+ <span className="st-dd-lead">
67
+ <span className="st-dd-check">{p.checked ? <StIcon name="check" size={13} /> : null}</span>
68
+ <span>{p.label}</span>
69
+ {p.phase ? <span className="st-dd-phase">{p.phase}</span> : null}
70
+ </span>
71
+ {p.shortcut ? <Kbd>{p.shortcut}</Kbd> : null}
72
+ </button>
73
+ ))}
74
+ <div className="st-dd-sep" />
75
+ <div className="st-dd-hd">Zoom</div>
76
+ {[
77
+ { op: 'in', label: 'Zoom In', shortcut: '⌘ +' },
78
+ { op: 'out', label: 'Zoom Out', shortcut: '⌘ −' },
79
+ { op: 'fit', label: 'Fit to Screen', shortcut: '⌘ 0' },
80
+ { op: 'actual', label: 'Actual Size · 100 %', shortcut: '⌘ 1' },
81
+ ].map((z) => (
82
+ <button
83
+ key={z.label}
84
+ type="button"
85
+ role="menuitem"
86
+ className="st-dd-item"
87
+ aria-disabled={hasCanvas ? undefined : 'true'}
88
+ onClick={() => {
89
+ if (!hasCanvas) return;
90
+ onZoom?.(z.op);
91
+ onClose();
92
+ }}
93
+ >
94
+ <span className="st-dd-lead">
95
+ <span className="st-dd-check" />
96
+ <span>{z.label}</span>
97
+ </span>
98
+ <Kbd>{z.shortcut}</Kbd>
99
+ </button>
100
+ ))}
101
+ </div>
102
+ );
103
+ }
104
+
105
+ // Help dropdown — cheat sheet · deep help · tour · what's new.
106
+ // Shared menubar dropdown — File / Edit / Selection / Tools / Help all render
107
+ // the identical {id,label,shortcut,sep?,disabled?} list over the same button
108
+ // skeleton, differing only in aria-label, left offset, and an optional header.
109
+ // (ViewDropdown stays separate — its checkbox/phase/zoom-op rows genuinely
110
+ // diverge.) Per the /flow:done simplifier pass — collapsed 5 near-dupes.
111
+ export function DropdownMenu({ label, left, header, items, onAction, onClose }) {
112
+ useDropdownClose(onClose);
113
+ return (
114
+ <div className="st-dropdown" role="menu" aria-label={label} style={{ left }}>
115
+ {header ? <div className="st-dd-hd">{header}</div> : null}
116
+ {items.map((it, i) =>
117
+ it.sep ? (
118
+ <div key={'s' + i} className="st-dd-sep" />
119
+ ) : (
120
+ <button
121
+ key={it.id}
122
+ type="button"
123
+ role="menuitem"
124
+ className="st-dd-item"
125
+ aria-disabled={it.disabled ? 'true' : undefined}
126
+ onClick={() => {
127
+ if (it.disabled) return;
128
+ onAction(it.id);
129
+ onClose();
130
+ }}
131
+ >
132
+ <span className="st-dd-lead">
133
+ <span className="st-dd-check" />
134
+ <span>{it.label}</span>
135
+ </span>
136
+ {it.shortcut ? <Kbd>{it.shortcut}</Kbd> : null}
137
+ </button>
138
+ )
139
+ )}
140
+ </div>
141
+ );
142
+ }
143
+
144
+ export function HelpDropdown({ onAction, onClose }) {
145
+ return (
146
+ <DropdownMenu
147
+ label="Help"
148
+ left={320}
149
+ onAction={onAction}
150
+ onClose={onClose}
151
+ items={[
152
+ { id: 'shortcuts', label: 'Keyboard shortcuts', shortcut: '?' },
153
+ { id: 'help', label: 'Help · commands & flows', shortcut: 'F1' },
154
+ { id: 'report-bug', label: 'Report a bug…' },
155
+ { sep: true },
156
+ { id: 'tour', label: 'Take the tour' },
157
+ { id: 'watch-intro', label: 'Watch the intro' },
158
+ // The collab "how sharing works" course teaches the plain-words Save →
159
+ // Publish → Pull cycle — a non-technical, native-app concern. A web-studio
160
+ // dev already knows git, so it's hidden there (DDR-119).
161
+ ...(isNativeApp() ? [{ id: 'collab-tour', label: 'How sharing works' }] : []),
162
+ // DDR-166 plan, Phase 2 (T7) — the quick-setup journey (design system →
163
+ // first canvas → first AI edit) is a native, no-terminal concern same as
164
+ // the two tours above.
165
+ ...(isNativeApp() ? [{ id: 'quick-setup', label: 'Quick setup' }] : []),
166
+ ...(isNativeApp() ? [{ id: 'readiness', label: 'Check AI editing readiness…' }] : []),
167
+ { id: 'whatsnew', label: "What's new" },
168
+ ]}
169
+ />
170
+ );
171
+ }
172
+
173
+ export function SelectionDropdown({ onAction, onClose, readOnly = false }) {
174
+ return (
175
+ <DropdownMenu
176
+ label="Selection"
177
+ left={214}
178
+ onAction={onAction}
179
+ onClose={onClose}
180
+ items={[
181
+ { id: 'deselect-all', label: 'Deselect all', shortcut: 'Esc' },
182
+ // Cloud Phase 25 C2 — annotation selection exists to edit/delete
183
+ // annotations; absent for a viewer.
184
+ ...(readOnly
185
+ ? []
186
+ : [{ id: 'select-all-annotations', label: 'Select all annotations', shortcut: '⌘ ⇧ A' }]),
187
+ ]}
188
+ />
189
+ );
190
+ }
191
+
192
+ export function ToolsDropdown({ onAction, onClose, readOnly = false }) {
193
+ // Mirrors DEFAULT_TOOLS in apps/studio/use-tool-mode.tsx — kept in sync by
194
+ // hand because the menubar lives in the dev-server shell (no shared bundle
195
+ // with the canvas iframes). Cloud Phase 25 C2 — a viewer keeps only the
196
+ // navigate/inspect tools (same READ_ONLY_TOOL_IDS the canvas enforces).
197
+ const items = [
198
+ // feature-4 (browse/move split) — Browse is the boot default (mock is
199
+ // alive); Move (V) is the select tool.
200
+ { id: 'browse', label: 'Browse (interact)', shortcut: '' },
201
+ { id: 'move', label: 'Select', shortcut: 'V' },
202
+ { id: 'hand', label: 'Hand', shortcut: 'H' },
203
+ ...(readOnly
204
+ ? []
205
+ : [
206
+ { id: 'comment', label: 'Comment', shortcut: 'C' },
207
+ { id: 'pen', label: 'Pen', shortcut: 'B' },
208
+ { id: 'rect', label: 'Rect', shortcut: 'R' },
209
+ { id: 'ellipse', label: 'Ellipse', shortcut: 'O' },
210
+ { id: 'sticky', label: 'Sticky', shortcut: 'N' },
211
+ { id: 'arrow', label: 'Arrow', shortcut: 'A' },
212
+ { id: 'text', label: 'Text', shortcut: 'T' },
213
+ { id: 'eraser', label: 'Eraser', shortcut: 'E' },
214
+ ]),
215
+ ];
216
+ return (
217
+ <DropdownMenu
218
+ label="Tools"
219
+ left={290}
220
+ header="Tool palette"
221
+ onAction={onAction}
222
+ onClose={onClose}
223
+ items={items}
224
+ />
225
+ );
226
+ }
227
+
228
+ // Plan C follow-up — File + Edit menus, previously inert. Both dispatch to real
229
+ // shell flows (File) or the in-canvas undo stack / selection bridges (Edit).
230
+ export function FileDropdown({ onAction, onClose, hasCanvas, hasSharePath, readOnly = false }) {
231
+ // Cloud Phase 25 C2 — a viewer keeps the reads (export, handoff, reload,
232
+ // close); create / assemble / generate / settings are absent.
233
+ const items = readOnly
234
+ ? [
235
+ { id: 'export', label: 'Export…', shortcut: '⇧⌘E' },
236
+ { id: 'share', label: 'Share link…', disabled: !hasSharePath },
237
+ { id: 'handoff', label: 'Handoff to production', shortcut: '⇧⌘H' },
238
+ { sep: true },
239
+ { id: 'reload', label: 'Reload canvas', shortcut: '⌘R', disabled: !hasCanvas },
240
+ { id: 'close', label: 'Close canvas', disabled: !hasCanvas },
241
+ ]
242
+ : [
243
+ // Bare N — the browser reserves ⌘N (New Window) and never delivers it.
244
+ { id: 'new', label: 'New canvas…', shortcut: 'N' },
245
+ // DDR-150 P4 Task 12 — one-click "udělej z toho video" from the clips
246
+ // dropped as reference chips on the active canvas.
247
+ { id: 'assemble', label: 'Assemble dropped clips → video', disabled: !hasCanvas },
248
+ { id: 'export', label: 'Export…', shortcut: '⇧⌘E' },
249
+ { id: 'share', label: 'Share link…', disabled: !hasSharePath },
250
+ { id: 'handoff', label: 'Handoff to production', shortcut: '⇧⌘H' },
251
+ { sep: true },
252
+ // feature-ai-media-generation (DDR-16x) — BYOK generate action + settings.
253
+ { id: 'generate', label: 'Generate with AI…' },
254
+ { id: 'settings', label: 'Settings…', shortcut: '⌘,' },
255
+ { sep: true },
256
+ { id: 'reload', label: 'Reload canvas', shortcut: '⌘R', disabled: !hasCanvas },
257
+ { id: 'close', label: 'Close canvas', disabled: !hasCanvas },
258
+ ];
259
+ return <DropdownMenu label="File" left={40} onAction={onAction} onClose={onClose} items={items} />;
260
+ }
261
+
262
+ export function EditDropdown({ onAction, onClose, hasCanvas, readOnly = false }) {
263
+ // Cloud Phase 25 C2 — a viewer's Edit menu is selection only; undo/redo,
264
+ // artboard insert and annotation ops are writes.
265
+ if (readOnly) {
266
+ return (
267
+ <DropdownMenu
268
+ label="Edit"
269
+ left={90}
270
+ onAction={onAction}
271
+ onClose={onClose}
272
+ items={[{ id: 'deselect-all', label: 'Deselect all', shortcut: 'Esc' }]}
273
+ />
274
+ );
275
+ }
276
+ return (
277
+ <DropdownMenu
278
+ label="Edit"
279
+ left={90}
280
+ onAction={onAction}
281
+ onClose={onClose}
282
+ items={[
283
+ { id: 'undo', label: 'Undo', shortcut: '⌘Z' },
284
+ { id: 'redo', label: 'Redo', shortcut: '⇧⌘Z' },
285
+ { sep: true },
286
+ { id: 'deselect-all', label: 'Deselect all', shortcut: 'Esc' },
287
+ { id: 'select-all-annotations', label: 'Select all annotations', shortcut: '⇧⌘A' },
288
+ // Stage I4 — insert an empty artboard from a device-size preset into the
289
+ // active canvas. Only meaningful with a canvas open.
290
+ ...(hasCanvas
291
+ ? [
292
+ { sep: true },
293
+ { id: 'new-artboard:desktop', label: 'New artboard: Desktop' },
294
+ { id: 'new-artboard:laptop', label: 'New artboard: Laptop' },
295
+ { id: 'new-artboard:tablet', label: 'New artboard: Tablet' },
296
+ { id: 'new-artboard:mobile', label: 'New artboard: Mobile' },
297
+ // feature-2-print-artboards T2 — "+ Artboard" quick-insert must
298
+ // set kind="print" + the print prop together (the plan's own
299
+ // gotcha for this task), not just a plain digital-sized board.
300
+ { id: 'new-artboard:print-a4', label: 'New artboard: A4 (print)' },
301
+ { id: 'new-artboard:print-letter', label: 'New artboard: Letter (print)' },
302
+ ]
303
+ : []),
304
+ ]}
305
+ />
306
+ );
307
+ }
308
+
309
+ export function Menubar({
310
+ activePath,
311
+ sharePath,
312
+ onShare,
313
+ project,
314
+ /** `{ dashboardUrl?, projectName }` when this is a cloud tab, else null. */
315
+ // Tri-state (see the note where this value is created): `undefined` until
316
+ // the server config answers, `null` for the desktop, an object for a cloud
317
+ // tab. Defaulting it to `null` here is what re-broke the boot 404 after the
318
+ // call sites were fixed — a default fires on `undefined`, so "not known yet"
319
+ // became "not cloud" one layer further in, invisibly.
320
+ cloud,
321
+ tabsCount,
322
+ openMenu,
323
+ setOpenMenu,
324
+ commentsPanelOpen,
325
+ onToggleComments,
326
+ changesOpen,
327
+ changesCount,
328
+ onToggleChanges,
329
+ onOpenSystem,
330
+ sidebarOpen,
331
+ onToggleSidebar,
332
+ showHidden,
333
+ onToggleShowHidden,
334
+ onOpenHelp,
335
+ onOpenShortcuts,
336
+ onReportBug,
337
+ onStartTour,
338
+ onStartCollabTour,
339
+ annotationsVisible,
340
+ onToggleAnnotations,
341
+ minimapVisible,
342
+ onToggleMinimap,
343
+ zoomCtlVisible,
344
+ onToggleZoomCtl,
345
+ presentMode,
346
+ onTogglePresent,
347
+ printGuidesVisible,
348
+ onTogglePrintGuides,
349
+ postToActiveCanvas,
350
+ onOpenWhatsNew,
351
+ onOpenReadiness,
352
+ onOpenQuickSetup,
353
+ onWatchIntro,
354
+ whatsNewCount,
355
+ exportCenter,
356
+ artboardCount = 0,
357
+ presence = null,
358
+ inspectorOpen,
359
+ inspectorTab,
360
+ onToggleInspector,
361
+ autoOpenInspector,
362
+ onToggleAutoOpenInspector,
363
+ onOpenLayers,
364
+ timelineOpen,
365
+ onToggleTimeline,
366
+ hasComps = false,
367
+ assistantOpen,
368
+ onToggleAssistant,
369
+ assistantBusy,
370
+ assistantUnseen,
371
+ onNewCanvas,
372
+ onAssembleVideo,
373
+ onOpenExport,
374
+ onOpenSettings,
375
+ onOpenGenerate,
376
+ onReload,
377
+ onCloseCanvas,
378
+ onInsertArtboard,
379
+ // Cloud Phase 25 C2 — viewer role: editing entries are absent from every
380
+ // menu, and the stamp says VIEW ONLY so the absence is legible.
381
+ readOnly = false,
382
+ }) {
383
+ const isSystem = activePath === SYSTEM_TAB;
384
+ const stamp = isSystem ? 'SYSTEM' : activePath ? 'CANVAS' : 'IDLE';
385
+ const fileLabel = isSystem ? (
386
+ <b>design system</b>
387
+ ) : activePath ? (
388
+ <>
389
+ {activePath.split('/').slice(0, -1).join('/')}/<b>{displayName(basename(activePath))}</b>
390
+ </>
391
+ ) : (
392
+ <span style={{ color: 'var(--u-fg-3)' }}>no canvas open</span>
393
+ );
394
+
395
+ // Cloud Phase 27 C1 — ROLE SHAPES WHAT IS OFFERED, NEVER WHAT IS VISIBLE.
396
+ //
397
+ // `inspector` and `layers` used to be on this list and should never have been.
398
+ // Read-only means cannot CHANGE, not cannot SEE: a reviewer needs the
399
+ // structure and the measured values to say anything useful, and hiding them
400
+ // is how a viewer's Maude became a worse Maude rather than a narrower one.
401
+ // What stays hidden is only what genuinely does not exist for this session —
402
+ // the agent chat (`assistant`, which needs a `claude` on the machine the app
403
+ // is running on) and auto-open (a preference for a surface you cannot edit).
404
+ // In the cloud the `assistant` row is the stated-absence row above, so it must
405
+ // NOT be filtered away here — a viewer would then get silence, which is the
406
+ // exact thing C2 forbids.
407
+ const viewerHiddenPanels = new Set(cloud ? ['autoopen'] : ['assistant', 'autoopen']);
408
+ const panels = [
409
+ { id: 'tree', label: 'Project Tree', shortcut: 'T', checked: sidebarOpen, disabled: false },
410
+ {
411
+ id: 'changes',
412
+ // In a cell this panel is History (the hub already committed the work),
413
+ // so the menu names what it opens rather than an unsaved count there is
414
+ // no way — and no reason — to act on.
415
+ label: cloud
416
+ ? 'History'
417
+ : changesCount > 0
418
+ ? `Changes · ${changesCount} unsaved`
419
+ : 'Changes',
420
+ shortcut: '⌘ ⇧ G',
421
+ checked: changesOpen,
422
+ disabled: false,
423
+ },
424
+ {
425
+ id: 'comments',
426
+ label: 'Comments Sidebar',
427
+ shortcut: '⌘ ⇧ M',
428
+ checked: commentsPanelOpen,
429
+ disabled: false,
430
+ },
431
+ {
432
+ id: 'hidden',
433
+ label: 'Show hidden files',
434
+ shortcut: 'H',
435
+ checked: showHidden,
436
+ disabled: false,
437
+ },
438
+ {
439
+ id: 'layers',
440
+ label: 'Layers',
441
+ shortcut: '',
442
+ checked: inspectorOpen && inspectorTab === 'layers',
443
+ disabled: false,
444
+ },
445
+ {
446
+ id: 'inspector',
447
+ label: 'Inspector',
448
+ shortcut: '⌘ ⇧ I',
449
+ checked: inspectorOpen,
450
+ disabled: false,
451
+ },
452
+ {
453
+ id: 'autoopen',
454
+ label: 'Auto-open Inspector on select',
455
+ shortcut: '',
456
+ checked: !!autoOpenInspector,
457
+ disabled: false,
458
+ },
459
+ // DDR-148 — Timeline (video-comp scrub). Phase-tag hints when the active
460
+ // canvas actually has a comp; the panel itself shows an empty state otherwise.
461
+ {
462
+ id: 'timeline',
463
+ label: 'Timeline',
464
+ shortcut: '⌘ ⇧ T',
465
+ phase: hasComps ? 'video' : undefined,
466
+ checked: timelineOpen,
467
+ disabled: false,
468
+ },
469
+ // Phase 31 (DDR-123) — native-only ACP chat sidepanel.
470
+ ...(isNativeApp()
471
+ ? [
472
+ {
473
+ id: 'assistant',
474
+ label: 'Assistant',
475
+ shortcut: '⌘ ⇧ A',
476
+ checked: assistantOpen,
477
+ disabled: false,
478
+ },
479
+ ]
480
+ : // Cloud Phase 27 C2 — THE AGENT'S ABSENCE IS STATED WHERE THE AGENT
481
+ // WOULD BE. It runs on YOUR `claude` subscription, on YOUR machine
482
+ // (DDR-123), so a browser tab genuinely cannot have it. That is a
483
+ // legitimate difference — but a menu that silently lacks an item its
484
+ // user has seen on the desktop reads as "the cloud one is broken", so
485
+ // the row stays, disabled, saying where to find it. Never a hidden
486
+ // item, never a dead button, never silence.
487
+ cloud
488
+ ? [
489
+ {
490
+ id: 'assistant',
491
+ label: 'Assistant — in the desktop app',
492
+ shortcut: '',
493
+ checked: false,
494
+ disabled: true,
495
+ href: 'https://maude.sh/download',
496
+ hint: 'The agent runs on your own Claude subscription, on your own machine.',
497
+ },
498
+ ]
499
+ : []),
500
+ {
501
+ id: 'annotate',
502
+ label: 'Annotations',
503
+ shortcut: '⇧ P',
504
+ checked: annotationsVisible,
505
+ disabled: false,
506
+ },
507
+ {
508
+ id: 'minimap',
509
+ label: 'Minimap',
510
+ shortcut: '',
511
+ checked: minimapVisible,
512
+ disabled: !activePath || isSystem,
513
+ },
514
+ {
515
+ id: 'zoomctl',
516
+ label: 'Zoom controls',
517
+ shortcut: '',
518
+ checked: zoomCtlVisible,
519
+ disabled: !activePath || isSystem,
520
+ },
521
+ {
522
+ id: 'present',
523
+ label: 'Presentation Mode',
524
+ shortcut: '',
525
+ checked: presentMode,
526
+ disabled: !activePath || isSystem,
527
+ },
528
+ // feature-2-print-artboards T3 — per-canvas persisted (overlays.print in
529
+ // view.json), same lane as the foundation's `guides` key; NOT gated on the
530
+ // active artboard actually being kind="print" (mirrors minimap/zoomctl,
531
+ // which aren't content-gated either — the overlay itself renders nothing
532
+ // for a non-print artboard regardless of this flag).
533
+ {
534
+ id: 'print-guides',
535
+ label: 'Show print guides',
536
+ shortcut: '',
537
+ checked: printGuidesVisible,
538
+ disabled: !activePath || isSystem,
539
+ },
540
+ ].filter((p) => !readOnly || !viewerHiddenPanels.has(p.id));
541
+
542
+ const DROPDOWN_MENUS = ['file', 'edit', 'view', 'selection', 'tools', 'help'];
543
+ function onMenuClick(key) {
544
+ if (DROPDOWN_MENUS.includes(key)) {
545
+ setOpenMenu(openMenu === key ? null : key);
546
+ }
547
+ }
548
+
549
+ // Keyboard menubar (native-menu parity): while a dropdown is open, ↑/↓ rove
550
+ // its items, ←/→ switch to the adjacent menu, Home/End jump, Esc returns
551
+ // focus to the trigger (useDropdownClose handles the close itself).
552
+ useEffect(() => {
553
+ if (!openMenu || !DROPDOWN_MENUS.includes(openMenu)) return;
554
+ // Move focus into the menu so ↑/↓ work immediately after a click.
555
+ const t = setTimeout(() => {
556
+ document
557
+ .querySelector('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])')
558
+ ?.focus();
559
+ }, 0);
560
+ function onKey(e) {
561
+ const items = [
562
+ ...document.querySelectorAll('.st-dropdown [role="menuitem"]:not([aria-disabled="true"])'),
563
+ ];
564
+ if (!items.length) return;
565
+ const idx = items.indexOf(document.activeElement);
566
+ if (e.key === 'ArrowDown') {
567
+ e.preventDefault();
568
+ items[(idx + 1) % items.length].focus();
569
+ } else if (e.key === 'ArrowUp') {
570
+ e.preventDefault();
571
+ items[(idx - 1 + items.length) % items.length].focus();
572
+ } else if (e.key === 'Home') {
573
+ e.preventDefault();
574
+ items[0].focus();
575
+ } else if (e.key === 'End') {
576
+ e.preventDefault();
577
+ items[items.length - 1].focus();
578
+ } else if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') {
579
+ e.preventDefault();
580
+ const dir = e.key === 'ArrowRight' ? 1 : -1;
581
+ const cur = DROPDOWN_MENUS.indexOf(openMenu);
582
+ setOpenMenu(DROPDOWN_MENUS[(cur + dir + DROPDOWN_MENUS.length) % DROPDOWN_MENUS.length]);
583
+ } else if (e.key === 'Escape') {
584
+ document.querySelector('.st-menu[aria-expanded="true"]')?.focus();
585
+ }
586
+ }
587
+ window.addEventListener('keydown', onKey);
588
+ return () => {
589
+ clearTimeout(t);
590
+ window.removeEventListener('keydown', onKey);
591
+ };
592
+ }, [openMenu, setOpenMenu]);
593
+
594
+ return (
595
+ <header
596
+ className="st-menubar"
597
+ aria-label="Application menubar"
598
+ data-testid="menubar"
599
+ >
600
+ <span className="st-brand" data-tour="brand">
601
+ <span className="st-brand-mark">
602
+ <svg viewBox="0 0 32 32" width="100%" height="100%" fill="none" aria-hidden="true"><path d="M16 5l2.8 8.2L27 16l-8.2 2.8L16 27l-2.8-8.2L5 16l8.2-2.8z" fill="currentColor" /></svg>
603
+ </span>
604
+ <span className="st-brand-name">maude</span>
605
+ </span>
606
+ {/* Cloud Phase 27 C4 — THE WAY BACK OUT.
607
+ A browser tab has no window title and no app switcher, so a teammate
608
+ who followed a link has nothing telling them which project they are in
609
+ or how to leave it. The desktop gets both for free from the OS; the
610
+ cloud has to say them. This is an ADDITION to the shared client behind
611
+ the same `cloud` flag as C2's agent notice — never a fork of the
612
+ component, which is how the two shells started diverging last time. */}
613
+ {cloud ? (
614
+ <span className="st-cloudback" data-testid="cloud-back">
615
+ {/* Only when there IS somewhere to go back TO. `dashboardUrl` is
616
+ absent on a self-hosted hub (one hub serves one project, so there
617
+ is no dashboard), and a hardcoded fallback here quietly re-created
618
+ the exact bug the server side just stopped: the link is the ONE
619
+ way out this tab offers, and it pointed at cloud.maude.sh. The
620
+ project name below stays either way — a tab must still say which
621
+ project it is showing. */}
622
+ {cloud.dashboardUrl ? (
623
+ <a
624
+ className="st-cloudback-link"
625
+ href={cloud.dashboardUrl}
626
+ title="Back to your projects"
627
+ >
628
+ ← Dashboard
629
+ </a>
630
+ ) : null}
631
+ {cloud.projectName ? (
632
+ <span className="st-cloudback-project" data-testid="cloud-project-name">
633
+ {cloud.projectName}
634
+ </span>
635
+ ) : null}
636
+ </span>
637
+ ) : null}
638
+ <nav className="st-menus" role="menubar" aria-label="Application menus" data-tour="menus">
639
+ {MENU_NAMES.map((name) => {
640
+ const key = name.toLowerCase();
641
+ const hasDropdown = DROPDOWN_MENUS.includes(key);
642
+ const interactive = hasDropdown || key === 'help';
643
+ const open = openMenu === key;
644
+ return (
645
+ <button
646
+ key={key}
647
+ type="button"
648
+ className="st-menu"
649
+ role="menuitem"
650
+ data-testid={`menu-${key}`}
651
+ data-tour={key === 'help' ? 'help' : undefined}
652
+ aria-haspopup={hasDropdown ? 'menu' : undefined}
653
+ aria-expanded={hasDropdown ? open : undefined}
654
+ onClick={() => onMenuClick(key)}
655
+ // F4 — once any menu is open, hovering another trigger switches to
656
+ // it (base-ui menubar behavior). Only among dropdown menus.
657
+ onMouseEnter={() => {
658
+ if (openMenu !== null && hasDropdown) setOpenMenu(key);
659
+ }}
660
+ >
661
+ {name}
662
+ </button>
663
+ );
664
+ })}
665
+ </nav>
666
+ {openMenu === 'file' && (
667
+ <FileDropdown
668
+ readOnly={readOnly}
669
+ hasCanvas={!!activePath}
670
+ hasSharePath={!!sharePath}
671
+ onAction={(id) => {
672
+ if (id === 'new') onNewCanvas?.();
673
+ else if (id === 'assemble') onAssembleVideo?.();
674
+ else if (id === 'export') onOpenExport?.('export');
675
+ else if (id === 'share') { document.querySelector('[data-testid="menu-file"]')?.focus(); onShare?.(); }
676
+ else if (id === 'handoff') onOpenExport?.('handoff');
677
+ else if (id === 'generate') onOpenGenerate?.();
678
+ else if (id === 'settings') onOpenSettings?.();
679
+ else if (id === 'reload') onReload?.();
680
+ else if (id === 'close') onCloseCanvas?.();
681
+ }}
682
+ onClose={() => setOpenMenu(null)}
683
+ />
684
+ )}
685
+ {openMenu === 'edit' && (
686
+ <EditDropdown
687
+ readOnly={readOnly}
688
+ hasCanvas={!!activePath && !isSystem}
689
+ onAction={(id) => {
690
+ if (id === 'undo') postToActiveCanvas({ dgn: 'undo' });
691
+ else if (id === 'redo') postToActiveCanvas({ dgn: 'redo' });
692
+ else if (id === 'deselect-all') postToActiveCanvas({ dgn: 'selection-clear' });
693
+ else if (id === 'select-all-annotations')
694
+ postToActiveCanvas({ dgn: 'annotation-select-all' });
695
+ else if (id.startsWith('new-artboard:'))
696
+ onInsertArtboard?.(id.slice('new-artboard:'.length));
697
+ }}
698
+ onClose={() => setOpenMenu(null)}
699
+ />
700
+ )}
701
+ {openMenu === 'view' && (
702
+ <ViewDropdown
703
+ panels={panels}
704
+ onToggle={(id) => {
705
+ if (id === 'tree') onToggleSidebar();
706
+ else if (id === 'changes') onToggleChanges();
707
+ else if (id === 'comments') onToggleComments();
708
+ else if (id === 'hidden') onToggleShowHidden();
709
+ else if (id === 'annotate') onToggleAnnotations();
710
+ else if (id === 'inspector') onToggleInspector();
711
+ else if (id === 'autoopen') onToggleAutoOpenInspector?.();
712
+ else if (id === 'timeline') onToggleTimeline?.();
713
+ else if (id === 'assistant') onToggleAssistant?.();
714
+ else if (id === 'layers') onOpenLayers?.();
715
+ else if (id === 'minimap') onToggleMinimap?.();
716
+ else if (id === 'zoomctl') onToggleZoomCtl?.();
717
+ else if (id === 'present') onTogglePresent?.();
718
+ else if (id === 'print-guides') onTogglePrintGuides?.();
719
+ }}
720
+ onZoom={(op) => postToActiveCanvas({ dgn: 'zoom', op })}
721
+ hasCanvas={!!activePath && !isSystem}
722
+ onClose={() => setOpenMenu(null)}
723
+ />
724
+ )}
725
+ {openMenu === 'selection' && (
726
+ <SelectionDropdown
727
+ readOnly={readOnly}
728
+ onAction={(id) => {
729
+ if (id === 'deselect-all') postToActiveCanvas({ dgn: 'selection-clear' });
730
+ else if (id === 'select-all-annotations')
731
+ postToActiveCanvas({ dgn: 'annotation-select-all' });
732
+ }}
733
+ onClose={() => setOpenMenu(null)}
734
+ />
735
+ )}
736
+ {openMenu === 'tools' && (
737
+ <ToolsDropdown
738
+ readOnly={readOnly}
739
+ onAction={(tool) => postToActiveCanvas({ dgn: 'tool-set', tool })}
740
+ onClose={() => setOpenMenu(null)}
741
+ />
742
+ )}
743
+ {openMenu === 'help' && (
744
+ <HelpDropdown
745
+ onAction={(id) => {
746
+ if (id === 'shortcuts') onOpenShortcuts?.();
747
+ else if (id === 'help') onOpenHelp?.();
748
+ else if (id === 'report-bug') onReportBug?.();
749
+ else if (id === 'tour') onStartTour?.();
750
+ else if (id === 'collab-tour') onStartCollabTour?.();
751
+ else if (id === 'quick-setup') onOpenQuickSetup?.();
752
+ else if (id === 'readiness') onOpenReadiness?.();
753
+ else if (id === 'whatsnew') onOpenWhatsNew?.();
754
+ else if (id === 'watch-intro') onWatchIntro?.();
755
+ }}
756
+ onClose={() => setOpenMenu(null)}
757
+ />
758
+ )}
759
+ <div className="st-mb-right" data-tour="status">
760
+ {presence ? <div className="st-presence">{presence}</div> : null}
761
+ {readOnly && (
762
+ <span
763
+ className="st-stamp st-stamp--viewonly"
764
+ data-testid="view-only-stamp"
765
+ data-tip={
766
+ cloud?.user
767
+ ? `${cloud.user} is a viewer on this project — you can browse, comment and export where available. Ask a project owner for edit access, or sign out if that is not the account you meant to use.`
768
+ : 'Your role in this project is viewer — you can browse, comment when available, and export where available. Ask a project owner for edit access.'
769
+ }
770
+ >
771
+ VIEW ONLY
772
+ </span>
773
+ )}
774
+ {/* Cloud Phase 27 C4 — WHO YOU ARE, AND HOW TO STOP BEING THEM.
775
+ A browser tab carries no account identity of its own: the cookie is
776
+ invisible, and the only thing on screen that reflected it was a
777
+ three-word stamp. An owner who read VIEW ONLY had no way to tell
778
+ whether the role was wrong or the ACCOUNT was, and no way to change
779
+ either — the session outlived any fix by up to twelve hours because
780
+ nothing in the studio could end it. This ends it. */}
781
+ {cloud?.user ? (
782
+ <span className="st-cloudwho" data-testid="cloud-account">
783
+ <span
784
+ className="st-cloudwho-email"
785
+ title={cloud.role ? `Signed in as ${cloud.user} — ${cloud.role}` : cloud.user}
786
+ >
787
+ {cloud.user}
788
+ </span>
789
+ {/* A FORM, not a link. Signing out revokes the token server-side,
790
+ so it is a write — and a write behind a GET is one any page can
791
+ force on you from across the internet. */}
792
+ <form method="post" action="/auth/browser/signout" className="st-cloudwho-form">
793
+ <button
794
+ type="submit"
795
+ className="st-cloudwho-out"
796
+ data-testid="cloud-signout"
797
+ title="Sign out of this project"
798
+ >
799
+ Sign out
800
+ </button>
801
+ </form>
802
+ </span>
803
+ ) : null}
804
+ {isNativeApp() && !readOnly && (
805
+ <button
806
+ type="button"
807
+ className="st-assistant"
808
+ data-testid="assistant-toggle"
809
+ data-active={assistantOpen ? 'true' : 'false'}
810
+ data-busy={assistantBusy ? 'true' : 'false'}
811
+ data-unseen={assistantUnseen ? 'true' : 'false'}
812
+ aria-label={`Assistant${assistantBusy ? ' — working' : assistantUnseen ? ' — new reply' : ''}`}
813
+ data-tip="Assistant ⌘⇧A"
814
+ onClick={onToggleAssistant}
815
+ >
816
+ <StIcon name="sparkle" size={15} />
817
+ </button>
818
+ )}
819
+ <button type="button" className="st-mb-icon st-share-btn" data-testid="share-btn" data-tip={sharePath ? 'Share link' : 'Open a canvas to share it'} aria-label="Share link" disabled={!sharePath} onClick={onShare}><StIcon name="share" size={15} /></button>
820
+ {exportCenter && <ExportBadge center={exportCenter} />}
821
+ <button
822
+ type="button"
823
+ className="st-reportbug"
824
+ data-testid="report-bug-toggle"
825
+ aria-label="Report a bug"
826
+ data-tip="Report a bug"
827
+ onClick={onReportBug}
828
+ >
829
+ <StIcon name="bug" size={15} />
830
+ </button>
831
+ <button
832
+ type="button"
833
+ className="st-whatsnew"
834
+ data-tour="whatsnew"
835
+ data-unseen={whatsNewCount > 0 ? 'true' : 'false'}
836
+ aria-label={`What's new${whatsNewCount > 0 ? ` — ${whatsNewCount} unseen` : ''}`}
837
+ data-tip="What's new"
838
+ onClick={onOpenWhatsNew}
839
+ >
840
+ <StIcon name="megaphone" size={15} />
841
+ </button>
842
+ <span className="st-stamp">{stamp}</span>
843
+ <span className="st-mb-file" title={activePath || ''}>
844
+ {fileLabel}
845
+ </span>
846
+ <span className="st-mb-sep" />
847
+ <span className="st-mb-count" data-tip="Artboards in the open canvas">
848
+ <span className="st-dot" style={{ background: 'var(--accent)' }} />
849
+ {artboardCount} ARTBOARDS
850
+ </span>
851
+ <span className="st-mb-sep" />
852
+ <span className="st-mb-proj">{project || 'maude'}</span>
853
+ </div>
854
+ </header>
855
+ );
856
+ }