@marver-design/marver 0.28.0 → 0.29.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 (62) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/README.md +2 -2
  3. package/dist/{anchor-check-PHUOFj1N.mjs → anchor-check-DhlpKl2K.mjs} +1 -1
  4. package/dist/{build-BsAyLMT1.mjs → build-CWbrb2bl.mjs} +5 -3
  5. package/dist/{capture-DdZ6xgoz.mjs → capture-DEtM4qm5.mjs} +168 -5
  6. package/dist/cli.mjs +10 -10
  7. package/dist/{comments-CrBHPEQl.mjs → comments-XNhMmSSu.mjs} +2 -2
  8. package/dist/{connectors-MR9d-EBP.mjs → connectors-DekQvKt9.mjs} +3 -1
  9. package/dist/{daemon-C5dg2R-V.mjs → daemon-Sc_z8gT6.mjs} +28 -29
  10. package/dist/{dev-D7YS7iT2.mjs → dev-DWBKQhxf.mjs} +19 -14
  11. package/dist/{init-WE5lQkQL.mjs → init-CYlFaRzG.mjs} +1 -1
  12. package/dist/logo-CXY-1yrn.mjs +305 -0
  13. package/dist/{ls-BZ5TAtd5.mjs → ls-NqmePKOf.mjs} +1 -1
  14. package/dist/{marks-Kmdab_5w.mjs → marks-BnNANic9.mjs} +20 -1
  15. package/dist/{marks-Dyn6tmjp.mjs → marks-DBp3h1Mc.mjs} +2 -5
  16. package/dist/{marver-id-gate-D-R0hSt_.mjs → marver-id-gate-vBLb_Icb.mjs} +1 -1
  17. package/dist/{perf-Cn5LiRaY.mjs → perf-Denssrko.mjs} +43 -25
  18. package/dist/{perf-jam-QxD_UnzN.mjs → perf-jam-CLkERSHo.mjs} +8 -1
  19. package/dist/{plugin-C_0yb-Fq.mjs → plugin-DqoZB-D6.mjs} +511 -298
  20. package/dist/{poster-DHi6I1fO.mjs → poster-CrsjqhY4.mjs} +1 -1
  21. package/dist/{profile-jIS6BcAs.mjs → profile-B1FKOM1e.mjs} +1 -1
  22. package/dist/{publish-bakes-r4PEZuPl.mjs → publish-bakes-DW-NDgU2.mjs} +3 -3
  23. package/dist/{queue-c-6aTHEz.mjs → queue-DeSQm24g.mjs} +29 -14
  24. package/dist/{recover-nrLEVLyJ.mjs → recover-GtJ9UDAB.mjs} +2 -2
  25. package/dist/{serve-Dp3nHstu.mjs → serve-DQv3Ti6X.mjs} +8 -4
  26. package/dist/{session-DyVE7cCk.mjs → session-VDJfXEEm.mjs} +1 -1
  27. package/dist/{share-Ce4tP7ji.mjs → share-Bu_kuOKL.mjs} +1 -1
  28. package/dist/{shot-BrRtqaiS.mjs → shot-T04Ixrvq.mjs} +3 -3
  29. package/dist/{slots-CFNnegCc.mjs → slots-Dn4Onb0V.mjs} +101 -3
  30. package/dist/{sync-CQdGARJ9.mjs → sync-CMozOwZ0.mjs} +1 -1
  31. package/docs/boards-and-folders.md +11 -0
  32. package/docs/jam-session.md +12 -3
  33. package/docs/live-jam.md +3 -0
  34. package/docs/performance.md +1 -1
  35. package/docs/publish.md +7 -0
  36. package/package.json +1 -1
  37. package/src/client/shell/Comments.tsx +5 -4
  38. package/src/client/shell/ContextMenu.tsx +5 -4
  39. package/src/client/shell/JamSurface.tsx +80 -9
  40. package/src/client/shell/Play.tsx +16 -4
  41. package/src/client/shell/api.ts +7 -3
  42. package/src/client/shell/app-bridge.ts +11 -3
  43. package/src/client/shell/comments-store.ts +14 -0
  44. package/src/client/shell/goto.ts +4 -3
  45. package/src/client/shell/jam-capture.ts +39 -15
  46. package/src/client/shell/jam-keys.ts +166 -40
  47. package/src/client/shell/jam-lines.ts +10 -1
  48. package/src/client/shell/jam-panel.tsx +8 -6
  49. package/src/client/shell/jam-queue.ts +6 -1
  50. package/src/client/shell/jam-session.tsx +2 -2
  51. package/src/client/shell/jam-state.ts +19 -4
  52. package/src/client/shell/jam-ui.tsx +4 -0
  53. package/src/client/shell/live-picture.ts +134 -0
  54. package/src/client/shell/open-item.ts +83 -0
  55. package/src/client/shell/open-resolve.ts +50 -0
  56. package/src/client/shell/store.ts +6 -2
  57. package/src/client/shell/styles.css +2 -0
  58. package/src/client/stage/main.tsx +30 -8
  59. package/src/shared/app-api.ts +173 -3
  60. package/src/shared/app-perf.ts +4 -2
  61. package/templates/instructions/jam.md +4 -0
  62. package/dist/live-Cgzsicwi.mjs +0 -4
@@ -10,17 +10,18 @@ import { ROUTE } from '../const.ts'
10
10
  import { captureCounts, endedToReview, useJamCapture } from './jam-capture.ts'
11
11
  import { useJamVoice, voiceSession, voiceSessionEnd, voiceSessionId, type Heard } from './jam-voice.ts'
12
12
  import { holdsSessionMic, PlayCounter, RecordDetail, StartSheet, WrapSheet } from './jam-session.tsx'
13
- import { FocusPanel, VoiceAsk } from './jam-panel.tsx'
13
+ import { AsksAnswer, FocusPanel, Marver, VoiceAsk } from './jam-panel.tsx'
14
14
  import { addNote, decideDraft, laneCards, openThread, openTile, pendingEdit, resumeDraft, reveal, saveEdit, shownLane, startCapture } from './jam-keys.ts'
15
15
  import { ContextMenu, useContextMenu, type MenuItem } from './ContextMenu.tsx'
16
16
  import { ArrowBendUpLeftIcon, ArrowLineUpIcon, ArrowUpIcon, CheckSquareOffsetIcon, CommentIcon, EyeIcon, NotebookIcon, PencilSimpleIcon, PlayIcon, ReloadIcon, XIcon } from './icons.tsx'
17
- import { laneLine, laneTip, timelineLines } from './jam-lines.ts'
17
+ import { laneLine, laneTip, pictureCaption, timelineLines } from './jam-lines.ts'
18
18
  import { changedShots, useJamQueue, type JamCard } from './jam-queue.ts'
19
- import { DONE_GROUP, doneFold, letGoOfTile, useJamUi } from './jam-state.ts'
19
+ import { DONE_GROUP, doneFold, jamSurface, letGoOfTile, useJamUi } from './jam-state.ts'
20
20
  import { CaptureLaneRow, FocusPanelView } from './jam-surface-parts.tsx'
21
21
  import { clearMoreDraft, EdgeRing, preloadShots } from './jam-panel.tsx'
22
22
  import { useComments } from './comments-store.ts'
23
- import { HARNESS } from './Comments.tsx'
23
+ import { Avatar, HARNESS } from './Comments.tsx'
24
+ import { TagStatus } from './jam-ui.tsx'
24
25
  import { PUBLISHED, useStore } from './store.ts'
25
26
  import { api, withWs } from './api.ts'
26
27
  import type { CaptureRecord } from '../../server/jam/types.ts'
@@ -127,6 +128,18 @@ export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
127
128
  // a draft being resumed is the capture recording (or sealing) now: its own tile steps aside
128
129
  const list = shownLane(cards, run, cap.resuming)
129
130
  const cm = useContextMenu()
131
+ // a tile's menu opened at the tile, for the helper that opens a stalled run's controls (jam-keys.ts openRunControls)
132
+ useEffect(() => {
133
+ jamSurface.tileMenu = (id) => {
134
+ const c = useJamQueue.getState().cards?.find((x) => x.id === id)
135
+ const el = document.querySelector(`.jm-lane [data-tile="${CSS.escape(id)}"]`)
136
+ if (!c || !el) return false
137
+ const r = el.getBoundingClientRect()
138
+ cm.open({ preventDefault() {}, clientX: r.left + 8, clientY: r.top - 8 }, tileMenu(c), `tile:${id}`)
139
+ return true
140
+ }
141
+ return () => { jamSurface.tileMenu = () => false }
142
+ }, [])
130
143
  // a comment opening (a pin, a thread, Open thread) takes the place of the read-back or review: the panel
131
144
  // closes; the tile lets go too, unless the thread is that tile's own (a capture that asks opens its thread)
132
145
  useEffect(() => useComments.subscribe((s, p) => {
@@ -166,7 +179,7 @@ export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
166
179
  onCapture: () => startCapture(), // as S: one started over an open review follows it
167
180
  } : undefined
168
181
 
169
- const panelCard = ui.panel ? cards?.find((c) => c.id === ui.panel!.id) : undefined
182
+ const panelCard = ui.panel && ui.panel.kind !== 'thread' ? cards?.find((c) => c.id === ui.panel!.id) : undefined
170
183
  // a card ready to review, and the one whose review is open: its pictures load now, every frame's - its review opens
171
184
  // at their size and moves between frames without waiting (each URL once; never a card that is not in review)
172
185
  useEffect(() => {
@@ -193,6 +206,7 @@ export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
193
206
  // the microphone question in a session with no capture recording: under the Jam button
194
207
  const askAlone = voice.asking && !cap.current && !!session
195
208
  if (!shown && !ui.panel && !sheetOpen && !askAlone) return null
209
+ const panel = ui.panel
196
210
  // in play the lane folds to a counter beside the navigator (Q opens it); the capture recording stays
197
211
  const folded = playing && !ui.laneKeys
198
212
  return (
@@ -208,7 +222,7 @@ export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
208
222
  tiles={folded ? [] : tiles} recording={recording} between={between} selected={ui.selected ?? undefined} keyboard={ui.laneKeys} followEnd={ui.followEnd}
209
223
  doneOpen={ui.doneOpen} onDoneOpen={(open, ids) => ui.setDoneOpen(open, ids)}
210
224
  onOpen={(id) => openTile(id)}
211
- onMenu={(e, id) => { const c = cards?.find((x) => x.id === id); if (c) { ui.select(id); cm.open(e, tileMenu(c)) } else e.preventDefault() }}
225
+ onMenu={(e, id) => { const c = cards?.find((x) => x.id === id); if (c) { ui.select(id); cm.open(e, tileMenu(c), `tile:${id}`) } else e.preventDefault() }}
212
226
  ask={voice.asking && cap.current ? voiceAsk(voice) : undefined}
213
227
  caption={cap.current ? captionOf(voice.heard[cap.current]) : undefined}
214
228
  notes={cap.noteOpen ? {
@@ -217,6 +231,11 @@ export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
217
231
  } : undefined}
218
232
  />
219
233
  )}
234
+ {panel?.kind === 'thread' && (
235
+ <FocusPanel left={sidebarRight} onClose={() => ui.close()}>
236
+ <ThreadPanel key={`${panel.board}/${panel.id}`} board={panel.board} id={panel.id} />
237
+ </FocusPanel>
238
+ )}
220
239
  {ui.panel && panelCard && panelCard.kind === 'wrapup' && (
221
240
  <FocusPanel left={sidebarRight} onClose={() => ui.close()}>
222
241
  <RecordDetail key={panelCard.id} card={panelCard} agent={agentName} more={ui.moreOpen} of={detail?.of} onPrev={step(-1)} onNext={step(1)}
@@ -231,16 +250,16 @@ export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
231
250
  })()} />
232
251
  </FocusPanel>
233
252
  )}
234
- {ui.panel && panelCard && panelCard.kind !== 'wrapup' && (
253
+ {panel && panel.kind !== 'thread' && panelCard && panelCard.kind !== 'wrapup' && (
235
254
  <FocusPanelView
236
255
  left={sidebarRight}
237
- kind={ui.panel.kind}
256
+ kind={panel.kind}
238
257
  card={panelCard}
239
258
  of={detail?.of}
240
259
  agent={agentName}
241
260
  reviewedTitle={panelCard.reviewing ? cards?.find((c) => c.id === panelCard.reviewing!.card)?.title : undefined}
242
261
  lines={rec ? timelineLines(rec.record, panelCard.edited ?? rec.edited) : []}
243
- pictures={(rec?.record.pictures ?? []).map((id, i) => ({ id, url: picture(id)!, caption: `picture ${i + 1}` }))}
262
+ pictures={(rec?.record.pictures ?? []).map((id, i) => ({ id, url: picture(id)!, caption: pictureCaption(rec!.record, id, i + 1) }))}
244
263
  shots={changedShots(panelCard.shots).map((x) => ({ frame: x.frame, before: picture(x.before), after: picture(x.after), ...(x.new ? { new: true } : {}) }))}
245
264
  reply={panelCard.reply ? replyText(panelCard) : ''}
246
265
  view={ui.view} tab={ui.tab} moreOpen={ui.moreOpen}
@@ -275,6 +294,58 @@ export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
275
294
  )
276
295
  }
277
296
 
297
+ /**
298
+ * A thread no card on the canvas can show (spec 28 A4.6 #30, r1 #3, r2 #2, r3 #1): a question with no frame, one whose
299
+ * frame left its board, an early question while its card still works, a resolved thread. Its root line, its last
300
+ * message, the status of each Jam comment card on it - the thread card's own icon, tooltip and popover, so its Retry or
301
+ * its three choices act as there - and a field that answers in the thread: with @marver when a Jam card is on the
302
+ * thread (the answer carries the work on, as the capture panel's does), as typed otherwise (a tag would start a run
303
+ * nobody asked for). Resolved, it reads only - "Resolved", no field: a reply would land in a closed thread and reopen
304
+ * nothing - and its cards' status stays, since a resolve keeps a working card running.
305
+ */
306
+ function ThreadPanel({ board, id }: { board: string; id: string }) {
307
+ const t = useComments((s) => s.threads.find((x) => x.id === id && (!x.board || x.board === board)))
308
+ const cards = useJamQueue((s) => s.cards)
309
+ const frame = useStore((s) => (t?.frame ? s.manifest?.frames.find((f) => f.id === t.frame)?.title ?? t.frame : null))
310
+ const onThread = (cards ?? []).filter((c) => c.board === board && c.thread === id)
311
+ const line = (b?: string) => (b ?? '').replace(/\s+/g, ' ').trim()
312
+ const last = t && t.replies.length ? t.replies[t.replies.length - 1] : t
313
+ return (
314
+ <div className="jm-panel jm-thread" data-jam-thread-panel={id} {...(t?.resolved ? { 'data-resolved': '' } : {})}>
315
+ <div className="top">
316
+ <h3>{frame ?? 'Thread'}</h3>
317
+ {t?.resolved && <span className="dim" data-jam-thread-resolved="">Resolved</span>}
318
+ </div>
319
+ <div className="jm-body">
320
+ {!t ? <p>This thread is gone.</p> : <>
321
+ <div className="jm-reply" data-jam-thread-root="">
322
+ {t.agent ? <Marver size={20} /> : <Avatar author={t.author} size={20} />}
323
+ <p>{line(t.body)}</p>
324
+ </div>
325
+ {last && last !== t && (
326
+ <div className="jm-reply" data-jam-thread-last="">
327
+ {last.agent ? <Marver size={20} /> : <Avatar author={last.author} size={20} />}
328
+ <p>{last.body}</p>
329
+ </div>
330
+ )}
331
+ {/* each Jam comment card's status, by its tag's time in the thread card: here the same icon and popover */}
332
+ {onThread.filter((c) => c.kind === 'comment').map((c) => (
333
+ <div key={c.id} className="jm-thread-status"><TagStatus board={board} eventId={c.events[c.events.length - 1]} harness={HARNESS} /></div>
334
+ ))}
335
+ {!t.resolved && (
336
+ <AsksAnswer tag={onThread.length > 0} onAnswer={async (text) => {
337
+ const body = onThread.length && !/@marver\b/i.test(text) ? `@marver ${text}` : text
338
+ const ok = await useComments.getState().replyOk(id, body)
339
+ if (!ok) useStore.getState().toast('your answer was not sent - try again')
340
+ return ok
341
+ }} />
342
+ )}
343
+ </>}
344
+ </div>
345
+ </div>
346
+ )
347
+ }
348
+
278
349
  /** In play: just right of the stage's navigator (its restart and frame arrows), where the counter sits. */
279
350
  function playNavRight(): number {
280
351
  const r = document.querySelector('.sh-play-nav')?.getBoundingClientRect()
@@ -164,6 +164,11 @@ export const playCtl = {
164
164
  setAt: (_at: string) => {},
165
165
  /** Apply a parsed play hash to the OPEN session - at, device, and theme alike. */
166
166
  sync: (_p: { at?: string; device?: string; theme?: string }) => {},
167
+ /** Leave play as its own Esc does: then back on the canvas at the frame you ended on */
168
+ exit: () => {},
169
+ /** Leave play and nothing more - no way back to its frame (no fit, no board switch): a notice's click opening something
170
+ * on the canvas owns what moves next (spec 28 A4.6 r4 #1; code review r2 P1). False on a board with no way out. */
171
+ leave: (): boolean => false,
167
172
  }
168
173
 
169
174
  export function PlayOverlay() {
@@ -351,14 +356,19 @@ function PlayInner() {
351
356
  useEffect(() => { postStage({ type: 'sh:laser', on: laser, inspect: laserInspect }) }, [laser, laserInspect])
352
357
  useEffect(() => { postStage({ type: 'sh:pick', on: commentMode, quiet: !useComments.getState().showAnchor }) }, [commentMode, playShowAnchor])
353
358
 
354
- const exit = () => {
359
+ /** Play torn down, nothing more: false where there is no way out */
360
+ const leave = (): boolean => {
355
361
  // the lock caps disclosure: a locked board has no way out into other modes,
356
362
  // and a deep-link visit carries no door on the surface (URL still works)
357
- if (noDoor) return
363
+ if (noDoor) return false
358
364
  frozenDeck = null
359
- const { at } = useStore.getState().play ?? {}
360
365
  if (isHideUI()) toggleHideUI() // never strand the canvas with its chrome hidden
361
366
  useStore.getState().setPlay(null)
367
+ return true
368
+ }
369
+ const exit = () => {
370
+ const { at } = useStore.getState().play ?? {}
371
+ if (!leave()) return
362
372
  // land back on the canvas at the frame you ended on
363
373
  const n = useStore.getState().nodes.find((x) => x.frame === at && !x.missing)
364
374
  if (n) { useStore.getState().select(n.key); setTimeout(() => canvasCtl.fitNode(n.key), 30) }
@@ -448,7 +458,9 @@ function PlayInner() {
448
458
  if (p.theme && p.theme !== cur.theme) setTheme(p.theme)
449
459
  if (p.at && p.at !== cur.at) playCtl.setAt(p.at)
450
460
  }
451
- return () => { playCtl.setAt = () => {}; playCtl.sync = () => {} }
461
+ playCtl.exit = exit
462
+ playCtl.leave = leave
463
+ return () => { playCtl.setAt = () => {}; playCtl.sync = () => {}; playCtl.exit = () => {}; playCtl.leave = () => false }
452
464
  }, [])
453
465
 
454
466
  // messages from the stage; source-validated against our one iframe
@@ -207,12 +207,16 @@ export const resumed: { outcome: ResumeOutcome; board?: string; camera?: { x: nu
207
207
  // words a person typed into the page and has not sent (a comment, a Jam edit, a name): a reload would drop them
208
208
  const typed = new WeakSet<EventTarget>()
209
209
  const TEXT_FIELDS = 'textarea, input:not([type]), input[type=text], input[type=search], input[type=email], input[type=url], input[type=password]'
210
+ /** Does a text field on the page hold words typed and not sent? The `typing` reason's own check, and what a notice's
211
+ * click reads before every move (spec 28 A4.6 #30, r2 #1): a board change, another thread or a panel replaced would
212
+ * unmount the field and lose them. Words the shell keeps with no field on screen (a More work draft, a read-back's
213
+ * edit still saving) are not here: they survive a move. */
214
+ export const typedUnsent = (): boolean => [...document.querySelectorAll<HTMLInputElement | HTMLTextAreaElement>(TEXT_FIELDS)].some((el) => typed.has(el) && el.value.trim() !== '')
210
215
  if (WS) {
211
216
  document.addEventListener('input', (e) => { if (e.target) typed.add(e.target); if (canvasStopped()) noteUnsaved(); workChanged() }, true)
212
- const typedWords = () => [...document.querySelectorAll<HTMLInputElement | HTMLTextAreaElement>(TEXT_FIELDS)].some((el) => typed.has(el) && el.value.trim() !== '')
213
- holdsReload(typedWords)
217
+ holdsReload(typedUnsent)
214
218
  // and leaving the page asks first (spec 28 A2.9): the words are only here
215
- unsavedWhen('typing', typedWords)
219
+ unsavedWhen('typing', typedUnsent)
216
220
  }
217
221
 
218
222
  // one question before this page goes, whatever it holds that the server does not have (unsaved.ts): a capture, a
@@ -17,7 +17,10 @@
17
17
  * name, never as an accelerator, so the key stays the page's (A2.7); a click replays that key, so the menu does
18
18
  * exactly what the key does;
19
19
  * - `mv:app-state`: `shown` runs a resume reconcile, `untrusted` stops every microphone track the page holds (A2.14
20
- * #13), `hidden` changes nothing (a hidden tab keeps running, A2.6).
20
+ * #13), `hidden` changes nothing (a hidden tab keeps running, A2.6) - but each of the two ends a notice's click in
21
+ * hand (A4.6 #30);
22
+ * - `mv:open` (app 0.3, A4.6 #29, #30): a notice's click, opened by open-item.ts and answered as `mv:opened`. An app
23
+ * without `onOpen` never sends one, and nothing here waits for it.
21
24
  *
22
25
  * The one ground (0.27.2, A3.8 #27, #31): `mv:hello` says the inset the shell applied (inset.ts's `TOP`: 44 only when
23
26
  * the app said so and gave the whole presentation contract), and each `mv:present { epoch, w, h, frames }` is answered
@@ -40,6 +43,7 @@ import { useJamCapture } from './jam-capture.ts'
40
43
  import { useJamQueue } from './jam-queue.ts'
41
44
  import { useJamUi } from './jam-state.ts'
42
45
  import { useJamVoice, voiceUntrusted } from './jam-voice.ts'
46
+ import { endOpen, openLiveItem } from './open-item.ts'
43
47
 
44
48
  /** The ground under the strip (A2.14 #26): the shell's own - never a frame's pinned theme. */
45
49
  export const shellDark = (): boolean => { const s = useStore.getState(); return !!s.play || s.viewTheme === 'dark' }
@@ -173,8 +177,10 @@ export async function resumeReconcile(): Promise<void> {
173
177
  }
174
178
 
175
179
  function onAppState(s: AppState): void {
176
- if (s === 'shown') void resumeReconcile()
177
- else if (s === 'untrusted') voiceUntrusted()
180
+ if (s === 'shown') { void resumeReconcile(); return }
181
+ // a notice's click still reading or waiting moves nothing more once the tab is hidden or its trust is gone
182
+ endOpen()
183
+ if (s === 'untrusted') voiceUntrusted()
178
184
  }
179
185
 
180
186
  // ---- the bridge ---------------------------------------------------------------------------------------------
@@ -193,6 +199,8 @@ export function startAppBridge(): void {
193
199
  // what the app says, listened for before the page says anything
194
200
  call(() => app.onAppState((s) => onAppState(s)))
195
201
  call(() => app.onMenuClick((p) => runMenuItem(typeof p?.id === 'string' ? p.id : '')))
202
+ // a notice's click (A4.6 #29, #30): the exact item, resolved against fresh reads and answered
203
+ if (typeof app.onOpen === 'function') call(() => { app.onOpen!((p) => openLiveItem(p)) })
196
204
  // the one ground's presentation requests (0.27.2): answered only when the shell took the inset - a shell that did
197
205
  // not is placed below the strip and never asked (A3.8 #31)
198
206
  if (TOP) call(() => { answerPresents(app, call) })
@@ -59,6 +59,9 @@ interface CommentsState {
59
59
  * path as the poll, so dedup + the reply notification behave identically. ANY board:
60
60
  * notifications must reach the user wherever they are on the canvas. */
61
61
  poke(board?: string): void
62
+ /** Read a board's log now and answer whether the read succeeded (spec 28 A4.6 #30): `poke`'s read, awaited, its
63
+ * events merged - the board, the open thread and a draft stay as they are (never `load`, which clears them first). */
64
+ refresh(board: string): Promise<boolean>
62
65
  /** A thread by id, from any board's log - one sweep first when it is not loaded yet. */
63
66
  findThread(id: string): Promise<Thread | null>
64
67
  /** `board` routes the write to a thread's ORIGIN log; default = the active board. */
@@ -253,6 +256,17 @@ export const useComments = create<CommentsState>((set, get) => {
253
256
  })
254
257
  },
255
258
 
259
+ async refresh(board) {
260
+ if (!board || apiOff || board === UNPLACED) return false
261
+ try {
262
+ const r = await api(`comments/${board}`)
263
+ if (!r.ok) return false
264
+ union(stamped(r.data.events, board))
265
+ baselinedBoards.add(board)
266
+ return true
267
+ } catch { return false }
268
+ },
269
+
256
270
  async load(board) {
257
271
  // threads are frame-scoped and global - a board switch keeps them all (the same
258
272
  // frame on another board keeps its pins); only the open card and a draft reset
@@ -72,9 +72,10 @@ export const isLatest = (seq: number): boolean => seq === gotoSeq
72
72
  * notification's View: the switch is navigation `nav`'s (a new one, unless the caller took it at its own start, before
73
73
  * a lookup), and true only once it landed with nothing newer since. What the caller does on the board - select, set a
74
74
  * mode, enter play, move the camera - waits for true: a switch a newer navigation cancelled comes back too, and may
75
- * find the board it asked for, the newer one's by then. */
76
- export async function switchFor(board: string, nav: number = navigated()): Promise<boolean> {
77
- await useStore.getState().switchBoard(board)
75
+ * find the board it asked for, the newer one's by then. `mayCommit`: the caller's own condition, read just before the
76
+ * board commits - false keeps the board shown (a notice's request, jam-keys.ts toBoard). */
77
+ export async function switchFor(board: string, nav: number = navigated(), mayCommit?: () => boolean): Promise<boolean> {
78
+ await useStore.getState().switchBoard(board, mayCommit)
78
79
  return isLatest(nav) && useStore.getState().board === board
79
80
  }
80
81
  /** The camera to a node once it is drawn - unless a newer navigation has it by then. */
@@ -25,6 +25,7 @@ import { onStageSize, stageSize } from './stage-size.ts'
25
25
  import { api, holdsReload } from './api.ts'
26
26
  import { unsavedWhen, workChanged } from './unsaved.ts'
27
27
  import { bytesOf } from './recorder-core.ts'
28
+ import { LIVE_PICTURE_MS, liveAsk, takeLive } from './live-picture.ts'
28
29
 
29
30
  const csrf = () => /(?:^|;\s*)mv_c=([\w-]+)/.exec(document.cookie)?.[1] ?? ''
30
31
  const now = () => performance.timeOrigin + performance.now()
@@ -94,8 +95,9 @@ interface Cap {
94
95
  pictures: string[]
95
96
  probes: number // probe answers still out
96
97
  shots: number // picture requests still out
97
- /** its timing (spec 27a Part D): when E was pressed, the wait for its last words, each picture's time, the missing ones */
98
- timing?: { endAt?: number; wordsMs?: number; pics: number[]; late: number; failed: number }
98
+ /** its timing (spec 27a Part D): when E was pressed, the wait for its last words, each picture's time, the missing ones;
99
+ * `live` (A4.6 #36): the app's pictures of the stage kept, the ones that failed, and the renders that replaced them */
100
+ timing?: { endAt?: number; wordsMs?: number; pics: number[]; late: number; failed: number; live?: { count: number; failed: number; fellBack: number } }
99
101
  shotFrames: string[] // frames pictured (or being pictured) in it: an automatic picture is taken once per frame
100
102
  review?: boolean // ended with ⇧E: it waits for its read-back (E: queued once sealed)
101
103
  endShot?: boolean // its end pictures were asked for (once its steps were all in)
@@ -520,12 +522,20 @@ let pointerAt: { key: string; at: number } | null = null
520
522
 
521
523
  // ---- pictures ------------------------------------------------------------------------------------------
522
524
 
525
+ /**
526
+ * One picture of `frame` - one bounded operation with one settlement, counted in `shots` from its start, so the seal
527
+ * waits for it (A4.6 #36): in the Mac app, when the shot is eligible (live-picture.ts, decided here at the trigger), the
528
+ * app's picture of the stage and its upload, under one deadline; on any failure there - and everywhere else - the
529
+ * server's render, as in 0.28. One step at the end: a picture (`source: 'live'` for a live one), or the render's
530
+ * missing step when that fails too; a live failure alone adds none.
531
+ */
523
532
  function shoot(id: string, frame: string, why: 'key' | 'pick' | 'end', key?: string) {
524
533
  const c = capOf(id)
525
534
  if (!c || c.pictures.length + c.shots >= MAX_PICTURES) return
526
535
  // each picture is a render on the server, and the capture waits for it as it ends: a point or the end
527
536
  // pictures a frame once - only I asks for another
528
537
  if (why !== 'key' && c.shotFrames.includes(frame)) return
538
+ const live = liveAsk(frame)
529
539
  // the instance pictured is the one this frame is about (its size for the run's pictures)
530
540
  // (an I picture is a touch at this instant: a hover from before it, answering late, never overrides it)
531
541
  const touchAt = now()
@@ -543,29 +553,43 @@ function shoot(id: string, frame: string, why: 'key' | 'pick' | 'end', key?: str
543
553
  const theme = st.play && st.play.at === frame ? st.play.theme : n?.theme ?? st.viewTheme
544
554
  mutate((s) => { const x = s.caps[id]; if (x) x.shots += 1 })
545
555
  const t0 = performance.now()
546
- const done = (pid: string | null, late: boolean) => {
556
+ const done = (pid: string | null, late: boolean, source?: 'live') => {
547
557
  mutate((s) => {
548
558
  const x = s.caps[id]
549
559
  if (!x) return
550
560
  x.shots -= 1
551
561
  const tm = (x.timing ??= { pics: [], late: 0, failed: 0 })
552
562
  if (pid) tm.pics.push(Math.round(performance.now() - t0)); else if (late) tm.late++; else tm.failed++
553
- if (pid) { x.pictures.push(pid); x.steps.push({ at, frame, event: 'picture', id: pid, why }) }
563
+ if (live) { const l = (tm.live ??= { count: 0, failed: 0, fellBack: 0 }); if (source) l.count++; else { l.failed++; if (pid) l.fellBack++ } }
564
+ if (pid) { x.pictures.push(pid); x.steps.push({ at, frame, event: 'picture', id: pid, why, ...(source ? { source } : {}) }) }
554
565
  else x.steps.push({ at, frame, event: 'missing', what: `no picture of ${frame} - ${late ? `it took over ${PICTURE_MS / 1000} s` : 'the render failed'}` })
555
566
  })
556
567
  trySeal(id)
557
568
  }
569
+ const render = () => {
570
+ const ctl = new AbortController()
571
+ const timer = setTimeout(() => ctl.abort(), PICTURE_MS)
572
+ // settled exactly once - a picture, or a missing one - whatever fails: the request, its body, the abort
573
+ let settled = false
574
+ const finish = (pid: string | null) => { if (settled) return; settled = true; clearTimeout(timer); done(pid, ctl.signal.aborted) }
575
+ api('jam/picture', {
576
+ method: 'POST', signal: ctl.signal, headers: { 'content-type': 'application/json', 'x-mv-c': csrf() },
577
+ body: JSON.stringify({ capture: id, frame, theme, ...(size ? { w: Math.round(size.width), h: Math.round(size.height) } : {}) }),
578
+ }).then(async (r) => (r.ok ? ((await r.json()) as { id?: string }).id ?? null : null))
579
+ .catch(() => null)
580
+ .then((pid) => finish(typeof pid === 'string' ? pid : null))
581
+ }
582
+ if (!live) { render(); return }
583
+ // the call and the upload under one deadline; a result after it is dropped, and the render starts. Sealed meanwhile
584
+ // (the page left: sealOnLeave sealed it as it stood), nothing changes
558
585
  const ctl = new AbortController()
559
- const timer = setTimeout(() => ctl.abort(), PICTURE_MS)
560
- // settled exactly once - a picture, or a missing one - whatever fails: the request, its body, the abort
561
- let settled = false
562
- const finish = (pid: string | null) => { if (settled) return; settled = true; clearTimeout(timer); done(pid, ctl.signal.aborted) }
563
- api('jam/picture', {
564
- method: 'POST', signal: ctl.signal, headers: { 'content-type': 'application/json', 'x-mv-c': csrf() },
565
- body: JSON.stringify({ capture: id, frame, theme, ...(size ? { w: Math.round(size.width), h: Math.round(size.height) } : {}) }),
566
- }).then(async (r) => (r.ok ? ((await r.json()) as { id?: string }).id ?? null : null))
567
- .catch(() => null)
568
- .then((pid) => finish(typeof pid === 'string' ? pid : null))
586
+ const timer = setTimeout(() => ctl.abort(), LIVE_PICTURE_MS)
587
+ void takeLive(live, id, () => !!capOf(id), ctl.signal).then((pid) => {
588
+ clearTimeout(timer)
589
+ if (!capOf(id)) return
590
+ if (pid && !ctl.signal.aborted) done(pid, false, 'live')
591
+ else render()
592
+ })
569
593
  }
570
594
 
571
595
  // ---- start, end, seal ----------------------------------------------------------------------------------
@@ -779,7 +803,7 @@ function timeCapture(c: Cap, interrupted: boolean) {
779
803
  const t = c.timing
780
804
  perf({ kind: 'capture', capture: c.id, ...(t?.endAt !== undefined && !interrupted ? { sealMs: performance.now() - t.endAt } : {}),
781
805
  ...(t?.wordsMs !== undefined ? { wordsWaitMs: t.wordsMs } : {}),
782
- pictures: { count: t?.pics.length ?? 0, ms: t?.pics ?? [], late: t?.late ?? 0, failed: t?.failed ?? 0 }, ...(interrupted ? { interrupted: true } : {}) }, interrupted)
806
+ pictures: { count: t?.pics.length ?? 0, ms: t?.pics ?? [], late: t?.late ?? 0, failed: t?.failed ?? 0, ...(t?.live ? { live: t.live } : {}) }, ...(interrupted ? { interrupted: true } : {}) }, interrupted)
783
807
  }
784
808
  const uploadTries = new Map<string, number>()
785
809