@marver-design/marver 0.26.0 → 0.27.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 (96) hide show
  1. package/CHANGELOG.md +158 -0
  2. package/README.md +10 -5
  3. package/dist/{anchor-check-Dg5xpNnU.mjs → anchor-check-ChdDqL5z.mjs} +1 -1
  4. package/dist/{audio-CmSRYFEs.mjs → audio-Dw1lfMdb.mjs} +14 -0
  5. package/dist/{bake-DtVlm0_F.mjs → bake-DM_uWgAA.mjs} +1 -1
  6. package/dist/{boards-DYG22tOe.mjs → boards-DlTcpF47.mjs} +1 -1
  7. package/dist/{build-C_gUgcdC.mjs → build-DZnFysGU.mjs} +4 -4
  8. package/dist/{capture-CrqvU_jh.mjs → capture-vadKjuCo.mjs} +2 -1
  9. package/dist/cli.mjs +28 -16
  10. package/dist/{comments-BqXua-XL.mjs → comments-DxOkCSNE.mjs} +4 -4
  11. package/dist/{daemon-DZo6o3rU.mjs → daemon-BSA0lV8d.mjs} +400 -274
  12. package/dist/detect-C0wpaePX.mjs +125 -0
  13. package/dist/dev-eQJhWsqg.mjs +1273 -0
  14. package/dist/dev-lock-C_FC70Mu.mjs +65 -0
  15. package/dist/exclusive-B1RtpeeP.mjs +150 -0
  16. package/dist/{init-D8DtrK_F.mjs → init-COD0x48i.mjs} +5 -3
  17. package/dist/{link-BNzLvdhI.mjs → link-DDXZVGtv.mjs} +20 -8
  18. package/dist/ls-D7O1G505.mjs +38 -0
  19. package/dist/{marks-NQi0wZJ4.mjs → marks-CWM3WJjc.mjs} +1 -1
  20. package/dist/perf-BWzQwZqj.mjs +369 -0
  21. package/dist/perf-BoDSkbEb.mjs +429 -0
  22. package/dist/perf-jam-D55U3FZK.mjs +242 -0
  23. package/dist/{plugin-CTD0rydA.mjs → plugin-C-E7omsh.mjs} +425 -66
  24. package/dist/{poster-ChjXGTS5.mjs → poster-Bx83ZYVK.mjs} +2 -1
  25. package/dist/{profile-WU9qcbIo.mjs → profile-Bh5Y5zpW.mjs} +1 -1
  26. package/dist/{publish-bakes-CEP_2NRc.mjs → publish-bakes-aljgm45S.mjs} +2 -2
  27. package/dist/{queue-BuiCKSX1.mjs → queue-CAM_vNmX.mjs} +3 -3
  28. package/dist/recover-t9Pno3u9.mjs +66 -0
  29. package/dist/{session-qZWKt_VA.mjs → session-BAaJsK5c.mjs} +1 -1
  30. package/dist/{share--oFJ1bCI.mjs → share-W5H3BNvP.mjs} +1 -1
  31. package/dist/shot-DoHLl6ig.mjs +139 -0
  32. package/dist/{shot-DqcxJibP.mjs → shot-LFhC-WYD.mjs} +343 -19
  33. package/dist/slots-DCDo3N0x.mjs +471 -0
  34. package/dist/speech-worker.mjs +40 -5
  35. package/dist/{sync-DKk-yT1V.mjs → sync-BQVlHZpx.mjs} +4 -3
  36. package/dist/{work-F5u-twpJ.mjs → work-Bp1p39kq.mjs} +4 -2
  37. package/dist/{work-VvX_JIgl.mjs → work-BroFwnup.mjs} +4 -2
  38. package/docs/boards-and-folders.md +3 -1
  39. package/docs/jam-session.md +78 -7
  40. package/docs/live-jam.md +8 -0
  41. package/docs/performance.md +262 -0
  42. package/package.json +2 -2
  43. package/src/client/content/index.tsx +3 -0
  44. package/src/client/content/video.tsx +6 -2
  45. package/src/client/frame-host/bridge.js +22 -6
  46. package/src/client/frame-host/inspect.js +8 -3
  47. package/src/client/frame-host/keys.js +6 -2
  48. package/src/client/frame-host/main.tsx +17 -5
  49. package/src/client/shell/App.tsx +188 -29
  50. package/src/client/shell/BoardList.tsx +5 -5
  51. package/src/client/shell/Comments.tsx +3 -2
  52. package/src/client/shell/JamSurface.tsx +13 -5
  53. package/src/client/shell/LockedApp.tsx +5 -5
  54. package/src/client/shell/Play.tsx +27 -15
  55. package/src/client/shell/Toolbar.tsx +17 -5
  56. package/src/client/shell/api.ts +206 -0
  57. package/src/client/shell/canvas/Canvas.tsx +30 -3
  58. package/src/client/shell/canvas/FrameNode.tsx +15 -5
  59. package/src/client/shell/canvas/admission.ts +8 -1
  60. package/src/client/shell/canvas/camera-broadcast.ts +15 -5
  61. package/src/client/shell/canvas/ctl.ts +2 -0
  62. package/src/client/shell/canvas/frame-registry.ts +28 -2
  63. package/src/client/shell/canvas/sleep.ts +4 -1
  64. package/src/client/shell/comments-store.ts +12 -4
  65. package/src/client/shell/goto.ts +22 -10
  66. package/src/client/shell/icons.tsx +2 -0
  67. package/src/client/shell/jam-capture.ts +96 -16
  68. package/src/client/shell/jam-keys.ts +51 -18
  69. package/src/client/shell/jam-lane.tsx +46 -5
  70. package/src/client/shell/jam-panel.tsx +66 -13
  71. package/src/client/shell/jam-queue.ts +3 -3
  72. package/src/client/shell/jam-session.tsx +14 -8
  73. package/src/client/shell/jam-state.ts +48 -6
  74. package/src/client/shell/jam-surface-parts.tsx +10 -6
  75. package/src/client/shell/jam-voice.ts +7 -5
  76. package/src/client/shell/legacy-links.ts +2 -2
  77. package/src/client/shell/main.tsx +4 -0
  78. package/src/client/shell/notes.ts +8 -1
  79. package/src/client/shell/perf.ts +69 -58
  80. package/src/client/shell/recorder-core.ts +183 -0
  81. package/src/client/shell/recorder.ts +565 -0
  82. package/src/client/shell/store.ts +268 -103
  83. package/src/client/shell/styles.css +54 -9
  84. package/src/client/stage/main.tsx +2 -0
  85. package/templates/AGENTS-embedded.md +22 -4
  86. package/templates/AGENTS-studio.md +22 -4
  87. package/templates/demo/dark.tsx +1 -1
  88. package/templates/demo/welcome.tsx +1 -1
  89. package/templates/instructions/jam.md +5 -3
  90. package/templates/instructions/welcome.md +6 -3
  91. package/dist/config-Cf7EjAMf.mjs +0 -292
  92. package/dist/dev-_Nlsc6v9.mjs +0 -742
  93. package/dist/dev-lock-DWSpa6nj.mjs +0 -179
  94. package/dist/perf-D6VmmJ2q.mjs +0 -68
  95. package/dist/perf-DPbLGhhO.mjs +0 -49
  96. package/dist/shot-CNbHoZ6H.mjs +0 -86
@@ -12,7 +12,8 @@
12
12
  import { useEffect, useLayoutEffect, useRef, useState } from 'react'
13
13
  import { JamStateIcon, type JamGlyph } from './jam-ui.tsx'
14
14
  import { Tip } from './Tip.tsx'
15
- import { CursorClickIcon, FileCodeIcon, ImagesSquareIcon, LaserIcon, MicrophoneIcon, MicrophoneSlashIcon, PencilSimpleIcon } from './icons.tsx'
15
+ import { DONE_CLOSE, DONE_GROUP, doneFold, doneLine } from './jam-state.ts'
16
+ import { ArrowsInLineHorizontalIcon, CursorClickIcon, FileCodeIcon, ImagesSquareIcon, LaserIcon, MicrophoneIcon, MicrophoneSlashIcon, PencilSimpleIcon } from './icons.tsx'
16
17
 
17
18
  /** The lane's height with its air: the 44 px tile + 12 px. While the lane shows, the sidebar stops
18
19
  * above it and everything else on the bottom edge (the Update pill, toasts, notices) rises this much. */
@@ -27,6 +28,10 @@ export interface LaneTile {
27
28
  line: string
28
29
  /** an exclusive card wears a file glyph: it changes how the queue runs */
29
30
  exclusive?: boolean
31
+ /** a done tile: the frames it changed (not the ones it left as they were) - the Done group counts each frame once */
32
+ frames?: string[]
33
+ /** a session record's tile (the Done group counts records apart from captures) */
34
+ record?: boolean
30
35
  }
31
36
 
32
37
  export interface LaneRecording {
@@ -87,8 +92,11 @@ export interface LaneBetween {
87
92
  onCapture(): void
88
93
  }
89
94
 
90
- export function Lane({ tiles, recording, between, selected, keyboard, onOpen, onMenu, followEnd }: {
95
+ export function Lane({ tiles, recording, between, selected, keyboard, onOpen, onMenu, followEnd, doneOpen = false, onDoneOpen }: {
91
96
  tiles: LaneTile[]
97
+ /** two or more done tiles fold into one Done tile (0.26.1): shown open, or folded */
98
+ doneOpen?: boolean
99
+ onDoneOpen?(open: boolean, doneIds: string[]): void
92
100
  recording?: LaneRecording
93
101
  /** no capture recording in a session: its own tile, last */
94
102
  between?: LaneBetween
@@ -101,6 +109,19 @@ export function Lane({ tiles, recording, between, selected, keyboard, onOpen, on
101
109
  }) {
102
110
  const ref = useRef<HTMLDivElement>(null)
103
111
  const [fade, setFade] = useState<'' | 'l' | 'r' | 'lr'>('')
112
+ // done tiles: folded into one (two or more), or shown first behind the collapse tile
113
+ const { fold, done, rest } = doneFold(tiles, doneOpen)
114
+ const shown = fold ? (doneOpen ? [...done, ...rest] : rest) : tiles
115
+ const doneFrames = new Set(done.flatMap((t) => t.frames ?? [])).size
116
+ // opening shows the done tiles where they are (the lane's start); folding goes back to the newest end
117
+ const firstOpen = useRef(true)
118
+ useLayoutEffect(() => {
119
+ if (firstOpen.current) { firstOpen.current = false; return }
120
+ const el = ref.current
121
+ // (folding with the group selected: the selection's own scroll shows the group)
122
+ if (el && (doneOpen || selected !== DONE_GROUP)) el.scrollLeft = doneOpen ? 0 : el.scrollWidth
123
+ measure()
124
+ }, [doneOpen])
104
125
  const measure = () => {
105
126
  const el = ref.current
106
127
  if (!el) return
@@ -138,12 +159,32 @@ export function Lane({ tiles, recording, between, selected, keyboard, onOpen, on
138
159
  }, [selected])
139
160
  return (
140
161
  <div className={`jm-lane${keyboard ? ' keyboard' : ''}`} data-jam-lane="">
141
- <div ref={ref} className={`jm-lane-in${fade ? ' ' + fade.split('').map((c) => `fade-${c}`).join(' ') : ''}`}
162
+ {fade.includes('l') && <span className="jm-lane-edge l" aria-hidden="true" />}
163
+ {fade.includes('r') && <span className="jm-lane-edge r" aria-hidden="true" />}
164
+ <div ref={ref} className="jm-lane-in"
142
165
  onScroll={measure}
143
166
  onWheel={(e) => { const el = ref.current; if (el && Math.abs(e.deltaY) > Math.abs(e.deltaX)) el.scrollLeft += e.deltaY }}>
144
- {tiles.map((t) => (
167
+ {fold && !doneOpen && (
168
+ <button key={DONE_GROUP} data-tile={DONE_GROUP} data-state="done" data-jam-done="folded"
169
+ className={`jm-card done group${selected === DONE_GROUP ? ' focus' : ''}`}
170
+ onClick={() => onDoneOpen?.(true, done.map((t) => t.id))}>
171
+ <JamStateIcon state="done" />
172
+ <span className="tx">
173
+ <span className="t">Done</span>
174
+ <span className="m">{doneLine(done, doneFrames)}</span>
175
+ </span>
176
+ </button>
177
+ )}
178
+ {fold && doneOpen && (
179
+ <button key={DONE_CLOSE} data-tile={DONE_CLOSE} data-jam-done="open" aria-label="Fold the done captures"
180
+ className={`jm-card close${selected === DONE_CLOSE ? ' focus' : ''}`}
181
+ onClick={() => onDoneOpen?.(false, done.map((t) => t.id))}>
182
+ <ArrowsInLineHorizontalIcon size={15} /><span className="t">Done</span>
183
+ </button>
184
+ )}
185
+ {shown.map((t) => (
145
186
  <button key={t.id} data-tile={t.id} data-state={t.state}
146
- className={`jm-card ${t.state}${selected === t.id ? ' focus' : ''}`}
187
+ className={`jm-card ${t.state}${selected === t.id ? ' focus' : ''}${fold && t.state === 'done' ? ' unfold' : ''}`}
147
188
  onClick={() => onOpen(t.id)} onContextMenu={onMenu ? (e) => onMenu(e, t.id) : undefined}>
148
189
  <JamStateIcon state={t.state} />
149
190
  <span className="tx">
@@ -6,7 +6,7 @@
6
6
  * Presentational only: every component takes what it shows and calls back what was chosen. The shell
7
7
  * (jam-capture.ts, App) owns state, keys and the API.
8
8
  */
9
- import { useEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react'
9
+ import { useEffect, useLayoutEffect, useRef, useState, type CSSProperties, type ReactNode } from 'react'
10
10
  import { JamStateIcon } from './jam-ui.tsx'
11
11
  import type { TimelineLine } from './jam-lines.ts'
12
12
  import { speechLines } from '../../shared/speech.ts'
@@ -18,6 +18,7 @@ import {
18
18
  import { LANE_H } from './jam-lane.tsx'
19
19
  import { Tip } from './Tip.tsx'
20
20
  import { useJamQueue } from './jam-queue.ts'
21
+ import { holdsReload } from './api.ts'
21
22
 
22
23
  /** A heading cut short by its ellipsis: its tooltip shows it whole (one that fits shows none). */
23
24
  const cutShort = (el: HTMLElement) => el.scrollWidth > el.clientWidth + 1
@@ -35,6 +36,9 @@ export const Marver = ({ size = 20 }: { size?: number }) => (
35
36
  * shell passes it), `width` px wide (520 at least). The panel inside fills it; its middle scrolls and
36
37
  * its footer stays in view. `onClose` adds a quiet close button in its corner. */
37
38
  export function FocusPanel({ children, left, width = 580, onClose }: { children: ReactNode; left: number; width?: number; onClose?: () => void }) {
39
+ // the window's width is the last word: follow it as it changes
40
+ const [, setTick] = useState(0)
41
+ useEffect(() => { const on = () => setTick((n) => n + 1); window.addEventListener('resize', on); return () => window.removeEventListener('resize', on) }, [])
38
42
  // 580: the footer's "For Claude Code" and its four actions on one line; never wider than the window allows
39
43
  // the window is the last word: a narrow one gets a narrower panel, never one past its edge
40
44
  const room = (typeof window !== 'undefined' ? window.innerWidth : 1400) - left - 12
@@ -54,6 +58,8 @@ const moreDrafts = new Map<string, string>()
54
58
  export const clearMoreDraft = (id: string) => { moreDrafts.delete(id) }
55
59
  export const moreDraftOf = (id: string): string => moreDrafts.get(id) ?? ''
56
60
  export const setMoreDraft = (id: string, t: string) => { if (t) moreDrafts.set(id, t); else moreDrafts.delete(id) }
61
+ // spec 28 A1.11: a page whose canvas came back reloads only once no such words wait (a reload would drop them)
62
+ holdsReload(() => moreDrafts.size > 0)
57
63
 
58
64
  const unquote = (s: string) => s.replace(/^"(.*)"$/s, '$1')
59
65
  const DEVICE: Record<string, string> = { phone: 'mobile', mobile: 'mobile', tablet: 'tablet', laptop: 'laptop', desktop: 'monitor', monitor: 'monitor', tv: 'tv' }
@@ -138,12 +144,19 @@ function AddedNotes({ added, onAdd }: { added: { at: number; text: string }[]; o
138
144
  }
139
145
 
140
146
  /** A picture, or the dashed "No picture" where a shot failed. */
141
- export const Shot = ({ url, cap, alt }: { url?: string; cap?: ReactNode; alt?: string }) => (
142
- <div className="jm-shot">
143
- {url ? <div className="pic"><img src={url} alt={alt ?? ''} draggable={false} /></div> : <div className="pic none"><ImagesSquareIcon size={13} />No picture</div>}
144
- {cap && <span className="cap">{cap}</span>}
145
- </div>
146
- )
147
+ export function Shot({ url, cap, alt, onSize }: { url?: string; cap?: ReactNode; alt?: string; onSize?: (w: number, h: number) => void }) {
148
+ // a picture that cannot load (gone, refused) is "No picture" too - never a broken image
149
+ const [failed, setFailed] = useState<string | null>(null)
150
+ const ok = !!url && failed !== url
151
+ return (
152
+ <div className="jm-shot">
153
+ {ok ? <div className="pic"><img src={url} alt={alt ?? ''} draggable={false} onError={() => setFailed(url!)}
154
+ onLoad={onSize ? (e) => onSize(e.currentTarget.naturalWidth, e.currentTarget.naturalHeight) : undefined} /></div>
155
+ : <div className="pic none"><ImagesSquareIcon size={13} />No picture</div>}
156
+ {cap && <span className="cap">{cap}</span>}
157
+ </div>
158
+ )
159
+ }
147
160
 
148
161
  /** "1 of 3" with its arrows - the walk's ends disable the arrow that has nowhere to go. */
149
162
  const Walk = ({ of, onPrev, onNext }: { of?: [number, number]; onPrev?: () => void; onNext?: () => void }) => of ? (
@@ -287,7 +300,7 @@ export function ReadBack({ title, head, of, onPrev, onNext, meta, lines, picture
287
300
  * `shots` are picture URLs per frame (`frames` names the tabs; it defaults to the shots' frames);
288
301
  * `alsoChanged` = shared files the job changed anyway.
289
302
  */
290
- export function ReviewDetail({ title, head, of, onPrev, onNext, frames, active, onTab, view, onFlip, reply, shots, alsoChanged, agent, when, more, onMore, onMoreOpen, onGood, onLater, onOpenThread, style, draftKey }: {
303
+ export function ReviewDetail({ title, head, of, onPrev, onNext, frames, active, onTab, view, onFlip, onFit, reply, shots, alsoChanged, agent, when, more, onMore, onMoreOpen, onGood, onLater, onOpenThread, style, draftKey }: {
291
304
  title: string
292
305
  /** beside the title: the Review | Capture switch */
293
306
  head?: ReactNode
@@ -297,8 +310,10 @@ export function ReviewDetail({ title, head, of, onPrev, onNext, frames, active,
297
310
  frames?: string[]
298
311
  active: number
299
312
  onTab(i: number): void
300
- view: 'before' | 'after'
301
- onFlip(view: 'before' | 'after'): void
313
+ view: 'both' | 'before' | 'after'
314
+ onFlip(view: 'both' | 'before' | 'after'): void
315
+ /** the panel width the pictures need (0.26.1): both at once, as big as the panel's height allows; undefined: the default */
316
+ onFit?(width: number | undefined): void
302
317
  reply: ReactNode
303
318
  /** `new`: a frame the run made - nothing before it */
304
319
  shots: { frame: string; before?: string; after?: string; new?: boolean }[]
@@ -318,6 +333,39 @@ export function ReviewDetail({ title, head, of, onPrev, onNext, frames, active,
318
333
  const names = frames ?? shots.map((s) => s.frame)
319
334
  const shot = shots[active] ?? shots.find((s) => s.frame === names[active])
320
335
  const isNew = (f: string) => !!shots.find((s) => s.frame === f)?.new
336
+ // the frame's shape, from its pictures as they load (After's, else Before's): taller than wide (or square) side by
337
+ // side, wider than tall stacked - and the panel as wide as that needs (0.26.1, the owner's first real session)
338
+ const [sizes, setSizes] = useState<Record<string, number>>({})
339
+ const sized = (url?: string) => (url ? (w: number, h: number) => { if (w > 0 && h > 0) setSizes((m) => (m[url] === w / h ? m : { ...m, [url]: w / h })) } : undefined)
340
+ const aspect = (shot?.after && sizes[shot.after]) || (shot?.before && sizes[shot.before]) || undefined
341
+ // both slots whenever the frame has a before at all (either may read "No picture") - a missing After never hides a Before
342
+ const both = view === 'both' && !!shot && !shot.new && !!(shot.before || shot.after)
343
+ const side = (aspect ?? 1.6) <= 1.1
344
+ const big = useRef<HTMLDivElement>(null)
345
+ useLayoutEffect(() => {
346
+ const el = big.current
347
+ if (!el || !onFit) return
348
+ // no picture of this one measured yet (loading, or none loads): the default width - never the last tab's
349
+ if (!aspect) { onFit(undefined); return }
350
+ const ask = () => {
351
+ const panel = el.closest('.jm-panel') as HTMLElement | null
352
+ if (!panel) return
353
+ // the chrome around the pictures: the panel's width minus the well's; the well's height is what they get
354
+ const chrome = panel.getBoundingClientRect().width - el.getBoundingClientRect().width
355
+ const h = el.getBoundingClientRect().height - 20 // the well's padding
356
+ const CAP = 18, GAP = 10
357
+ let well: number
358
+ if (both && side) well = 2 * (h - CAP) * aspect + GAP // side by side: each the whole height
359
+ else if (both) well = ((h - GAP - 2 * CAP) / 2) * aspect // stacked: each half of it
360
+ else well = h * aspect // one picture
361
+ const want = Math.round(chrome + well + 20)
362
+ onFit(Math.round(want / 8) * 8)
363
+ }
364
+ ask()
365
+ const ro = new ResizeObserver(ask)
366
+ ro.observe(el)
367
+ return () => ro.disconnect()
368
+ }, [aspect, both, side, onFit])
321
369
  const label = (f: string) => f.split('/').pop() ?? f
322
370
  // the More work words outlive the panel: a click elsewhere closes it, and the words wait for its return -
323
371
  // they go only when sent, or when you leave the composer yourself (Esc)
@@ -353,13 +401,18 @@ export function ReviewDetail({ title, head, of, onPrev, onNext, frames, active,
353
401
  <span className="sp" />
354
402
  {/* a frame the run made has nothing before it: no switch */}
355
403
  {shot?.new ? <span className="dim" data-jam-new="">New frame</span> : (
356
- <Tip side="bottom" label={<span>Before / After<kbd style={{ marginLeft: 8 }}>B</kbd></span>}>
357
- <div className="jm-ftabs" data-jam-flip="">{(['before', 'after'] as const).map((v) => <button key={v} className={v === view ? 'on' : undefined} aria-pressed={v === view} onClick={() => onFlip(v)}>{v === 'before' ? 'Before' : 'After'}</button>)}</div>
404
+ <Tip side="bottom" label={<span>Both / Before / After<kbd style={{ marginLeft: 8 }}>B</kbd></span>}>
405
+ <div className="jm-ftabs" data-jam-flip="">{(['both', 'before', 'after'] as const).map((v) => <button key={v} className={v === view ? 'on' : undefined} aria-pressed={v === view} onClick={() => onFlip(v)}>{v === 'both' ? 'Both' : v === 'before' ? 'Before' : 'After'}</button>)}</div>
358
406
  </Tip>
359
407
  )}
360
408
  </div>
361
409
  )}
362
- <div className="jm-big"><Shot url={view === 'before' && !shot?.new ? shot?.before : shot?.after} alt={`${label(names[active] ?? '')} ${shot?.new ? 'new' : view}`} /></div>
410
+ <div ref={big} className={`jm-big${both ? ` pair ${side ? 'side' : 'stack'}` : ''}`} data-jam-pair={both ? (side ? 'side' : 'stack') : 'one'}>
411
+ {both
412
+ ? <><Shot key={`b-${shot!.before ?? 'none'}`} url={shot!.before} cap="Before" alt={`${label(names[active] ?? '')} before`} onSize={sized(shot!.before)} /><Shot key={`a-${shot!.after ?? 'none'}`} url={shot!.after} cap="After" alt={`${label(names[active] ?? '')} after`} onSize={sized(shot!.after)} /></>
413
+ : <Shot url={view === 'before' && !shot?.new ? shot?.before : shot?.after} alt={`${label(names[active] ?? '')} ${shot?.new ? 'new' : view}`}
414
+ onSize={sized(view === 'before' && !shot?.new ? shot?.before : shot?.after)} />}
415
+ </div>
363
416
  {alsoChanged && alsoChanged.length > 0 && (
364
417
  <div className="jm-file"><FileCodeIcon size={14} /><span>Also changed {alsoChanged.map((f, i) => <span key={f}>{i > 0 && ', '}<code>{f.split('/').pop()}</code></span>)}</span></div>
365
418
  )}
@@ -5,8 +5,8 @@
5
5
  * failed). A card that fails raises one notice; nothing else here interrupts.
6
6
  */
7
7
  import { create } from 'zustand'
8
- import { ROUTE } from '../const.ts'
9
8
  import { PUBLISHED } from './store.ts'
9
+ import { api } from './api.ts'
10
10
 
11
11
  export type JamAction = 'drop' | 'retry' | 'keep' | 'first' | 'confirm' | 'edit' | 'good' | 'more' | 'later' | 'rename' | 'note'
12
12
  export type JamCardState = 'draft' | 'confirming' | 'queued' | 'working' | 'asks' | 'review' | 'done' | 'kept' | 'failed' | 'dropped'
@@ -72,7 +72,7 @@ export const useJamQueue = create<QueueState>((set, get) => {
72
72
  async load() {
73
73
  if (PUBLISHED) return
74
74
  try {
75
- const res = await fetch(`${ROUTE}/api/jam/queue`, { headers: { 'x-mv-c': csrf() } })
75
+ const res = await api('jam/queue', { headers: { 'x-mv-c': csrf() } })
76
76
  if (res.ok) get().apply(await res.json())
77
77
  } catch { /* no queue: no icons */ }
78
78
  },
@@ -113,7 +113,7 @@ export const useJamQueue = create<QueueState>((set, get) => {
113
113
  if (get().session?.id === session) set({ session: null })
114
114
  },
115
115
  async act(card, action, body) {
116
- const res = await fetch(`${ROUTE}/api/jam/card`, {
116
+ const res = await api('jam/card', {
117
117
  method: 'POST', headers: { 'content-type': 'application/json', 'x-mv-c': csrf() },
118
118
  body: JSON.stringify({ id: card.id, rev: card.rev, action, ...(body !== undefined ? { body } : {}) }),
119
119
  }).catch(() => null)
@@ -10,7 +10,6 @@
10
10
  * crossed microphone without one); a teal dot only while a capture records. Blue only on hover and press.
11
11
  */
12
12
  import { useEffect, useRef, useState, type CSSProperties } from 'react'
13
- import { ROUTE } from '../const.ts'
14
13
  import { setSessionEnding, useJamCapture } from './jam-capture.ts'
15
14
  import { laneCards, startCapture } from './jam-keys.ts'
16
15
  import { useJamQueue, type JamCard } from './jam-queue.ts'
@@ -22,7 +21,8 @@ import { HARNESS } from './Comments.tsx'
22
21
  import { ArrowRightIcon, CaretIcon, KeyboardIcon, MicrophoneIcon, MicrophoneSlashIcon, WarningIcon, WaveformIcon } from './icons.tsx'
23
22
  import { Tip } from './Tip.tsx'
24
23
  import { useSessionClock } from './jam-lane.tsx'
25
- import { CONFIG, useStore } from './store.ts'
24
+ import { CONFIG, stoppedFor, useStore } from './store.ts'
25
+ import { api, STOPPED_TIP, useStopped } from './api.ts'
26
26
 
27
27
  const csrf = () => /(?:^|;\s*)mv_c=([\w-]+)/.exec(document.cookie)?.[1] ?? ''
28
28
  const now = () => performance.timeOrigin + performance.now()
@@ -32,7 +32,7 @@ const now = () => performance.timeOrigin + performance.now()
32
32
  /** Why the last session move was refused (the server's words), for the one line that says so. */
33
33
  let lastError: string | undefined
34
34
  async function post(body: Record<string, unknown>, onAnswer?: (ok: boolean) => void): Promise<boolean> {
35
- const r = await fetch(`${ROUTE}/api/jam/session`, { method: 'POST', headers: { 'content-type': 'application/json', 'x-mv-c': csrf() }, body: JSON.stringify(body) }).catch(() => null)
35
+ const r = await api('jam/session', { method: 'POST', headers: { 'content-type': 'application/json', 'x-mv-c': csrf() }, body: JSON.stringify(body) }).catch(() => null)
36
36
  lastError = r && !r.ok ? ((await r.json().catch(() => null)) as { error?: string } | null)?.error : r ? undefined : 'marver dev did not answer'
37
37
  // what the server's answer settles happens at once, never behind the refresh (which may be slow, and a push
38
38
  // may come first)
@@ -43,6 +43,7 @@ async function post(body: Record<string, unknown>, onAnswer?: (ok: boolean) => v
43
43
 
44
44
  /** Start a session: the dev server holds it (it survives a reload); the microphone hears its talk. */
45
45
  export async function startSession(): Promise<boolean> {
46
+ if (stoppedFor('Jam needs the canvas running')) return false // spec 28 A1.11
46
47
  const id = `ses-${Date.now()}-${Math.random().toString(36).slice(2, 8).padEnd(6, '0')}`
47
48
  // this tab holds the session's microphone (a reload of it takes it back; other tabs never take it) - from
48
49
  // the moment the server has it: the push of it may come before the refresh
@@ -112,6 +113,8 @@ let endingOp = 0
112
113
  * capture recording ends first, and the wrap-up waits for its read-back to close. */
113
114
  export function pressJ() {
114
115
  const ui = useJamUi.getState()
116
+ // the canvas stopped (spec 28 A1.11): a sheet open still closes; nothing new starts or wraps up
117
+ if (!ui.sheet && stoppedFor('Jam needs the canvas running')) return
115
118
  if (!useJamQueue.getState().session) { ui.setSheet(ui.sheet === 'start' ? null : 'start'); return }
116
119
  if (ui.sheet === 'wrap' || ui.sheet === 'wrap-pending') { ui.setSheet(null); return }
117
120
  if (useJamCapture.getState().current) { useJamCapture.getState().end(); ui.setSheet('wrap-pending'); return }
@@ -132,11 +135,14 @@ export function JamButton({ inPlay }: { inPlay?: boolean }) {
132
135
  // off: no, blocked, no engine - or stopped (another tab has it, the connection went) while you said yes
133
136
  const micOff = voice.choice === 'no' || voice.denied || voice.server === 'unavailable' || (!!session && voice.choice === 'yes' && !voice.live && !recording)
134
137
  const state = recording ? 'rec' : session ? 'live' : 'idle'
135
- const label = session ? <><b>End the session</b><span>J</span></> : <><b>Jam session</b><span>J</span></>
138
+ // the canvas stopped (spec 28 A1.11): quiet, saying why - a capture already recording goes on
139
+ const stopped = useStopped()
140
+ const label = stopped ? <div className="sh-tip-lines"><b>Jam needs the canvas running</b><small>{STOPPED_TIP}</small></div>
141
+ : session ? <><b>End the session</b><span>J</span></> : <><b>Jam session</b><span>J</span></>
136
142
  return (
137
143
  <Tip side="bottom" inv={inPlay} label={label}>
138
- <button className={`sh-pill-btn jm-jam${state !== 'idle' ? ` ${state}` : ''}${sheet === 'start' || sheet === 'wrap' ? ' press' : ''}`}
139
- data-jam-button={state} aria-label={session ? 'End the Jam session' : 'Jam session'} onClick={pressJ}>
144
+ <button className={`sh-pill-btn jm-jam${state !== 'idle' ? ` ${state}` : ''}${sheet === 'start' || sheet === 'wrap' ? ' press' : ''}${stopped ? ' off' : ''}`}
145
+ data-jam-button={state} data-stopped={stopped ? '' : undefined} aria-disabled={stopped || undefined} aria-label={session ? 'End the Jam session' : 'Jam session'} onClick={pressJ}>
140
146
  {/* the whole session reads as on: the dot pulses from start to end, between captures too */}
141
147
  {session || recording ? <i className="jm-live-dot" /> : <WaveformIcon size={16} />}
142
148
  {session && <span className="jm-clock">{minutes}</span>}
@@ -226,7 +232,7 @@ export function WrapSheet({ style }: { style?: CSSProperties }) {
226
232
  const [busy, setBusy] = useState(false)
227
233
  const field = useRef<HTMLTextAreaElement>(null)
228
234
  useEffect(() => {
229
- fetch(`${ROUTE}/api/jam/session`, { headers: { 'x-mv-c': csrf() } }).then((r) => (r.ok ? r.json() : null)).then((b) => { setTalkMin(b?.talkMinutes ?? 0); setTags(b?.tags ?? 0); setFolder(typeof b?.folder === 'string' ? b.folder : null) }, () => {})
235
+ api('jam/session', { headers: { 'x-mv-c': csrf() } }).then((r) => (r.ok ? r.json() : null)).then((b) => { setTalkMin(b?.talkMinutes ?? 0); setTags(b?.tags ?? 0); setFolder(typeof b?.folder === 'string' ? b.folder : null) }, () => {})
230
236
  requestAnimationFrame(() => field.current?.focus())
231
237
  }, [])
232
238
  // the field grows with its words: three lines at least
@@ -309,7 +315,7 @@ export function RecordDetail({ card, agent, more, onMore, onMoreOpen, onGood, on
309
315
  const [rec, setRec] = useState<{ file: string; text: string | null; reply?: string } | null>(null)
310
316
  useEffect(() => {
311
317
  let live = true
312
- fetch(`${ROUTE}/api/jam/record?id=${encodeURIComponent(card.id)}`, { headers: { 'x-mv-c': csrf() } })
318
+ api(`jam/record?id=${encodeURIComponent(card.id)}`, { headers: { 'x-mv-c': csrf() } })
313
319
  .then((r) => (r.ok ? r.json() : null)).then((b) => { if (live && b) setRec(b) }, () => {})
314
320
  return () => { live = false }
315
321
  }, [card.id, card.state, card.rev])
@@ -12,12 +12,16 @@ interface JamUi {
12
12
  selected: string | null
13
13
  /** the lane has the keyboard (Q) */
14
14
  laneKeys: boolean
15
- /** the review: Before | After, the frame tab, the More work composer */
16
- view: 'after' | 'before'
15
+ /** the review: Both (before and after at once - 0.26.1) | Before | After, the frame tab, the More work composer */
16
+ view: 'both' | 'before' | 'after'
17
17
  tab: number
18
18
  moreOpen: boolean
19
19
  /** bumps when the lane should come back to its right end (a new capture or draft) */
20
20
  followEnd: number
21
+ /** the lane's done tiles shown (the Done group opened) - folded into one tile by default (0.26.1) */
22
+ doneOpen: boolean
23
+ /** folding hands a selected done tile's selection to the group (`doneIds`: the tiles it folds) */
24
+ setDoneOpen(open: boolean, doneIds?: string[]): void
21
25
  /** the session's sheets (Part 5): the start sheet (J at rest), the wrap-up (J in a session) - or
22
26
  * 'wrap-pending': J pressed while a capture recorded, the wrap-up waits for its read-back to close */
23
27
  sheet: 'start' | 'wrap' | 'wrap-pending' | null
@@ -27,21 +31,35 @@ interface JamUi {
27
31
  setLaneKeys(on: boolean): void
28
32
  select(id: string | null): void
29
33
  flip(): void
34
+ /** a choice in the review's switch: Both, Before or After */
35
+ setView(view: JamUi['view']): void
30
36
  setTab(i: number): void
31
37
  setMoreOpen(on: boolean): void
32
38
  follow(): void
33
39
  }
34
40
 
35
41
  export const useJamUi = create<JamUi>((set, get) => ({
36
- panel: null, selected: null, laneKeys: false, view: 'after', tab: 0, moreOpen: false, followEnd: 0, sheet: null,
42
+ panel: null, selected: null, laneKeys: false, view: 'both', tab: 0, moreOpen: false, followEnd: 0, sheet: null, doneOpen: false,
37
43
  setSheet(s) { set({ sheet: s }) },
38
- // the next card opens on After, its first frame
39
- open(panel) { set({ panel, selected: panel?.id ?? get().selected, view: 'after', tab: 0, moreOpen: false }) },
44
+ // the next card opens on Both, its first frame
45
+ open(panel) { set({ panel, selected: panel?.id ?? get().selected, view: 'both', tab: 0, moreOpen: false }) },
40
46
  close() { set({ panel: null, moreOpen: false }) },
41
47
  setLaneKeys(on) { set({ laneKeys: on }) },
48
+ // folding: a done tile that was selected hands its selection to the group
49
+ // the selection follows the fold: folding, a selected done tile or the collapse tile hands it to the group; opening,
50
+ // a selected group hands it to the first done tile
51
+ setDoneOpen(open, doneIds = []) {
52
+ set((s) => ({
53
+ doneOpen: open,
54
+ ...(!open && s.selected && (s.selected === DONE_CLOSE || doneIds.includes(s.selected)) ? { selected: DONE_GROUP } : {}),
55
+ ...(open && s.selected === DONE_GROUP ? { selected: doneIds[0] ?? DONE_CLOSE } : {}),
56
+ }))
57
+ },
42
58
  select(id) { set({ selected: id }) },
43
- flip() { set((s) => ({ view: s.view === 'after' ? 'before' : 'after' })) },
59
+ // B: Both -> Before -> After -> Both
60
+ flip() { set((s) => ({ view: s.view === 'both' ? 'before' : s.view === 'before' ? 'after' : 'both' })) },
44
61
  setTab(i) { set({ tab: i }) },
62
+ setView(view) { set({ view }) },
45
63
  setMoreOpen(on) { set({ moreOpen: on }) },
46
64
  follow() { set((s) => ({ followEnd: s.followEnd + 1 })) },
47
65
  }))
@@ -59,3 +77,27 @@ export function letGoOfTile() {
59
77
  }
60
78
 
61
79
  if (typeof window !== 'undefined' && (import.meta as any).env?.DEV) (window as any).__mvJamUi = useJamUi
80
+
81
+ // ---- the Done fold (0.26.1): two or more done tiles fold into one, at the lane's left end ------------------
82
+
83
+ /** The folded group's stop, and the collapse tile's when it is open. */
84
+ export const DONE_GROUP = 'jam-done-group'
85
+ export const DONE_CLOSE = 'jam-done-close'
86
+
87
+ /** How the lane shows `items` (oldest first): two or more done ones fold into one group; open, they lead, behind a
88
+ * collapse tile. `stops`: the lane's keyboard stops in that order. */
89
+ export function doneFold<T extends { id: string; state: string }>(items: T[], open: boolean): { fold: boolean; done: T[]; rest: T[]; stops: string[] } {
90
+ const done = items.filter((t) => t.state === 'done')
91
+ const rest = items.filter((t) => t.state !== 'done')
92
+ const fold = done.length >= 2
93
+ const stops = !fold ? items.map((t) => t.id) : open ? [DONE_CLOSE, ...done.map((t) => t.id), ...rest.map((t) => t.id)] : [DONE_GROUP, ...rest.map((t) => t.id)]
94
+ return { fold, done, rest, stops }
95
+ }
96
+
97
+ /** What the Done group holds: "3 captures", "2 captures · 1 record", and "· 4 frames changed" when known. */
98
+ export function doneLine(done: { record?: boolean }[], frames: number): string {
99
+ const records = done.filter((t) => t.record).length, captures = done.length - records
100
+ const parts = [captures ? `${captures} capture${captures === 1 ? '' : 's'}` : '', records ? `${records} record${records === 1 ? '' : 's'}` : '', frames ? `${frames} frame${frames === 1 ? '' : 's'} changed` : ''].filter(Boolean)
101
+ return parts.join(' · ')
102
+ }
103
+
@@ -9,8 +9,9 @@ import { Caption, FocusPanel, NotesCard, ReadBack, ReviewDetail, VoiceAsk } from
9
9
  import type { TimelineLine } from './jam-lines.ts'
10
10
  import type { JamCard } from './jam-queue.ts'
11
11
 
12
- export function CaptureLaneRow({ tiles, recording, between, selected, keyboard, followEnd, onOpen, onMenu, notes, ask, caption }: {
12
+ export function CaptureLaneRow({ tiles, recording, between, selected, keyboard, followEnd, onOpen, onMenu, notes, ask, caption, doneOpen, onDoneOpen }: {
13
13
  tiles: LaneTile[]; recording?: LaneRecording; between?: LaneBetween; selected?: string; keyboard?: boolean; followEnd?: number; onOpen(id: string): void
14
+ doneOpen?: boolean; onDoneOpen?(open: boolean, doneIds: string[]): void
14
15
  onMenu?(e: React.MouseEvent, id: string): void
15
16
  notes?: { notes: { t: string; text: string }[]; draft: string; onDraft(t: string): void; onAdd(): void; onClose(): void }
16
17
  /** the microphone question (and the model's download), over the capture tile */
@@ -35,7 +36,7 @@ export function CaptureLaneRow({ tiles, recording, between, selected, keyboard,
35
36
  const roomLeft = (at?.left ?? 10) - 8 >= 300
36
37
  return (
37
38
  <>
38
- <Lane tiles={tiles} recording={recording} between={between} selected={selected} keyboard={keyboard} followEnd={followEnd} onOpen={onOpen} onMenu={onMenu} />
39
+ <Lane tiles={tiles} recording={recording} between={between} selected={selected} keyboard={keyboard} followEnd={followEnd} onOpen={onOpen} onMenu={onMenu} doneOpen={doneOpen} onDoneOpen={onDoneOpen} />
39
40
  {/* one lane up, over the capture tile: the question, then the notes card above it; the words just
40
41
  left of the notes card (bottoms aligned), or over the tile when it is closed */}
41
42
  {(notes || ask) && (
@@ -59,8 +60,8 @@ export function FocusPanelView(p: {
59
60
  left: number; kind: 'capture' | 'review' | 'wrapup'; card: JamCard; of: [number, number] | undefined; agent: string; reviewedTitle?: string
60
61
  lines: TimelineLine[]; pictures: { id: string; url: string; caption: string }[]
61
62
  shots: { frame: string; before?: string; after?: string; new?: boolean }[]; reply: string
62
- view: 'after' | 'before'; tab: number; moreOpen: boolean
63
- onTab(i: number): void; onFlip(): void; onMoreOpen(on: boolean): void; onClose(): void
63
+ view: 'both' | 'before' | 'after'; tab: number; moreOpen: boolean
64
+ onTab(i: number): void; onFlip(view: 'both' | 'before' | 'after'): void; onMoreOpen(on: boolean): void; onClose(): void
64
65
  onEdit(text: string): void; onConfirm(): void; onKeep(): void; onDrop(): void; onResume?: () => void
65
66
  onGood(): void; onMore(text: string): void; onLater(): void; onOpenThread(): void
66
67
  onPrev?: () => void; onNext?: () => void; pending?: string; onRetry?: () => void; locked?: boolean
@@ -72,6 +73,9 @@ export function FocusPanelView(p: {
72
73
  // a capture under review: its review, or the capture itself as it was read back (its pictures, its timeline)
73
74
  const [pane, setPane] = useState<'review' | 'capture'>('review')
74
75
  useEffect(() => { setPane('review') }, [c.id])
76
+ // the review asks for the width its pictures need (both at once, as big as the panel's height allows)
77
+ const [fit, setFit] = useState<number | undefined>(undefined)
78
+ useEffect(() => { setFit(undefined) }, [c.id])
75
79
  const head = p.kind === 'review' ? (
76
80
  <div className="jm-ftabs jm-panes" role="tablist" data-jam-panes="">
77
81
  {(['review', 'capture'] as const).map((v) => <button key={v} role="tab" aria-selected={v === pane} className={v === pane ? 'on' : undefined} onClick={() => setPane(v)}>{v === 'review' ? 'Review' : 'Capture'}</button>)}
@@ -84,10 +88,10 @@ export function FocusPanelView(p: {
84
88
  points ? `${points} point${points === 1 ? '' : 's'}` : '', p.pictures.length ? `${p.pictures.length} picture${p.pictures.length === 1 ? '' : 's'}` : '',
85
89
  notes ? `${notes} note${notes === 1 ? '' : 's'}` : ''].filter(Boolean)
86
90
  return (
87
- <FocusPanel left={p.left} onClose={p.onClose}>
91
+ <FocusPanel left={p.left} onClose={p.onClose} width={p.kind === 'review' && pane === 'review' ? fit : undefined}>
88
92
  {p.kind === 'review' && pane === 'review' ? (
89
93
  <ReviewDetail key={c.id} title={title} head={head} of={p.of} onPrev={p.onPrev} onNext={p.onNext} frames={p.shots.map((s) => s.frame)} active={p.tab} onTab={p.onTab}
90
- view={p.view} onFlip={() => p.onFlip()} reply={p.reply} shots={p.shots} agent={p.agent}
94
+ view={p.view} onFlip={(v) => p.onFlip(v)} onFit={setFit} reply={p.reply} shots={p.shots} agent={p.agent}
91
95
  more={p.moreOpen} draftKey={c.id} onMore={p.onMore} onMoreOpen={p.onMoreOpen} onGood={p.onGood} onLater={p.onLater} onOpenThread={p.onOpenThread} />
92
96
  ) : (
93
97
  <ReadBack key={c.id} title={title} head={head} of={p.of} onPrev={p.onPrev} onNext={p.onNext} meta={meta} lines={p.lines} pictures={p.pictures} edited={c.edited} pending={p.pending}
@@ -18,6 +18,7 @@
18
18
  import { create } from 'zustand'
19
19
  import { ROUTE } from '../const.ts'
20
20
  import { CONFIG, useStore } from './store.ts'
21
+ import { api } from './api.ts'
21
22
 
22
23
  export const RATE = 16_000
23
24
  const FINAL_MS = 3_000
@@ -68,20 +69,20 @@ export const useJamVoice = create<VoiceStore>((set, get) => ({
68
69
  },
69
70
  async refresh() {
70
71
  try {
71
- const r = await fetch(`${ROUTE}/api/jam/voice`, { headers: { 'x-mv-c': csrf() } })
72
+ const r = await api('jam/voice', { headers: { 'x-mv-c': csrf() } })
72
73
  if (!r.ok) { set({ server: 'unavailable', reason: 'jam is not running here' }); return }
73
74
  const b = await r.json()
74
75
  set({ server: b.state, reason: b.reason, download: b.download ?? null, mb: b.mb ?? 490 })
75
76
  } catch { set({ server: 'unavailable', reason: 'marver dev did not answer' }) }
76
77
  },
77
78
  async startDownload() {
78
- try { await fetch(`${ROUTE}/api/jam/voice`, { method: 'POST', headers: { 'x-mv-c': csrf(), 'content-type': 'application/json' }, body: JSON.stringify({ download: true }) }) } catch { /* the poll says */ }
79
+ try { await api('jam/voice', { method: 'POST', headers: { 'x-mv-c': csrf(), 'content-type': 'application/json' }, body: JSON.stringify({ download: true }) }) } catch { /* the poll says */ }
79
80
  poll()
80
81
  },
81
82
  async retry() {
82
83
  toldUnavailable = false
83
84
  try {
84
- const r = await fetch(`${ROUTE}/api/jam/voice`, { method: 'POST', headers: { 'x-mv-c': csrf(), 'content-type': 'application/json' }, body: JSON.stringify({ retry: true }) })
85
+ const r = await api('jam/voice', { method: 'POST', headers: { 'x-mv-c': csrf(), 'content-type': 'application/json' }, body: JSON.stringify({ retry: true }) })
85
86
  if (r.ok) { const b = await r.json(); set({ server: b.state, reason: b.reason, download: b.download ?? null, mb: b.mb ?? 490 }); return }
86
87
  } catch { /* below */ }
87
88
  await get().refresh()
@@ -168,7 +169,8 @@ function socket(reclaim = false): Promise<WebSocket | null> {
168
169
  if (wsOpen) return wsOpen
169
170
  wsOpen = (async () => {
170
171
  try {
171
- const r = await fetch(`${ROUTE}/api/jam/audio-ticket`, { method: 'POST', headers: { 'x-mv-c': csrf() } })
172
+ // the ticket names this canvas's workspace like every request (A1.11); the socket it opens is bound by it
173
+ const r = await api('jam/audio-ticket', { method: 'POST', headers: { 'x-mv-c': csrf() } })
172
174
  if (!r.ok) return null
173
175
  const { ticket } = await r.json()
174
176
  const s = new WebSocket(`${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}${ROUTE}/api/jam/audio?ticket=${encodeURIComponent(ticket)}${reclaim ? '&reclaim=1' : ''}`)
@@ -242,7 +244,7 @@ function takeBackLater() {
242
244
  waitingBack = setInterval(async () => {
243
245
  if (!session || (mic && !mic.closed)) { clearInterval(waitingBack!); waitingBack = null; return }
244
246
  try {
245
- const r = await fetch(`${ROUTE}/api/jam/voice`, { headers: { 'x-mv-c': csrf() } })
247
+ const r = await api('jam/voice', { headers: { 'x-mv-c': csrf() } })
246
248
  const b = r.ok ? await r.json() : null
247
249
  if (b && b.busy === false) { clearInterval(waitingBack!); waitingBack = null; reclaiming = true; void reconcile() }
248
250
  } catch { /* ask again */ }
@@ -17,7 +17,7 @@ import { stableNodeKey } from './keys.ts'
17
17
  import { UNPLACED, type HashState } from './hash.ts'
18
18
  import { ALL_SCENES_KEYS, boardLabel, fetchMembership, PUBLISHED } from './store.ts'
19
19
  import { useComments } from './comments-store.ts'
20
- import { ROUTE } from '../const.ts'
20
+ import { api } from './api.ts'
21
21
 
22
22
  export const isLegacyLink = (h: HashState): boolean => h.board === ALL_SCENES
23
23
 
@@ -44,7 +44,7 @@ export async function landLegacy(h: HashState): Promise<{ hash: HashState; notic
44
44
  const byKey = new Map([...live.map((id) => [stableNodeKey(ALL_SCENES, id, 0), id] as const), ...Object.entries(ALL_SCENES_KEYS)])
45
45
  if (!PUBLISHED) {
46
46
  try {
47
- const leftover = (await (await fetch(`${ROUTE}/api/boards/${ALL_SCENES}`)).json())?.board as { nodes?: { key?: unknown; frame?: unknown }[] } | null
47
+ const leftover = (await (await api(`boards/${ALL_SCENES}`)).json())?.board as { nodes?: { key?: unknown; frame?: unknown }[] } | null
48
48
  for (const node of Array.isArray(leftover?.nodes) ? leftover.nodes : []) if (typeof node?.key === 'string' && typeof node.frame === 'string') byKey.set(node.key, node.frame)
49
49
  } catch { /* no leftover, or not JSON: the minted keys stand */ }
50
50
  }
@@ -1,9 +1,13 @@
1
1
  import { createRoot } from 'react-dom/client'
2
2
  import { App, ShellBoundary } from './App.tsx'
3
3
  import { useStore } from './store.ts'
4
+ import { startRecorder } from './recorder.ts'
5
+ import { capturesPending, sealOnLeave } from './jam-capture.ts'
4
6
  import './styles.css'
5
7
 
6
8
  // dev aid: inspectable store (harmless in builds; the canvas is a dev surface)
7
9
  ;(window as any).__sh = useStore
10
+ // what each board load does, from the page (spec 28 A1.7): before the first load; nothing on a published canvas
11
+ startRecorder({ capturesPending, sealCaptures: sealOnLeave })
8
12
 
9
13
  createRoot(document.getElementById('root')!).render(<ShellBoundary><App /></ShellBoundary>)
@@ -106,7 +106,9 @@ export function notesCramped(
106
106
 
107
107
  // ---- per-viewer visibility -------------------------------------------------------------
108
108
 
109
- const STORAGE = 'mv-notes'
109
+ /** The viewer's choice is kept per canvas (spec 28 A1.6): the shell names the key at boot (store.ts),
110
+ * so this module stays importable without the plugin's virtual modules (test/notes.test.ts). */
111
+ let STORAGE = 'mv-notes'
110
112
  interface NotesState {
111
113
  /** the N toggle: false hides every note on the canvas */
112
114
  all: boolean
@@ -143,6 +145,11 @@ export const useNotes = create<NotesState>((set, get) => ({
143
145
  set(next); save(next)
144
146
  },
145
147
  }))
148
+ /** Keep the notes' visibility under this canvas's key (`mv-notes:<workspace>`), read from it now. */
149
+ export function scopeNotes(key: string) {
150
+ STORAGE = key
151
+ useNotes.setState(load())
152
+ }
146
153
  /** Every note id currently on the canvas - read from the DOM, the one place that knows. */
147
154
  const allIds = (): string[] => (typeof document === 'undefined' ? [] : [...document.querySelectorAll('[data-note]')].map((el) => el.getAttribute('data-note')!))
148
155