@1agh/maude 2.3.1 → 2.3.2

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.
@@ -147,6 +147,7 @@ import { VoteDots } from './annotations/ui/vote-dots.tsx';
147
147
  import { projectStrokes, type StrokeCache } from './annotations/ui/world.ts';
148
148
  import { elementsToStrokes, strokesToElementMap } from './annotations/v1-adapter.ts';
149
149
  import { reasonProps } from './client/v2/access/disabled-reason.js';
150
+ import { setAnnotationCount } from './editing/annotation-count.ts';
150
151
  import { frameCaf, frameRaf } from './frame-clock.ts';
151
152
  import { setStickerSelected } from './toolbars/shell-panels.ts';
152
153
  /**
@@ -1270,6 +1271,13 @@ export function AnnotationsLayer() {
1270
1271
  () => preview ?? (uploading.length ? [...boardStrokes, ...uploading] : boardStrokes),
1271
1272
  [preview, uploading, boardStrokes]
1272
1273
  );
1274
+ // #227 — the empty canvas ("Your canvas is ready.") must not sit over a canvas that has been drawn on:
1275
+ // the reporter sends this with the artboard count. The board's own count — hidden or far-zoom still counts.
1276
+ const annotationTotal = boardStrokes.length + uploading.length;
1277
+ useEffect(() => {
1278
+ setAnnotationCount(annotationTotal);
1279
+ }, [annotationTotal]);
1280
+ useEffect(() => () => setAnnotationCount(0), []);
1273
1281
  const [drawing, setDrawing] = useState<Stroke | null>(null);
1274
1282
  // S4.8 — colour, ink, thickness, Marker tip and the Highlighter's hue / nib are the tool state
1275
1283
  // (annotations/ui/tool-state.ts): the toolbar's popovers set them, and they are the person's own,
@@ -0,0 +1,5 @@
1
+ // bin/_capture-init.js — loaded into the capture helper's own browser before the studio's code (#228).
2
+ // A capture opens the studio in a browser with no history, so the questions the studio asks a person once
3
+ // (the sync consent sheet) would be asked again and would cover the very window the capture is of.
4
+ // Nothing here answers a question: the studio only holds it back while this window is a capture.
5
+ window.__MAUDE_CAPTURE__ = true;
@@ -479,7 +479,13 @@ navigate_once() {
479
479
  # screenshot" — which for the Report-a-Bug shell shot means a blank image
480
480
  # labelled "Maude window" lands in someone's bug report.
481
481
  # its own output can echo the URL (an opening link, a frame capability): never to stderr
482
- if ! "$AB" open "$URL" >/dev/null 2>&1; then
482
+ # #228 — a shell capture says so to the studio (bin/_capture-init.js), which then holds back the
483
+ # ask-once sheets a browser with no history would raise over the window being captured.
484
+ local open_extra=()
485
+ if [ "$MODE" = "shell" ] && [ -f "$(dirname "$0")/_capture-init.js" ]; then
486
+ open_extra=(--init-script "$(dirname "$0")/_capture-init.js")
487
+ fi
488
+ if ! "$AB" open "$URL" ${open_extra[@]+"${open_extra[@]}"} >/dev/null 2>&1; then
483
489
  echo "✗ navigation failed: $(shown_url "$URL")" >&2
484
490
  return 1
485
491
  fi
@@ -315,7 +315,8 @@ export interface CanvasToShell {
315
315
  // legacy, no in-tree sender (accepted today; removal needs a characterization proof)
316
316
  select: { selection: Selection };
317
317
  'clear-select': Empty;
318
- artboards: { count: number };
318
+ /** `annotations` (#227): how many annotations the canvas's board holds; absent from an older canvas. */
319
+ artboards: { count: number; annotations?: number };
319
320
  /** S11.2 — the ONE selected artboard has nothing on it (the shell draws the hint at `rect`, iframe viewport px);
320
321
  * `rect: null` = it is not empty now / something else is selected. `label` / `from` are untrusted text. */
321
322
  'artboard-empty': {
@@ -1853,7 +1854,7 @@ const c2s: C2S = {
1853
1854
  gate: 'active',
1854
1855
  status: 'live',
1855
1856
  owner: 'v2/empty (S11.2); the shell bridge keeps the Layers count',
1856
- parse: p({ count: num }),
1857
+ parse: p({ count: num, annotations: opt(num) }),
1857
1858
  },
1858
1859
  // S11.2 — the shell draws the empty-artboard hint (Q5 of S11-slices): the copy lives in one table.
1859
1860
  'artboard-empty': {
@@ -51,12 +51,14 @@ import { HUD_TOKENS_CSS } from './canvas-hud-tokens.gen.ts';
51
51
  import {
52
52
  type ArtboardRect,
53
53
  fitRectIntoHost,
54
+ getLiveViewport,
54
55
  PhotoPreviewBridge,
55
56
  SnapGuideOverlay,
56
57
  useArtboardsContext,
57
58
  useDragStateContext,
58
59
  useViewportControllerContext,
59
60
  type ViewportControllerHandle,
61
+ type ViewportState,
60
62
  } from './canvas-lib.tsx';
61
63
  import {
62
64
  CanvasPagesSwitch,
@@ -78,6 +80,7 @@ import {
78
80
  } from './commands/edit-source-command.ts';
79
81
  import { type AlignMode, alignLabel, equalSpacingLabel } from './commands/equal-spacing-command.ts';
80
82
  import { buildReorderRecord, type ReorderRevertFn } from './commands/reorder-command.ts';
83
+ import { COMMENT_REVEAL_EVENT, type CommentRevealDetail } from './comments/reveal.ts';
81
84
  import {
82
85
  ContextMenuProvider,
83
86
  type ContextRegistry,
@@ -2534,6 +2537,33 @@ export function revealElementViaCamera(
2534
2537
  if (dx !== 0 || dy !== 0) controller.panBy(dx, dy);
2535
2538
  }
2536
2539
 
2540
+ /** Room (screen px) a comment's thread card needs beside its pin — it opens to the pin's right or left. */
2541
+ export const COMMENT_REVEAL_ROOM_PX = 120;
2542
+
2543
+ /**
2544
+ * #229 — where the camera goes so a comment's place (`pos`, client px) is in view: null when it already is
2545
+ * (the pin and room for its thread card inside the view box), else the camera that puts it in the middle
2546
+ * of the view box. A jump from the Comments panel is a "take me there", so it centres rather than nudging.
2547
+ */
2548
+ export function commentRevealTarget(
2549
+ view: { left: number; top: number; right: number; bottom: number },
2550
+ pos: { x: number; y: number; w: number; h: number },
2551
+ vp: ViewportState,
2552
+ room = COMMENT_REVEAL_ROOM_PX
2553
+ ): ViewportState | null {
2554
+ const cx = pos.x + pos.w / 2;
2555
+ const cy = pos.y + pos.h / 2;
2556
+ const mx = Math.min(room, Math.max(0, (view.right - view.left) / 2 - 1));
2557
+ const my = Math.min(room, Math.max(0, (view.bottom - view.top) / 2 - 1));
2558
+ const inside =
2559
+ cx >= view.left + mx && cx <= view.right - mx && cy >= view.top + my && cy <= view.bottom - my;
2560
+ if (inside) return null;
2561
+ const dx = (view.left + view.right) / 2 - cx;
2562
+ const dy = (view.top + view.bottom) / 2 - cy;
2563
+ if (!Number.isFinite(dx) || !Number.isFinite(dy)) return null;
2564
+ return { x: vp.x + dx, y: vp.y + dy, zoom: vp.zoom };
2565
+ }
2566
+
2537
2567
  // ─────────────────────────────────────────────────────────────────────────────
2538
2568
  // feature-4 T7b — locked-layer enforcement. The shell owns the padlock UI +
2539
2569
  // view.json persistence; the canvas only needs the LIVE set to refuse
@@ -2742,6 +2772,30 @@ function CanvasRouter({
2742
2772
 
2743
2773
  // Shell View-menu zoom bridge (dgn:'zoom') — same controller the zoom pill uses.
2744
2774
  const zoomController = useViewportControllerContext();
2775
+ // #229 — a thread opened from the Comments panel: the overlay (which knows the comment) asks for its place
2776
+ // to be brought into view. A comment on another page turns to that page first; the place is measured after.
2777
+ useEffect(() => {
2778
+ if (typeof document === 'undefined' || !zoomController) return;
2779
+ const onReveal = (e: Event) => {
2780
+ const d = (e as CustomEvent<CommentRevealDetail>).detail;
2781
+ if (typeof d?.locate !== 'function') return;
2782
+ const go = () => {
2783
+ const host = hostRef.current;
2784
+ const pos = d.locate();
2785
+ if (!host || !pos) return;
2786
+ const next = commentRevealTarget(
2787
+ revealViewBox(host.getBoundingClientRect(), canvasInsets()),
2788
+ pos,
2789
+ getLiveViewport() ?? zoomController.viewport
2790
+ );
2791
+ if (next) zoomController.animateTo(next, 220);
2792
+ };
2793
+ if (d.artboard && turnToPage(d.artboard)) frameRaf(() => frameRaf(go));
2794
+ else go();
2795
+ };
2796
+ document.addEventListener(COMMENT_REVEAL_EVENT, onReveal);
2797
+ return () => document.removeEventListener(COMMENT_REVEAL_EVENT, onReveal);
2798
+ }, [zoomController, hostRef]);
2745
2799
  // Shell View-menu chrome-visibility bridge (dgn:'view-chrome') — minimap /
2746
2800
  // zoom-controls toggles + Presentation Mode. Drives the shared chrome store
2747
2801
  // the floating chrome (DCMiniMap, DCZoomToolbar, ToolPalette, AnnotationsLayer)
@@ -62,7 +62,10 @@ export default function SyncConsentDialog({ status, cloud }) {
62
62
 
63
63
  // Never on a cell (a member browsing someone's hosted project is not the
64
64
  // machine whose files sync), never for loopback, never before sync speaks.
65
- const due = !cloud && url && !isLoopback(url) && !answered && !readConsent(url);
65
+ // #228 — never in a capture helper's own browser (bin/_capture-init.js): it has no history, so the sheet
66
+ // would rise over every "Maude window" shot a bug report attaches. Nothing is answered for the person.
67
+ const capture = typeof window !== 'undefined' && window.__MAUDE_CAPTURE__ === true;
68
+ const due = !capture && !cloud && url && !isLoopback(url) && !answered && !readConsent(url);
66
69
 
67
70
  // The dialog steals the screen, so say so to assistive tech the same way
68
71
  // the other modals do — but only while actually shown.
@@ -53,7 +53,7 @@ export function EmptyHost() {
53
53
  const native = isNativeApp();
54
54
  const canAsk = native && canEdit;
55
55
  const [claude] = useClaudeState(canAsk && canvasOpen);
56
- const { lane, count, hint } = useEmptyLane({
56
+ const { lane, count, annotations, hint } = useEmptyLane({
57
57
  activePath,
58
58
  iframesRef,
59
59
  canvasOrigin: cfg?.canvasOrigin,
@@ -66,7 +66,16 @@ export function EmptyHost() {
66
66
  if (loadingPath) lane.loadStarted(loadingPath);
67
67
  }, [lane, loadingPath]);
68
68
  const model = canvasOpen
69
- ? emptyCanvasModel({ count, mode, canEdit, online, claude, canAsk, loading: canvasLoading })
69
+ ? emptyCanvasModel({
70
+ count,
71
+ annotations,
72
+ mode,
73
+ canEdit,
74
+ online,
75
+ claude,
76
+ canAsk,
77
+ loading: canvasLoading,
78
+ })
70
79
  : null;
71
80
  // rc3-h (#182): a run of yours on this empty canvas — the ghost where the first artboard lands, not the invitation
72
81
  const { view: runsView } = useAiRuns();
@@ -40,13 +40,15 @@ export function hubAway(syncStatus) {
40
40
  /**
41
41
  * Which empty-canvas situation applies — or null (nothing to show).
42
42
  *
43
- * @param {{ count: number|null|undefined, mode: string, canEdit: boolean, online: boolean,
43
+ * @param {{ count: number|null|undefined, annotations?: number|null, mode: string, canEdit: boolean, online: boolean,
44
44
  * claude: 'present'|'absent'|'unknown', canAsk: boolean, loading?: boolean }} f
45
45
  * `count` is what the CANVAS reported (null until it has: no flash while it loads). `canEdit` false =
46
46
  * Can view / Can comment: no create affordance at all. `canAsk`: the AI chat exists here (desktop app).
47
47
  */
48
48
  export function emptyCanvasModel(f) {
49
49
  if (f.count !== 0) return null;
50
+ // #227 — no artboards, but somebody has drawn on it (stickies, arrows, a board template): not empty.
51
+ if (f.annotations > 0) return null;
50
52
  // #204 — only for a canvas KNOWN to be empty once its load has finished: a 0 said while the canvas is
51
53
  // still loading (before its artboards mount) put the invitation over artboards drawn a moment later.
52
54
  if (f.loading) return null;
@@ -117,7 +119,8 @@ export function hintPlacement(frame, rect, viewport, size) {
117
119
  */
118
120
  export function createEmptyLane(deps) {
119
121
  const counts = new Map();
120
- let state = { count: null, hint: null };
122
+ const annots = new Map(); // #227 — path → how many annotations its board holds
123
+ let state = { count: null, annotations: null, hint: null };
121
124
  const subs = new Set();
122
125
  const set = (next) => {
123
126
  state = next;
@@ -131,6 +134,10 @@ export function createEmptyLane(deps) {
131
134
  const p = deps.activePath();
132
135
  return p && counts.has(p) ? counts.get(p) : null;
133
136
  };
137
+ const annotsOf = () => {
138
+ const p = deps.activePath();
139
+ return p && annots.has(p) ? annots.get(p) : null;
140
+ };
134
141
  return {
135
142
  get: () => state,
136
143
  subscribe(fn) {
@@ -147,7 +154,9 @@ export function createEmptyLane(deps) {
147
154
  if (m.dgn === 'artboards') {
148
155
  if (!path) return;
149
156
  counts.set(path, Math.max(0, Math.round(m.count)));
150
- set({ ...state, count: countOf() });
157
+ if (typeof m.annotations === 'number')
158
+ annots.set(path, Math.max(0, Math.round(m.annotations)));
159
+ set({ ...state, count: countOf(), annotations: annotsOf() });
151
160
  } else if (m.dgn === 'artboard-empty') {
152
161
  if (!m.rect || !m.artboardId) {
153
162
  if (state.hint) set({ ...state, hint: null });
@@ -171,18 +180,24 @@ export function createEmptyLane(deps) {
171
180
  },
172
181
  /** The active canvas changed: what was said about the last one is not about this one. */
173
182
  switched() {
174
- set({ count: countOf(), hint: null });
183
+ set({ count: countOf(), annotations: annotsOf(), hint: null });
175
184
  },
176
185
  /** #204 — a canvas started (re)loading: what its last document said about it is not about the next. */
177
186
  loadStarted(path) {
178
187
  if (!path || !counts.has(path)) return;
179
188
  counts.delete(path);
180
- set({ ...state, count: countOf() });
189
+ annots.delete(path);
190
+ set({ ...state, count: countOf(), annotations: annotsOf() });
181
191
  },
182
192
  /** A canvas left the project / was closed. */
183
193
  forget(path) {
184
194
  counts.delete(path);
185
- set({ count: countOf(), hint: state.hint?.path === path ? null : state.hint });
195
+ annots.delete(path);
196
+ set({
197
+ count: countOf(),
198
+ annotations: annotsOf(),
199
+ hint: state.hint?.path === path ? null : state.hint,
200
+ });
186
201
  },
187
202
  };
188
203
  }
@@ -234,7 +249,7 @@ export function useClaudeState(enabled) {
234
249
 
235
250
  /**
236
251
  * The lane for the active canvas, bound to the window. One lane per shell; the returned snapshot is
237
- * `{ count, hint }`.
252
+ * `{ count, annotations, hint }`.
238
253
  */
239
254
  export function useEmptyLane({ activePath, iframesRef, canvasOrigin }) {
240
255
  const live = useRef({});
@@ -216,6 +216,7 @@ export function ShellPreviewChrome() {
216
216
  onUndo={() => menuRunner.run('edit.undo')}
217
217
  onRedo={() => menuRunner.run('edit.redo')}
218
218
  onFit={() => menuRunner.run('view.zoom-fit')}
219
+ onReportBug={() => menuRunner.run('help.report-bug')}
219
220
  />
220
221
  ) : null;
221
222
  if (!canvasOpen) return null;
@@ -7,7 +7,8 @@
7
7
  //
8
8
  // Undo and Redo run the same verbs as ⌘Z / ⇧⌘Z (`edit.undo` / `edit.redo` through the menu runner), so
9
9
  // the stack that takes back an AI edit, a timeline cut and a move is the one these buttons use. The
10
- // percentage is a button: it fits the canvas (⌘0), which is what a person asks of the number.
10
+ // percentage is a button: it fits the canvas (⌘0), which is what a person asks of the number. Last, behind
11
+ // a hairline, Report a bug (#228) — Help › Report a bug… (`help.report-bug`) from where the person already is.
11
12
 
12
13
  import { modeCell } from '../../../bridge/mode-shows.ts';
13
14
  import { StIcon } from '../../shell/icons.jsx';
@@ -29,7 +30,7 @@ export function zoomPctLabel(zoom, fit) {
29
30
  return fit ? `Zoom to fit · ${zoomLabel(zoom)}` : zoomLabel(zoom);
30
31
  }
31
32
 
32
- export function ZoomUndo({ zoom, fit = false, form = 'full', onUndo, onRedo, onFit }) {
33
+ export function ZoomUndo({ zoom, fit = false, form = 'full', onUndo, onRedo, onFit, onReportBug }) {
33
34
  const full = form === 'full';
34
35
  return (
35
36
  <div
@@ -74,6 +75,22 @@ export function ZoomUndo({ zoom, fit = false, form = 'full', onUndo, onRedo, onF
74
75
  >
75
76
  {zoomPctLabel(zoom, fit)}
76
77
  </button>
78
+ {/* #228 — Report a bug, one press away in every form of the island (it was three menus deep, in Help). */}
79
+ {onReportBug ? (
80
+ <>
81
+ <span className="sh-zoomundo-div" aria-hidden="true" />
82
+ <button
83
+ type="button"
84
+ className="icon-btn"
85
+ data-testid="zoom-undo-report-bug"
86
+ aria-label="Report a bug"
87
+ title="Report a bug"
88
+ onClick={onReportBug}
89
+ >
90
+ <StIcon name="bug" size={16} />
91
+ </button>
92
+ </>
93
+ ) : null}
77
94
  </div>
78
95
  );
79
96
  }
@@ -0,0 +1,13 @@
1
+ // apps/studio/comments/reveal.ts — #229: "bring this comment into view".
2
+ //
3
+ // The comments overlay knows the comment (where its pin sits, which artboard it is on); canvas-shell.tsx
4
+ // holds the camera. The overlay asks over a document event so neither imports the other.
5
+
6
+ export const COMMENT_REVEAL_EVENT = 'cm:reveal';
7
+
8
+ export interface CommentRevealDetail {
9
+ /** The artboard the comment is on, when known (Pages turns to its page first). */
10
+ artboard: string | null;
11
+ /** Where the comment sits NOW, client px — measured by the camera's owner after any page turn. */
12
+ locate: () => { x: number; y: number; w: number; h: number } | null;
13
+ }
@@ -78,6 +78,7 @@ import {
78
78
  import { handleOfName } from './comments/mentions.ts';
79
79
  import { mineIdsOf, restampMine, viewerFor } from './comments/mine-stamp.ts';
80
80
  import { committerRows, type MentionRow } from './comments/people.ts';
81
+ import { COMMENT_REVEAL_EVENT, type CommentRevealDetail } from './comments/reveal.ts';
81
82
  import { mmAtArtboardPx, trimOfPrint, videoPinVisible, whereOf } from './comments/where.ts';
82
83
  import { resolveByDomPath } from './dom-selection.ts';
83
84
  import { frameCaf, frameRaf } from './frame-clock.ts';
@@ -698,9 +699,24 @@ export function CommentsOverlay(): React.ReactNode {
698
699
  // Keep the latest comments list reachable from the message handler without
699
700
  // re-attaching the listener on every comments mutation.
700
701
  const commentsRef = useRef<OverlayComment[]>(comments);
702
+ // #229 — the thread the shell asked to see, until its comment is known and its place has been asked for
703
+ const revealWantRef = useRef<string | null>(null);
704
+ const revealWanted = useCallback(() => {
705
+ const id = revealWantRef.current;
706
+ if (!id || typeof document === 'undefined') return;
707
+ const c = commentsRef.current.find((x) => x.id === id);
708
+ if (!c) return;
709
+ revealWantRef.current = null;
710
+ // next frame: the pin and the selection this focus made are laid out by then
711
+ frameRaf(() => requestCommentReveal(c));
712
+ }, []);
701
713
  /** the comment / reply ids the shell's last `comments-set` marked as the viewer's */
702
714
  const mineIdsRef = useRef<ReadonlySet<string>>(new Set());
703
715
  commentsRef.current = comments;
716
+ // biome-ignore lint/correctness/useExhaustiveDependencies: `comments` arriving is the trigger
717
+ useEffect(() => {
718
+ revealWanted();
719
+ }, [comments, revealWanted]);
704
720
 
705
721
  // Phase 8 Task 3 — when a collab room is connected, the Y.Array of comments
706
722
  // is the live source of truth. observe() fires on every remote mutation
@@ -762,6 +778,10 @@ export function CommentsOverlay(): React.ReactNode {
762
778
  else setReplyFocus(0);
763
779
  const target = id ? commentsRef.current.find((c) => c.id === id) : undefined;
764
780
  mirrorSelection(target);
781
+ // #229 — and bring its place into view (a newly opened tab has no comments yet: asked again
782
+ // when they arrive, below)
783
+ revealWantRef.current = id;
784
+ revealWanted();
765
785
  }
766
786
  };
767
787
  window.addEventListener('message', onMessage);
@@ -1450,6 +1470,22 @@ export function locateComment(comment: OverlayComment): {
1450
1470
  return { pos, missing: anchored };
1451
1471
  }
1452
1472
 
1473
+ /** #229 — the overlay asks the canvas (canvas-shell.tsx, which holds the camera) to bring a comment into view. */
1474
+ /** The artboard a comment is on: its v2 anchor, else the `data-dc-screen` in its element selector. */
1475
+ export function commentArtboard(c: OverlayComment): string | null {
1476
+ const own = c.artboard;
1477
+ if (typeof own === 'string' && own) return own;
1478
+ return c.selector?.match(/data-dc-screen="([^"]+)"/)?.[1] ?? null;
1479
+ }
1480
+ export function requestCommentReveal(comment: OverlayComment): void {
1481
+ if (typeof document === 'undefined') return;
1482
+ const detail: CommentRevealDetail = {
1483
+ artboard: commentArtboard(comment),
1484
+ locate: () => locateComment(comment).pos,
1485
+ };
1486
+ document.dispatchEvent(new CustomEvent(COMMENT_REVEAL_EVENT, { detail }));
1487
+ }
1488
+
1453
1489
  /** The one letter a pin wears: the author's initial — the letter the Comments list's avatar wears too. */
1454
1490
  export function pinInitial(author: string): string {
1455
1491
  return authorFace(author).letter;