@marver-design/marver 0.25.1 → 0.26.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.
- package/CHANGELOG.md +62 -0
- package/README.md +3 -1
- package/dist/{anchor-DVV732zR.mjs → anchor-5H1vnoLu.mjs} +6 -1
- package/dist/{anchor-check-DGZnYviN.mjs → anchor-check-Dg5xpNnU.mjs} +1 -1
- package/dist/audio-CmSRYFEs.mjs +429 -0
- package/dist/{auth-DdUKeVKt.mjs → auth-Dix8wrXV.mjs} +1 -1
- package/dist/{bake-BpxMZfij.mjs → bake-DtVlm0_F.mjs} +1 -1
- package/dist/{boards-Csxj2WJn.mjs → boards-DYG22tOe.mjs} +2 -2
- package/dist/{build-DKaGhoVN.mjs → build-C_gUgcdC.mjs} +16 -9
- package/dist/capture-CrqvU_jh.mjs +729 -0
- package/dist/cli.mjs +23 -17
- package/dist/{collab-gqNdScUE.mjs → collab-Dxg2trOK.mjs} +4 -3
- package/dist/{comments-Zoch254k.mjs → comments-0BSbb04K.mjs} +14 -3
- package/dist/{comments-pTLlhjh4.mjs → comments-BqXua-XL.mjs} +7 -7
- package/dist/{config-cKgZBRj0.mjs → config-Cf7EjAMf.mjs} +12 -1
- package/dist/{context-D2ugHqwO.mjs → context-HQ4Giw58.mjs} +1 -1
- package/dist/daemon-DZo6o3rU.mjs +2445 -0
- package/dist/{dev-Diqx1Rt8.mjs → dev-_Nlsc6v9.mjs} +189 -18
- package/dist/dev-lock-DWSpa6nj.mjs +179 -0
- package/dist/{events-DnK_AnrW.mjs → events-CLH4ijKP.mjs} +14 -4
- package/dist/{init-DO4DhUt_.mjs → init-D8DtrK_F.mjs} +2 -2
- package/dist/{ledger-BNXW14Xw.mjs → ledger-D54iROST.mjs} +17 -1
- package/dist/{link-C-qUIuKU.mjs → link-BNzLvdhI.mjs} +2 -2
- package/dist/live-Cgzsicwi.mjs +4 -0
- package/dist/{manifest-DnAte_fB.mjs → manifest-Nl3KSVOk.mjs} +1 -1
- package/dist/{marks-koRsbHfe.mjs → marks-CKgzucHZ.mjs} +2 -2
- package/dist/{marks-DFuintmJ.mjs → marks-NQi0wZJ4.mjs} +23 -5
- package/dist/{marver-id-gate-DGANtVyC.mjs → marver-id-gate-BjF6v4bT.mjs} +4 -4
- package/dist/{perf-QJIWtTw1.mjs → perf-D6VmmJ2q.mjs} +1 -1
- package/dist/{perf-CCisg-ny.mjs → perf-DPbLGhhO.mjs} +1 -1
- package/dist/{plugin-dTF5reck.mjs → plugin-CTD0rydA.mjs} +277 -37
- package/dist/{poster-D-zjYpgk.mjs → poster-ChjXGTS5.mjs} +1 -1
- package/dist/{profile-Do0nGkXO.mjs → profile-WU9qcbIo.mjs} +1 -1
- package/dist/{publish-bakes-C_9VZ-Mq.mjs → publish-bakes-CEP_2NRc.mjs} +3 -3
- package/dist/queue-BuiCKSX1.mjs +1319 -0
- package/dist/reserve-BURNQ2Y3.mjs +53 -0
- package/dist/{rolldown-runtime-D7D4PA-g.mjs → rolldown-runtime-8H4AJuhK.mjs} +1 -0
- package/dist/{serve-wv2QWdxB.mjs → serve-C8rVheYk.mjs} +12 -12
- package/dist/session-qZWKt_VA.mjs +191 -0
- package/dist/{share-ScamJcks.mjs → share--oFJ1bCI.mjs} +2 -2
- package/dist/{shot-jdO_B6Qw.mjs → shot-CNbHoZ6H.mjs} +1 -1
- package/dist/{shot-CUlmkqFX.mjs → shot-DqcxJibP.mjs} +4 -3
- package/dist/speech-models-DomiLQcY.mjs +299 -0
- package/dist/speech-worker.mjs +319 -0
- package/dist/{summary-CrW88e3q.mjs → summary-Y8MY1Wuc.mjs} +2 -2
- package/dist/{sync-C3035OnJ.mjs → sync-DKk-yT1V.mjs} +9 -8
- package/dist/{work-GE88wb_3.mjs → work-F5u-twpJ.mjs} +28 -5
- package/dist/{work-CpJn1gwY.mjs → work-VvX_JIgl.mjs} +2 -2
- package/docs/jam-session.md +177 -0
- package/docs/live-jam.md +21 -3
- package/package.json +7 -1
- package/src/client/frame-host/bridge.js +20 -2
- package/src/client/frame-host/inspect.d.ts +4 -0
- package/src/client/frame-host/inspect.js +88 -3
- package/src/client/frame-host/keys.d.ts +6 -0
- package/src/client/frame-host/keys.js +55 -0
- package/src/client/frame-host/trail.d.ts +7 -0
- package/src/client/frame-host/trail.js +204 -0
- package/src/client/shell/App.tsx +45 -5
- package/src/client/shell/Comments.tsx +20 -6
- package/src/client/shell/JamSurface.tsx +340 -0
- package/src/client/shell/Play.tsx +22 -3
- package/src/client/shell/Tip.tsx +8 -3
- package/src/client/shell/canvas/Canvas.tsx +12 -2
- package/src/client/shell/canvas/FrameNode.tsx +11 -2
- package/src/client/shell/comments-store.ts +23 -16
- package/src/client/shell/icons.tsx +15 -0
- package/src/client/shell/jam-capture.ts +939 -0
- package/src/client/shell/jam-keys.ts +329 -0
- package/src/client/shell/jam-lane.tsx +208 -0
- package/src/client/shell/jam-lines.ts +115 -0
- package/src/client/shell/jam-panel.tsx +506 -0
- package/src/client/shell/jam-queue.ts +126 -0
- package/src/client/shell/jam-session.tsx +389 -0
- package/src/client/shell/jam-state.ts +61 -0
- package/src/client/shell/jam-surface-parts.tsx +102 -0
- package/src/client/shell/jam-ui.tsx +104 -0
- package/src/client/shell/jam-voice.ts +479 -0
- package/src/client/shell/sound.ts +22 -0
- package/src/client/shell/stage-size.ts +11 -0
- package/src/client/shell/store.ts +34 -13
- package/src/client/shell/styles.css +544 -2
- package/src/client/stage/main.tsx +16 -2
- package/src/shared/capture-frames.ts +41 -0
- package/src/shared/events.ts +19 -4
- package/src/shared/speech.ts +16 -0
- package/templates/AGENTS-embedded.md +10 -2
- package/templates/AGENTS-studio.md +10 -2
- package/templates/instructions/iterate.md +8 -6
- package/templates/instructions/jam.md +129 -59
- package/dist/daemon-Cl8KXGW4.mjs +0 -1523
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Jam session in the shell (spec 27, Part 5): `J` (or the Jam button) opens the start sheet; Start
|
|
3
|
+
* begins the session - the microphone (if you said yes) hears its talk between captures; `J` again ends
|
|
4
|
+
* it with the wrap-up sheet: every capture of the session with where it stands, your instructions to the
|
|
5
|
+
* agent, whether to include what was said between captures - "Write the record" queues the record job,
|
|
6
|
+
* "End without a record" just ends it. The record comes back as the run's last tile, reviewed in the focus
|
|
7
|
+
* panel like a capture.
|
|
8
|
+
*
|
|
9
|
+
* The Jam button (between Laser and Tidy): the waveform at rest; the session's minutes while one runs (a
|
|
10
|
+
* crossed microphone without one); a teal dot only while a capture records. Blue only on hover and press.
|
|
11
|
+
*/
|
|
12
|
+
import { useEffect, useRef, useState, type CSSProperties } from 'react'
|
|
13
|
+
import { ROUTE } from '../const.ts'
|
|
14
|
+
import { setSessionEnding, useJamCapture } from './jam-capture.ts'
|
|
15
|
+
import { laneCards, startCapture } from './jam-keys.ts'
|
|
16
|
+
import { useJamQueue, type JamCard } from './jam-queue.ts'
|
|
17
|
+
import { useJamUi } from './jam-state.ts'
|
|
18
|
+
import { JamStateIcon } from './jam-ui.tsx'
|
|
19
|
+
import { Marver, moreDraftOf, setMoreDraft } from './jam-panel.tsx'
|
|
20
|
+
import { useJamVoice, voiceSession, voiceSessionEnd, voiceSessionId } from './jam-voice.ts'
|
|
21
|
+
import { HARNESS } from './Comments.tsx'
|
|
22
|
+
import { ArrowRightIcon, CaretIcon, KeyboardIcon, MicrophoneIcon, MicrophoneSlashIcon, WarningIcon, WaveformIcon } from './icons.tsx'
|
|
23
|
+
import { Tip } from './Tip.tsx'
|
|
24
|
+
import { useSessionClock } from './jam-lane.tsx'
|
|
25
|
+
import { CONFIG, useStore } from './store.ts'
|
|
26
|
+
|
|
27
|
+
const csrf = () => /(?:^|;\s*)mv_c=([\w-]+)/.exec(document.cookie)?.[1] ?? ''
|
|
28
|
+
const now = () => performance.timeOrigin + performance.now()
|
|
29
|
+
|
|
30
|
+
// ---- the session's moves -------------------------------------------------------------------------------
|
|
31
|
+
|
|
32
|
+
/** Why the last session move was refused (the server's words), for the one line that says so. */
|
|
33
|
+
let lastError: string | undefined
|
|
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)
|
|
36
|
+
lastError = r && !r.ok ? ((await r.json().catch(() => null)) as { error?: string } | null)?.error : r ? undefined : 'marver dev did not answer'
|
|
37
|
+
// what the server's answer settles happens at once, never behind the refresh (which may be slow, and a push
|
|
38
|
+
// may come first)
|
|
39
|
+
try { onAnswer?.(!!r?.ok) } catch { /* the refresh still runs */ }
|
|
40
|
+
await useJamQueue.getState().load()
|
|
41
|
+
return !!r?.ok
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Start a session: the dev server holds it (it survives a reload); the microphone hears its talk. */
|
|
45
|
+
export async function startSession(): Promise<boolean> {
|
|
46
|
+
const id = `ses-${Date.now()}-${Math.random().toString(36).slice(2, 8).padEnd(6, '0')}`
|
|
47
|
+
// this tab holds the session's microphone (a reload of it takes it back; other tabs never take it) - from
|
|
48
|
+
// the moment the server has it: the push of it may come before the refresh
|
|
49
|
+
// the talk starts once the queue shows the session - whichever comes first: the push (before the answer,
|
|
50
|
+
// or after it), or the refresh; a session ended meanwhile never gets the microphone
|
|
51
|
+
const hear = () => { if (useJamQueue.getState().session?.id === id && voiceSessionId() !== id) void voiceSession(id, now()) }
|
|
52
|
+
const ok = await post({ action: 'start', id }, (ok) => {
|
|
53
|
+
if (!ok) return
|
|
54
|
+
try { sessionStorage.setItem(MIC_OWNER, id) } catch { /* this page only */ }
|
|
55
|
+
useJamUi.getState().setSheet(null)
|
|
56
|
+
// the session starts capturing at once - its first capture is under way as soon as it starts (its talk
|
|
57
|
+
// begins when that capture ends)
|
|
58
|
+
// (over an open review it follows that review, as S does)
|
|
59
|
+
if (!useJamCapture.getState().current) startCapture(id)
|
|
60
|
+
hear()
|
|
61
|
+
})
|
|
62
|
+
if (!ok) { useStore.getState().toast('the session could not start - look again'); return false }
|
|
63
|
+
useJamUi.getState().setSheet(null)
|
|
64
|
+
hear()
|
|
65
|
+
return true
|
|
66
|
+
}
|
|
67
|
+
/** The session whose microphone this tab holds (per tab: it survives a reload, not another tab). */
|
|
68
|
+
export const MIC_OWNER = 'mv-jam-session-mic'
|
|
69
|
+
export const holdsSessionMic = (id: string): boolean => { try { return sessionStorage.getItem(MIC_OWNER) === id } catch { return false } }
|
|
70
|
+
|
|
71
|
+
/** End the session - with a record (the wrap-up's instructions and talk switch), or without one. */
|
|
72
|
+
export async function endSession(write: { instructions: string; includeTalk: boolean } | null, onAnswer?: () => void): Promise<boolean> {
|
|
73
|
+
const ses = useJamQueue.getState().session
|
|
74
|
+
if (!ses) { useJamUi.getState().setSheet(null); return true }
|
|
75
|
+
// never over a capture still recording, sealing or sending: it belongs in the session (and its record)
|
|
76
|
+
const cap = useJamCapture.getState()
|
|
77
|
+
if (cap.current || Object.keys(cap.caps).length || cap.unsent.length) {
|
|
78
|
+
useStore.getState().toast(cap.current ? 'a capture is recording - end it first (E), then wrap up' : 'a capture is still being sent - a moment, then wrap up')
|
|
79
|
+
return false
|
|
80
|
+
}
|
|
81
|
+
// from here until the server answers, no capture starts (the record must not miss it); the server also
|
|
82
|
+
// refuses the record while a capture of the session is open in any tab
|
|
83
|
+
setSessionEnding(true)
|
|
84
|
+
// each try is its own: an older one finishing late (its refresh slow) never frees what a newer one holds
|
|
85
|
+
const op = ++endingOp
|
|
86
|
+
const mine = () => op === endingOp
|
|
87
|
+
// the server's answer, acted on at once (not behind the refresh): captures may start again; refused, the
|
|
88
|
+
// session goes on - its talk heard again in the tab that holds its microphone, and you are told why
|
|
89
|
+
const answered = (ok: boolean) => {
|
|
90
|
+
if (!mine()) return
|
|
91
|
+
// ended: gone from this page at once - a capture started from here on is not the session's
|
|
92
|
+
if (ok) useJamQueue.getState().forget(ses.id)
|
|
93
|
+
setSessionEnding(false)
|
|
94
|
+
onAnswer?.()
|
|
95
|
+
if (ok) { useJamUi.getState().setSheet(null); return }
|
|
96
|
+
if (useJamQueue.getState().session?.id === ses.id && holdsSessionMic(ses.id) && voiceSessionId() !== ses.id) void voiceSession(ses.id, now())
|
|
97
|
+
useStore.getState().toast(write ? `the record could not be written - ${lastError ?? 'look again'}` : 'the session could not end - look again')
|
|
98
|
+
}
|
|
99
|
+
try {
|
|
100
|
+
// the talk's last words first: they belong in the transcript the record reads
|
|
101
|
+
await voiceSessionEnd()
|
|
102
|
+
return write
|
|
103
|
+
? await post({ action: 'wrapup', id: ses.id, instructions: write.instructions, includeTalk: write.includeTalk, board: useStore.getState().board }, answered)
|
|
104
|
+
: await post({ action: 'end', id: ses.id }, answered)
|
|
105
|
+
} finally { if (mine()) setSessionEnding(false) }
|
|
106
|
+
}
|
|
107
|
+
/** The latest try at ending the session (each Write or End is one). */
|
|
108
|
+
let endingOp = 0
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
/** `J` (or the Jam button): at rest, the start sheet (again: closes it); in a session, the wrap-up - a
|
|
112
|
+
* capture recording ends first, and the wrap-up waits for its read-back to close. */
|
|
113
|
+
export function pressJ() {
|
|
114
|
+
const ui = useJamUi.getState()
|
|
115
|
+
if (!useJamQueue.getState().session) { ui.setSheet(ui.sheet === 'start' ? null : 'start'); return }
|
|
116
|
+
if (ui.sheet === 'wrap' || ui.sheet === 'wrap-pending') { ui.setSheet(null); return }
|
|
117
|
+
if (useJamCapture.getState().current) { useJamCapture.getState().end(); ui.setSheet('wrap-pending'); return }
|
|
118
|
+
ui.setSheet('wrap')
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// ---- the Jam button ----------------------------------------------------------------------------------------
|
|
122
|
+
|
|
123
|
+
/** The session's length in minutes, ticking. */
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
export function JamButton({ inPlay }: { inPlay?: boolean }) {
|
|
127
|
+
const session = useJamQueue((s) => s.session)
|
|
128
|
+
const recording = useJamCapture((s) => !!s.current)
|
|
129
|
+
const sheet = useJamUi((s) => s.sheet)
|
|
130
|
+
const voice = useJamVoice()
|
|
131
|
+
const minutes = useSessionClock(session?.since)
|
|
132
|
+
// off: no, blocked, no engine - or stopped (another tab has it, the connection went) while you said yes
|
|
133
|
+
const micOff = voice.choice === 'no' || voice.denied || voice.server === 'unavailable' || (!!session && voice.choice === 'yes' && !voice.live && !recording)
|
|
134
|
+
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></>
|
|
136
|
+
return (
|
|
137
|
+
<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}>
|
|
140
|
+
{/* the whole session reads as on: the dot pulses from start to end, between captures too */}
|
|
141
|
+
{session || recording ? <i className="jm-live-dot" /> : <WaveformIcon size={16} />}
|
|
142
|
+
{session && <span className="jm-clock">{minutes}</span>}
|
|
143
|
+
{session && micOff && <MicrophoneSlashIcon size={14} className="jm-nomic" />}
|
|
144
|
+
</button>
|
|
145
|
+
</Tip>
|
|
146
|
+
)
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ---- the start sheet -----------------------------------------------------------------------------------------
|
|
150
|
+
|
|
151
|
+
/** Jam's keys, one list: the shortcuts tooltip (the key table in jam-keys.ts is the source of truth). */
|
|
152
|
+
export const JAM_KEYS: [string, string][] = [
|
|
153
|
+
['Start a capture', 'S'], ['End it', 'E'], ['Drop it', 'esc'], ['Add a note', 'N'], ['Picture of the frame', 'I'],
|
|
154
|
+
['Resume a capture', 'R'], ['The captures', 'Q'], ['Open a capture', '⏎'], ['Keep it, not sent', 'K'], ['Review the next', 'V'], ['End the session', 'J'],
|
|
155
|
+
]
|
|
156
|
+
|
|
157
|
+
/** "Keyboard shortcuts": one row; hovering or focusing it shows every Jam key in one column, action then
|
|
158
|
+
* key, in the inverse theme. */
|
|
159
|
+
function ShortcutsRow() {
|
|
160
|
+
const [on, setOn] = useState(false)
|
|
161
|
+
return (
|
|
162
|
+
<div className={`jm-sc-row${on ? ' hover' : ''}`} tabIndex={0} data-jam-shortcuts=""
|
|
163
|
+
onMouseEnter={() => setOn(true)} onMouseLeave={() => setOn(false)} onFocus={() => setOn(true)} onBlur={() => setOn(false)}>
|
|
164
|
+
<KeyboardIcon size={15} /><span>Keyboard shortcuts</span><span className="v">View<CaretIcon size={10} style={{ transform: 'rotate(-90deg)' }} /></span>
|
|
165
|
+
{on && (
|
|
166
|
+
<div className="jm-sctip" style={{ right: 'calc(100% + 18px)', top: -8 }} role="tooltip">
|
|
167
|
+
<div className="hd">Jam keys</div>
|
|
168
|
+
{JAM_KEYS.map(([a, k]) => <div key={a}>{a}<b>{k}</b></div>)}
|
|
169
|
+
</div>
|
|
170
|
+
)}
|
|
171
|
+
</div>
|
|
172
|
+
)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export function StartSheet({ style }: { style?: CSSProperties }) {
|
|
176
|
+
const agent = useJamQueue((s) => s.agent)
|
|
177
|
+
const voice = useJamVoice()
|
|
178
|
+
const mic = voice.choice === 'yes' && voice.server !== 'unavailable' && !voice.denied
|
|
179
|
+
const name = agent ? HARNESS[agent] ?? agent : null
|
|
180
|
+
return (
|
|
181
|
+
<div className="jm-panel jm-sheet" data-jam-sheet="start" style={style}>
|
|
182
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
|
|
183
|
+
<h3>Jam session</h3>
|
|
184
|
+
<p>Start captures at once. Between captures the session stays on; S captures again, J wraps up.</p>
|
|
185
|
+
</div>
|
|
186
|
+
<div className="rows">
|
|
187
|
+
<button className="row" data-jam-mic-switch={mic ? 'on' : 'off'} onClick={() => voice.setChoice(mic ? 'no' : 'yes')}>
|
|
188
|
+
{mic ? <MicrophoneIcon size={15} /> : <MicrophoneSlashIcon size={15} />}
|
|
189
|
+
<span>Microphone<br /><small>Transcribed on this Mac{CONFIG.jam?.names ? ' · Claude Haiku names each capture from its words, sent to Anthropic' : ''}</small></span>
|
|
190
|
+
<span className="v">{mic ? 'On' : 'Off'}<i className={`jm-switch${mic ? ' on' : ''}`} /></span>
|
|
191
|
+
</button>
|
|
192
|
+
{name
|
|
193
|
+
? <div className="row"><ArrowRightIcon size={15} /><span>Hands work to</span><span className="v"><span className="jm-agent"><i />{name}</span></span></div>
|
|
194
|
+
: <div className="note-line warn" style={{ margin: '4px 0' }}><WarningIcon size={14} /><span>No coding agent found - work waits in the queue.<br /><code style={{ color: 'inherit', opacity: .8 }}>npx marver init</code> sets one up.</span></div>}
|
|
195
|
+
</div>
|
|
196
|
+
<ShortcutsRow />
|
|
197
|
+
<div className="actions">
|
|
198
|
+
<span className="sp" />
|
|
199
|
+
<button className="jm-btn ghost" onClick={() => useJamUi.getState().setSheet(null)}>Not now</button>
|
|
200
|
+
<button className="jm-btn primary" onClick={() => void startSession()}>Start <kbd>⏎</kbd></button>
|
|
201
|
+
</div>
|
|
202
|
+
</div>
|
|
203
|
+
)
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// ---- the wrap-up ----------------------------------------------------------------------------------------------
|
|
207
|
+
|
|
208
|
+
/** The open wrap-up sheet's Write the record (the key row calls it). */
|
|
209
|
+
export const wrapWrite: { current: (() => void) | null } = { current: null }
|
|
210
|
+
|
|
211
|
+
const STATE_NOTE: Partial<Record<JamCard['state'], string>> = {
|
|
212
|
+
draft: 'to confirm', confirming: 'sending', queued: 'queued', working: 'with the agent', asks: 'asks you', review: 'to review',
|
|
213
|
+
done: 'done', kept: 'kept - for the record', failed: 'failed',
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function WrapSheet({ style }: { style?: CSSProperties }) {
|
|
217
|
+
const session = useJamQueue((s) => s.session)
|
|
218
|
+
const cards = useJamQueue((s) => s.cards)
|
|
219
|
+
const run = useJamQueue((s) => s.run)
|
|
220
|
+
const agent = useJamQueue((s) => s.agent)
|
|
221
|
+
const [text, setText] = useState('')
|
|
222
|
+
const [talk, setTalk] = useState(true)
|
|
223
|
+
const [talkMin, setTalkMin] = useState(0)
|
|
224
|
+
const [tags, setTags] = useState(0)
|
|
225
|
+
const [folder, setFolder] = useState<string | null>(null)
|
|
226
|
+
const [busy, setBusy] = useState(false)
|
|
227
|
+
const field = useRef<HTMLTextAreaElement>(null)
|
|
228
|
+
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) }, () => {})
|
|
230
|
+
requestAnimationFrame(() => field.current?.focus())
|
|
231
|
+
}, [])
|
|
232
|
+
// the field grows with its words: three lines at least
|
|
233
|
+
useEffect(() => { const el = field.current; if (el) { el.style.height = 'auto'; el.style.height = `${Math.max(el.scrollHeight, 66)}px` } }, [text])
|
|
234
|
+
useEffect(() => () => { wrapWrite.current = null }, [])
|
|
235
|
+
const tries = useRef(0) // (a hook: above the early return)
|
|
236
|
+
if (!session) return null
|
|
237
|
+
const minutes = Math.max(1, Math.round((Date.now() - session.since) / 60_000))
|
|
238
|
+
// the session's captures - the lane's tiles - with where each stands
|
|
239
|
+
const caps = laneCards(cards, run).filter((c) => c.kind === 'capture' && c.session === session.id && c.state !== 'dropped')
|
|
240
|
+
const name = agent ? HARNESS[agent] ?? agent : 'your agent'
|
|
241
|
+
// Write is busy until the server answers THIS try (an older try's late end never frees it)
|
|
242
|
+
const write = async () => {
|
|
243
|
+
if (busy) return
|
|
244
|
+
const n = ++tries.current
|
|
245
|
+
setBusy(true)
|
|
246
|
+
await endSession({ instructions: text.trim(), includeTalk: talk }, () => { if (n === tries.current) setBusy(false) })
|
|
247
|
+
if (n === tries.current) setBusy(false)
|
|
248
|
+
}
|
|
249
|
+
// ⏎ anywhere in the sheet writes the record - it never reaches a panel beneath it (jam-keys' sheet row)
|
|
250
|
+
wrapWrite.current = () => void write()
|
|
251
|
+
const summary = caps.length
|
|
252
|
+
? `${caps.length} capture${caps.length === 1 ? '' : 's'} in ${minutes} min.`
|
|
253
|
+
: `No captures in ${minutes} min.`
|
|
254
|
+
return (
|
|
255
|
+
<div className="jm-panel jm-wrapup" data-jam-sheet="wrap" style={style}>
|
|
256
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
|
|
257
|
+
<div className="top"><h3>Wrap up the session</h3><span className="dim">{minutes} min</span></div>
|
|
258
|
+
<p>{summary}{tags ? ` ${tags} tag${tags === 1 ? ' was' : 's were'} answered in ${tags === 1 ? 'its thread' : 'their threads'}.` : ''}</p>
|
|
259
|
+
</div>
|
|
260
|
+
{caps.length > 0 && (
|
|
261
|
+
<div className="jm-list">
|
|
262
|
+
{caps.map((c) => (
|
|
263
|
+
<div key={c.id} className={c.state === 'done' || c.state === 'kept' ? 'dim' : undefined} data-jam-wrap-row={c.state}>
|
|
264
|
+
<JamStateIcon state={c.state as any} /><span>{c.title ?? 'Capture'}</span><small>{STATE_NOTE[c.state] ?? c.state}</small>
|
|
265
|
+
</div>
|
|
266
|
+
))}
|
|
267
|
+
</div>
|
|
268
|
+
)}
|
|
269
|
+
<div style={{ display: 'flex', flexDirection: 'column', gap: 6 }}>
|
|
270
|
+
<span className="hd">For {name}</span>
|
|
271
|
+
<textarea ref={field} className="jm-field" rows={3} value={text} data-jam-wrap-field=""
|
|
272
|
+
placeholder="How should it take this in? Do the checkout fixes first, file the small ideas as backlog..."
|
|
273
|
+
onChange={(e) => setText(e.target.value)}
|
|
274
|
+
onKeyDown={(e) => {
|
|
275
|
+
e.stopPropagation()
|
|
276
|
+
if ((e.nativeEvent as unknown as { isComposing?: boolean }).isComposing) return
|
|
277
|
+
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); void write() }
|
|
278
|
+
else if (e.key === 'Escape') { e.preventDefault(); useJamUi.getState().setSheet(null) }
|
|
279
|
+
}} />
|
|
280
|
+
</div>
|
|
281
|
+
<div className="rows">
|
|
282
|
+
<button className="row" data-jam-talk={talk ? 'on' : 'off'} onClick={() => setTalk(!talk)}>
|
|
283
|
+
<span>Include what was said between captures</span>
|
|
284
|
+
<span className="v">{talkMin ? <small>{talkMin} min</small> : null}<i className={`jm-switch${talk ? ' on' : ''}`} /></span>
|
|
285
|
+
</button>
|
|
286
|
+
</div>
|
|
287
|
+
<p style={{ fontSize: 12, color: 'var(--glass-ink-3)', margin: 0 }}>
|
|
288
|
+
{name} reads your instructions, every capture you sent or kept with its reply, and your verdicts{talk ? ', and what was said between captures' : ''}. It writes one page{folder ? <> in <code>{folder}</code></> : null} and nothing else.
|
|
289
|
+
</p>
|
|
290
|
+
<div className="actions">
|
|
291
|
+
<button className="jm-btn ghost" onClick={() => void endSession(null)}>End without a record</button>
|
|
292
|
+
<span className="sp" />
|
|
293
|
+
<button className="jm-btn primary" disabled={busy} onClick={() => void write()}>Write the record <kbd>⏎</kbd></button>
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
)
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// ---- the record, in the focus panel ------------------------------------------------------------------------
|
|
300
|
+
|
|
301
|
+
/** A session record (a wrap-up card): the page the agent wrote, its reply, and the review's moves. */
|
|
302
|
+
export function RecordDetail({ card, agent, more, onMore, onMoreOpen, onGood, onLater, onRetry, onDrop, of, onPrev, onNext }: {
|
|
303
|
+
card: JamCard; agent: string; more: boolean; of?: [number, number]
|
|
304
|
+
onMore(text: string): void; onMoreOpen(on: boolean): void; onGood(): void; onLater(): void
|
|
305
|
+
/** a record job that failed: try it again, or let it go */
|
|
306
|
+
onRetry(): void; onDrop(): void
|
|
307
|
+
onPrev?: () => void; onNext?: () => void
|
|
308
|
+
}) {
|
|
309
|
+
const [rec, setRec] = useState<{ file: string; text: string | null; reply?: string } | null>(null)
|
|
310
|
+
useEffect(() => {
|
|
311
|
+
let live = true
|
|
312
|
+
fetch(`${ROUTE}/api/jam/record?id=${encodeURIComponent(card.id)}`, { headers: { 'x-mv-c': csrf() } })
|
|
313
|
+
.then((r) => (r.ok ? r.json() : null)).then((b) => { if (live && b) setRec(b) }, () => {})
|
|
314
|
+
return () => { live = false }
|
|
315
|
+
}, [card.id, card.state, card.rev])
|
|
316
|
+
// unsent words outlive the panel (a click elsewhere closes it), as a capture review's do
|
|
317
|
+
const [note, setNoteState] = useState(() => moreDraftOf(card.id))
|
|
318
|
+
const setNote = (t: string) => { setNoteState(t); setMoreDraft(card.id, t) }
|
|
319
|
+
useEffect(() => { if (moreDraftOf(card.id) && !more) onMoreOpen(true) }, [])
|
|
320
|
+
// left on purpose (Esc cleared the draft): the field's words go too; closed by a click elsewhere, they stay
|
|
321
|
+
useEffect(() => { if (!more && !moreDraftOf(card.id)) setNoteState('') }, [more])
|
|
322
|
+
const field = useRef<HTMLTextAreaElement>(null)
|
|
323
|
+
useEffect(() => { if (more) field.current?.focus() }, [more])
|
|
324
|
+
const review = card.state === 'review'
|
|
325
|
+
const failed = card.state === 'failed'
|
|
326
|
+
return (
|
|
327
|
+
<div className="jm-panel jm-review jm-record-panel" data-jam-record="">
|
|
328
|
+
<div className="top">
|
|
329
|
+
<JamStateIcon state={card.state as any} />
|
|
330
|
+
<h3>{card.title ?? 'Session record'}</h3>
|
|
331
|
+
{of && <><span className="dim">{of[0]} of {of[1]}</span>
|
|
332
|
+
<button className="jm-iconbtn" disabled={!onPrev} onClick={onPrev} aria-label="Previous"><CaretIcon size={11} style={{ transform: 'rotate(90deg)' }} /></button>
|
|
333
|
+
<button className="jm-iconbtn" disabled={!onNext} onClick={onNext} aria-label="Next"><CaretIcon size={11} style={{ transform: 'rotate(-90deg)' }} /></button></>}
|
|
334
|
+
</div>
|
|
335
|
+
<div className="meta"><span><code>{rec?.file ?? card.file ?? 'context/sessions/'}</code></span><i /><span>{agent}</span></div>
|
|
336
|
+
{rec?.reply && <div className="jm-reply"><Marver size={20} /><p>{rec.reply}</p></div>}
|
|
337
|
+
<div className="jm-body">
|
|
338
|
+
{failed ? <div className="note-line err" data-jam-record-failed=""><WarningIcon size={14} /><span>The record was not written{card.note ? ` - ${card.note}` : ''}. Retry runs it again.</span></div>
|
|
339
|
+
: rec?.text ? <div className="jm-record">{rec.text}</div>
|
|
340
|
+
: <div className="note-line info"><span>{review ? 'The record file is not there - the agent may not have written it.' : card.state === 'working' ? 'The agent is writing the record...' : 'Queued - the record is written when the agent is free.'}</span></div>}
|
|
341
|
+
</div>
|
|
342
|
+
{failed && <div className="rule" />}
|
|
343
|
+
{failed && (
|
|
344
|
+
<div className="actions">
|
|
345
|
+
<button className="jm-btn primary" onClick={onRetry}>Retry</button>
|
|
346
|
+
<button className="jm-btn ghost" onClick={onDrop}>Drop</button>
|
|
347
|
+
</div>
|
|
348
|
+
)}
|
|
349
|
+
{review && <div className="rule" />}
|
|
350
|
+
{review && (more ? (
|
|
351
|
+
<div className="jm-more">
|
|
352
|
+
<textarea ref={field} className="txt" rows={1} value={note} placeholder="What should the record add or change?"
|
|
353
|
+
onChange={(e) => setNote(e.target.value)}
|
|
354
|
+
onKeyDown={(e) => {
|
|
355
|
+
e.stopPropagation()
|
|
356
|
+
if ((e.nativeEvent as unknown as { isComposing?: boolean }).isComposing) return
|
|
357
|
+
if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); if (note.trim()) onMore(note.trim()) }
|
|
358
|
+
if (e.key === 'Escape') { e.preventDefault(); setNote(''); onMoreOpen(false) }
|
|
359
|
+
}} />
|
|
360
|
+
<button className="jm-send" disabled={!note.trim()} onClick={() => onMore(note.trim())}>Send <kbd>⏎</kbd></button>
|
|
361
|
+
</div>
|
|
362
|
+
) : (
|
|
363
|
+
<div className="actions">
|
|
364
|
+
<button className="jm-btn primary" onClick={onGood}>Looks good <kbd>⏎</kbd></button>
|
|
365
|
+
<button className="jm-btn" onClick={() => onMoreOpen(true)}>More work <kbd>⇧⏎</kbd></button>
|
|
366
|
+
<button className="jm-btn ghost" onClick={onLater}>Later <kbd>→</kbd></button>
|
|
367
|
+
</div>
|
|
368
|
+
))}
|
|
369
|
+
</div>
|
|
370
|
+
)
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// ---- in play: the lane folds to a counter ---------------------------------------------------------------
|
|
374
|
+
|
|
375
|
+
/** The run's captures as a counter beside the navigator, by where they stand; Q opens the lane. */
|
|
376
|
+
export function PlayCounter({ cards, style }: { cards: JamCard[]; style?: CSSProperties }) {
|
|
377
|
+
const n = (s: JamCard['state']) => cards.filter((c) => c.state === s).length
|
|
378
|
+
// what needs you first, then what runs; what is settled counts as one more pair (the run still shows)
|
|
379
|
+
const pairs = (['asks', 'failed', 'review', 'draft', 'confirming', 'working', 'queued'] as const).map((s) => [s, n(s)] as const).filter(([, k]) => k > 0)
|
|
380
|
+
const settled = cards.filter((c) => c.state === 'done' || c.state === 'kept').length
|
|
381
|
+
if (!pairs.length && !settled) return null
|
|
382
|
+
return (
|
|
383
|
+
<div className="jm-count jm-stage" data-jam-counter="" style={style} onClick={() => useJamUi.getState().setLaneKeys(true)}>
|
|
384
|
+
{pairs.map(([s, k]) => <span key={s}><JamStateIcon state={s as any} size={13} />{k}</span>)}
|
|
385
|
+
{settled > 0 && <span key="done"><JamStateIcon state="done" size={13} />{settled}</span>}
|
|
386
|
+
<i className="sep" /><span className="q">Q</span>
|
|
387
|
+
</div>
|
|
388
|
+
)
|
|
389
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where Jam's surfaces stand in the shell (spec 27): the one focus panel (a capture's detail, a
|
|
3
|
+
* review, a wrap-up), the lane's selection and its keyboard (`Q`), the review's picture view.
|
|
4
|
+
*/
|
|
5
|
+
import { create } from 'zustand'
|
|
6
|
+
|
|
7
|
+
export type Panel = { kind: 'capture' | 'review' | 'wrapup'; id: string } | null
|
|
8
|
+
|
|
9
|
+
interface JamUi {
|
|
10
|
+
panel: Panel
|
|
11
|
+
/** the tile that opened the panel (or Q's focus) wears the accent ring */
|
|
12
|
+
selected: string | null
|
|
13
|
+
/** the lane has the keyboard (Q) */
|
|
14
|
+
laneKeys: boolean
|
|
15
|
+
/** the review: Before | After, the frame tab, the More work composer */
|
|
16
|
+
view: 'after' | 'before'
|
|
17
|
+
tab: number
|
|
18
|
+
moreOpen: boolean
|
|
19
|
+
/** bumps when the lane should come back to its right end (a new capture or draft) */
|
|
20
|
+
followEnd: number
|
|
21
|
+
/** the session's sheets (Part 5): the start sheet (J at rest), the wrap-up (J in a session) - or
|
|
22
|
+
* 'wrap-pending': J pressed while a capture recorded, the wrap-up waits for its read-back to close */
|
|
23
|
+
sheet: 'start' | 'wrap' | 'wrap-pending' | null
|
|
24
|
+
setSheet(s: JamUi['sheet']): void
|
|
25
|
+
open(panel: Panel): void
|
|
26
|
+
close(): void
|
|
27
|
+
setLaneKeys(on: boolean): void
|
|
28
|
+
select(id: string | null): void
|
|
29
|
+
flip(): void
|
|
30
|
+
setTab(i: number): void
|
|
31
|
+
setMoreOpen(on: boolean): void
|
|
32
|
+
follow(): void
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const useJamUi = create<JamUi>((set, get) => ({
|
|
36
|
+
panel: null, selected: null, laneKeys: false, view: 'after', tab: 0, moreOpen: false, followEnd: 0, sheet: null,
|
|
37
|
+
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 }) },
|
|
40
|
+
close() { set({ panel: null, moreOpen: false }) },
|
|
41
|
+
setLaneKeys(on) { set({ laneKeys: on }) },
|
|
42
|
+
select(id) { set({ selected: id }) },
|
|
43
|
+
flip() { set((s) => ({ view: s.view === 'after' ? 'before' : 'after' })) },
|
|
44
|
+
setTab(i) { set({ tab: i }) },
|
|
45
|
+
setMoreOpen(on) { set({ moreOpen: on }) },
|
|
46
|
+
follow() { set((s) => ({ followEnd: s.followEnd + 1 })) },
|
|
47
|
+
}))
|
|
48
|
+
|
|
49
|
+
/** A click somewhere else - the canvas, a frame, inside an interactive frame: the read-back or review open
|
|
50
|
+
* closes, its tile lets go, and the lane gives the keys back (trial 1: "anywhere on the canvas should
|
|
51
|
+
* close the review card and deselect the capture card"). Words being edited in the read-back save first:
|
|
52
|
+
* the field is left before the panel goes. */
|
|
53
|
+
export function letGoOfTile() {
|
|
54
|
+
const s = useJamUi.getState()
|
|
55
|
+
if (!s.panel && !s.selected && !s.laneKeys) return
|
|
56
|
+
const a = document.activeElement
|
|
57
|
+
if (a instanceof HTMLElement && a.closest('.jm-focus')) a.blur()
|
|
58
|
+
useJamUi.setState({ panel: null, moreOpen: false, selected: null, laneKeys: false })
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (typeof window !== 'undefined' && (import.meta as any).env?.DEV) (window as any).__mvJamUi = useJamUi
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The adapters between Jam's stores (JamSurface.tsx) and its presentational pieces (jam-lane.tsx,
|
|
3
|
+
* jam-panel.tsx): the lane row with the notes card floating over the capture tile, and the focus
|
|
4
|
+
* panel showing a capture's detail (a draft's read-back) or a review.
|
|
5
|
+
*/
|
|
6
|
+
import { useEffect, useState } from 'react'
|
|
7
|
+
import { Lane, type LaneBetween, type LaneRecording, type LaneTile } from './jam-lane.tsx'
|
|
8
|
+
import { Caption, FocusPanel, NotesCard, ReadBack, ReviewDetail, VoiceAsk } from './jam-panel.tsx'
|
|
9
|
+
import type { TimelineLine } from './jam-lines.ts'
|
|
10
|
+
import type { JamCard } from './jam-queue.ts'
|
|
11
|
+
|
|
12
|
+
export function CaptureLaneRow({ tiles, recording, between, selected, keyboard, followEnd, onOpen, onMenu, notes, ask, caption }: {
|
|
13
|
+
tiles: LaneTile[]; recording?: LaneRecording; between?: LaneBetween; selected?: string; keyboard?: boolean; followEnd?: number; onOpen(id: string): void
|
|
14
|
+
onMenu?(e: React.MouseEvent, id: string): void
|
|
15
|
+
notes?: { notes: { t: string; text: string }[]; draft: string; onDraft(t: string): void; onAdd(): void; onClose(): void }
|
|
16
|
+
/** the microphone question (and the model's download), over the capture tile */
|
|
17
|
+
ask?: Parameters<typeof VoiceAsk>[0]
|
|
18
|
+
/** the words heard so far: the earlier ones and the newest phrase */
|
|
19
|
+
caption?: { old: string; live: string }
|
|
20
|
+
}) {
|
|
21
|
+
// the notes card floats one lane up over the capture tile, left edges aligned, clamped on screen
|
|
22
|
+
const [at, setAt] = useState<{ left: number } | null>(null)
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!notes && !ask && !caption) return
|
|
25
|
+
const place = () => {
|
|
26
|
+
const tile = document.querySelector('.jm-lane .jm-chip, .jm-lane [data-jam-recording]') as HTMLElement | null
|
|
27
|
+
const r = tile?.getBoundingClientRect()
|
|
28
|
+
setAt(r ? { left: Math.max(10, Math.min(r.left, window.innerWidth - 340)) } : { left: 10 })
|
|
29
|
+
}
|
|
30
|
+
place()
|
|
31
|
+
window.addEventListener('resize', place)
|
|
32
|
+
return () => window.removeEventListener('resize', place)
|
|
33
|
+
}, [!!notes, !!ask, !!caption, tiles.length])
|
|
34
|
+
const words = !!caption && !!(caption.old || caption.live)
|
|
35
|
+
const roomLeft = (at?.left ?? 10) - 8 >= 300
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<Lane tiles={tiles} recording={recording} between={between} selected={selected} keyboard={keyboard} followEnd={followEnd} onOpen={onOpen} onMenu={onMenu} />
|
|
39
|
+
{/* one lane up, over the capture tile: the question, then the notes card above it; the words just
|
|
40
|
+
left of the notes card (bottoms aligned), or over the tile when it is closed */}
|
|
41
|
+
{(notes || ask) && (
|
|
42
|
+
<div className="jm-over" style={{ position: 'absolute', left: at?.left ?? 10, bottom: 'calc(var(--edge) + 56px + 8px)', zIndex: 41, display: 'flex', flexDirection: 'column-reverse', gap: 8, alignItems: 'flex-start' }}>
|
|
43
|
+
{ask && <VoiceAsk {...ask} />}
|
|
44
|
+
{notes && <NotesCard {...notes} />}
|
|
45
|
+
{/* no room to its left (the tile near the window's left edge): the words go on top */}
|
|
46
|
+
{words && !roomLeft && <Caption old={caption!.old} live={caption!.live} />}
|
|
47
|
+
</div>
|
|
48
|
+
)}
|
|
49
|
+
{words && (!(notes || ask) || roomLeft) && (
|
|
50
|
+
<Caption old={caption!.old} live={caption!.live} style={notes || ask
|
|
51
|
+
? { position: 'absolute', right: `calc(100% - ${(at?.left ?? 10) - 8}px)`, bottom: 'calc(var(--edge) + 56px + 8px)', zIndex: 41 }
|
|
52
|
+
: { position: 'absolute', left: at?.left ?? 10, bottom: 'calc(var(--edge) + 56px + 8px)', zIndex: 41 }} />
|
|
53
|
+
)}
|
|
54
|
+
</>
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function FocusPanelView(p: {
|
|
59
|
+
left: number; kind: 'capture' | 'review' | 'wrapup'; card: JamCard; of: [number, number] | undefined; agent: string; reviewedTitle?: string
|
|
60
|
+
lines: TimelineLine[]; pictures: { id: string; url: string; caption: string }[]
|
|
61
|
+
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
|
|
64
|
+
onEdit(text: string): void; onConfirm(): void; onKeep(): void; onDrop(): void; onResume?: () => void
|
|
65
|
+
onGood(): void; onMore(text: string): void; onLater(): void; onOpenThread(): void
|
|
66
|
+
onPrev?: () => void; onNext?: () => void; pending?: string; onRetry?: () => void; locked?: boolean
|
|
67
|
+
/** a note added in the read-back (a draft) */
|
|
68
|
+
onAddNote?(text: string, id: string): Promise<boolean>
|
|
69
|
+
}) {
|
|
70
|
+
const c = p.card
|
|
71
|
+
const title = c.title ?? 'Capture'
|
|
72
|
+
// a capture under review: its review, or the capture itself as it was read back (its pictures, its timeline)
|
|
73
|
+
const [pane, setPane] = useState<'review' | 'capture'>('review')
|
|
74
|
+
useEffect(() => { setPane('review') }, [c.id])
|
|
75
|
+
const head = p.kind === 'review' ? (
|
|
76
|
+
<div className="jm-ftabs jm-panes" role="tablist" data-jam-panes="">
|
|
77
|
+
{(['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>)}
|
|
78
|
+
</div>
|
|
79
|
+
) : undefined
|
|
80
|
+
// points are picks and clicks (a picture line carries its own number, not a point)
|
|
81
|
+
const points = p.lines.filter((l) => l.point != null && (l.kind === 'pick' || l.kind === 'click')).length
|
|
82
|
+
const notes = p.lines.filter((l) => l.kind === 'note').length
|
|
83
|
+
const meta = [p.lines.length ? p.lines[p.lines.length - 1].t : '0:00', `${c.frames.length} frame${c.frames.length === 1 ? '' : 's'}`,
|
|
84
|
+
points ? `${points} point${points === 1 ? '' : 's'}` : '', p.pictures.length ? `${p.pictures.length} picture${p.pictures.length === 1 ? '' : 's'}` : '',
|
|
85
|
+
notes ? `${notes} note${notes === 1 ? '' : 's'}` : ''].filter(Boolean)
|
|
86
|
+
return (
|
|
87
|
+
<FocusPanel left={p.left} onClose={p.onClose}>
|
|
88
|
+
{p.kind === 'review' && pane === 'review' ? (
|
|
89
|
+
<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}
|
|
91
|
+
more={p.moreOpen} draftKey={c.id} onMore={p.onMore} onMoreOpen={p.onMoreOpen} onGood={p.onGood} onLater={p.onLater} onOpenThread={p.onOpenThread} />
|
|
92
|
+
) : (
|
|
93
|
+
<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}
|
|
94
|
+
added={c.added} onAddNote={c.state === 'draft' ? p.onAddNote : undefined} autoNamed={!!c.name && !c.named && title === c.name}
|
|
95
|
+
readOnly={c.state !== 'draft'} locked={p.locked} agent={p.agent}
|
|
96
|
+
follows={c.reviewing ? p.reviewedTitle ?? 'the review on screen' : undefined}
|
|
97
|
+
onEdit={p.onEdit} onConfirm={p.onConfirm} onKeep={p.onKeep} onDrop={p.onDrop} onResume={c.state === 'draft' ? p.onResume : undefined} onOpenThread={c.thread ? p.onOpenThread : undefined}
|
|
98
|
+
onRetry={c.state === 'failed' ? p.onRetry : undefined} />
|
|
99
|
+
)}
|
|
100
|
+
</FocusPanel>
|
|
101
|
+
)
|
|
102
|
+
}
|