@marver-design/marver 0.27.2 → 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 (91) hide show
  1. package/CHANGELOG.md +160 -0
  2. package/README.md +6 -4
  3. package/dist/{anchor-check-gkxkPAIv.mjs → anchor-check-DhlpKl2K.mjs} +1 -1
  4. package/dist/{audio-Dw1lfMdb.mjs → audio-DX4POHAj.mjs} +39 -4
  5. package/dist/{boards-BqUqKNW8.mjs → boards-BeWtjGUM.mjs} +49 -4
  6. package/dist/boards-EH2onUXM.mjs +995 -0
  7. package/dist/{build-VgNg4rr8.mjs → build-CWbrb2bl.mjs} +9 -5
  8. package/dist/{capture-vadKjuCo.mjs → capture-DEtM4qm5.mjs} +259 -34
  9. package/dist/cli.mjs +40 -19
  10. package/dist/{comments-YEU1Zhv9.mjs → comments-XNhMmSSu.mjs} +4 -4
  11. package/dist/config-BezZTiov.mjs +182 -0
  12. package/dist/conn-BMiHS42T.mjs +222 -0
  13. package/dist/connectors-DekQvKt9.mjs +292 -0
  14. package/dist/{context-Ccjrhr1J.mjs → context-BUnFiyA3.mjs} +2 -2
  15. package/dist/{daemon-Dc9AH0M3.mjs → daemon-Sc_z8gT6.mjs} +2209 -205
  16. package/dist/{dev-ri6nAlRp.mjs → dev-DWBKQhxf.mjs} +31 -15
  17. package/dist/{init-W0nxR1OY.mjs → init-CYlFaRzG.mjs} +7 -2
  18. package/dist/jam-Cj5gBvwD.mjs +373 -0
  19. package/dist/{link-CdTgn94Y.mjs → link-BFFRgrMt.mjs} +3 -3
  20. package/dist/listener-DdLEM79A.mjs +80 -0
  21. package/dist/logo-CXY-1yrn.mjs +305 -0
  22. package/dist/{ls-BZ5TAtd5.mjs → ls-NqmePKOf.mjs} +1 -1
  23. package/dist/{manifest-aFyDmL8C.mjs → manifest-DPZ3WNg_.mjs} +1 -1
  24. package/dist/{marks-CnCCfAbD.mjs → marks-BnNANic9.mjs} +22 -3
  25. package/dist/{marks-BF9pNEgH.mjs → marks-DBp3h1Mc.mjs} +3 -6
  26. package/dist/{marver-id-gate-D-R0hSt_.mjs → marver-id-gate-vBLb_Icb.mjs} +1 -1
  27. package/dist/{perf-DkAUFT6W.mjs → perf-Denssrko.mjs} +45 -27
  28. package/dist/{perf-jam-BaH3Lg0m.mjs → perf-jam-CLkERSHo.mjs} +9 -2
  29. package/dist/permit-DDa6wqOs.mjs +187 -0
  30. package/dist/{plugin-B8UghYuF.mjs → plugin-DqoZB-D6.mjs} +849 -789
  31. package/dist/{poster-BNgafWMK.mjs → poster-CrsjqhY4.mjs} +1 -1
  32. package/dist/{profile-jIS6BcAs.mjs → profile-B1FKOM1e.mjs} +1 -1
  33. package/dist/{publish-bakes-38Nja78p.mjs → publish-bakes-DW-NDgU2.mjs} +3 -3
  34. package/dist/{queue-CAM_vNmX.mjs → queue-DeSQm24g.mjs} +189 -35
  35. package/dist/{recover-B8AiI29B.mjs → recover-GtJ9UDAB.mjs} +2 -2
  36. package/dist/{serve-Dp3nHstu.mjs → serve-DQv3Ti6X.mjs} +8 -4
  37. package/dist/{session-BAaJsK5c.mjs → session-VDJfXEEm.mjs} +1 -1
  38. package/dist/{share-Ce4tP7ji.mjs → share-Bu_kuOKL.mjs} +1 -1
  39. package/dist/{shot-CMQgMVZm.mjs → shot-DBWN8hPP.mjs} +1 -1
  40. package/dist/{shot-Ch24tiMO.mjs → shot-T04Ixrvq.mjs} +7 -6
  41. package/dist/sizes-wjXDev3b.mjs +139 -0
  42. package/dist/{slots-CFNnegCc.mjs → slots-Dn4Onb0V.mjs} +101 -3
  43. package/dist/speech-worker.mjs +23 -3
  44. package/dist/{sync-CQdGARJ9.mjs → sync-CMozOwZ0.mjs} +1 -1
  45. package/dist/transport-C5FnY9ni.mjs +203 -0
  46. package/dist/{work-Bxz-ObF3.mjs → work-BYWD_1Zf.mjs} +3 -3
  47. package/dist/{work-CNhFF9pU.mjs → work-DJxH7cCX.mjs} +1 -1
  48. package/docs/boards-and-folders.md +11 -0
  49. package/docs/jam-session.md +52 -18
  50. package/docs/live-jam.md +95 -10
  51. package/docs/performance.md +1 -1
  52. package/docs/publish.md +7 -0
  53. package/package.json +1 -1
  54. package/src/client/shell/Comments.tsx +5 -4
  55. package/src/client/shell/ContextMenu.tsx +5 -4
  56. package/src/client/shell/JamSurface.tsx +135 -29
  57. package/src/client/shell/Play.tsx +16 -4
  58. package/src/client/shell/api.ts +7 -3
  59. package/src/client/shell/app-bridge.ts +11 -3
  60. package/src/client/shell/comments-store.ts +14 -0
  61. package/src/client/shell/goto.ts +4 -3
  62. package/src/client/shell/icons.tsx +1 -0
  63. package/src/client/shell/jam-capture.ts +136 -37
  64. package/src/client/shell/jam-keys.ts +170 -18
  65. package/src/client/shell/jam-lane.tsx +14 -5
  66. package/src/client/shell/jam-lines.ts +76 -10
  67. package/src/client/shell/jam-panel.tsx +58 -4
  68. package/src/client/shell/jam-queue.ts +55 -8
  69. package/src/client/shell/jam-session.tsx +55 -6
  70. package/src/client/shell/jam-state.ts +19 -4
  71. package/src/client/shell/jam-surface-parts.tsx +6 -3
  72. package/src/client/shell/jam-ui.tsx +10 -1
  73. package/src/client/shell/jam-voice-wait.ts +21 -0
  74. package/src/client/shell/jam-voice.ts +14 -5
  75. package/src/client/shell/live-picture.ts +134 -0
  76. package/src/client/shell/open-item.ts +83 -0
  77. package/src/client/shell/open-resolve.ts +50 -0
  78. package/src/client/shell/store.ts +6 -2
  79. package/src/client/shell/styles.css +29 -11
  80. package/src/client/shell/tidy.ts +3 -2
  81. package/src/client/stage/main.tsx +30 -8
  82. package/src/shared/app-api.ts +173 -3
  83. package/src/shared/app-perf.ts +4 -2
  84. package/src/shared/approval.ts +20 -0
  85. package/src/shared/events.ts +1 -1
  86. package/templates/AGENTS-embedded.md +28 -1
  87. package/templates/AGENTS-studio.md +28 -1
  88. package/templates/instructions/boards.md +7 -1
  89. package/templates/instructions/jam.md +94 -0
  90. package/dist/boards-BHKP5yhI.mjs +0 -342
  91. package/dist/live-Cgzsicwi.mjs +0 -4
@@ -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,9 +95,11 @@ 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
102
+ review?: boolean // ended with ⇧E: it waits for its read-back (E: queued once sealed)
100
103
  endShot?: boolean // its end pictures were asked for (once its steps were all in)
101
104
  inherited?: string[] // Resume: the frames the capture it continues was about (its card's)
102
105
  endSizes?: Record<string, { w: number; h: number; play?: true }> // the sizes as they were at E (what it was about, then)
@@ -125,16 +128,20 @@ interface CaptureState {
125
128
  /** Start one - never while one records (it says so instead) */
126
129
  /** `session`: the session it belongs to, when the caller knows it before the queue shows it (Start) */
127
130
  start(reviewing?: Cap['reviewing'], session?: string): void
128
- end(): void
131
+ /** E: it goes straight to the queue once it seals; ⇧E (`review`): its read-back opens to check and add to first */
132
+ end(review?: boolean): void
129
133
  drop(): void
130
134
  note(text: string): void
131
135
  setNoteOpen(open: boolean): void
132
136
  setNoteDraft(text: string): void
133
137
  picture(frame?: string): void
134
- /** the drafts sealed, in order - their read-backs open when capturing stops */
135
- sealed: { id: string; card?: { id: string; rev: number } }[]
138
+ /** the captures sealed, in order, and the card the server made of each - the read-back of one stopped to review
139
+ * (`review`: ⇧E, or J's wrap-up) opens when capturing stops; one stopped with E never opens anything */
140
+ sealed: { id: string; card?: { id: string; rev: number }; review?: true }[]
136
141
  /** sealed captures the server does not hold yet (kept, sent again until it takes them) */
137
142
  unsent: string[]
143
+ /** the server did not answer the last send: what is unsent waits for it (sent again every 5 s) */
144
+ away: boolean
138
145
  /** Continue a draft that ended too soon: its record is loaded and recording goes on from where it
139
146
  * stopped, under a new id that takes the draft's place when it seals. Dropping it leaves the draft. */
140
147
  resume(draft: string, ready?: () => Promise<boolean>): Promise<boolean>
@@ -144,7 +151,8 @@ interface CaptureState {
144
151
  * locked meanwhile, so nothing typed can race the start - set by the caller (resumeDraft) before its
145
152
  * first wait, cleared when the Resume is over */
146
153
  settling: string | null
147
- /** the capture ended last (E): its read-back is the one that opens, whatever seals first */
154
+ /** the capture ended last (E or ⇧E): if it was stopped to review, its read-back is the one that opens, whatever
155
+ * seals first */
148
156
  lastEnded: string | null
149
157
  }
150
158
 
@@ -514,12 +522,20 @@ let pointerAt: { key: string; at: number } | null = null
514
522
 
515
523
  // ---- pictures ------------------------------------------------------------------------------------------
516
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
+ */
517
532
  function shoot(id: string, frame: string, why: 'key' | 'pick' | 'end', key?: string) {
518
533
  const c = capOf(id)
519
534
  if (!c || c.pictures.length + c.shots >= MAX_PICTURES) return
520
535
  // each picture is a render on the server, and the capture waits for it as it ends: a point or the end
521
536
  // pictures a frame once - only I asks for another
522
537
  if (why !== 'key' && c.shotFrames.includes(frame)) return
538
+ const live = liveAsk(frame)
523
539
  // the instance pictured is the one this frame is about (its size for the run's pictures)
524
540
  // (an I picture is a touch at this instant: a hover from before it, answering late, never overrides it)
525
541
  const touchAt = now()
@@ -537,29 +553,43 @@ function shoot(id: string, frame: string, why: 'key' | 'pick' | 'end', key?: str
537
553
  const theme = st.play && st.play.at === frame ? st.play.theme : n?.theme ?? st.viewTheme
538
554
  mutate((s) => { const x = s.caps[id]; if (x) x.shots += 1 })
539
555
  const t0 = performance.now()
540
- const done = (pid: string | null, late: boolean) => {
556
+ const done = (pid: string | null, late: boolean, source?: 'live') => {
541
557
  mutate((s) => {
542
558
  const x = s.caps[id]
543
559
  if (!x) return
544
560
  x.shots -= 1
545
561
  const tm = (x.timing ??= { pics: [], late: 0, failed: 0 })
546
562
  if (pid) tm.pics.push(Math.round(performance.now() - t0)); else if (late) tm.late++; else tm.failed++
547
- 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 } : {}) }) }
548
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'}` })
549
566
  })
550
567
  trySeal(id)
551
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
552
585
  const ctl = new AbortController()
553
- const timer = setTimeout(() => ctl.abort(), PICTURE_MS)
554
- // settled exactly once - a picture, or a missing one - whatever fails: the request, its body, the abort
555
- let settled = false
556
- const finish = (pid: string | null) => { if (settled) return; settled = true; clearTimeout(timer); done(pid, ctl.signal.aborted) }
557
- api('jam/picture', {
558
- method: 'POST', signal: ctl.signal, headers: { 'content-type': 'application/json', 'x-mv-c': csrf() },
559
- body: JSON.stringify({ capture: id, frame, theme, ...(size ? { w: Math.round(size.width), h: Math.round(size.height) } : {}) }),
560
- }).then(async (r) => (r.ok ? ((await r.json()) as { id?: string }).id ?? null : null))
561
- .catch(() => null)
562
- .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
+ })
563
593
  }
564
594
 
565
595
  // ---- start, end, seal ----------------------------------------------------------------------------------
@@ -688,7 +718,8 @@ function drain(id: string) {
688
718
  const st = useStore.getState()
689
719
  if (st.play) { mutate((s) => { const x = s.caps[id]; if (x) x.endShot = true }); shoot(id, st.play.at, 'end') }
690
720
  broadcast({ type: 'sh:capture', id, on: false })
691
- // the audio is cut at the key press, then its last words are awaited (3 s at most)
721
+ // the audio is cut at the key press, then its last words are awaited (15 s at most - E queues it only once they
722
+ // are in its record, as ⇧E's read-back shows them)
692
723
  mutate((st) => { const x = st.caps[id]; if (x) x.hearing = true })
693
724
  const tWords = performance.now()
694
725
  void voiceEnd(id).then((complete) => {
@@ -772,7 +803,7 @@ function timeCapture(c: Cap, interrupted: boolean) {
772
803
  const t = c.timing
773
804
  perf({ kind: 'capture', capture: c.id, ...(t?.endAt !== undefined && !interrupted ? { sealMs: performance.now() - t.endAt } : {}),
774
805
  ...(t?.wordsMs !== undefined ? { wordsWaitMs: t.wordsMs } : {}),
775
- 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)
776
807
  }
777
808
  const uploadTries = new Map<string, number>()
778
809
 
@@ -782,7 +813,7 @@ function buildRecord(c: Cap, steps: Cap['steps'], interrupted = false): CaptureR
782
813
  const timeline = [...steps].sort((a, b) => a.at - b.at || (a.seq ?? 0) - (b.seq ?? 0)).map(({ seq: _s, src: _k, ...step }) => step as Step)
783
814
  return {
784
815
  format: 'marver.jam.capture', v: 1, id: c.id,
785
- context: { canvas: location.host, board: c.board, ...(c.session ? { session: c.session } : {}), ...(c.reviewing ? { reviewing: c.reviewing } : {}), ...(c.resumes ? { resumes: c.resumes } : {}), ...(interrupted ? { interrupted: true as const } : {}) },
816
+ context: { canvas: location.host, board: c.board, ...(c.session ? { session: c.session } : {}), ...(c.reviewing ? { reviewing: c.reviewing } : {}), ...(c.resumes ? { resumes: c.resumes } : {}), ...(interrupted ? { interrupted: true as const } : {}), ...(c.review ? { review: true as const } : {}) },
786
817
  view: (timeline.find((x) => x.event === 'view') as Extract<Step, { event: 'view' }> | undefined)?.view ?? {},
787
818
  timeline, pictures: c.pictures, ...(() => { const sizes = sealedSizes(c); return Object.keys(sizes).length ? { sizes } : {} })(),
788
819
  }
@@ -799,7 +830,7 @@ function trySeal(id: string) {
799
830
  const record = buildRecord(c2, c2.steps)
800
831
  timeCapture(c2, false)
801
832
  // sealed: drop everything for this id that arrives later
802
- useJamCapture.setState((st) => { const caps = { ...st.caps }; delete caps[id]; return { caps, tick: st.tick + 1, sealed: [...st.sealed, { id }] } })
833
+ useJamCapture.setState((st) => { const caps = { ...st.caps }; delete caps[id]; return { caps, tick: st.tick + 1, sealed: [...st.sealed, { id, ...(c2.review ? { review: true as const } : {}) }] } })
803
834
  forgetHeard(id)
804
835
  keepSealed(record)
805
836
  void upload(record)
@@ -815,13 +846,19 @@ const syncUnsent = () => useJamCapture.setState({ unsent: [...pendingUploads.key
815
846
  * the pagehide listeners run in. */
816
847
  export const capturesPending = (): boolean => { const s = useJamCapture.getState(); return s.unsent.length > 0 || Object.keys(s.caps).length > 0 }
817
848
  const keepSealed = (r: CaptureRecord) => { try { const all = JSON.parse(localStorage.getItem(KEPT) ?? '{}'); all[r.id] = r; localStorage.setItem(KEPT, JSON.stringify(all)) } catch { /* memory only */ } pendingUploads.set(r.id, r); syncUnsent() }
818
- const forgetSealed = (id: string) => { pendingUploads.delete(id); syncUnsent(); try { const all = JSON.parse(localStorage.getItem(KEPT) ?? '{}'); delete all[id]; localStorage.setItem(KEPT, JSON.stringify(all)) } catch { /* memory only */ } }
849
+ const forgetKept = (id: string) => { try { const all = JSON.parse(localStorage.getItem(KEPT) ?? '{}'); delete all[id]; localStorage.setItem(KEPT, JSON.stringify(all)) } catch { /* memory only */ } }
819
850
  const pendingUploads = new Map<string, CaptureRecord>()
851
+ /** taken by the server, waiting only for its card on the page's queue: never posted again (a retry for another capture,
852
+ * a page shown again) - its one wait goes on, and its Sending tile with it */
853
+ const acked = new Set<string>()
854
+ /** posted, its answer not back yet: a retry round meanwhile leaves it alone (its answer starts the one wait) */
855
+ const inflight = new Set<string>()
820
856
  let retryTimer: ReturnType<typeof setTimeout> | null = null
821
857
  /** Post a sealed record - the same id, idempotent on the server - until it takes. A refusal about the
822
858
  * record itself (not the network) is final and said once; a dev server that is away is waited for. */
823
859
  async function upload(record: CaptureRecord, leaving = false): Promise<void> {
824
- type Verdict = { ok?: boolean; card?: { id: string; rev: number }; error?: string; outside?: boolean }
860
+ if (acked.has(record.id) || inflight.has(record.id)) return
861
+ type Verdict = { ok?: boolean; card?: { id: string; rev: number }; error?: string; outside?: boolean; held?: string }
825
862
  let r: Verdict | null = null
826
863
  try {
827
864
  // the workspace it was made in travels with it: another project served on this port refuses it
@@ -830,8 +867,12 @@ async function upload(record: CaptureRecord, leaving = false): Promise<void> {
830
867
  const payload = JSON.stringify({ record, workspace: CONFIG.workspace })
831
868
  // a page that is going sends with keepalive (64 kB at most, counted in UTF-8 bytes as the body carries it - not
832
869
  // `.length`: notes in another script are wider) so the request outlives it; a bigger one, the next page
833
- const res = await api('jam/capture', { method: 'POST', headers: { 'content-type': 'application/json', 'x-mv-c': csrf() }, body: payload, ...(leaving && bytesOf(payload) < 60_000 ? { keepalive: true } : {}) })
834
- const body = (await res.json().catch(() => null)) as Verdict | null
870
+ inflight.add(record.id)
871
+ let res: Response, body: Verdict | null
872
+ try {
873
+ res = await api('jam/capture', { method: 'POST', headers: { 'content-type': 'application/json', 'x-mv-c': csrf() }, body: payload, ...(leaving && bytesOf(payload) < 60_000 ? { keepalive: true } : {}) })
874
+ body = (await res.json().catch(() => null)) as Verdict | null
875
+ } finally { inflight.delete(record.id) }
835
876
  // only an explicit verdict on THIS record is final: taken (200, naming its card) or refused as a
836
877
  // record (400, saying why). Anything else - jam not running yet, another workspace, an unreadable
837
878
  // answer, a gate, a server error - is the server being away: keep it and try again
@@ -842,26 +883,77 @@ async function upload(record: CaptureRecord, leaving = false): Promise<void> {
842
883
  if (!r) {
843
884
  if (!retryTimer) useStore.getState().toast('the capture is kept here and will be sent when marver dev answers')
844
885
  retryTimer ??= setTimeout(() => { retryTimer = null; for (const x of pendingUploads.values()) void upload(x) }, 5_000)
886
+ if (!useJamCapture.getState().away) useJamCapture.setState({ away: true })
845
887
  return
846
888
  }
847
- forgetSealed(record.id)
889
+ if (useJamCapture.getState().away) useJamCapture.setState({ away: false })
890
+ forgetKept(record.id)
848
891
  releaseOpen(record.id, !r.ok) // it landed (the server knows); refused, it is no longer open either
849
- // the server holds it: a resumed draft is replaced now (or, refused, shows again)
892
+ useJamCapture.setState((st) => ({ sealed: st.sealed.map((x) => (x.id === record.id ? { ...x, ...(r!.card ? { card: r!.card } : {}) } : x)) }))
893
+ // what stands for it here - its Sending tile, a resumed draft kept off the lane - stays until the queue holds its
894
+ // card: the answer comes before the push that carries it, and in between the lane showed the old draft's To confirm
895
+ // in its place, or (nothing else on it) folded away and came back. A refresh that fails is not the end of the wait
896
+ if (r.ok) {
897
+ if (acked.has(record.id)) return // another answer for it already started its wait
898
+ acked.add(record.id); try { await untilQueued(record.id) } finally { acked.delete(record.id) }
899
+ }
900
+ pendingUploads.delete(record.id); syncUnsent()
901
+ // the resumed draft it replaced was dropped on the server - it leaves the lane for good; refused, it shows again
850
902
  const was = record.context.resumes?.id
851
- useJamCapture.setState((st) => ({ sealed: st.sealed.map((x) => (x.id === record.id ? { ...x, ...(r!.card ? { card: r!.card } : {}) } : x)), ...(was ? { resuming: st.resuming.filter((x) => x !== was) } : {}) }))
852
- void import('./jam-queue.ts').then(({ useJamQueue }) => useJamQueue.getState().load())
903
+ if (was) useJamCapture.setState((st) => ({ resuming: st.resuming.filter((x) => x !== was) }))
853
904
  if (!r.ok) useStore.getState().toast(`the capture could not be kept: ${r.error ?? 'unknown error'}`)
854
- // it reached the server after its session ended (another tab wrote the record): on its own
855
- else if (r.outside) leftOutOfSession(record.id)
905
+ else {
906
+ // stopped with E and the queue would not take it: it waits on the lane as a draft - said once, nothing opens
907
+ if (r.held) useStore.getState().toast(`the capture was not queued - it waits on the lane as a draft: ${r.held}`)
908
+ // it reached the server after its session ended (another tab wrote the record): on its own
909
+ if (r.outside) leftOutOfSession(record.id)
910
+ }
911
+ }
912
+
913
+ /** Until the page's queue holds this card: loaded now (a load that hangs is given 10 s), then again after 2, 4, 8 s and every 10 s on, unless a push
914
+ * brings it first - never given up on, so what stands for it never leaves the lane before its card is there. Any
915
+ * answer to a load ends it too: built after the canvas took the card, a view shows it (every card waiting or under way
916
+ * is shown, any other for a minute after it last changed) - unless it was finished elsewhere and has left the lane
917
+ * (another tab reviewed it while this page's refreshes failed), and then there is nothing left to wait for. */
918
+ async function untilQueued(id: string): Promise<void> {
919
+ const q = (await import('./jam-queue.ts')).useJamQueue
920
+ const held = () => !!q.getState().cards?.some((c) => c.id === id)
921
+ if (held()) return
922
+ // a push that brings the card ends the wait at any moment - a load that hangs never holds it up
923
+ let pushed = (): void => {}
924
+ const push = new Promise<true>((res) => { pushed = () => res(true) })
925
+ const un = q.subscribe(() => { if (held()) pushed() })
926
+ try {
927
+ const after = <T,>(ms: number, v: T) => new Promise<T>((res) => setTimeout(() => res(v), ms))
928
+ for (let wait = 2_000; !held(); wait = Math.min(wait * 2, 10_000)) {
929
+ // a refresh that hangs is given 10 s, then cancelled and the next one asked - it never stops the retries, and
930
+ // abandoned requests never pile up on the browser's connections. Only a refresh still unanswered at its 10 s is
931
+ // cancelled: one that answered, or that a push overtook, is left alone (it answers in a moment, and its view is
932
+ // applied only if newer than the push's). Cancelling those too (as each wait ended) reached whatever else on the
933
+ // page watches its requests - a browser extension's fetch hook - as a rejection it never handles, printed by Vite
934
+ // in the marver dev terminal on every E (29 Oct)
935
+ const ac = new AbortController()
936
+ const hang = setTimeout(() => ac.abort(), 10_000)
937
+ const answered = await Promise.race([q.getState().load({ signal: ac.signal }).finally(() => clearTimeout(hang)), push, after(10_000, false)])
938
+ if (answered) return
939
+ await Promise.race([push, after(wait, undefined)])
940
+ }
941
+ } finally { un() }
942
+ }
943
+
944
+ /** Was this capture (recording, sealing or not sent yet) stopped to review (⇧E, J)? E's never was. */
945
+ export function endedToReview(id: string): boolean {
946
+ const s = useJamCapture.getState()
947
+ return !!(s.caps[id]?.review ?? s.sealed.find((x) => x.id === id)?.review ?? pendingUploads.get(id)?.context.review)
856
948
  }
857
949
 
858
950
  /** A capture still recording, or finishing (its pictures and last words coming in), lives only in this page until it
859
951
  * seals; a sealed one is kept in localStorage until it lands. Leaving the page asks first - unsaved.ts's one
860
952
  * `beforeunload`, which hears this module's two reasons below - and if you leave anyway (`pagehide`: a close, a
861
953
  * reload, a navigation, the back-forward cache alike), every capture not sealed yet is sealed at once, as it stood,
862
- * for good: a missing step says so, the server keeps it as a draft, and it goes out like any sealed record not sent
863
- * yet - from the next page, or this one if it comes back. Carrying on is Resume, with a new id. Best effort: a crash
864
- * or a killed process fires nothing. */
954
+ * for good: a missing step says so, the server keeps it as a draft (one already stopped with E is queued, as E does),
955
+ * and it goes out like any sealed record not sent yet - from the next page, or this one if it comes back. Carrying on
956
+ * is Resume, with a new id. Best effort: a crash or a killed process fires nothing. */
865
957
  let guarded = false
866
958
  function guardUnload() {
867
959
  if (guarded || typeof window === 'undefined') return
@@ -884,7 +976,10 @@ export function sealOnLeave() {
884
976
  // text written in the notes card and never added is the capture's last note, as at E
885
977
  if (c.id === s.current && draft) steps.push({ at, event: 'note', text: draft })
886
978
  steps.push({ at, event: 'missing', what: c.state === 'recording' ? 'the page closed while it recorded' : 'the page closed before it finished' })
887
- records.push(buildRecord(c, steps, true))
979
+ // stopped with E and still finishing (its last words, its pictures): you sent it to work - it is queued as E does,
980
+ // the missing step saying what it lacks, never brought back as a draft to confirm. Recording, or stopped to
981
+ // review: a draft that waits for its read-back
982
+ records.push(buildRecord(c, steps, c.state === 'recording' || !!c.review))
888
983
  timeCapture(c, true)
889
984
  // its frames stop recording, its microphone is let go; a late picture or word finds nothing to change
890
985
  broadcast({ type: 'sh:capture', id: c.id, on: false })
@@ -947,6 +1042,7 @@ export const useJamCapture = create<CaptureState>((set, get) => ({
947
1042
  tick: 0,
948
1043
  sealed: [],
949
1044
  unsent: [],
1045
+ away: false,
950
1046
  resuming: [],
951
1047
  lastEnded: null,
952
1048
  settling: null,
@@ -964,9 +1060,12 @@ export const useJamCapture = create<CaptureState>((set, get) => ({
964
1060
  if (sessionEnding) { useStore.getState().toast('the session is being wrapped up - a moment'); return }
965
1061
  begin(reviewing, undefined, session)
966
1062
  },
967
- end() {
1063
+ end(review = false) {
968
1064
  const id = get().current
969
1065
  if (!id) return
1066
+ // ⇧E: its record says so, and it waits for its read-back; E: the server makes its card queued - no read-back,
1067
+ // nothing opens or moves here
1068
+ if (review) mutate((st) => { const x = st.caps[id]; if (x) x.review = true })
970
1069
  set({ current: null, lastEnded: id })
971
1070
  cancelDwell()
972
1071
  drain(id)
@@ -5,9 +5,10 @@
5
5
  *
6
6
  * a read-back open ⏎ confirm · K keep · R resume (it ended too soon) · Esc drop
7
7
  * the notes card open Esc closes the card · N puts the focus back in its field
8
- * a capture open E end · S says to end it first · N notes card · I picture · Esc drop
8
+ * a capture open E end (queued at once) · ⇧E end to review · S says to end it first · N notes card · I picture · Esc drop
9
9
  * a review open ⏎ looks good · ⇧⏎ more work · → later / next · ← back · B before/after ·
10
10
  * ⌥← ⌥→ frame tabs · Esc leave
11
+ * a thread panel open Esc close it
11
12
  * the lane has the keys ← → move · ⏎ open · ⌘⏎ do next · K keep · ⌫ drop · Esc leave
12
13
  * a session sheet open ⏎ start (the start sheet) · Esc close it
13
14
  * always S start a capture · J the session (start it, or end it) · Q the lane · V next capture to review
@@ -18,11 +19,13 @@
18
19
  */
19
20
  import { useJamCapture, setOwnedKeys } from './jam-capture.ts'
20
21
  import { changedShots, useJamQueue, type JamCard } from './jam-queue.ts'
21
- import { DONE_CLOSE, DONE_GROUP, doneFold, useJamUi } from './jam-state.ts'
22
+ import { DONE_CLOSE, DONE_GROUP, doneFold, jamSurface, useJamUi } from './jam-state.ts'
22
23
  import { pressJ, startSession, wrapWrite } from './jam-session.tsx'
23
24
  import { clearMoreDraft } from './jam-panel.tsx'
24
25
  import { CONFIG, PUBLISHED, SOURCE_REVEALED, useStore } from './store.ts'
26
+ import { ALL_SCENES } from '../../shared/board-tree.ts'
25
27
  import { holdsReload } from './api.ts'
28
+ import { navigated, switchFor } from './goto.ts'
26
29
  import { unsavedWhen, workChanged } from './unsaved.ts'
27
30
 
28
31
  export interface KeyIn { key: string; shift?: boolean; alt?: boolean; meta?: boolean; ctrl?: boolean }
@@ -164,37 +167,181 @@ export async function resumeDraft(id: string) {
164
167
  } finally { useJamCapture.setState({ settling: null }) }
165
168
  }
166
169
 
170
+ /** A request's life (spec 28 A4.6 #30): read before every step that moves the UI. A click passes none - always true. */
171
+ export type Alive = () => boolean
172
+ const always: Alive = () => true
173
+ /** How long a click waits for a board, a thread or a panel to draw; a notice's request has its own deadline in `alive`. */
174
+ const waitMs = (o: { alive?: Alive }, away = false) => (o.alive ? 10_000 : away ? 6_000 : 3_000)
175
+ /** Wait until `ok`, while `alive` holds and `ms` lasts: false once `alive` fails first, or the time is up. */
176
+ async function waitFor(ok: () => boolean, alive: Alive, ms: number): Promise<boolean> {
177
+ const until = performance.now() + ms
178
+ for (;;) {
179
+ if (!alive()) return false
180
+ if (ok()) return true
181
+ if (performance.now() > until) return false
182
+ await new Promise((r) => setTimeout(r, 30))
183
+ }
184
+ }
185
+ const drawn = (sel: string) => () => !!document.querySelector(sel)
186
+ /** A card's status popover, open (jam-ui.tsx TagStatus): its run's controls on the page. */
187
+ const statusOpen = (card: string) => `.cm-tstat.on[data-jam-card="${CSS.escape(card)}"]`
188
+
189
+ /** Another board (A4.6 #30). A request's switch commits only while its `alive` holds, read just before the board commits
190
+ * (store.ts switchBoard): words typed while the board loads, a hidden tab, the deadline or a later click leave the board,
191
+ * its draft and its open thread as they were - a hash set and left to the router would land whatever came after. A
192
+ * click (no request) follows the board's link, as before. True once the board is shown. */
193
+ export async function toBoard(board: string, alive?: Alive): Promise<boolean> {
194
+ if (!alive) {
195
+ location.hash = `#/b/${encodeURIComponent(board)}`
196
+ return waitFor(() => useStore.getState().board === board, always, waitMs({}, true))
197
+ }
198
+ if (!alive()) return false
199
+ // a stale overlay never survives into another board (App.tsx's router does the same)
200
+ if (useStore.getState().play) useStore.getState().setPlay(null)
201
+ // the wait is the request's too, however long the board's save or read takes (code review r2 P2) - and the switch,
202
+ // should it finish later, cannot commit: its predicate is alive, which never holds again once it failed (open-item.ts)
203
+ return (await whileAlive(switchFor(board, navigated(), alive), alive)) && alive()
204
+ }
205
+
206
+ /** `p`, or false as soon as `alive` fails, read every 30 ms: a request never waits past its own life - its deadline, or
207
+ * its end - whatever it waits on (a board's save or read, a hidden view's frames). The look stops once either settles. */
208
+ async function whileAlive<T>(p: Promise<T>, alive: Alive): Promise<T | false> {
209
+ // a click has no request to outlive: it waits on `p` alone, leaving no look behind in a hidden view (code review r4 P3)
210
+ if (alive === always) return p
211
+ let done = false
212
+ const ended = new Promise<false>((r) => { const look = () => { if (done) return; if (!alive()) { r(false); return } setTimeout(look, 30) }; look() })
213
+ try { return await Promise.race([p, ended]) } finally { done = true }
214
+ }
215
+
216
+ /** Play is left, then a frame passes for the layout (A4.6 r4 #1): what opens on the canvas - a thread card, a tile and
217
+ * its menu - is never drawn under the Play overlay, and the lane is folded there. Left with no way back to its frame
218
+ * (playCtl.leave, not Esc's exit): Esc's return - a fit, or a switch to the board a frame of another board lives on -
219
+ * would run outside the request, and land on another board over a reply typed after the thread opened (code review r2
220
+ * P1). False when `alive` failed, or when Play could not be left - a board locked to its mode has no way out (Play.tsx
221
+ * `noDoor`); the caller tells them apart by `alive()` and opens over Play instead. */
222
+ async function leavePlay(alive: Alive): Promise<boolean> {
223
+ if (!useStore.getState().play) return true
224
+ const { playCtl } = await import('./Play.tsx')
225
+ if (!alive()) return false
226
+ if (!playCtl.leave() || useStore.getState().play) return false
227
+ // two frames for the layout, under the request: a hidden view can hold its frames for good (code review r3 P2), and
228
+ // the frame asked for is cancelled once the request has ended
229
+ let raf = 0
230
+ const laid = await whileAlive(new Promise<true>((r) => { raf = requestAnimationFrame(() => { raf = requestAnimationFrame(() => r(true)) }) }), alive)
231
+ if (!laid) cancelAnimationFrame(raf)
232
+ return laid && alive()
233
+ }
234
+
167
235
  /** What clicking a tile (or ⏎ on it) does: a review opens the review detail, a card that asks opens
168
- * its thread, any other capture its detail - the read-back for a draft. */
169
- export function openTile(id: string) {
236
+ * its thread, any other capture its detail - the read-back for a draft. True once its surface is drawn. */
237
+ export async function openTile(id: string, o: { alive?: Alive } = {}): Promise<boolean> {
238
+ const alive = o.alive ?? always
170
239
  const c = cardById(id)
240
+ if (!c || !alive()) return false
171
241
  const ui = useJamUi.getState()
172
- if (!c) return
173
242
  if (c.state === 'asks' && c.thread) {
174
243
  ui.select(id)
175
- openThread(c)
176
- return
244
+ return openThreadAt(c.board, c.thread, { card: c, alive })
177
245
  }
246
+ // a request's card on another board: that board first, under the request (a click's reveal follows the link)
247
+ if (o.alive && c.board !== useStore.getState().board && !(await toBoard(c.board, o.alive))) return false
178
248
  ui.open({ kind: c.state === 'review' ? 'review' : c.kind === 'wrapup' ? 'wrapup' : 'capture', id })
179
- reveal(c)
249
+ reveal(c, o.alive)
250
+ return waitFor(() => useJamUi.getState().panel?.id === id && !!document.querySelector('[data-jam-focus]'), alive, waitMs(o))
251
+ }
252
+
253
+ /**
254
+ * Open a thread where you can see it (spec 28 A4.6 #30, r1 #3, r2 #2, r3 #1) - one helper for notices and every path
255
+ * that opens a thread. On another board, that board opens first (toBoard) - the legacy all-scenes log is no board a link
256
+ * lands on (App.tsx sends it elsewhere), so its threads open on the board shown. An open thread whose frame a node of
257
+ * the board hosts shows in its thread card: Play left first, comments hidden by Shift+C turned on (a hidden layer draws
258
+ * nothing), then revealed; Play that cannot be left (a board locked to its mode) keeps the canvas under it, so the
259
+ * thread opens over Play as an unhosted one does. A capture's thread with no host opens the capture's own panel - with
260
+ * its question and a field when it asks - as in 0.28. Every other thread - frameless, its frame gone, resolved - opens
261
+ * in the thread panel, a resolved one read-only. `status` (a card id) asks that card's status icon to open its popover once, in its thread
262
+ * card or the thread panel: the run's controls in view. True only once a surface for the thread is drawn - its card
263
+ * mounted, or a panel open on it, and with `status` that popover open; false when `alive` failed first.
264
+ */
265
+ export async function openThreadAt(board: string, thread: string, o: { card?: JamCard; status?: string; alive?: Alive } = {}): Promise<boolean> {
266
+ const alive = o.alive ?? always
267
+ const away = board !== ALL_SCENES && board !== useStore.getState().board
268
+ const ms = waitMs(o, away)
269
+ if (away && !(await toBoard(board, o.alive))) return false
270
+ const [{ revealThread }, { useComments }, { threadHostKey }] = await Promise.all([import('./Comments.tsx'), import('./comments-store.ts'), import('./keys.ts')])
271
+ const find = () => useComments.getState().threads.find((t) => t.id === thread && (!t.board || t.board === board))
272
+ // the board's comments may still be loading: known, or the time is up
273
+ await waitFor(() => !!find(), alive, ms)
274
+ if (!alive()) return false
275
+ const t = find()
276
+ const ok = (sel: string) => waitFor(() => drawn(sel)() && (!o.status || drawn(statusOpen(o.status))()), alive, ms)
277
+ // only an open thread has a card (the layer keeps open threads); Play kept, a card would draw under it
278
+ let host = t && !t.resolved ? threadHostKey(t, useStore.getState().nodes) : null
279
+ if (host && !(await leavePlay(alive))) {
280
+ if (!alive()) return false
281
+ host = null
282
+ }
283
+ if (host) {
284
+ if (!useComments.getState().show) { if (!alive()) return false; useComments.getState().setShow(true) }
285
+ if (!alive()) return false
286
+ if (o.status) useJamUi.getState().askStatus(o.status)
287
+ if (!revealThread(thread, alive)) return false
288
+ return ok(`.cm-card[data-thread="${CSS.escape(thread)}"]`)
289
+ }
290
+ const c = o.card
291
+ if (c?.kind === 'capture' && !t?.resolved) {
292
+ if (!alive()) return false
293
+ useJamUi.getState().select(c.id)
294
+ useJamUi.getState().open({ kind: 'capture', id: c.id })
295
+ reveal(c, o.alive)
296
+ return ok('[data-jam-readback]')
297
+ }
298
+ if (!t || !alive()) return false
299
+ if (o.status) useJamUi.getState().askStatus(o.status)
300
+ useJamUi.getState().open({ kind: 'thread', id: thread, board })
301
+ return ok(`[data-jam-thread-panel="${CSS.escape(thread)}"]`)
180
302
  }
181
303
 
182
- /** Open a card's thread - on another board, its link opens that board, then the thread (as a
183
- * notification's does). */
304
+ /** Open a card's thread where you can see it, as a notification does (openThreadAt): a click is never a no-op. */
184
305
  export function openThread(c: JamCard) {
185
- if (!c.thread) return
186
- if (c.board !== useStore.getState().board) { location.hash = `#/b/${encodeURIComponent(c.board)}?c=${encodeURIComponent(c.thread)}`; return }
187
- void import('./comments-store.ts').then(({ useComments }) => useComments.getState().setActive(c.thread!))
306
+ if (c.thread) void openThreadAt(c.board, c.thread, { card: c })
188
307
  }
189
308
 
190
- /** Bring a card's frames into view beside the panel - on its own board (a frame link lands there). */
191
- export function reveal(c: JamCard) {
309
+ /**
310
+ * A failed or stalled run's controls in view (spec 28 A4.6 #30, r3 #1), true only once they are on the page. A comment
311
+ * card has no tile: its thread opens with its status popover open on Retry or the three choices - in its thread card,
312
+ * or the thread panel. A capture or a record (the cards with a tile): failed, its panel with Retry and Drop in its
313
+ * footer; stalled, its tile selected and the tile's menu opened at it (Play left first: Play folds the lane - Play that
314
+ * cannot be left opens its lane over the stage, as Q does there).
315
+ */
316
+ export async function openRunControls(c: JamCard, o: { alive?: Alive } = {}): Promise<boolean> {
317
+ const alive = o.alive ?? always
318
+ if (c.kind === 'comment') return c.thread ? openThreadAt(c.board, c.thread, { card: c, status: c.id, alive }) : false
319
+ if (c.state === 'failed') return (await openTile(c.id, o)) && waitFor(drawn('[data-jam-focus] [data-jam-run-act="retry"]'), alive, waitMs(o))
320
+ if (!(await leavePlay(alive))) {
321
+ if (!alive()) return false
322
+ useJamUi.getState().setLaneKeys(true)
323
+ }
324
+ if (!(await waitFor(drawn(`.jm-lane [data-tile="${CSS.escape(c.id)}"]`), alive, waitMs(o)))) return false
325
+ if (!alive()) return false
326
+ useJamUi.getState().select(c.id)
327
+ if (!jamSurface.tileMenu(c.id)) return false
328
+ return waitFor(drawn(`.sh-ctxmenu[data-menu="tile:${CSS.escape(c.id)}"]`), alive, waitMs(o))
329
+ }
330
+
331
+ /** Bring a card's frames into view beside the panel - on its own board (a frame link lands there). A request's `alive`
332
+ * (A4.6 #30) is read again when the camera moves: one that ended meanwhile - a later click, a hidden tab, the deadline,
333
+ * words typed - moves nothing, and its board is switched under it (toBoard), never by a link. */
334
+ export function reveal(c: JamCard, alive?: Alive) {
192
335
  const s = useStore.getState()
193
336
  if (!c.frames.length) return
194
- if (c.board !== s.board) { location.hash = `#/b/${encodeURIComponent(c.board)}?f=${c.frames.map(encodeURIComponent).join(',')}`; return }
337
+ if (c.board !== s.board) {
338
+ if (!alive) location.hash = `#/b/${encodeURIComponent(c.board)}?f=${c.frames.map(encodeURIComponent).join(',')}`
339
+ else void toBoard(c.board, alive).then((ok) => { if (ok) reveal(c, alive) })
340
+ return
341
+ }
195
342
  const keys = s.nodes.filter((n) => c.frames.includes(n.frame)).map((n) => n.key)
196
343
  // after the panel has drawn, so the fit measures it and lands the frames in the space right of it
197
- if (keys.length) void import('./canvas/ctl.ts').then(({ canvasCtl }) => requestAnimationFrame(() => requestAnimationFrame(() => canvasCtl.fitNodes(keys))))
344
+ if (keys.length) void import('./canvas/ctl.ts').then(({ canvasCtl }) => requestAnimationFrame(() => requestAnimationFrame(() => { if (!alive || alive()) canvasCtl.fitNodes(keys) })))
198
345
  }
199
346
 
200
347
  /** The next capture to review after `from` (or the oldest), walking the lane left to right. */
@@ -273,7 +420,8 @@ const rows = (): Row[] => {
273
420
  { // a capture open
274
421
  on: () => !!cap.current,
275
422
  keys: {
276
- e: () => cap.end(),
423
+ e: () => cap.end(), // straight to the queue
424
+ 'Shift+e': () => cap.end(true), // stop to review: its read-back opens
277
425
  s: () => cap.start(), // one at a time: it says to end this one first
278
426
  // L: laser picks - a pick inside a capture is its pick (frames forward it while interacting)
279
427
  // L: the pointer laser; ⌥L: inspect - a laser click inside a capture is its pick either way
@@ -298,6 +446,10 @@ const rows = (): Row[] => {
298
446
  Escape: () => { if (ui.moreOpen) { clearMoreDraft(panelCard!.id); ui.setMoreOpen(false) } else ui.close() }, // Esc leaves the composer: its words go
299
447
  },
300
448
  },
449
+ { // the thread panel open (a notice's thread no card can show): Esc closes it
450
+ on: () => ui.panel?.kind === 'thread',
451
+ keys: { Escape: () => { if (laserOff()) return; ui.close() } },
452
+ },
301
453
  { // the lane has the keyboard
302
454
  on: () => ui.laneKeys,
303
455
  keys: (() => {
@@ -13,7 +13,7 @@ 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
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
+ import { ArrowsInLineHorizontalIcon, CursorClickIcon, FileCodeIcon, ImagesSquareIcon, LaserIcon, MicrophoneIcon, MicrophoneSlashIcon, PauseIcon, PencilSimpleIcon } from './icons.tsx'
17
17
 
18
18
  /** The lane's height with its air: the 44 px tile + 12 px. While the lane shows, the sidebar stops
19
19
  * above it and everything else on the bottom edge (the Update pill, toasts, notices) rises this much. */
@@ -26,6 +26,8 @@ export interface LaneTile {
26
26
  title: string
27
27
  /** the status line - jam-lines.ts `laneLine` */
28
28
  line: string
29
+ /** a working tile's status line on hover: whose run it is (jam-lines.ts `laneTip`) */
30
+ tip?: string
29
31
  /** an exclusive card wears a file glyph: it changes how the queue runs */
30
32
  exclusive?: boolean
31
33
  /** a done tile: the frames it changed (not the ones it left as they were) - the Done group counts each frame once */
@@ -56,6 +58,7 @@ export interface LaneRecording {
56
58
  onMic?(): void
57
59
  onNote(): void
58
60
  onStop(): void
61
+ onStopReview(): void
59
62
  }
60
63
 
61
64
  /**
@@ -190,7 +193,7 @@ export function Lane({ tiles, recording, between, selected, keyboard, onOpen, on
190
193
  <span className="tx">
191
194
  {/* the whole title, in the shell's own tooltip - only when the tile cuts it short */}
192
195
  <Tip label={<span className="jm-tip-title">{t.title}</span>} only={(el) => el.scrollWidth > el.clientWidth + 1}><span className="t">{t.title}</span></Tip>
193
- <span className="m">{t.line}</span>
196
+ {t.tip ? <Tip label={<div className="sh-tip-lines">{t.tip}</div>}><span className="m">{t.line}</span></Tip> : <span className="m">{t.line}</span>}
194
197
  </span>
195
198
  {t.exclusive && <span className="x" aria-label="changes a shared file"><FileCodeIcon size={13} /></span>}
196
199
  </button>
@@ -218,8 +221,9 @@ export function BetweenTile({ since, mic, onCapture }: LaneBetween) {
218
221
  }
219
222
 
220
223
  /** The capture recording now: a pulsing teal dot, "Capturing" and the timer over what it holds so far,
221
- * then the Note button (N, with the count) and Stop (E). After E it reads "Finishing". */
222
- export function CaptureTile({ time, points, pictures = 0, picturesMax, steps, counts, notes, noteOn, finishing, mic, onMic, onNote, onStop }: LaneRecording) {
224
+ * then the Note button (N, with the count), Stop (E: queued at once) and Stop to review (⇧E, a pause icon: its read-back opens).
225
+ * After either it reads "Finishing". */
226
+ export function CaptureTile({ time, points, pictures = 0, picturesMax, steps, counts, notes, noteOn, finishing, mic, onMic, onNote, onStop, onStopReview }: LaneRecording) {
223
227
  return (
224
228
  <div className={`jm-chip${finishing ? ' finishing' : ''}`} data-tile="capturing">
225
229
  {finishing ? <JamStateIcon state="confirming" /> : <i className="jm-live-dot" />}
@@ -243,7 +247,12 @@ export function CaptureTile({ time, points, pictures = 0, picturesMax, steps, co
243
247
  <button className={`notebtn${noteOn ? ' on' : ''}`} onClick={onNote} disabled={finishing} aria-pressed={noteOn}>
244
248
  <PencilSimpleIcon size={13} />Note{notes ? <b>{notes}</b> : null}<kbd>N</kbd>
245
249
  </button>
246
- <button className="stop" onClick={onStop} disabled={finishing}>Stop<kbd>E</kbd></button>
250
+ <Tip label="Stop and queue it - the agent starts on it">
251
+ <button className="stop" onClick={onStop} disabled={finishing}>Stop<kbd>E</kbd></button>
252
+ </Tip>
253
+ <Tip label="Stop and look it over first - add notes, then queue it">
254
+ <button className="stop review" onClick={onStopReview} disabled={finishing}><PauseIcon size={12} />Stop to review<kbd>⇧E</kbd></button>
255
+ </Tip>
247
256
  </div>
248
257
  )
249
258
  }