@marver-design/marver 0.29.0 → 0.30.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 +44 -0
- package/README.md +2 -1
- package/dist/{anchor-check-DhlpKl2K.mjs → anchor-check-c52IDkiQ.mjs} +1 -1
- package/dist/{build-CWbrb2bl.mjs → build-C3mUtjEn.mjs} +5 -4
- package/dist/cli.mjs +5 -5
- package/dist/{daemon-Sc_z8gT6.mjs → daemon-B0Wi1OQ3.mjs} +5 -3
- package/dist/{dev-DWBKQhxf.mjs → dev-5dlxoW28.mjs} +8 -8
- package/dist/{perf-Denssrko.mjs → perf-6MOTHxay.mjs} +710 -99
- package/dist/perf-BCxAo0IS.mjs +1743 -0
- package/dist/{plugin-DqoZB-D6.mjs → plugin-CXRoMA8g.mjs} +898 -539
- package/dist/{poster-CrsjqhY4.mjs → poster-CYmCa00B.mjs} +1 -1
- package/dist/{publish-bakes-DW-NDgU2.mjs → publish-bakes-C_2ZtHou.mjs} +2 -2
- package/dist/{recover-GtJ9UDAB.mjs → recover-XD8iXJOj.mjs} +1 -1
- package/dist/{shot-T04Ixrvq.mjs → shot-CRRGgxru.mjs} +3 -3
- package/docs/app.md +194 -0
- package/docs/performance.md +98 -18
- package/package.json +1 -1
- package/src/client/frame-host/bridge.js +17 -8
- package/src/client/frame-host/inplace.ts +124 -0
- package/src/client/frame-host/inspect.d.ts +1 -0
- package/src/client/frame-host/inspect.js +13 -4
- package/src/client/frame-host/main.tsx +12 -3
- package/src/client/frame-host/messages.ts +85 -0
- package/src/client/frame-host/signals.d.ts +15 -0
- package/src/client/frame-host/signals.js +219 -0
- package/src/client/recorder-level.ts +41 -0
- package/src/client/shell/App.tsx +158 -88
- package/src/client/shell/BoardList.tsx +103 -48
- package/src/client/shell/Comments.tsx +66 -42
- package/src/client/shell/ContextMenu.tsx +3 -2
- package/src/client/shell/JamSurface.tsx +116 -71
- package/src/client/shell/LockedApp.tsx +19 -3
- package/src/client/shell/Play.tsx +94 -58
- package/src/client/shell/StatusPicker.tsx +19 -9
- package/src/client/shell/Toolbar.tsx +15 -7
- package/src/client/shell/api.ts +18 -4
- package/src/client/shell/app-bridge.ts +12 -6
- package/src/client/shell/app-perf.ts +31 -1
- package/src/client/shell/canvas/Canvas.tsx +17 -6
- package/src/client/shell/canvas/FrameNode.tsx +25 -12
- package/src/client/shell/canvas/Sticky.tsx +4 -2
- package/src/client/shell/canvas/ctl.ts +2 -0
- package/src/client/shell/canvas/ready-watch.ts +4 -0
- package/src/client/shell/canvas/sleep.ts +2 -0
- package/src/client/shell/canvas/updates.ts +13 -6
- package/src/client/shell/commands.ts +765 -0
- package/src/client/shell/comments-store.ts +42 -27
- package/src/client/shell/goto.ts +11 -6
- package/src/client/shell/jam-keys.ts +141 -75
- package/src/client/shell/jam-lane.tsx +19 -12
- package/src/client/shell/jam-panel.tsx +61 -48
- package/src/client/shell/jam-session.tsx +41 -37
- package/src/client/shell/jam-state.ts +9 -1
- package/src/client/shell/jam-surface-parts.tsx +8 -6
- package/src/client/shell/jam-ui.tsx +9 -6
- package/src/client/shell/jam-voice.ts +4 -2
- package/src/client/shell/main.tsx +7 -1
- package/src/client/shell/marks-ui.tsx +11 -0
- package/src/client/shell/perf.ts +51 -5
- package/src/client/shell/recorder-core.ts +4 -1
- package/src/client/shell/recorder-hmr.ts +36 -0
- package/src/client/shell/recorder-reloads.ts +264 -0
- package/src/client/shell/recorder-seams.ts +116 -0
- package/src/client/shell/recorder-self.ts +73 -0
- package/src/client/shell/recorder-signals-core.ts +139 -0
- package/src/client/shell/recorder-signals.ts +485 -0
- package/src/client/shell/recorder.ts +115 -41
- package/src/client/shell/store.ts +56 -22
- package/src/client/shell/whiteout-probes.ts +3 -1
- package/src/client/stage/main.tsx +10 -5
- package/src/shared/app-api.ts +28 -6
- package/src/shared/app-perf.ts +99 -6
- package/src/shared/app-report.ts +586 -0
- package/src/shared/perf-records.ts +445 -0
- package/src/shared/perf-run.ts +6 -2
- package/dist/perf-jam-CLkERSHo.mjs +0 -642
|
@@ -11,12 +11,13 @@ import { captureCounts, endedToReview, useJamCapture } from './jam-capture.ts'
|
|
|
11
11
|
import { useJamVoice, voiceSession, voiceSessionEnd, voiceSessionId, type Heard } from './jam-voice.ts'
|
|
12
12
|
import { holdsSessionMic, PlayCounter, RecordDetail, StartSheet, WrapSheet } from './jam-session.tsx'
|
|
13
13
|
import { AsksAnswer, FocusPanel, Marver, VoiceAsk } from './jam-panel.tsx'
|
|
14
|
-
import { addNote, decideDraft, laneCards, openThread, openTile, pendingEdit, resumeDraft, reveal, saveEdit, shownLane, startCapture } from './jam-keys.ts'
|
|
14
|
+
import { addNote, decideDraft, endOnRecording, laneCards, openThread, openTile, pendingEdit, resumeDraft, reveal, saveEdit, shownLane, startCapture } from './jam-keys.ts'
|
|
15
15
|
import { ContextMenu, useContextMenu, type MenuItem } from './ContextMenu.tsx'
|
|
16
16
|
import { ArrowBendUpLeftIcon, ArrowLineUpIcon, ArrowUpIcon, CheckSquareOffsetIcon, CommentIcon, EyeIcon, NotebookIcon, PencilSimpleIcon, PlayIcon, ReloadIcon, XIcon } from './icons.tsx'
|
|
17
17
|
import { laneLine, laneTip, pictureCaption, timelineLines } from './jam-lines.ts'
|
|
18
|
-
import { changedShots, useJamQueue, type JamCard } from './jam-queue.ts'
|
|
19
|
-
import { DONE_GROUP, doneFold, jamSurface, letGoOfTile, useJamUi } from './jam-state.ts'
|
|
18
|
+
import { changedShots, useJamQueue, type JamAction, type JamCard } from './jam-queue.ts'
|
|
19
|
+
import { DONE_GROUP, doneFold, endOnOk, jamSurface, letGoOfTile, useJamUi } from './jam-state.ts'
|
|
20
|
+
import { cmd, COMMANDS, endAfterFrames, keysOf, type CmdHandle, type CmdName, type CmdOpts } from './commands.ts'
|
|
20
21
|
import { CaptureLaneRow, FocusPanelView } from './jam-surface-parts.tsx'
|
|
21
22
|
import { clearMoreDraft, EdgeRing, preloadShots } from './jam-panel.tsx'
|
|
22
23
|
import { useComments } from './comments-store.ts'
|
|
@@ -30,6 +31,52 @@ const csrf = () => /(?:^|;\s*)mv_c=([\w-]+)/.exec(document.cookie)?.[1] ?? ''
|
|
|
30
31
|
/** An <img> cannot send a header: its URL names the workspace, which the server's guard reads (A1.11). */
|
|
31
32
|
const picture = (id?: string) => (id ? withWs(`${ROUTE}/api/jam/picture?id=${encodeURIComponent(id)}`) : undefined)
|
|
32
33
|
|
|
34
|
+
/** A lane tile clicked: its command (spec 30) ends once its surface is drawn, or could not be. */
|
|
35
|
+
const openFromLane = (id: string, h: CmdHandle) => void endOnOk(h, openTile(id))
|
|
36
|
+
|
|
37
|
+
/** What a capture's panel does with what was chosen: its button named the command, each move ends it (spec 30). */
|
|
38
|
+
function panelMoves(c: JamCard) {
|
|
39
|
+
const ui = useJamUi.getState()
|
|
40
|
+
const act = (card: JamCard | undefined, action: JamAction, body?: string) => (card ? useJamQueue.getState().act(card, action, body) : Promise.resolve(false))
|
|
41
|
+
return {
|
|
42
|
+
onEdit: (text: string, h: CmdHandle) => void endOnOk(h, saveEdit(c, text)),
|
|
43
|
+
onConfirm: (h: CmdHandle) => void endOnOk(h, decideDraft(c.id, 'confirm')),
|
|
44
|
+
onKeep: (h: CmdHandle) => void endOnOk(h, decideDraft(c.id, 'keep')),
|
|
45
|
+
onDrop: (h: CmdHandle) => void endOnOk(h, decideDraft(c.id, 'drop')),
|
|
46
|
+
onResume: (h: CmdHandle) => void endOnOk(h, resumeDraft(c.id)),
|
|
47
|
+
onAddNote: async (text: string, id: string) => { const ok = await addNote(c, text, id); if (!ok) useStore.getState().toast('the note was not added - try again'); return ok },
|
|
48
|
+
onGood: (h: CmdHandle) => { void endOnOk(h, act(c, 'good')); ui.close() },
|
|
49
|
+
onMore: (text: string, h: CmdHandle) => void (async () => {
|
|
50
|
+
// the composer and its words stay until the follow-up is really queued
|
|
51
|
+
if (await endOnOk(h, act(c, 'more', text))) { clearMoreDraft(c.id); ui.setMoreOpen(false); ui.close() }
|
|
52
|
+
else useStore.getState().toast('your follow-up was not sent - try again')
|
|
53
|
+
})(),
|
|
54
|
+
onLater: (h: CmdHandle) => { void endOnOk(h, act(c, 'later')); ui.close() },
|
|
55
|
+
onOpenThread: (h: CmdHandle) => void endOnOk(h, openThread(c)),
|
|
56
|
+
asks: c.thread ? { question: replyText(c), onAnswer: async (text: string) => {
|
|
57
|
+
const ok = await useComments.getState().replyOk(c.thread!, /@marver\b/i.test(text) ? text : `@marver ${text}`)
|
|
58
|
+
if (!ok) useStore.getState().toast('your answer was not sent - try again')
|
|
59
|
+
else ui.close()
|
|
60
|
+
return ok
|
|
61
|
+
} } : undefined,
|
|
62
|
+
onRetry: (h: CmdHandle) => void (async () => { if (await endOnOk(h, act(useJamQueue.getState().cards?.find((x) => x.id === c.id), 'retry'))) ui.close(); else useStore.getState().toast('the capture could not be retried - look again') })(),
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The same for a session record's panel. */
|
|
67
|
+
function recordMoves(c: JamCard) {
|
|
68
|
+
const ui = useJamUi.getState()
|
|
69
|
+
const act = (action: JamAction, body?: string) => useJamQueue.getState().act(c, action, body)
|
|
70
|
+
const andClose = (action: JamAction) => (h: CmdHandle) => { void endOnOk(h, act(action)); ui.close() }
|
|
71
|
+
return {
|
|
72
|
+
onGood: andClose('good'), onLater: andClose('later'), onRetry: andClose('retry'), onDrop: andClose('drop'),
|
|
73
|
+
onMore: (text: string, h: CmdHandle) => void (async () => {
|
|
74
|
+
if (await endOnOk(h, act('more', text))) { clearMoreDraft(c.id); ui.setMoreOpen(false); ui.close() }
|
|
75
|
+
else useStore.getState().toast('your note was not sent - try again')
|
|
76
|
+
})(),
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
33
80
|
/** Is the lane showing? While a run lasts with a capture in it, or a capture records. */
|
|
34
81
|
export function useLaneShown(): boolean {
|
|
35
82
|
const cards = useJamQueue((s) => s.cards)
|
|
@@ -170,13 +217,13 @@ export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
|
|
|
170
217
|
return { time: counts.time, points: c?.points.length ?? 0, pictures: c?.pictures.length ?? 0, picturesMax: (c?.pictures.length ?? 0) >= 12, steps,
|
|
171
218
|
notes: counts.notes, noteOn: cap.noteOpen, onNote: () => cap.setNoteOpen(!cap.noteOpen), onStop: () => cap.end(), onStopReview: () => cap.end(true),
|
|
172
219
|
// the microphone: on while it hears this capture; off once you were asked (a click asks again)
|
|
173
|
-
...(voice.hearing === cap.current ? { mic: 'on' as const } : voice.choice !== null || voice.denied ? { mic: 'off' as const, onMic: () => useJamVoice.setState({ asking: true, choice: null }) } : {}) }
|
|
220
|
+
...(voice.hearing === cap.current ? { mic: 'on' as const } : voice.choice !== null || voice.denied ? { mic: 'off' as const, onMic: (h: CmdHandle) => { useJamVoice.setState({ asking: true, choice: null }); endAfterFrames(h) } } : {}) }
|
|
174
221
|
})() : undefined
|
|
175
222
|
|
|
176
223
|
// a session between captures (none recording, none still sealing here): its own tile
|
|
177
224
|
const between = session && !cap.current ? {
|
|
178
225
|
since: session.since, mic: voice.live,
|
|
179
|
-
onCapture: () => startCapture(), // as S: one started over an open review follows it
|
|
226
|
+
onCapture: (h: CmdHandle) => { startCapture(); endOnRecording(h) }, // as S: one started over an open review follows it
|
|
180
227
|
} : undefined
|
|
181
228
|
|
|
182
229
|
const panelCard = ui.panel && ui.panel.kind !== 'thread' ? cards?.find((c) => c.id === ui.panel!.id) : undefined
|
|
@@ -187,7 +234,6 @@ export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
|
|
|
187
234
|
}, [cards, ui.panel])
|
|
188
235
|
const rec = useRecord(ui.panel?.kind === 'capture' || ui.panel?.kind === 'review' ? ui.panel.id : undefined)
|
|
189
236
|
const agentName = agent ? HARNESS[agent] ?? agent : 'your agent'
|
|
190
|
-
const act = (c: JamCard | undefined, action: Parameters<ReturnType<typeof useJamQueue.getState>['act']>[1], body?: string) => (c ? useJamQueue.getState().act(c, action, body) : Promise.resolve(false))
|
|
191
237
|
/** The panel's arrows: the previous or next card of the same kind on the lane (reviews among reviews). */
|
|
192
238
|
const step = (d: number) => {
|
|
193
239
|
if (!ui.panel || !panelCard) return undefined
|
|
@@ -202,6 +248,9 @@ export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
|
|
|
202
248
|
return { of: [idx + 1, of.length] as [number, number] }
|
|
203
249
|
}, [ui.panel, panelCard, list])
|
|
204
250
|
|
|
251
|
+
// a right-click on a tile: its menu (each item a command of its own)
|
|
252
|
+
const menuAt = (e: React.MouseEvent, id: string) => { const c = cards?.find((x) => x.id === id); if (c) { ui.select(id); cm.open(e, tileMenu(c), `tile:${id}`) } else e.preventDefault() }
|
|
253
|
+
|
|
205
254
|
const sheetOpen = ui.sheet === 'start' || ui.sheet === 'wrap'
|
|
206
255
|
// the microphone question in a session with no capture recording: under the Jam button
|
|
207
256
|
const askAlone = voice.asking && !cap.current && !!session
|
|
@@ -220,9 +269,9 @@ export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
|
|
|
220
269
|
{shown && (
|
|
221
270
|
<CaptureLaneRow
|
|
222
271
|
tiles={folded ? [] : tiles} recording={recording} between={between} selected={ui.selected ?? undefined} keyboard={ui.laneKeys} followEnd={ui.followEnd}
|
|
223
|
-
doneOpen={ui.doneOpen} onDoneOpen={
|
|
224
|
-
onOpen={
|
|
225
|
-
onMenu={
|
|
272
|
+
doneOpen={ui.doneOpen} onDoneOpen={ui.setDoneOpen}
|
|
273
|
+
onOpen={openFromLane}
|
|
274
|
+
onMenu={menuAt}
|
|
226
275
|
ask={voice.asking && cap.current ? voiceAsk(voice) : undefined}
|
|
227
276
|
caption={cap.current ? captionOf(voice.heard[cap.current]) : undefined}
|
|
228
277
|
notes={cap.noteOpen ? {
|
|
@@ -232,22 +281,14 @@ export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
|
|
|
232
281
|
/>
|
|
233
282
|
)}
|
|
234
283
|
{panel?.kind === 'thread' && (
|
|
235
|
-
<FocusPanel left={sidebarRight} onClose={
|
|
284
|
+
<FocusPanel left={sidebarRight} onClose={ui.close}>
|
|
236
285
|
<ThreadPanel key={`${panel.board}/${panel.id}`} board={panel.board} id={panel.id} />
|
|
237
286
|
</FocusPanel>
|
|
238
287
|
)}
|
|
239
288
|
{ui.panel && panelCard && panelCard.kind === 'wrapup' && (
|
|
240
|
-
<FocusPanel left={sidebarRight} onClose={
|
|
289
|
+
<FocusPanel left={sidebarRight} onClose={ui.close}>
|
|
241
290
|
<RecordDetail key={panelCard.id} card={panelCard} agent={agentName} more={ui.moreOpen} of={detail?.of} onPrev={step(-1)} onNext={step(1)}
|
|
242
|
-
onMoreOpen={
|
|
243
|
-
onGood={() => { void act(panelCard, 'good'); ui.close() }}
|
|
244
|
-
onLater={() => { void act(panelCard, 'later'); ui.close() }}
|
|
245
|
-
onRetry={() => { void act(panelCard, 'retry'); ui.close() }}
|
|
246
|
-
onDrop={() => { void act(panelCard, 'drop'); ui.close() }}
|
|
247
|
-
onMore={(text) => void (async () => {
|
|
248
|
-
if (await act(panelCard, 'more', text)) { clearMoreDraft(panelCard.id); ui.setMoreOpen(false); ui.close() }
|
|
249
|
-
else useStore.getState().toast('your note was not sent - try again')
|
|
250
|
-
})()} />
|
|
291
|
+
onMoreOpen={ui.setMoreOpen} {...recordMoves(panelCard)} />
|
|
251
292
|
</FocusPanel>
|
|
252
293
|
)}
|
|
253
294
|
{panel && panel.kind !== 'thread' && panelCard && panelCard.kind !== 'wrapup' && (
|
|
@@ -263,30 +304,10 @@ export function JamSurface({ sidebarRight }: { sidebarRight: number }) {
|
|
|
263
304
|
shots={changedShots(panelCard.shots).map((x) => ({ frame: x.frame, before: picture(x.before), after: picture(x.after), ...(x.new ? { new: true } : {}) }))}
|
|
264
305
|
reply={panelCard.reply ? replyText(panelCard) : ''}
|
|
265
306
|
view={ui.view} tab={ui.tab} moreOpen={ui.moreOpen}
|
|
266
|
-
onTab={
|
|
267
|
-
onClose={
|
|
268
|
-
|
|
269
|
-
onConfirm={() => void decideDraft(panelCard.id, 'confirm')}
|
|
270
|
-
onKeep={() => void decideDraft(panelCard.id, 'keep')}
|
|
271
|
-
onDrop={() => void decideDraft(panelCard.id, 'drop')}
|
|
272
|
-
onResume={() => void resumeDraft(panelCard.id)}
|
|
273
|
-
onAddNote={async (text, id) => { const ok = await addNote(panelCard, text, id); if (!ok) useStore.getState().toast('the note was not added - try again'); return ok }}
|
|
274
|
-
onGood={() => { void act(panelCard, 'good'); ui.close() }}
|
|
275
|
-
onMore={(text) => void (async () => {
|
|
276
|
-
// the composer and its words stay until the follow-up is really queued
|
|
277
|
-
if (await act(panelCard, 'more', text)) { clearMoreDraft(panelCard.id); ui.setMoreOpen(false); ui.close() }
|
|
278
|
-
else useStore.getState().toast('your follow-up was not sent - try again')
|
|
279
|
-
})()}
|
|
280
|
-
onLater={() => { void act(panelCard, 'later'); ui.close() }}
|
|
281
|
-
onOpenThread={() => openThread(panelCard)}
|
|
282
|
-
asks={panelCard.thread ? { question: replyText(panelCard), onAnswer: async (text) => {
|
|
283
|
-
const ok = await useComments.getState().replyOk(panelCard.thread!, /@marver\b/i.test(text) ? text : `@marver ${text}`)
|
|
284
|
-
if (!ok) useStore.getState().toast('your answer was not sent - try again')
|
|
285
|
-
else ui.close()
|
|
286
|
-
return ok
|
|
287
|
-
} } : undefined}
|
|
307
|
+
onTab={ui.setTab} onFlip={ui.setView} onMoreOpen={ui.setMoreOpen}
|
|
308
|
+
onClose={ui.close}
|
|
309
|
+
{...panelMoves(panelCard)}
|
|
288
310
|
onPrev={step(-1)} onNext={step(1)} pending={pendingEdit(panelCard.id)} locked={cap.settling === panelCard.id}
|
|
289
|
-
onRetry={() => void (async () => { if (await act(useJamQueue.getState().cards?.find((x) => x.id === panelCard.id), 'retry')) ui.close(); else useStore.getState().toast('the capture could not be retried - look again') })()}
|
|
290
311
|
/>
|
|
291
312
|
)}
|
|
292
313
|
<ContextMenu menu={cm.menu} close={cm.close} />
|
|
@@ -310,6 +331,12 @@ function ThreadPanel({ board, id }: { board: string; id: string }) {
|
|
|
310
331
|
const onThread = (cards ?? []).filter((c) => c.board === board && c.thread === id)
|
|
311
332
|
const line = (b?: string) => (b ?? '').replace(/\s+/g, ' ').trim()
|
|
312
333
|
const last = t && t.replies.length ? t.replies[t.replies.length - 1] : t
|
|
334
|
+
const answer = async (text: string) => {
|
|
335
|
+
const body = onThread.length && !/@marver\b/i.test(text) ? `@marver ${text}` : text
|
|
336
|
+
const ok = await useComments.getState().replyOk(id, body)
|
|
337
|
+
if (!ok) useStore.getState().toast('your answer was not sent - try again')
|
|
338
|
+
return ok
|
|
339
|
+
}
|
|
313
340
|
return (
|
|
314
341
|
<div className="jm-panel jm-thread" data-jam-thread-panel={id} {...(t?.resolved ? { 'data-resolved': '' } : {})}>
|
|
315
342
|
<div className="top">
|
|
@@ -333,12 +360,7 @@ function ThreadPanel({ board, id }: { board: string; id: string }) {
|
|
|
333
360
|
<div key={c.id} className="jm-thread-status"><TagStatus board={board} eventId={c.events[c.events.length - 1]} harness={HARNESS} /></div>
|
|
334
361
|
))}
|
|
335
362
|
{!t.resolved && (
|
|
336
|
-
<AsksAnswer tag={onThread.length > 0} onAnswer={
|
|
337
|
-
const body = onThread.length && !/@marver\b/i.test(text) ? `@marver ${text}` : text
|
|
338
|
-
const ok = await useComments.getState().replyOk(id, body)
|
|
339
|
-
if (!ok) useStore.getState().toast('your answer was not sent - try again')
|
|
340
|
-
return ok
|
|
341
|
-
}} />
|
|
363
|
+
<AsksAnswer tag={onThread.length > 0} onAnswer={answer} />
|
|
342
364
|
)}
|
|
343
365
|
</>}
|
|
344
366
|
</div>
|
|
@@ -362,10 +384,26 @@ function voiceAsk(v: ReturnType<typeof useJamVoice.getState>) {
|
|
|
362
384
|
: d?.state === 'failed' ? 'failed' as const : 'download' as const
|
|
363
385
|
return {
|
|
364
386
|
step, mb: v.mb, progress: d && d.total ? d.received / d.total : 0, error: v.server === 'unavailable' ? v.reason : d?.error,
|
|
365
|
-
|
|
387
|
+
// `jam-voice` ends when the consent or the download state changed; "Not now" backed out, "Typed notes only" chose
|
|
388
|
+
onYes: (h: CmdHandle) => void v.setChoice('yes').then(() => h.done(), () => h.done()),
|
|
389
|
+
onNo: (h: CmdHandle) => { void v.setChoice('no'); if (step === 'unavailable') h.done(); else h.cancel() },
|
|
390
|
+
onDownload: (h: CmdHandle) => void v.startDownload().then(() => endOnDownload(h)),
|
|
366
391
|
}
|
|
367
392
|
}
|
|
368
393
|
|
|
394
|
+
/** `jam-voice`'s Download or Try again: ends with the download, as the poll sees it after the request was answered - each
|
|
395
|
+
* answer's `download` is a new object, so a failure from before it never counts. The listener goes once nothing more can
|
|
396
|
+
* be written: the command's deadline, and as long again for a late end. */
|
|
397
|
+
function endOnDownload(h: CmdHandle) {
|
|
398
|
+
const stop = useJamVoice.subscribe((s, p) => {
|
|
399
|
+
if (s.download === p.download && s.server === p.server) return
|
|
400
|
+
const d = s.download?.state
|
|
401
|
+
if (d === 'failed' || s.server === 'unavailable') { stop(); h.fail('download-failed') }
|
|
402
|
+
else if (d === 'done' || s.server === 'ready' || s.server === 'loading') { stop(); h.done() }
|
|
403
|
+
})
|
|
404
|
+
setTimeout(stop, 2 * COMMANDS['jam-voice'].deadlineMs)
|
|
405
|
+
}
|
|
406
|
+
|
|
369
407
|
/** The caption's words: the newest phrase in ink, a little of what came before it dim. */
|
|
370
408
|
function captionOf(heard: Heard[] | undefined): { old: string; live: string } | undefined {
|
|
371
409
|
if (!heard?.length) return undefined
|
|
@@ -375,10 +413,10 @@ function captionOf(heard: Heard[] | undefined): { old: string; live: string } |
|
|
|
375
413
|
return { old: old.join(' '), live: live.join(' ') }
|
|
376
414
|
}
|
|
377
415
|
|
|
378
|
-
/** Open a card's thread with the caret in its reply field - to add to the conversation. */
|
|
379
|
-
function replyIn(c: JamCard) {
|
|
380
|
-
if (!c.thread) return
|
|
381
|
-
openThread(c)
|
|
416
|
+
/** Open a card's thread with the caret in its reply field - to add to the conversation. `h` ends once the thread is drawn. */
|
|
417
|
+
function replyIn(c: JamCard, h: CmdHandle) {
|
|
418
|
+
if (!c.thread) { h.fail('refused'); return }
|
|
419
|
+
void endOnOk(h, openThread(c))
|
|
382
420
|
// once the thread's card has drawn (on another board, once that board has loaded)
|
|
383
421
|
const until = performance.now() + 3_000
|
|
384
422
|
const focus = () => {
|
|
@@ -391,30 +429,31 @@ function replyIn(c: JamCard) {
|
|
|
391
429
|
|
|
392
430
|
/** A tile's right-click menu: what can be done with this capture now. */
|
|
393
431
|
function tileMenu(c: JamCard): MenuItem[] {
|
|
394
|
-
const
|
|
395
|
-
const act = (a:
|
|
396
|
-
|
|
432
|
+
const fresh = () => useJamQueue.getState().cards?.find((x) => x.id === c.id)
|
|
433
|
+
const act = (a: JamAction) => (h: CmdHandle) => { const card = fresh(); if (card) void endOnOk(h, useJamQueue.getState().act(card, a)); else h.fail('refused') }
|
|
434
|
+
// each item is its command: named at its click, ended by what it runs
|
|
435
|
+
const item = (label: string, icon: ReactNode, name: CmdName, run: (h: CmdHandle) => void): MenuItem => ({ label, icon, onClick: () => run(cmd(name, { via: 'context', in: 'shell' })) })
|
|
397
436
|
// one icon per action, never two alike in a menu: open (eye), review (checklist), resume (play), rename
|
|
398
437
|
// (pencil), add to queue (send arrow), keep (notebook), do next (to the top), retry, reply, thread, drop
|
|
399
|
-
const open = item(c.state === 'review' ? 'Review' : c.state === 'draft' ? 'Open read-back' : 'Open', c.state === 'review' ? <CheckSquareOffsetIcon size={14} /> : <EyeIcon size={14} />, () => openTile(c.id))
|
|
438
|
+
const open = item(c.state === 'review' ? 'Review' : c.state === 'draft' ? 'Open read-back' : 'Open', c.state === 'review' ? <CheckSquareOffsetIcon size={14} /> : <EyeIcon size={14} />, 'jam-open', (h) => void endOnOk(h, openTile(c.id)))
|
|
400
439
|
const rename: MenuItem = { label: 'Rename', icon: <PencilSimpleIcon size={14} />, panel: (close) => <RenameField card={c} close={close} /> }
|
|
401
|
-
const reply = c.thread ? [item('Reply in thread', <ArrowBendUpLeftIcon size={14} />, () => replyIn(c))] : []
|
|
402
|
-
const thread = c.thread ? [item('Open thread', <CommentIcon size={14} />, () => openThread(c))] : []
|
|
440
|
+
const reply = c.thread ? [item('Reply in thread', <ArrowBendUpLeftIcon size={14} />, 'jam-reply', (h) => replyIn(c, h))] : []
|
|
441
|
+
const thread = c.thread ? [item('Open thread', <CommentIcon size={14} />, 'jam-thread', (h) => void endOnOk(h, openThread(c)))] : []
|
|
403
442
|
switch (c.state) {
|
|
404
|
-
case 'draft': return [open, item('Resume capture', <PlayIcon size={14} />, () => void resumeDraft(c.id)), rename,
|
|
405
|
-
item('Add to queue', <ArrowUpIcon size={14} />, () => void decideDraft(c.id, 'confirm')), item('Keep, do not send', <NotebookIcon size={14} />, () => void decideDraft(c.id, 'keep')),
|
|
406
|
-
item('Drop', <XIcon size={14} />, () => void decideDraft(c.id, 'drop'))]
|
|
443
|
+
case 'draft': return [open, item('Resume capture', <PlayIcon size={14} />, 'jam-resume', (h) => void endOnOk(h, resumeDraft(c.id))), rename,
|
|
444
|
+
item('Add to queue', <ArrowUpIcon size={14} />, 'jam-confirm', (h) => void endOnOk(h, decideDraft(c.id, 'confirm'))), item('Keep, do not send', <NotebookIcon size={14} />, 'jam-keep', (h) => void endOnOk(h, decideDraft(c.id, 'keep'))),
|
|
445
|
+
item('Drop', <XIcon size={14} />, 'jam-drop', (h) => void endOnOk(h, decideDraft(c.id, 'drop')))]
|
|
407
446
|
case 'queued': return c.kind === 'capture'
|
|
408
|
-
? [open, rename, item('Do next', <ArrowLineUpIcon size={14} />,
|
|
409
|
-
: [open, item('Drop', <XIcon size={14} />,
|
|
447
|
+
? [open, rename, item('Do next', <ArrowLineUpIcon size={14} />, 'jam-do-next', act('first')), item('Keep, do not send', <NotebookIcon size={14} />, 'jam-keep', act('keep')), item('Drop', <XIcon size={14} />, 'jam-drop', act('drop'))]
|
|
448
|
+
: [open, item('Drop', <XIcon size={14} />, 'jam-drop', act('drop'))] // a queued record: open or drop it
|
|
410
449
|
case 'review': return [open, ...reply, ...thread, rename]
|
|
411
450
|
case 'asks': return [...reply, open, rename]
|
|
412
|
-
case 'failed': return [item('Retry', <ReloadIcon size={14} />,
|
|
451
|
+
case 'failed': return [item('Retry', <ReloadIcon size={14} />, 'jam-retry', act('retry')), open, ...thread, item('Drop', <XIcon size={14} />, 'jam-drop', act('drop'))]
|
|
413
452
|
case 'working': {
|
|
414
453
|
// a run your session went quiet on (spec 29b): give it back, run it in the background, or drop it
|
|
415
454
|
if (c.runner?.kind !== 'session' || c.runner.state !== 'stalled') return [open, ...reply, ...thread, rename]
|
|
416
|
-
const run = (a: 'again' | 'background' | 'drop') => () => { const
|
|
417
|
-
return [item('Give it back to your session', <ReloadIcon size={14} />, run('again')), item('Run it in the background', <ArrowUpIcon size={14} />, run('background')), open, ...thread, item('Drop it', <XIcon size={14} />, run('drop'))]
|
|
455
|
+
const run = (a: 'again' | 'background' | 'drop') => (h: CmdHandle) => { const card = fresh(); if (card) void endOnOk(h, useJamQueue.getState().runAct(card, a)); else h.fail('refused') }
|
|
456
|
+
return [item('Give it back to your session', <ReloadIcon size={14} />, 'jam-again', run('again')), item('Run it in the background', <ArrowUpIcon size={14} />, 'jam-background', run('background')), open, ...thread, item('Drop it', <XIcon size={14} />, 'jam-drop', run('drop'))]
|
|
418
457
|
}
|
|
419
458
|
default: return [open, ...reply, ...thread, rename]
|
|
420
459
|
}
|
|
@@ -425,16 +464,22 @@ function RenameField({ card, close }: { card: JamCard; close: () => void }) {
|
|
|
425
464
|
const [text, setText] = useState(card.named ? card.title ?? '' : card.title === 'Capture' ? '' : card.title ?? '')
|
|
426
465
|
const ref = useRef<HTMLInputElement>(null)
|
|
427
466
|
useEffect(() => { requestAnimationFrame(() => ref.current?.select()) }, [])
|
|
428
|
-
const save = async () => {
|
|
467
|
+
const save = async (h: CmdHandle) => {
|
|
429
468
|
const fresh = useJamQueue.getState().cards?.find((x) => x.id === card.id)
|
|
430
|
-
if (
|
|
469
|
+
if (!fresh) h.fail('refused')
|
|
470
|
+
else if (!(await endOnOk(h, useJamQueue.getState().act(fresh, 'rename', text)))) useStore.getState().toast('the capture could not be renamed - look again')
|
|
431
471
|
close()
|
|
432
472
|
}
|
|
433
473
|
return (
|
|
434
474
|
<div className="jm-rename">
|
|
435
475
|
<input ref={ref} value={text} maxLength={80} placeholder="Name this capture" aria-label="Capture name"
|
|
436
476
|
onChange={(e) => setText(e.target.value)}
|
|
437
|
-
onKeyDown={(e) => {
|
|
477
|
+
onKeyDown={(e) => {
|
|
478
|
+
e.stopPropagation()
|
|
479
|
+
const how: CmdOpts = { via: 'key', in: 'shell', keys: keysOf(e) }
|
|
480
|
+
if (e.key === 'Enter') void save(cmd('jam-rename', how))
|
|
481
|
+
if (e.key === 'Escape') { cmd('jam-rename', how).cancel(); close() }
|
|
482
|
+
}} />
|
|
438
483
|
</div>
|
|
439
484
|
)
|
|
440
485
|
}
|
|
@@ -16,6 +16,7 @@ import { UNPLACED, bootHash, parseHash, retargetBoot, writeHash } from './hash.t
|
|
|
16
16
|
import { isLegacyLink, landLegacy } from './legacy-links.ts'
|
|
17
17
|
import { useComments } from './comments-store.ts'
|
|
18
18
|
import { isLatest, navigated, switchFor } from './goto.ts'
|
|
19
|
+
import { cmd, endAfterFrames, endOnLoad, endOnStage, shellReload, type CmdHandle } from './commands.ts'
|
|
19
20
|
|
|
20
21
|
/** App.tsx's headless-run probe (perf-run-probe.ts): a run's page is always a dev canvas, never a locked bundle. */
|
|
21
22
|
export function startPerfRunProbe(): void {}
|
|
@@ -29,7 +30,7 @@ export class ShellBoundary extends Component<{ children: ReactNode }, { err: Err
|
|
|
29
30
|
<div style={{ fontFamily: 'ui-monospace, monospace', padding: 32 }}>
|
|
30
31
|
<b style={{ color: '#a81f16' }}>shell crashed</b>
|
|
31
32
|
<pre style={{ whiteSpace: 'pre-wrap', fontSize: 12 }}>{this.state.err.message}</pre>
|
|
32
|
-
<button onClick={() => location.reload()}>reload</button>
|
|
33
|
+
<button onClick={() => { shellReload(cmd('shell-reload', { via: 'click', in: 'shell' })); location.reload() }}>reload</button>
|
|
33
34
|
</div>
|
|
34
35
|
)
|
|
35
36
|
}
|
|
@@ -100,9 +101,17 @@ export function App() {
|
|
|
100
101
|
|
|
101
102
|
// back/forward + pasted links, within what the lock allows
|
|
102
103
|
useEffect(() => {
|
|
104
|
+
let recorded: { hash: string; at: number; h: CmdHandle | null; run: number } = { hash: '', at: -1_000, h: null, run: 0 }
|
|
103
105
|
const onPop = async () => {
|
|
104
106
|
// a lookup newer navigation overtook - a link, a goto, a step on the stage - is dropped
|
|
105
107
|
const nav = navigated(), was = useStore.getState()
|
|
108
|
+
// spec 30: back/forward fires popstate AND hashchange; the second carries the first's command on
|
|
109
|
+
const hash = location.hash
|
|
110
|
+
const again = hash === recorded.hash && performance.now() - recorded.at < 250
|
|
111
|
+
const run = recorded.run + 1
|
|
112
|
+
const nav_ = again ? recorded.h : cmd('history-nav', { via: 'click', in: 'shell' })
|
|
113
|
+
recorded = { hash, at: performance.now(), h: nav_, run }
|
|
114
|
+
const giveUp = () => { if (recorded.run === run) nav_?.cancel('superseded') }
|
|
106
115
|
const parsed = parseHash()
|
|
107
116
|
const raw = parsed.board === UNPLACED ? {} : parsed // dev's view, and what it names: not here
|
|
108
117
|
// an old All Scenes link lands on a real board; it, and the bare #/, with no board: the landing one
|
|
@@ -110,17 +119,24 @@ export function App() {
|
|
|
110
119
|
const h = r.hash
|
|
111
120
|
const board = h.board ?? (h.focus ? undefined : await landingBoard())
|
|
112
121
|
const s = useStore.getState()
|
|
113
|
-
if (!isLatest(nav) || s.board !== was.board || s.play?.at !== was.play?.at) return
|
|
122
|
+
if (!isLatest(nav) || s.board !== was.board || s.play?.at !== was.play?.at) return giveUp()
|
|
114
123
|
if (r.notice) s.toast(r.notice)
|
|
115
124
|
if (h.c) pendingThread = h.c
|
|
116
125
|
if (board && board !== s.board) {
|
|
117
|
-
if (
|
|
126
|
+
if (nav_) endOnLoad(nav_, board) // another board: its load's way ends it (#49)
|
|
127
|
+
if (!await switchFor(board, nav)) return giveUp() // failed, or a newer navigation's board and stage by now
|
|
118
128
|
useStore.getState().setPlay(null) // the stage restarts on the board the link names, at its frame
|
|
119
129
|
if (h.play?.slides) enterSlides(h.play)
|
|
120
130
|
else if (h.play) enterPlay(h.play)
|
|
121
131
|
else land(h.f?.[0])
|
|
122
132
|
return
|
|
123
133
|
}
|
|
134
|
+
// the same board: the stage's next screen when it moves, else the change once drawn (#49)
|
|
135
|
+
const toStage = (at?: string) => { if (nav_) { if (s.play && (!at || at === s.play.at)) endAfterFrames(nav_); else endOnStage(nav_, at) } }
|
|
136
|
+
if (h.f?.length && s.play) toStage(h.f[0])
|
|
137
|
+
else if (h.focus) toStage(h.focus.at)
|
|
138
|
+
else if (h.play) toStage(h.play.at)
|
|
139
|
+
else if (nav_) endAfterFrames(nav_) // a thread link, or the board itself: nothing else moves
|
|
124
140
|
openPending() // same board: its comments are here already
|
|
125
141
|
if (h.f?.length && s.play) return playCtl.setAt(h.f[0]) // the stage on screen steps to the frame named
|
|
126
142
|
if (h.focus) enterFocus(h.focus.at, { ...h.focus, deep: true })
|