@1agh/maude 2.1.1 → 2.2.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 (71) hide show
  1. package/apps/studio/actions/agents.ts +18 -42
  2. package/apps/studio/actions/verbs.ts +49 -0
  3. package/apps/studio/actions.manifest.json +103 -19
  4. package/apps/studio/ai/create-claim.ts +1 -1
  5. package/apps/studio/bin/_asset-file.mjs +117 -0
  6. package/apps/studio/bin/_canvas-file.mjs +146 -0
  7. package/apps/studio/bin/_footage.mjs +123 -0
  8. package/apps/studio/bin/_pdf-playwright.mjs +14 -0
  9. package/apps/studio/bin/_png-playwright.mjs +15 -1
  10. package/apps/studio/bin/_pw-launch.mjs +98 -0
  11. package/apps/studio/bin/_retry-save.mjs +49 -0
  12. package/apps/studio/bin/_sync.mjs +145 -2
  13. package/apps/studio/bin/asset-rename.sh +12 -0
  14. package/apps/studio/bin/asset-trash.sh +12 -0
  15. package/apps/studio/bin/canvas-move.sh +12 -0
  16. package/apps/studio/bin/canvas-new.sh +12 -0
  17. package/apps/studio/bin/footage.sh +12 -0
  18. package/apps/studio/bin/generate.sh +7 -0
  19. package/apps/studio/bin/retry-save.sh +13 -0
  20. package/apps/studio/bridge/canvas-mode-store.ts +11 -2
  21. package/apps/studio/bridge/dgn-protocol.ts +8 -3
  22. package/apps/studio/bridge/occlusion.ts +45 -0
  23. package/apps/studio/canvas-theme-pill.tsx +182 -38
  24. package/apps/studio/client/export-center.jsx +32 -3
  25. package/apps/studio/client/home/HomeAccountBanner.jsx +61 -0
  26. package/apps/studio/client/home/HomeAccountsChip.jsx +404 -0
  27. package/apps/studio/client/home/HomeConnection.jsx +4 -3
  28. package/apps/studio/client/home/ProjectRows.jsx +514 -0
  29. package/apps/studio/client/home/home-accounts-model.js +148 -99
  30. package/apps/studio/client/home/home-api.js +4 -0
  31. package/apps/studio/client/home/home-app.jsx +127 -432
  32. package/apps/studio/client/home/home-icons.jsx +8 -0
  33. package/apps/studio/client/home/home-model.js +109 -0
  34. package/apps/studio/client/home/home.css +447 -111
  35. package/apps/studio/client/home/use-account-fix.js +123 -0
  36. package/apps/studio/client/v2/assets/generate-ask.jsx +3 -1
  37. package/apps/studio/client/v2/export/done-toast.jsx +2 -5
  38. package/apps/studio/client/v2/export/export-sheet.jsx +9 -2
  39. package/apps/studio/client/v2/export/export.css +9 -0
  40. package/apps/studio/client/v2/export/exports-model.js +16 -3
  41. package/apps/studio/client/v2/export/file-rows.jsx +81 -5
  42. package/apps/studio/client/v2/export/native-save.js +33 -0
  43. package/apps/studio/client/v2/export/sections/print-copy.js +3 -0
  44. package/apps/studio/client/v2/export/sections/print.jsx +37 -20
  45. package/apps/studio/client/v2/shell/occlusion-insets.js +37 -9
  46. package/apps/studio/client/v2/shell/use-occluded-insets.js +13 -3
  47. package/apps/studio/collab/room.ts +21 -7
  48. package/apps/studio/dist/client.bundle.js +692 -692
  49. package/apps/studio/dist/comment-mount.js +2 -2
  50. package/apps/studio/dist/styles.css +1 -1
  51. package/apps/studio/exporters/ghostscript.ts +78 -1
  52. package/apps/studio/exporters/pdf-fonts.ts +31 -4
  53. package/apps/studio/generation/jobs.ts +6 -0
  54. package/apps/studio/http.ts +6 -2
  55. package/apps/studio/routes/agent.ts +6 -2
  56. package/apps/studio/routes/project-undo.ts +10 -0
  57. package/apps/studio/server.ts +25 -0
  58. package/apps/studio/shell/cli-yield.ts +48 -11
  59. package/apps/studio/whats-new.json +18 -0
  60. package/cli/commands/design.mjs +74 -16
  61. package/cli/lib/bash-guard.mjs +4 -4
  62. package/cli/lib/confine-read.mjs +2 -0
  63. package/cli/lib/design-help.gen.mjs +15 -2
  64. package/cli/lib/design-hook.mjs +1 -1
  65. package/cli/lib/desktop-locate.mjs +36 -8
  66. package/cli/lib/studio-locate.mjs +8 -2
  67. package/cli/lib/sub-verbs.mjs +13 -1
  68. package/package.json +8 -8
  69. package/plugins/flow/.claude-plugin/config.schema.json +11 -1
  70. package/apps/studio/client/home/HomeAccounts.jsx +0 -262
  71. package/apps/studio/client/home/HomeAccountsRow.jsx +0 -221
@@ -8,6 +8,16 @@
8
8
  // same sentence the toast shows (effect shared → prompt: it re-compares every file with the
9
9
  // cloud copy and sends what is newer here). Nothing is overwritten.
10
10
  //
11
+ // Sync details' own buttons (fix-bulk 2026-11-10 follow-up — they were taught as `curl-local` recipes,
12
+ // which a keyed studio answers 401, sec-loopback-bearer §7; `call` sends the studio's key). Each falls
13
+ // to the `sync` tier entry (prompt), as the recipes did:
14
+ // compare <canvas> GET /_api/project/conflict?file= a held source conflict's two sides
15
+ // keep-mine|use-theirs|keep-both <canvas>
16
+ // POST /_api/project/conflict { file, choice }
17
+ // publish-ai-edit|discard-ai-edit [--run <id>]
18
+ // POST /_api/project/ai-action { choice, runId? }
19
+ // cancel-transfer POST /_api/sync/cancel-assets stops the picture/video transfer
20
+ //
11
21
  // Hub URLs, file names and conflict paths come from a peer or a config: only counts, the word and the
12
22
  // hub's host are printed, inside the untrusted block (`--json` carries `untrusted: true`).
13
23
 
@@ -19,7 +29,10 @@ import {
19
29
  } from '../client/v2/diagnostics/resync-model.js';
20
30
  import {
21
31
  call,
32
+ clean,
33
+ cleanLines,
22
34
  connect,
35
+ DESIGN_REL,
23
36
  field,
24
37
  parseWords,
25
38
  runVerb,
@@ -30,11 +43,23 @@ import {
30
43
 
31
44
  export const USAGE = `usage: maude design sync status [--json] [--root <project>]
32
45
  maude design sync resync [--no-wait] [--json] [--root <project>]
46
+ maude design sync compare <canvas> [--json] [--root <project>]
47
+ maude design sync keep-mine|use-theirs|keep-both <canvas> [--json] [--root <project>]
48
+ maude design sync publish-ai-edit|discard-ai-edit [--run <id>] [--json] [--root <project>]
49
+ maude design sync cancel-transfer [--json] [--root <project>]
33
50
  status Sync in one word (Up to date · Syncing… · Offline · Needs you · Local project), the hub's
34
51
  host, the file counts, and the last resync's result
35
52
  resync compare every file with the cloud copy: what is newer here is sent, what is newer there is
36
53
  fetched, a file changed on both sides becomes a conflict in Sync details. Nothing is
37
54
  overwritten. Waits and prints the result; --no-wait only starts it.
55
+ compare a held source conflict's two versions: this Mac's and the project's (Sync details › Compare)
56
+ keep-mine · use-theirs · keep-both
57
+ answer a held source conflict, as its card does; keep-both keeps this Mac's version as a
58
+ new canvas "<name> this Mac". <canvas> is the canvas path or the slug \`sync status\` names.
59
+ publish-ai-edit · discard-ai-edit
60
+ the answer to an unfinished AI edit held from the project (--run: that run only)
61
+ cancel-transfer
62
+ stops the picture and video transfer that is running (it starts again on the next sync)
38
63
  Exit 0 ok · 1 sync is not running / the studio refused / it stopped early · 2 usage · 3 no studio running.
39
64
  `;
40
65
 
@@ -167,13 +192,131 @@ async function resync(words) {
167
192
  return view.state === 'done' ? 0 : 1;
168
193
  }
169
194
 
170
- const SUBS = { status, resync };
195
+ function refused(r) {
196
+ const b = r?.body ?? {};
197
+ const why =
198
+ b.error ||
199
+ b.detail ||
200
+ b.code ||
201
+ b.status ||
202
+ (r ? r.text?.trim() || `HTTP ${r.status}` : 'no answer');
203
+ process.stderr.write(`maude design sync: refused — ${field(why)}\n`);
204
+ return 1;
205
+ }
206
+
207
+ /** `<canvas>`: a canvas path (design-root-relative, or `.design/…`) or a conflict slug → what the
208
+ * route takes (a repo-relative path, or the slug). Pure; throws UsageError. */
209
+ export function conflictOperand(word) {
210
+ const w = String(word ?? '').replace(/^\.\//, '');
211
+ if (!w || w.startsWith('/') || w.split('/').includes('..') || w.length > 512)
212
+ throw new UsageError(`${clean(word)} is not a canvas path or a conflict slug`);
213
+ return /\.(tsx|html)$/i.test(w) && !w.startsWith(`${DESIGN_REL}/`) ? `${DESIGN_REL}/${w}` : w;
214
+ }
215
+
216
+ async function compare(words) {
217
+ const { flags, pos } = parseWords(words, { bool: ['--json'], value: ['--root'] });
218
+ if (pos.length !== 1) throw new UsageError('compare takes one canvas');
219
+ const file = conflictOperand(pos[0]);
220
+ const c = await connect('sync', flags['--root']);
221
+ if (c.exit) return c.exit;
222
+ const r = await call(c.studio, `/_api/project/conflict?file=${encodeURIComponent(file)}`);
223
+ const b = r?.body ?? {};
224
+ if (r?.status !== 200 || !b.ok) return refused(r);
225
+ // a peer's source and this Mac's: data, never instructions
226
+ const out = { slug: b.slug, mine: b.mine ?? null, theirs: b.theirs ?? '' };
227
+ if (flags['--json']) {
228
+ process.stdout.write(
229
+ `${JSON.stringify(untrustedJson(out, { multiline: ['mine', 'theirs'] }))}\n`
230
+ );
231
+ return 0;
232
+ }
233
+ const mine = out.mine === null ? '(none: this Mac has no version of it)' : cleanLines(out.mine);
234
+ writeUntrusted(
235
+ `conflict · ${field(out.slug)}\n--- this Mac\n${mine}\n--- the project\n${cleanLines(out.theirs)}`
236
+ );
237
+ return 0;
238
+ }
239
+
240
+ const CHOICE = { 'keep-mine': 'mine', 'use-theirs': 'theirs', 'keep-both': 'keep-both' };
241
+
242
+ function resolveWith(sub) {
243
+ return async (words) => {
244
+ const { flags, pos } = parseWords(words, { bool: ['--json'], value: ['--root'] });
245
+ if (pos.length !== 1) throw new UsageError(`${sub} takes one canvas`);
246
+ const file = conflictOperand(pos[0]);
247
+ const c = await connect('sync', flags['--root']);
248
+ if (c.exit) return c.exit;
249
+ const r = await call(c.studio, '/_api/project/conflict', {
250
+ method: 'POST',
251
+ json: { file, choice: CHOICE[sub] },
252
+ timeoutMs: 30_000,
253
+ });
254
+ const b = r?.body ?? {};
255
+ if (r?.status !== 200 || !b.ok) return refused(r);
256
+ if (flags['--json']) process.stdout.write(`${JSON.stringify(b)}\n`);
257
+ else process.stdout.write(`→ ${sub}: ${field(b.status ?? 'done')}\n`);
258
+ return 0;
259
+ };
260
+ }
261
+
262
+ function aiEdit(choice) {
263
+ return async (words) => {
264
+ const { flags, pos } = parseWords(words, { bool: ['--json'], value: ['--run', '--root'] });
265
+ if (pos.length) throw new UsageError(`${choice}-ai-edit takes no operand`);
266
+ const body = { choice };
267
+ if (flags['--run'] !== undefined) {
268
+ if (!/^[A-Za-z0-9_-]{1,64}$/.test(flags['--run'])) throw new UsageError('--run is a run id');
269
+ body.runId = flags['--run'];
270
+ }
271
+ const c = await connect('sync', flags['--root']);
272
+ if (c.exit) return c.exit;
273
+ const r = await call(c.studio, '/_api/project/ai-action', {
274
+ method: 'POST',
275
+ json: body,
276
+ timeoutMs: 30_000,
277
+ });
278
+ const b = r?.body ?? {};
279
+ if (r?.status !== 200 || !b.ok) return refused(r);
280
+ if (flags['--json']) process.stdout.write(`${JSON.stringify(b)}\n`);
281
+ else
282
+ process.stdout.write(`→ ${choice === 'publish' ? 'published' : 'discarded'} the AI edit\n`);
283
+ return 0;
284
+ };
285
+ }
286
+
287
+ async function cancelTransfer(words) {
288
+ const { flags, pos } = parseWords(words, { bool: ['--json'], value: ['--root'] });
289
+ if (pos.length) throw new UsageError('cancel-transfer takes no operand');
290
+ const c = await connect('sync', flags['--root']);
291
+ if (c.exit) return c.exit;
292
+ const r = await call(c.studio, '/_api/sync/cancel-assets', { method: 'POST' });
293
+ const b = r?.body ?? {};
294
+ if (r?.status !== 200 || !b.ok) return refused(r);
295
+ if (flags['--json']) process.stdout.write(`${JSON.stringify({ cancelled: !!b.cancelled })}\n`);
296
+ else
297
+ process.stdout.write(b.cancelled ? '→ the transfer stopped\n' : '→ no transfer was running\n');
298
+ return 0;
299
+ }
300
+
301
+ const SUBS = {
302
+ status,
303
+ resync,
304
+ compare,
305
+ 'keep-mine': resolveWith('keep-mine'),
306
+ 'use-theirs': resolveWith('use-theirs'),
307
+ 'keep-both': resolveWith('keep-both'),
308
+ 'publish-ai-edit': aiEdit('publish'),
309
+ 'discard-ai-edit': aiEdit('discard'),
310
+ 'cancel-transfer': cancelTransfer,
311
+ };
171
312
 
172
313
  if (import.meta.main) {
173
314
  runVerb('sync', USAGE, async (words) => {
174
315
  const sub = words[0];
175
316
  if (!sub || !Object.hasOwn(SUBS, sub))
176
- throw new UsageError(sub ? `unknown sub-verb ${sub}` : 'name a sub-verb: status or resync');
317
+ throw new UsageError(
318
+ sub ? `unknown sub-verb ${clean(sub)}` : `name a sub-verb: ${Object.keys(SUBS).join(', ')}`
319
+ );
177
320
  return SUBS[sub](words.slice(1));
178
321
  });
179
322
  }
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+ # asset-rename.sh — `maude design asset-rename` (fix-bulk 2026-11-10 follow-up). Reached via `maude design
3
+ # asset-rename` (DDR-062), never a raw bin path. The Assets panel's Rename… (POST /_api/assets/rename),
4
+ # sent with the studio's key — see _asset-file.mjs. Exit 0 ok · 1 refused · 2 usage · 3 no studio.
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+
7
+ if ! command -v bun >/dev/null 2>&1; then
8
+ echo "asset-rename.sh: bun is required (hard dependency — see plugins/design/dependencies.json)." >&2
9
+ exit 1
10
+ fi
11
+
12
+ exec bun run "$SCRIPT_DIR/_asset-file.mjs" rename "$@"
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+ # asset-trash.sh — `maude design asset-trash` (fix-bulk 2026-11-10 follow-up). Reached via `maude design
3
+ # asset-trash` (DDR-062), never a raw bin path. The Assets panel's Move to trash (POST /_api/assets/trash),
4
+ # sent with the studio's key — see _asset-file.mjs. Exit 0 ok · 1 refused · 2 usage · 3 no studio.
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+
7
+ if ! command -v bun >/dev/null 2>&1; then
8
+ echo "asset-trash.sh: bun is required (hard dependency — see plugins/design/dependencies.json)." >&2
9
+ exit 1
10
+ fi
11
+
12
+ exec bun run "$SCRIPT_DIR/_asset-file.mjs" trash "$@"
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+ # canvas-move.sh — `maude design canvas-move` (fix-bulk W1 follow-up). Reached via `maude design
3
+ # canvas-move` (DDR-062), never a raw bin path. The studio's own rename / move (POST /_api/fs-move),
4
+ # sent with the studio's key — see _canvas-file.mjs. Exit 0 ok · 1 refused · 2 usage · 3 no studio.
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+
7
+ if ! command -v bun >/dev/null 2>&1; then
8
+ echo "canvas-move.sh: bun is required (hard dependency — see plugins/design/dependencies.json)." >&2
9
+ exit 1
10
+ fi
11
+
12
+ exec bun run "$SCRIPT_DIR/_canvas-file.mjs" move "$@"
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+ # canvas-new.sh — `maude design canvas-new` (fix-bulk W1 follow-up). Reached via `maude design
3
+ # canvas-new` (DDR-062), never a raw bin path. The studio's own create (POST /_api/canvas), sent with
4
+ # the studio's key — see _canvas-file.mjs. Exit 0 ok · 1 refused · 2 usage · 3 no studio running.
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+
7
+ if ! command -v bun >/dev/null 2>&1; then
8
+ echo "canvas-new.sh: bun is required (hard dependency — see plugins/design/dependencies.json)." >&2
9
+ exit 1
10
+ fi
11
+
12
+ exec bun run "$SCRIPT_DIR/_canvas-file.mjs" new "$@"
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env bash
2
+ # footage.sh — `maude design footage show|save` (fix-bulk 2026-11-10 follow-up). Reached via `maude design
3
+ # footage` (DDR-062), never a raw bin path. A clip's footage analysis or a cut's EDL (GET / PUT
4
+ # /_api/footage), sent with the studio's key — see _footage.mjs. Exit 0 ok · 1 refused · 2 usage · 3 no studio.
5
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
6
+
7
+ if ! command -v bun >/dev/null 2>&1; then
8
+ echo "footage.sh: bun is required (hard dependency — see plugins/design/dependencies.json)." >&2
9
+ exit 1
10
+ fi
11
+
12
+ exec bun run "$SCRIPT_DIR/_footage.mjs" "$@"
@@ -178,6 +178,13 @@ JOB_ID=$(printf '%s' "$RESP" | jq -r '.jobId // empty' 2>/dev/null || echo "")
178
178
  if [ -z "$JOB_ID" ]; then
179
179
  REASON=$(printf '%s' "$RESP" | jq -r '.reason // empty' 2>/dev/null || echo "")
180
180
  MSG=$(printf '%s' "$RESP" | jq -r '.message // empty' 2>/dev/null || echo "")
181
+ # #218 — the studio refused THIS helper (its own local access key was missing or wrong), before
182
+ # any provider was asked. Never word it as a provider key: the person's Gemini key was never read.
183
+ case "$(printf '%s' "$RESP" | jq -r '.error // empty' 2>/dev/null || echo "")" in
184
+ api-key-required|api-key-invalid)
185
+ echo "generate.sh: Maude's project server refused this command: it could not prove it runs on this Mac for this project. This is not your provider key — that was never read. Run the command again as it is, in a fresh shell; if HOME was changed in this shell, unset that change first." >&2
186
+ exit 1 ;;
187
+ esac
181
188
  case "$REASON" in
182
189
  needs-confirm)
183
190
  echo "generate.sh: $MSG" >&2
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env bash
2
+ # retry-save.sh — `maude design retry-save` (fix-bulk 2026-11-10 follow-up). Reached via `maude design
3
+ # retry-save` (DDR-062), never a raw bin path. Retry on the saves a full disk held (POST
4
+ # /_api/diagnostics/disk-retry), sent with the studio's key — see _retry-save.mjs.
5
+ # Exit 0 every held save landed · 1 some still held / refused · 2 usage · 3 no studio.
6
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7
+
8
+ if ! command -v bun >/dev/null 2>&1; then
9
+ echo "retry-save.sh: bun is required (hard dependency — see plugins/design/dependencies.json)." >&2
10
+ exit 1
11
+ fi
12
+
13
+ exec bun run "$SCRIPT_DIR/_retry-save.mjs" "$@"
@@ -31,12 +31,15 @@ import {
31
31
  type ToolId,
32
32
  } from './canvas-modes.ts';
33
33
  import { acceptFromShell } from './dgn-protocol.ts';
34
- import { type Insets, ZERO_INSETS } from './occlusion.ts';
34
+ import { type Insets, type TopBand, ZERO_INSETS } from './occlusion.ts';
35
35
 
36
36
  export interface CanvasModeSnapshot {
37
37
  readonly insets: Readonly<Insets>;
38
38
  /** The `seq` of the applied `occluded-insets` (-1 = none yet). */
39
39
  readonly insetsSeq: number;
40
+ /** #217 — the free top band between the shell's top islands (iframe px), with the insets; null when the
41
+ * shell sent none (an older shell, Present, no room) — the top-centre pill then centres on the frame. */
42
+ readonly topBand: Readonly<TopBand> | null;
40
43
  /** Governed (V2-4.3b): the shell's mode; null until the first applied `set-mode`. */
41
44
  readonly mode: CanvasModeV2 | null;
42
45
  readonly present: PresentSpec | null;
@@ -86,6 +89,7 @@ export function canvasModeStore(win: Window): CanvasModeStore {
86
89
  let snap: CanvasModeSnapshot = {
87
90
  insets: ZERO_INSETS,
88
91
  insetsSeq: -1,
92
+ topBand: null,
89
93
  mode: null,
90
94
  present: null,
91
95
  caps: null,
@@ -176,7 +180,12 @@ export function canvasModeStore(win: Window): CanvasModeStore {
176
180
  }
177
181
  if (m?.dgn !== 'occluded-insets') return;
178
182
  if (m.seq <= snap.insetsSeq) return; // I4 — an older (or repeated) seq is dropped
179
- snap = { ...snap, insets: Object.freeze({ ...m.insets }), insetsSeq: m.seq };
183
+ snap = {
184
+ ...snap,
185
+ insets: Object.freeze({ ...m.insets }),
186
+ insetsSeq: m.seq,
187
+ topBand: m.topBand ? Object.freeze({ ...m.topBand }) : null,
188
+ };
180
189
  for (const fn of subs) fn(snap);
181
190
  });
182
191
  Object.defineProperty(store, 'doc', { value: win.document });
@@ -32,7 +32,7 @@ import {
32
32
  TOOL_IDS,
33
33
  type ToolId,
34
34
  } from './canvas-modes.ts';
35
- import { clampInsets, type Insets } from './occlusion.ts';
35
+ import { clampInsets, clampTopBand, type Insets, type TopBand } from './occlusion.ts';
36
36
  import { parsePasteData } from './paste-data.ts';
37
37
  import { stillImageBytes } from './still-webp.ts';
38
38
 
@@ -743,7 +743,9 @@ export interface ShellToCanvas {
743
743
  tool?: ToolId;
744
744
  caps: ModeCaps;
745
745
  };
746
- 'occluded-insets': { seq: number; insets: Insets };
746
+ // #217 — `topBand`: the free stretch of the top edge between the top islands (iframe px); the canvas
747
+ // centres its top-centre pill there. Absent from an older shell (the pill centres on the frame).
748
+ 'occluded-insets': { seq: number; insets: Insets; topBand?: TopBand };
747
749
  'present-step': { to: number | 'next' | 'prev' };
748
750
  // S3.7a — the follower page tells its canvas which session to follow (`sid: null` = the first
749
751
  // presenter seen), whether it is live, and whether it is the locked audience window.
@@ -1069,6 +1071,9 @@ const sid: V = (v) => (typeof v === 'string' && PRESENT_SID.test(v) ? v : BAD);
1069
1071
  export const PRESENT_NAME_MAX = 64;
1070
1072
  const presenterName: V = (v) => (typeof v === 'string' && v.length <= PRESENT_NAME_MAX ? v : BAD);
1071
1073
  const insets: V = (v) => clampInsets(v) ?? BAD;
1074
+ /** #217 — an optional cosmetic hint: a bad band is dropped (the pill centres on the frame), never the insets
1075
+ * the camera needs. */
1076
+ const topBand: V = (v) => (v === undefined ? undefined : (clampTopBand(v) ?? undefined));
1072
1077
  /** S10.4 — a designRoot-relative `.css` path; the same rule as the shell's `DS_CSS_REL` (no URL, no `..`). */
1073
1078
  const DS_CSS_REL = /^(?!\/)(?!.*\.\.)[A-Za-z0-9_][A-Za-z0-9 ._/-]{0,255}\.css$/;
1074
1079
  const dsCssPath: V = (v) => (typeof v === 'string' && DS_CSS_REL.test(v) ? v : BAD);
@@ -2685,7 +2690,7 @@ const s2c: S2C = {
2685
2690
  gate: 'parent',
2686
2691
  status: 'new',
2687
2692
  owner: 'bridge/canvas-mode-store',
2688
- parse: p({ seq: num, insets }),
2693
+ parse: p({ seq: num, insets, topBand }),
2689
2694
  },
2690
2695
  // S3.1 — live: the shell lane's `step` sends it; canvas-mode-store keeps it for the Present stage.
2691
2696
  'present-step': {
@@ -106,3 +106,48 @@ export function revealViewBox(host: Box, ins: Insets | null | undefined): Box {
106
106
  bottom: host.top + v.y + v.h,
107
107
  };
108
108
  }
109
+
110
+ /** #217 — the free stretch of the top edge between the top islands, in iframe px from its left edge
111
+ * (`left` = the left island's right edge, `right` = the right cluster's left edge). The canvas centres
112
+ * its top-centre pill (canvas-theme-pill.tsx) in it instead of in the whole frame. */
113
+ export interface TopBand {
114
+ left: number;
115
+ right: number;
116
+ }
117
+
118
+ /** Validate an untrusted top band: both edges finite, 0 ≤ left < right ≤ 8192, rounded; else null. */
119
+ export function clampTopBand(raw: unknown): TopBand | null {
120
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;
121
+ const { left, right } = raw as Record<string, unknown>;
122
+ if (typeof left !== 'number' || typeof right !== 'number') return null;
123
+ if (!Number.isFinite(left) || !Number.isFinite(right)) return null;
124
+ const l = Math.round(left);
125
+ const r = Math.round(right);
126
+ if (l < 0 || r > MAX_INSET_PX || !(l < r)) return null;
127
+ return { left: l, right: r };
128
+ }
129
+
130
+ /** Shell side: the top band the `top` islands leave free on the frame. An island whose centre is left of
131
+ * the frame's centre bounds the band on the left (its right edge), any other on the right (its left
132
+ * edge). Hidden islands, other edges and islands off the frame count for nothing. Null when no room is
133
+ * left. */
134
+ export function topBandFromIslands(
135
+ frame: Box,
136
+ islands: ReadonlyArray<{ rect: Box; edge: IslandEdge }>
137
+ ): TopBand | null {
138
+ if (!(frame.right > frame.left)) return null;
139
+ const mid = (frame.left + frame.right) / 2;
140
+ let lo = frame.left;
141
+ let hi = frame.right;
142
+ for (const { rect: r, edge } of islands) {
143
+ if (edge !== 'top' || !(r.right > r.left && r.bottom > r.top)) continue;
144
+ const ix = Math.min(r.right, frame.right) - Math.max(r.left, frame.left);
145
+ const iy = Math.min(r.bottom, frame.bottom) - Math.max(r.top, frame.top);
146
+ if (ix <= 0 || iy <= 0) continue; // off the frame (docked beside it)
147
+ if ((r.left + r.right) / 2 <= mid) lo = Math.max(lo, r.right);
148
+ else hi = Math.min(hi, r.left);
149
+ }
150
+ const left = Math.ceil(lo - frame.left);
151
+ const right = Math.floor(hi - frame.left);
152
+ return left < right ? { left, right } : null;
153
+ }