@1agh/maude 0.18.2 → 0.19.1

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 (31) hide show
  1. package/cli/bin/maude.mjs +16 -0
  2. package/cli/lib/update-check.mjs +145 -0
  3. package/cli/lib/update-check.test.mjs +32 -0
  4. package/package.json +8 -8
  5. package/plugins/design/dev-server/annotations-context-toolbar.tsx +14 -6
  6. package/plugins/design/dev-server/annotations-layer.tsx +144 -22
  7. package/plugins/design/dev-server/api.ts +72 -19
  8. package/plugins/design/dev-server/artboard-marquee.tsx +170 -0
  9. package/plugins/design/dev-server/canvas-lib-resolver.ts +10 -1
  10. package/plugins/design/dev-server/canvas-lib.tsx +190 -94
  11. package/plugins/design/dev-server/canvas-shell.tsx +478 -34
  12. package/plugins/design/dev-server/client/app.jsx +177 -56
  13. package/plugins/design/dev-server/client/styles/1-tokens.css +15 -8
  14. package/plugins/design/dev-server/client/styles/4-components.css +32 -2
  15. package/plugins/design/dev-server/config.schema.json +31 -5
  16. package/plugins/design/dev-server/context-menu.tsx +3 -3
  17. package/plugins/design/dev-server/context.ts +37 -3
  18. package/plugins/design/dev-server/dist/client.bundle.js +219 -107
  19. package/plugins/design/dev-server/dist/styles.css +38 -2
  20. package/plugins/design/dev-server/export-dialog.tsx +3 -3
  21. package/plugins/design/dev-server/http.ts +14 -2
  22. package/plugins/design/dev-server/input-router.tsx +22 -8
  23. package/plugins/design/dev-server/server.mjs +86 -20
  24. package/plugins/design/dev-server/server.ts +76 -30
  25. package/plugins/design/dev-server/test/context-resolve-tokens.test.ts +97 -0
  26. package/plugins/design/dev-server/test/snap-distance-pill.test.ts +68 -0
  27. package/plugins/design/dev-server/test/system-endpoint.test.ts +144 -0
  28. package/plugins/design/dev-server/tool-palette.tsx +71 -15
  29. package/plugins/design/dev-server/use-annotation-resize.tsx +295 -0
  30. package/plugins/design/dev-server/use-snap-guides.tsx +25 -1
  31. package/plugins/design/dev-server/use-tool-mode.tsx +31 -2
package/cli/bin/maude.mjs CHANGED
@@ -1,7 +1,9 @@
1
1
  #!/usr/bin/env node
2
+ import { readFileSync } from 'node:fs';
2
3
  import { dirname, resolve } from 'node:path';
3
4
  // maude — Maude CLI. Scaffold .ai workspace, run dev servers, manage config.
4
5
  import { fileURLToPath } from 'node:url';
6
+ import { runUpdateCheck } from '../lib/update-check.mjs';
5
7
 
6
8
  const __filename = fileURLToPath(import.meta.url);
7
9
  const __dirname = dirname(__filename);
@@ -16,10 +18,24 @@ const COMMANDS = {
16
18
  version: () => import('../commands/version.mjs'),
17
19
  };
18
20
 
21
+ function readCurrentVersion() {
22
+ try {
23
+ const raw = readFileSync(resolve(PKG_ROOT, 'package.json'), 'utf8');
24
+ return JSON.parse(raw).version || null;
25
+ } catch {
26
+ return null;
27
+ }
28
+ }
29
+
19
30
  async function main(argv) {
20
31
  const args = argv.slice(2);
21
32
  const cmd = args[0];
22
33
 
34
+ // Print "update available" notice (from cached registry data) before
35
+ // dispatch, so it lands on stderr ahead of any subcommand output. Hot
36
+ // path is sync + non-blocking — the stale-cache refresh is detached.
37
+ runUpdateCheck(readCurrentVersion());
38
+
23
39
  if (!cmd || cmd === '--help' || cmd === '-h') {
24
40
  const { run } = await COMMANDS.help();
25
41
  return run({ args: args.slice(1), pkgRoot: PKG_ROOT });
@@ -0,0 +1,145 @@
1
+ // Update-availability notifier for the `maude` CLI.
2
+ //
3
+ // Design (intentional, see PR discussion):
4
+ // • Hot path reads ONLY the local cache. Never blocks on a network fetch.
5
+ // • A detached child process refreshes the cache when stale (>24h). The
6
+ // notice for a freshly published version therefore appears on the run
7
+ // AFTER the cache rolls — same pattern as `update-notifier`.
8
+ // • Opt-out via MAUDE_NO_UPDATE_CHECK=1, NO_UPDATE_NOTIFIER=1, CI=true,
9
+ // or any non-TTY stderr (pipes, CI logs, etc.).
10
+ // • Best-effort everywhere: cache read/write, registry fetch, and spawn
11
+ // all swallow errors. The CLI must never fail because of this module.
12
+
13
+ import { spawn } from 'node:child_process';
14
+ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
15
+ import { homedir } from 'node:os';
16
+ import { dirname, join } from 'node:path';
17
+ import { fileURLToPath } from 'node:url';
18
+
19
+ const PKG_NAME = '@1agh/maude';
20
+ const REGISTRY_URL = `https://registry.npmjs.org/${PKG_NAME}/latest`;
21
+ const CACHE_TTL_MS = 24 * 60 * 60 * 1000;
22
+ const FETCH_TIMEOUT_MS = 3000;
23
+
24
+ function cachePath() {
25
+ const base = process.env.XDG_CACHE_HOME || join(homedir(), '.cache');
26
+ return join(base, 'maude', 'update-check.json');
27
+ }
28
+
29
+ function shouldSkip() {
30
+ if (process.env.MAUDE_NO_UPDATE_CHECK) return true;
31
+ if (process.env.NO_UPDATE_NOTIFIER) return true;
32
+ if (process.env.CI) return true;
33
+ if (!process.stderr.isTTY) return true;
34
+ return false;
35
+ }
36
+
37
+ // Compare semver x.y.z (ignoring prerelease/build metadata). Returns
38
+ // positive if a > b, negative if a < b, 0 if equal.
39
+ export function cmpSemver(a, b) {
40
+ const parse = (v) =>
41
+ String(v)
42
+ .split(/[-+]/)[0]
43
+ .split('.')
44
+ .map((n) => Number(n) || 0);
45
+ const pa = parse(a);
46
+ const pb = parse(b);
47
+ for (let i = 0; i < 3; i += 1) {
48
+ const x = pa[i] || 0;
49
+ const y = pb[i] || 0;
50
+ if (x !== y) return x - y;
51
+ }
52
+ return 0;
53
+ }
54
+
55
+ function readCacheSync() {
56
+ try {
57
+ const raw = readFileSync(cachePath(), 'utf8');
58
+ const parsed = JSON.parse(raw);
59
+ if (typeof parsed?.latest === 'string' && typeof parsed?.checkedAt === 'number') {
60
+ return parsed;
61
+ }
62
+ } catch {
63
+ /* missing or corrupt — treat as no cache */
64
+ }
65
+ return null;
66
+ }
67
+
68
+ function writeCacheSync(data) {
69
+ const path = cachePath();
70
+ try {
71
+ mkdirSync(dirname(path), { recursive: true });
72
+ writeFileSync(path, JSON.stringify(data), 'utf8');
73
+ } catch {
74
+ /* read-only fs / no permission — non-fatal */
75
+ }
76
+ }
77
+
78
+ function printNotice(current, latest) {
79
+ const msg = [
80
+ '',
81
+ ` ⚠ maude update available: ${current} → ${latest}`,
82
+ ` Run: npm i -g ${PKG_NAME}@latest (or pnpm add -g / bun add -g)`,
83
+ '',
84
+ '',
85
+ ].join('\n');
86
+ process.stderr.write(msg);
87
+ }
88
+
89
+ function spawnDetachedRefresh() {
90
+ try {
91
+ const self = fileURLToPath(import.meta.url);
92
+ const child = spawn(process.execPath, [self, '--refresh'], {
93
+ detached: true,
94
+ stdio: 'ignore',
95
+ windowsHide: true,
96
+ env: { ...process.env, MAUDE_UPDATE_CHECK_CHILD: '1' },
97
+ });
98
+ child.unref();
99
+ } catch {
100
+ /* spawn failed — skip the refresh, will retry next run */
101
+ }
102
+ }
103
+
104
+ async function refreshCache() {
105
+ const ac = new AbortController();
106
+ const timer = setTimeout(() => ac.abort(), FETCH_TIMEOUT_MS);
107
+ try {
108
+ const res = await fetch(REGISTRY_URL, {
109
+ headers: { accept: 'application/json' },
110
+ signal: ac.signal,
111
+ });
112
+ if (!res.ok) return;
113
+ const json = await res.json();
114
+ if (typeof json?.version === 'string') {
115
+ writeCacheSync({ latest: json.version, checkedAt: Date.now() });
116
+ }
117
+ } catch {
118
+ /* offline, DNS failure, registry down — ignore */
119
+ } finally {
120
+ clearTimeout(timer);
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Run the update check from the CLI entry. Synchronous-fast: reads cache,
126
+ * prints notice if outdated, kicks off a detached refresh when the cache
127
+ * is stale, returns immediately.
128
+ */
129
+ export function runUpdateCheck(currentVersion) {
130
+ if (shouldSkip()) return;
131
+ if (!currentVersion) return;
132
+
133
+ const cache = readCacheSync();
134
+ if (cache?.latest && cmpSemver(cache.latest, currentVersion) > 0) {
135
+ printNotice(currentVersion, cache.latest);
136
+ }
137
+ const isStale = !cache || Date.now() - cache.checkedAt > CACHE_TTL_MS;
138
+ if (isStale) spawnDetachedRefresh();
139
+ }
140
+
141
+ // Entrypoint when invoked as a detached refresh child:
142
+ // node cli/lib/update-check.mjs --refresh
143
+ if (process.argv[1]?.endsWith('update-check.mjs') && process.argv.includes('--refresh')) {
144
+ refreshCache().catch(() => process.exit(0));
145
+ }
@@ -0,0 +1,32 @@
1
+ import assert from 'node:assert/strict';
2
+ import { test } from 'node:test';
3
+ import { cmpSemver } from './update-check.mjs';
4
+
5
+ test('cmpSemver: equal versions return 0', () => {
6
+ assert.equal(cmpSemver('0.18.2', '0.18.2'), 0);
7
+ assert.equal(cmpSemver('1.0.0', '1.0.0'), 0);
8
+ });
9
+
10
+ test('cmpSemver: newer patch > older', () => {
11
+ assert.ok(cmpSemver('0.18.3', '0.18.2') > 0);
12
+ assert.ok(cmpSemver('0.18.2', '0.18.3') < 0);
13
+ });
14
+
15
+ test('cmpSemver: newer minor > older', () => {
16
+ assert.ok(cmpSemver('0.19.0', '0.18.99') > 0);
17
+ assert.ok(cmpSemver('0.18.99', '0.19.0') < 0);
18
+ });
19
+
20
+ test('cmpSemver: newer major > older', () => {
21
+ assert.ok(cmpSemver('1.0.0', '0.99.99') > 0);
22
+ });
23
+
24
+ test('cmpSemver: prerelease tags stripped (compares core only)', () => {
25
+ assert.equal(cmpSemver('0.18.2-beta.1', '0.18.2'), 0);
26
+ assert.ok(cmpSemver('0.19.0-rc.0', '0.18.2') > 0);
27
+ });
28
+
29
+ test('cmpSemver: missing components default to 0', () => {
30
+ assert.equal(cmpSemver('1', '1.0.0'), 0);
31
+ assert.equal(cmpSemver('1.2', '1.2.0'), 0);
32
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1agh/maude",
3
- "version": "0.18.2",
3
+ "version": "0.19.1",
4
4
  "description": "Marketplace of Claude Code plugins by Michal Dovrtěl: `design` (canvas-first design iteration) + `flow` (generic agentic workflow loop with .ai second brain). Ships the `maude` CLI (with `mdcc` legacy alias) to scaffold workspace, run the design dev server, and manage configs.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -41,13 +41,13 @@
41
41
  "prepublishOnly": "bash scripts/check-version-parity.sh"
42
42
  },
43
43
  "optionalDependencies": {
44
- "@1agh/maude-darwin-arm64": "0.18.2",
45
- "@1agh/maude-darwin-x64": "0.18.2",
46
- "@1agh/maude-linux-arm64": "0.18.2",
47
- "@1agh/maude-linux-arm64-musl": "0.18.2",
48
- "@1agh/maude-linux-x64": "0.18.2",
49
- "@1agh/maude-linux-x64-musl": "0.18.2",
50
- "@1agh/maude-win32-x64": "0.18.2"
44
+ "@1agh/maude-darwin-arm64": "0.19.1",
45
+ "@1agh/maude-darwin-x64": "0.19.1",
46
+ "@1agh/maude-linux-arm64": "0.19.1",
47
+ "@1agh/maude-linux-arm64-musl": "0.19.1",
48
+ "@1agh/maude-linux-x64": "0.19.1",
49
+ "@1agh/maude-linux-x64-musl": "0.19.1",
50
+ "@1agh/maude-win32-x64": "0.19.1"
51
51
  },
52
52
  "files": [
53
53
  "cli",
@@ -36,11 +36,11 @@ const TOOLBAR_CSS = `
36
36
  display: flex;
37
37
  align-items: center;
38
38
  gap: 6px;
39
- background: var(--u-bg-2, var(--bg-1, rgba(255,255,255,0.98)));
39
+ background: var(--u-bg-0, var(--bg-0, rgba(255,255,255,0.98)));
40
40
  border: 1px solid var(--u-fg-0, #1c1917);
41
- border-radius: 0;
41
+ border-radius: 8px;
42
42
  padding: 6px 8px;
43
- box-shadow: 4px 4px 0 var(--u-fg-0, #1c1917);
43
+ box-shadow: 0 6px 24px color-mix(in oklab, var(--u-fg-0, #1c1917) 10%, transparent);
44
44
  font-family: var(--u-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
45
45
  font-size: 12px;
46
46
  color: var(--u-fg-0, var(--fg-0, #1a1a1a));
@@ -147,7 +147,10 @@ export function AnnotationContextToolbar() {
147
147
  return { color: false, fill: false, thickness: false, fontSize: false };
148
148
  }
149
149
  const allFillable = selectedStrokes.every((s) => s.tool === 'rect' || s.tool === 'ellipse');
150
- const allThickness = selectedStrokes.every((s) => s.tool === 'pen' || s.tool === 'arrow');
150
+ // T20 rect + ellipse now carry stroke weight too.
151
+ const allThickness = selectedStrokes.every(
152
+ (s) => s.tool === 'pen' || s.tool === 'arrow' || s.tool === 'rect' || s.tool === 'ellipse'
153
+ );
151
154
  const anyText = selectedStrokes.some((s) => s.tool === 'text');
152
155
  return {
153
156
  color: true,
@@ -226,7 +229,8 @@ export function AnnotationContextToolbar() {
226
229
  (w: number) => {
227
230
  if (!store) return;
228
231
  for (const s of selectedStrokes) {
229
- if (s.tool === 'pen' || s.tool === 'arrow') {
232
+ // T20 rect + ellipse now carry stroke weight.
233
+ if (s.tool === 'pen' || s.tool === 'arrow' || s.tool === 'rect' || s.tool === 'ellipse') {
230
234
  store.updateStroke(s.id, { width: w } as Partial<Stroke>);
231
235
  }
232
236
  }
@@ -263,7 +267,11 @@ export function AnnotationContextToolbar() {
263
267
  : undefined;
264
268
  const uniqThickness = caps.thickness
265
269
  ? uniformValue(
266
- selectedStrokes.map((s) => (s.tool === 'pen' || s.tool === 'arrow' ? s.width : undefined))
270
+ selectedStrokes.map((s) =>
271
+ s.tool === 'pen' || s.tool === 'arrow' || s.tool === 'rect' || s.tool === 'ellipse'
272
+ ? s.width
273
+ : undefined
274
+ )
267
275
  )
268
276
  : undefined;
269
277
  const uniqFontSize = caps.fontSize
@@ -35,6 +35,7 @@ import { createPortal } from 'react-dom';
35
35
 
36
36
  import { AnnotationContextToolbar } from './annotations-context-toolbar.tsx';
37
37
  import { useViewportControllerContext, useWorldRefContext } from './canvas-lib.tsx';
38
+ import { AnnotationResizeOverlay } from './use-annotation-resize.tsx';
38
39
  import { useAnnotationSelectionOptional } from './use-annotation-selection.tsx';
39
40
  import { useAnnotationsVisibility } from './use-annotations-visibility.tsx';
40
41
  import { useSelectionSetOptional } from './use-selection-set.tsx';
@@ -457,15 +458,15 @@ const ANNOT_CSS = `
457
458
  display: flex;
458
459
  align-items: center;
459
460
  gap: 8px;
460
- background: var(--u-bg-2, var(--bg-1, rgba(255,255,255,0.98)));
461
+ background: var(--u-bg-0, var(--bg-0, rgba(255,255,255,0.98)));
461
462
  border: 1px solid var(--u-fg-0, #1c1917);
462
- border-radius: 0;
463
+ border-radius: 8px;
463
464
  padding: 6px 10px;
464
465
  font-family: var(--u-font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
465
466
  font-size: 11px;
466
467
  color: var(--u-fg-0, rgba(40,30,20,0.85));
467
468
  z-index: 6;
468
- box-shadow: 4px 4px 0 var(--u-fg-0, #1c1917);
469
+ box-shadow: 0 6px 24px color-mix(in oklab, var(--u-fg-0, #1c1917) 10%, transparent);
469
470
  user-select: none;
470
471
  }
471
472
  .dc-annot-chrome .dc-annot-swatches { display: flex; gap: 4px; }
@@ -618,7 +619,7 @@ export { useAnnotationsVisibility } from './use-annotations-visibility.tsx';
618
619
 
619
620
  export function AnnotationsLayer() {
620
621
  ensureAnnotStyles();
621
- const { tool } = useToolMode();
622
+ const { tool, setTool, sticky } = useToolMode();
622
623
  const controller = useViewportControllerContext();
623
624
  const vp = controller?.viewport ?? null;
624
625
  const worldRef = useWorldRefContext();
@@ -653,7 +654,11 @@ export function AnnotationsLayer() {
653
654
  const isDraw = tool === 'pen' || tool === 'rect' || tool === 'arrow' || tool === 'ellipse';
654
655
  const isErase = tool === 'eraser';
655
656
  const isActive = isDraw || isErase;
656
- const supportsThickness = tool === 'pen' || tool === 'arrow';
657
+ // T20 rect + ellipse expose stroke weight too (FigJam ships thickness on
658
+ // every shape). The annotation toolbar reads supportsThickness to decide
659
+ // whether to render the Thin / Thick chips.
660
+ const supportsThickness =
661
+ tool === 'pen' || tool === 'arrow' || tool === 'rect' || tool === 'ellipse';
657
662
  const supportsFill = tool === 'rect' || tool === 'ellipse';
658
663
 
659
664
  // Load existing annotations on mount.
@@ -839,7 +844,7 @@ export function AnnotationsLayer() {
839
844
  id,
840
845
  tool: 'rect',
841
846
  color,
842
- width: STROKE_WIDTH_THIN,
847
+ width,
843
848
  x: wx,
844
849
  y: wy,
845
850
  w: 0,
@@ -851,7 +856,7 @@ export function AnnotationsLayer() {
851
856
  id,
852
857
  tool: 'ellipse',
853
858
  color,
854
- width: STROKE_WIDTH_THIN,
859
+ width,
855
860
  cx: wx,
856
861
  cy: wy,
857
862
  rx: 0,
@@ -935,9 +940,38 @@ export function AnnotationsLayer() {
935
940
  scheduleSave(next);
936
941
  return next;
937
942
  });
943
+ // T18 — auto-select the freshly drawn shape so the user can immediately
944
+ // see + adjust it. annotSel is optional (some test harnesses mount
945
+ // AnnotationsLayer without the provider), so guard the call.
946
+ if (annotSel) annotSel.replace(committed.id);
938
947
  }
948
+ // T18 / T19 — flip the tool back to Move after every commit UNLESS sticky
949
+ // mode is locked on this tool. Sticky lets the user draw many shapes in a
950
+ // row (canonical pattern: tldraw double-click to lock). Eraser stays
951
+ // armed by default — that tool is destructive, not constructive.
952
+ const toolJustUsed = cur.tool;
953
+ if (toolJustUsed !== 'eraser') {
954
+ const stickyOnThis = sticky.locked && sticky.tool === toolJustUsed;
955
+ if (!stickyOnThis) setTool('move');
956
+ }
957
+ setDrawing(null);
958
+ }, [isActive, isErase, visible, scheduleSave, annotSel, setTool, sticky]);
959
+
960
+ // T21 — abort a mid-stroke draw without committing. Dispatched by the
961
+ // canvas-shell Esc handler (`maude:cancel-stroke`). Safe to call when
962
+ // nothing is being drawn — the early-return on drawingRef keeps it
963
+ // a no-op.
964
+ const cancelStroke = useCallback(() => {
965
+ if (!drawingRef.current) return;
939
966
  setDrawing(null);
940
- }, [isActive, isErase, visible, scheduleSave]);
967
+ }, []);
968
+
969
+ useEffect(() => {
970
+ if (typeof document === 'undefined') return;
971
+ const onCancel = () => cancelStroke();
972
+ document.addEventListener('maude:cancel-stroke', onCancel);
973
+ return () => document.removeEventListener('maude:cancel-stroke', onCancel);
974
+ }, [cancelStroke]);
941
975
 
942
976
  const renderStrokes = useMemo(
943
977
  () => (drawing ? [...strokes, drawing] : strokes),
@@ -1064,8 +1098,9 @@ export function AnnotationsLayer() {
1064
1098
  return;
1065
1099
  }
1066
1100
 
1067
- // Empty world — start a drag-select gesture. A small movement falls
1068
- // back to a "click on empty world → clear selection" (Figma-style).
1101
+ // Empty world — start a drag-select gesture. A bare click without
1102
+ // moving is a no-op (post-Wave-2 feedback: click-on-empty-space
1103
+ // does NOT clear selection; Esc is the canonical deselect).
1069
1104
  const addToSelection = e.shiftKey;
1070
1105
  let moved = false;
1071
1106
  const onMove = (mv: PointerEvent) => {
@@ -1080,8 +1115,8 @@ export function AnnotationsLayer() {
1080
1115
  document.removeEventListener('pointerup', onUp, true);
1081
1116
  document.removeEventListener('pointercancel', onUp, true);
1082
1117
  if (!moved) {
1083
- // True click on empty world → clear (unless modifier add-mode).
1084
- if (!addToSelection && annotSel.selectedIds.length > 0) annotSel.clear();
1118
+ // Click without movement on empty world → no-op. Selection
1119
+ // survives accidental misses; Esc is how the user deselects.
1085
1120
  return;
1086
1121
  }
1087
1122
  const final = marqueeRef.current;
@@ -1100,13 +1135,10 @@ export function AnnotationsLayer() {
1100
1135
  hits.push(s.id);
1101
1136
  }
1102
1137
  }
1103
- if (addToSelection) {
1104
- annotSel.add(hits);
1105
- } else if (hits.length === 0) {
1106
- annotSel.clear();
1107
- } else {
1108
- annotSel.replace(hits);
1109
- }
1138
+ // Marquee that captured no strokes — preserve existing selection.
1139
+ if (hits.length === 0) return;
1140
+ if (addToSelection) annotSel.add(hits);
1141
+ else annotSel.replace(hits);
1110
1142
  };
1111
1143
  document.addEventListener('pointermove', onMove, true);
1112
1144
  document.addEventListener('pointerup', onUp, true);
@@ -1257,6 +1289,7 @@ export function AnnotationsLayer() {
1257
1289
  />
1258
1290
  ) : null}
1259
1291
  <AnnotationContextToolbar />
1292
+ {visible && tool === 'move' ? <AnnotationResizeOverlay store={strokesStore} /> : null}
1260
1293
  {isActive ? (
1261
1294
  <AnnotationsChrome
1262
1295
  color={color}
@@ -1382,8 +1415,14 @@ function AnnotationsSvg({
1382
1415
  <StrokeNode key={s.id} stroke={s} anchorsById={anchorsById} interactive={selectMode} />
1383
1416
  ))}
1384
1417
  {selectedStrokes.map((s) => (
1385
- <SelectionHalo key={`halo-${s.id}`} stroke={s} anchorsById={anchorsById} />
1418
+ <SelectionHalo
1419
+ key={`halo-${s.id}`}
1420
+ stroke={s}
1421
+ anchorsById={anchorsById}
1422
+ multi={selectedStrokes.length > 1}
1423
+ />
1386
1424
  ))}
1425
+ <AnnotGroupBbox selectedStrokes={selectedStrokes} anchorsById={anchorsById} />
1387
1426
  {marquee ? (
1388
1427
  <rect
1389
1428
  className="dc-annot-marquee"
@@ -1507,12 +1546,26 @@ function TextEditor({
1507
1546
  function SelectionHalo({
1508
1547
  stroke,
1509
1548
  anchorsById,
1549
+ multi,
1510
1550
  }: {
1511
1551
  stroke: Stroke;
1512
1552
  anchorsById: Map<string, RectStroke | EllipseStroke>;
1553
+ multi: boolean;
1513
1554
  }) {
1514
1555
  const bbox = strokeBBox(stroke, anchorsById);
1515
1556
  if (!bbox) return null;
1557
+ // T17 + post-Wave-2 fix — annotation halo idioms:
1558
+ // * Single select → 2 px solid border, NO ring, NO corner ticks.
1559
+ // The resize overlay (T23) renders the corner handles in screen-space,
1560
+ // so painting SVG ticks here too would duplicate them. The element
1561
+ // halo uses CSS box-shadow for the 18% ring; the SVG equivalent (a
1562
+ // second outline rect) reads as "double frame" rather than a halo —
1563
+ // user feedback flagged this immediately. Solid 2 px is enough signal
1564
+ // once the resize handles claim the corners.
1565
+ // * Multi member → 1.5 px solid full accent, no ring, no ticks (group
1566
+ // bbox above carries the container affordance).
1567
+ // Marquee STAYS dashed (drawn elsewhere) — dashed is reserved for the
1568
+ // ambient group-container + active-gesture idioms per DDR-046 rev 2.
1516
1569
  const pad = 4;
1517
1570
  return (
1518
1571
  <rect
@@ -1522,8 +1575,7 @@ function SelectionHalo({
1522
1575
  height={bbox.h + pad * 2}
1523
1576
  fill="none"
1524
1577
  stroke="var(--accent, #d63b1f)"
1525
- strokeWidth={1.5}
1526
- strokeDasharray="4 3"
1578
+ strokeWidth={multi ? 1.5 : 2}
1527
1579
  vectorEffect="non-scaling-stroke"
1528
1580
  pointerEvents="none"
1529
1581
  rx={2}
@@ -1531,6 +1583,76 @@ function SelectionHalo({
1531
1583
  );
1532
1584
  }
1533
1585
 
1586
+ // T17 — group bbox dashed rect for multi-stroke annotation selection. Mirrors
1587
+ // the element-side GroupBbox idiom (1 px dashed accent + 6 × 6 corner handles).
1588
+ function AnnotGroupBbox({
1589
+ selectedStrokes,
1590
+ anchorsById,
1591
+ }: {
1592
+ selectedStrokes: readonly Stroke[];
1593
+ anchorsById: Map<string, RectStroke | EllipseStroke>;
1594
+ }) {
1595
+ if (selectedStrokes.length < 2) return null;
1596
+ let xMin = Number.POSITIVE_INFINITY;
1597
+ let yMin = Number.POSITIVE_INFINITY;
1598
+ let xMax = Number.NEGATIVE_INFINITY;
1599
+ let yMax = Number.NEGATIVE_INFINITY;
1600
+ let any = false;
1601
+ for (const s of selectedStrokes) {
1602
+ const b = strokeBBox(s, anchorsById);
1603
+ if (!b) continue;
1604
+ any = true;
1605
+ if (b.x < xMin) xMin = b.x;
1606
+ if (b.y < yMin) yMin = b.y;
1607
+ if (b.x + b.w > xMax) xMax = b.x + b.w;
1608
+ if (b.y + b.h > yMax) yMax = b.y + b.h;
1609
+ }
1610
+ if (!any) return null;
1611
+ const pad = 6;
1612
+ const x = xMin - pad;
1613
+ const y = yMin - pad;
1614
+ const w = xMax - xMin + pad * 2;
1615
+ const h = yMax - yMin + pad * 2;
1616
+ const handle = 6;
1617
+ const inset = 3;
1618
+ const handles = [
1619
+ { corner: 'nw', x: x - inset, y: y - inset },
1620
+ { corner: 'ne', x: x + w - handle + inset, y: y - inset },
1621
+ { corner: 'sw', x: x - inset, y: y + h - handle + inset },
1622
+ { corner: 'se', x: x + w - handle + inset, y: y + h - handle + inset },
1623
+ ];
1624
+ return (
1625
+ <g pointerEvents="none">
1626
+ <rect
1627
+ x={x}
1628
+ y={y}
1629
+ width={w}
1630
+ height={h}
1631
+ fill="none"
1632
+ stroke="var(--accent, #d63b1f)"
1633
+ strokeWidth={1}
1634
+ strokeDasharray="4 3"
1635
+ vectorEffect="non-scaling-stroke"
1636
+ rx={2}
1637
+ />
1638
+ {handles.map((c) => (
1639
+ <rect
1640
+ key={c.corner}
1641
+ x={c.x}
1642
+ y={c.y}
1643
+ width={handle}
1644
+ height={handle}
1645
+ fill="var(--accent, #d63b1f)"
1646
+ stroke="var(--bg-0, #ffffff)"
1647
+ strokeWidth={1}
1648
+ vectorEffect="non-scaling-stroke"
1649
+ rx={1}
1650
+ />
1651
+ ))}
1652
+ </g>
1653
+ );
1654
+ }
1655
+
1534
1656
  // ─────────────────────────────────────────────────────────────────────────────
1535
1657
  // Stroke renderer
1536
1658