@lincyaw/workbench 0.2.0-rc.9 → 0.2.0-rc.90

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 (90) hide show
  1. package/package.json +5 -4
  2. package/src/MediaClipEditor.tsx +4 -3
  3. package/src/StepProductionEditor.tsx +13 -4
  4. package/src/approvals.tsx +6 -1
  5. package/src/audio-recording.ts +27 -5
  6. package/src/authoring-client.ts +10 -10
  7. package/src/authoring-draft-fragment.ts +3 -1
  8. package/src/authoring-window.ts +100 -0
  9. package/src/body-draft-actions.ts +60 -0
  10. package/src/caption-timing-drafts.ts +18 -1
  11. package/src/component-property-drafts.ts +5 -5
  12. package/src/components.tsx +22 -31
  13. package/src/context.tsx +5 -3
  14. package/src/diagnostics.ts +1 -1
  15. package/src/document-draft-store.ts +45 -18
  16. package/src/document-drafts.ts +28 -19
  17. package/src/document-editing.ts +484 -0
  18. package/src/document-editor/BlockNoteSurface.tsx +25 -9
  19. package/src/document-editor/ComponentMaterials.tsx +3 -9
  20. package/src/document-editor/ComponentPropertiesDialog.tsx +4 -4
  21. package/src/document-editor/DocumentBlockPreview.tsx +4 -2
  22. package/src/document-editor/DocumentComments.tsx +85 -14
  23. package/src/document-editor/DocumentEditor.tsx +44 -7
  24. package/src/document-editor/DocumentStepNarration.tsx +33 -25
  25. package/src/document-editor/NarrationEditor.tsx +54 -20
  26. package/src/document-editor/NewCommentDrafts.tsx +114 -31
  27. package/src/document-editor/PlaceComment.tsx +228 -0
  28. package/src/document-editor/comment-draft-actions.ts +40 -20
  29. package/src/document-editor/comment-draft-inspection.ts +2 -2
  30. package/src/document-editor/comment-drafts.ts +73 -25
  31. package/src/document-editor/comments.ts +30 -10
  32. package/src/document-editor/component-label.ts +11 -0
  33. package/src/document-editor/file-input.ts +2 -2
  34. package/src/document-editor/focus.ts +0 -2
  35. package/src/document-editor/insertion-place.ts +60 -0
  36. package/src/document-editor/messages.ts +3 -3
  37. package/src/document-editor/narration-schema.tsx +12 -6
  38. package/src/document-editor/narration.ts +19 -3
  39. package/src/document-editor/page-body.ts +60 -0
  40. package/src/document-editor/projection.ts +2 -2
  41. package/src/document-editor/rich-text.ts +3 -2
  42. package/src/document-editor/selection.ts +13 -0
  43. package/src/document-editor/style.css +12 -1
  44. package/src/document-editor/table-identities.ts +2 -1
  45. package/src/document-production.ts +491 -0
  46. package/src/document-session.ts +202 -56
  47. package/src/document-timing-drafts.ts +22 -2
  48. package/src/history.ts +5 -5
  49. package/src/index.ts +6 -5
  50. package/src/jobs.ts +1 -1
  51. package/src/media-drafts.ts +43 -1
  52. package/src/messages.ts +31 -14
  53. package/src/panels/DocumentView.tsx +71 -28
  54. package/src/panels/DocumentVoiceDialog.tsx +25 -9
  55. package/src/panels/DocumentVoiceField.tsx +1 -1
  56. package/src/panels/ExportPanel.tsx +1 -6
  57. package/src/panels/HistoryPanel.tsx +32 -2
  58. package/src/panels/PageDeleteDialog.tsx +4 -4
  59. package/src/panels/PageRenameDialog.tsx +1 -1
  60. package/src/panels/PreviewPanel.tsx +1 -4
  61. package/src/panels/ProductionCaptionSize.tsx +20 -0
  62. package/src/panels/ProductionCaptionTiming.tsx +12 -9
  63. package/src/panels/ProductionMediaClips.tsx +23 -7
  64. package/src/panels/ProductionPanel.tsx +8 -4
  65. package/src/panels/ProductionRecording.tsx +86 -9
  66. package/src/panels/ProductionRecordingRange.tsx +21 -19
  67. package/src/panels/ProductionTimeline.tsx +6 -1
  68. package/src/panels/ProductionTranscription.tsx +5 -4
  69. package/src/panels/SourceDocumentPanel.tsx +16 -36
  70. package/src/panels/TranscriptionAdoption.tsx +40 -34
  71. package/src/panels/VoiceCloneDialog.tsx +2 -1
  72. package/src/panels/VoiceoverDialog.tsx +1 -1
  73. package/src/places.ts +1 -36
  74. package/src/preview-playback.ts +1 -1
  75. package/src/production-draft-actions.ts +37 -0
  76. package/src/production-messages.ts +6 -0
  77. package/src/production-playback.ts +1 -1
  78. package/src/production-voice-playback.ts +3 -2
  79. package/src/sha256.ts +9 -0
  80. package/src/styles.css +21 -43
  81. package/src/transcription-drafts.ts +124 -0
  82. package/src/use-recording-adoption.ts +2 -2
  83. package/src/voice-drafts.ts +32 -8
  84. package/src/voiceover-jobs.ts +1 -1
  85. package/src/workbench-state.ts +157 -0
  86. package/src/workbench.ts +258 -951
  87. package/src/workspace-client.ts +21 -11
  88. package/src/assistant-mascot.ts +0 -62
  89. package/src/mascot-preference.ts +0 -37
  90. package/src/panels/ChangeTrail.tsx +0 -79
@@ -1,9 +1,10 @@
1
+ import { hasRole } from '@lincyaw/kernel'
1
2
  import type { HistoryRevision } from '@lincyaw/kernel'
2
3
  import { PmBadge, PmButton, PmEmpty, PmIcon, PmIconButton, PmNotice } from '../components.tsx'
3
4
  import type { IconName } from '@lincyaw/design'
4
5
  import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
5
6
  import { timeAgo } from '../messages.ts'
6
- import { isAgentChanging } from '../workbench.ts'
7
+ import { isAgentChanging } from '../workbench-state.ts'
7
8
 
8
9
  /** A host-owned operation on a version, such as restoring an entire saved snapshot. This never replaces selective undo. */
9
10
  export interface HistoryRevisionAction {
@@ -26,11 +27,15 @@ export function HistoryPanel({ onClose, revisionAction }: HistoryPanelProps) {
26
27
  const workbench = useWorkbench()
27
28
  const history = useWorkbenchState(state => state.history)
28
29
  const outside = useWorkbenchState(state => state.outside)
30
+ const source = useWorkbenchState(state => state.authoring)
29
31
  const changing = useWorkbenchState(state => state.isHistoryBusy || state.isHistoryPreparing || isAgentChanging(state))
30
- const busy = changing || revisionAction?.pendingRevision !== undefined
32
+ const busy = changing || revisionAction?.pendingRevision !== undefined || Boolean(source?.recovering)
31
33
  const readOnly = workbench.client.capabilities?.readOnly === true
32
34
  const locale = useWorkbenchState(state => state.locale)
33
35
  const memberId = useWorkbenchState(state => state.authoring?.member?.id)
36
+ const drafts = source?.recoveryDrafts ?? []
37
+ const draftBusy = busy || readOnly || Boolean(source?.member && !hasRole(source.member, 'editor'))
38
+ || !source?.identity || Boolean(source.loading || source.saving || source.composing || source.recovering)
34
39
  const revisions = history?.revisions ?? []
35
40
  // Undoing and redoing are not versions of their own: they mark the change they act on.
36
41
  const changes = revisions.filter(revision => !revision.reverts)
@@ -48,6 +53,31 @@ export function HistoryPanel({ onClose, revisionAction }: HistoryPanelProps) {
48
53
  <PmButton small disabled={busy} onClick={() => void workbench.recordOutsideChanges()}>{t.recordOutside}</PmButton>
49
54
  </PmNotice>
50
55
  )}
56
+ {source?.recoveryReadFailure && <PmNotice tone="warn">{t.documentDraftUnreadable}</PmNotice>}
57
+ {source?.recoveryChanged && <PmNotice tone="accent">{t.documentDraftChanged}</PmNotice>}
58
+ {drafts.length > 0 && <section className="pmw-history-group" aria-labelledby="pmw-history-drafts">
59
+ <header className="pmw-history-group__header">
60
+ <h3 id="pmw-history-drafts" className="pmw-pane__title">{t.documentDrafts} <PmBadge>{drafts.length}</PmBadge></h3>
61
+ {drafts.length > 1 && <PmButton small disabled={draftBusy} onClick={() => { if (source?.identity) workbench.forgetDocumentDrafts(drafts, source.identity) }}>{t.documentDraftDiscardAll}</PmButton>}
62
+ </header>
63
+ <ol className="pmw-versions">
64
+ {drafts.map((draft, index) => <li key={JSON.stringify([draft.id, draft.revision, draft.token])} className="pmw-version">
65
+ <span className="pmw-version__icon" aria-hidden="true"><PmIcon name="edit" /></span>
66
+ <div className="pmw-version__body">
67
+ <p className="pmw-version__summary">{t.documentDraftName(index + 1)}</p>
68
+ <p className="pmw-version__meta">
69
+ <span>{t.unsaved}</span><span>·</span>
70
+ <time dateTime={new Date(draft.updatedAt).toISOString()} title={new Date(draft.updatedAt).toLocaleString(locale)}>{timeAgo(new Date(draft.updatedAt).toISOString(), locale)}</time>
71
+ </p>
72
+ </div>
73
+ <div className="pmw-version__actions">
74
+ <PmButton small disabled={draftBusy} onClick={() => { if (source?.identity) void workbench.recoverDocumentDraft(draft, source.identity) }}>{t.documentDraftRestore}</PmButton>
75
+ <PmButton small disabled={draftBusy} onClick={() => { if (source?.identity) workbench.forgetDocumentDrafts([draft], source.identity) }}>{t.narrationDiscard}</PmButton>
76
+ </div>
77
+ </li>)}
78
+ </ol>
79
+ </section>}
80
+ {drafts.length > 0 && <div className="pmw-history-group__header"><h3 className="pmw-pane__title">{t.historySavedVersions}</h3></div>}
51
81
  {changes.length === 0
52
82
  ? <PmEmpty icon="versions">{t.noHistory}</PmEmpty>
53
83
  : (
@@ -12,7 +12,7 @@ export function PageDeleteDialog({ section, title, trigger, onClose }: { section
12
12
  useEffect(() => {
13
13
  let current = true
14
14
  setLoading(true); setError(undefined)
15
- void workbench.preparePageDeletion(section).then(answer => { if (current) setPlan(answer) }, () => { if (current) setError(t.pageEditRequestFailed) }).finally(() => { if (current) setLoading(false) })
15
+ void workbench.editing.preparePageDeletion(section).then(answer => { if (current) setPlan(answer) }, () => { if (current) setError(t.pageEditRequestFailed) }).finally(() => { if (current) setLoading(false) })
16
16
  return () => { current = false }
17
17
  }, [workbench, section, attempt])
18
18
  return <PmDialog open label={t.pageDeleteTitle(title)} description={plan ? t.pageDeleteHint(plan.counts.steps, plan.counts.narration) : t.pageDeleteLoading} busy={busy} closeLabel={t.close} onClose={onClose} onCloseAutoFocus={event => {
@@ -21,12 +21,12 @@ export function PageDeleteDialog({ section, title, trigger, onClose }: { section
21
21
  }}>
22
22
  <div className="pmw-operation">
23
23
  {plan?.last && <PmNotice>{t.pageDeleteLast}</PmNotice>}
24
- {plan && !plan.allowed && <PmNotice tone="warn">{workbench.pageDeleteMessage(plan.reason ?? 'page-boundary')}</PmNotice>}
24
+ {plan && !plan.allowed && <PmNotice tone="warn">{workbench.editing.deletionMessage(plan.reason ?? 'page-boundary')}</PmNotice>}
25
25
  {(error || failure) && <PmNotice tone="danger">{error || failure}</PmNotice>}
26
26
  <div className="pmw-operation__actions">
27
27
  <PmButton disabled={busy} onClick={onClose}>{t.cancel}</PmButton>
28
- {error || failure ? <PmButton disabled={busy} onClick={() => { workbench.clearPageEditFailure(); setAttempt(value => value + 1) }}>{t.retry}</PmButton>
29
- : <PmButton variant="danger" loading={loading || busy} disabled={!plan?.allowed || loading} onClick={() => { if (plan) void workbench.deletePage(plan).then(saved => { if (saved) onClose() }) }}>{t.pageDelete}</PmButton>}
28
+ {error || failure ? <PmButton disabled={busy} onClick={() => { workbench.editing.clearFailure(); setAttempt(value => value + 1) }}>{t.retry}</PmButton>
29
+ : <PmButton variant="danger" loading={loading || busy} disabled={!plan?.allowed || loading} onClick={() => { if (plan) void workbench.editing.deletePage(plan).then(saved => { if (saved) onClose() }) }}>{t.pageDelete}</PmButton>}
30
30
  </div>
31
31
  </div>
32
32
  </PmDialog>
@@ -15,7 +15,7 @@ export function PageRenameDialog({ section, title: original, trigger, onClose }:
15
15
  }} onSubmit={event => {
16
16
  event.preventDefault()
17
17
  if (busy || !title.trim()) return
18
- void workbench.renamePage(section, title.trim()).then(saved => { if (saved) onClose() })
18
+ void workbench.editing.renamePage(section, title.trim()).then(saved => { if (saved) onClose() })
19
19
  }}>
20
20
  <PmInput label={t.pageTitle} density="regular" value={title} error={failure} required autoFocus readOnly={busy} onChange={event => setTitle(event.target.value)} />
21
21
  <div className="pmw-operation__actions">
@@ -6,7 +6,6 @@ import { PmButton, PmNotice } from '../components.tsx'
6
6
  import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
7
7
  import { slideAspect } from '../workbench.ts'
8
8
  import { failureReason } from '../messages.ts'
9
- import { PreviewChangeTrail } from './ChangeTrail.tsx'
10
9
 
11
10
  /**
12
11
  * The open document as its readers see it (the web form or the slides), with the tools for what the author points at.
@@ -29,7 +28,6 @@ export function PreviewPanel({ active = true, onPresentationAction, presentation
29
28
  const reload = useWorkbenchState(state => state.previewReload)
30
29
  const aspect = useWorkbenchState(state => (state.previewRenderer === 'slides' ? slideAspect(state.ir) : undefined))
31
30
  const container = useRef<HTMLDivElement>(null)
32
- const stage = useRef<HTMLDivElement>(null)
33
31
  const pool = useRef<ReturnType<typeof createPreviewPool>>()
34
32
  const [loads, setLoads] = useState(0)
35
33
  const [{ ready, mismatch, identityFailure, handshakeFailure, canvasGate }, setStatus] = useState<PreviewFrameStatus>({ ready: false })
@@ -70,9 +68,8 @@ export function PreviewPanel({ active = true, onPresentationAction, presentation
70
68
  {failure && <PmNotice tone="danger"><span>{t.previewFailed(failureReason(t, failure))}</span><PmButton small onClick={() => workbench.retryPreview()}>{t.retry}</PmButton></PmNotice>}
71
69
  {(!ready || !snapshotMatches) && !failure && !handshakeFailure && !(renderer === 'slides' && preview && !preview.slides) && <p className="pmw-muted pmw-preview__loading">{presentation && ready && !snapshotMatches && !preparing ? t.presentationOutdated : address ? t.previewLoading : t.previewPreparing}</p>}
72
70
  {renderer === 'slides' && preview && !preview.slides && <p className="pmw-muted pmw-preview__loading">{t.noSlides}</p>}
73
- <div ref={stage} className="pmw-preview__stage">
71
+ <div className="pmw-preview__stage">
74
72
  <div ref={container} className="pmw-preview__frames" data-renderer={renderer} data-pending-snapshot={!snapshotMatches || undefined} data-presentation-gated={presentation && canvasGate || undefined} style={aspect === undefined ? undefined : { '--pmw-slide-aspect': aspect } as CSSProperties} />
75
- {!presentation && <PreviewChangeTrail stage={stage} frames={container} />}
76
73
  </div>
77
74
  </section>
78
75
  )
@@ -0,0 +1,20 @@
1
+ import { useState } from 'react'
2
+ import { captionScale, CAPTION_SCALE_MAX, CAPTION_SCALE_MIN } from '@lincyaw/kernel'
3
+ import type { TeachingDocument } from '@lincyaw/kernel'
4
+ import { PmField, PmRange } from '../components.tsx'
5
+ import { useWorkbench, useWorkbenchState } from '../context.tsx'
6
+ import { PRODUCTION_MESSAGES } from '../production-messages.ts'
7
+
8
+ /** The document's caption size in percent steps of ten; a released drag or a key records it once. */
9
+ export function ProductionCaptionSize({ identity, document, disabled, onChanged }: { identity: string, document: TeachingDocument, disabled: boolean, onChanged(): void }) {
10
+ const workbench = useWorkbench(), locale = useWorkbenchState(state => state.locale), p = PRODUCTION_MESSAGES[locale]
11
+ const [preview, setPreview] = useState<number>()
12
+ const percent = Math.round(captionScale(document.production) * 100)
13
+ return <PmField label={p.captionSize} group hint={p.captionSizeHint}>
14
+ <div className="pm-ui-range-row">
15
+ <PmRange label={p.captionSize} value={percent} min={Math.round(CAPTION_SCALE_MIN * 100)} max={Math.round(CAPTION_SCALE_MAX * 100)} step={10} disabled={disabled} valueText={value => `${Math.round(value)}%`}
16
+ onPreviewChange={setPreview} onValueCommit={value => { workbench.production.setCaptionScale(value / 100, identity); onChanged() }} />
17
+ <output>{Math.round(preview ?? percent)}%</output>
18
+ </div>
19
+ </PmField>
20
+ }
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useRef, useState } from 'react'
2
- import { CAPTION_TIMING_MAX_SEGMENTS, captionSourceFingerprint, captionTimingProblem, stepCaptionText } from '@lincyaw/kernel'
2
+ import { CAPTION_TIMING_MAX_SEGMENTS, captionSourceFingerprint, captionTimingProblem, randomUUID, stepCaptionText } from '@lincyaw/kernel'
3
3
  import type { CaptionTiming, CaptionTimingSource, DocumentCaptionTimingAction, ProductionPlan } from '@lincyaw/kernel'
4
4
  import { PmButton, PmCard, PmDialog, PmInput, PmNotice } from '../components.tsx'
5
5
  import { useWorkbench, useWorkbenchState } from '../context.tsx'
@@ -23,7 +23,7 @@ function lineRows(text: string): Row[] {
23
23
  else if (ranges.length && !text.slice(ranges.at(-1)!.from, ranges.at(-1)!.to).trim()) ranges[ranges.length - 1]!.to = to
24
24
  else ranges.push({ from, to })
25
25
  }
26
- return ranges.map(range => ({ ...range, id: crypto.randomUUID(), start: '', end: '' }))
26
+ return ranges.map(range => ({ ...range, id: randomUUID(), start: '', end: '' }))
27
27
  }
28
28
  function valueOf(draft: Draft): CaptionTiming | undefined {
29
29
  if (!draft.basis.available || !draft.basis.playbackFingerprint || draft.basis.durationMs === undefined) return
@@ -43,14 +43,17 @@ export function ProductionCaptionTiming({ identity, stepId, plan, current, loadi
43
43
  const pendingSteps = useWorkbenchState(state => state.captionTimingDraftSteps), storageFailure = useWorkbenchState(state => state.captionTimingDraftStorageFailure)
44
44
  const [open, setOpen] = useState(false), [busy, setBusy] = useState(false), [failure, setFailure] = useState<string>(), [saved, setSaved] = useState(false), [, render] = useState(0)
45
45
  const drafts = useRef(new Map<string, Draft>()), alive = useRef(true), request = useRef<AbortController>(), needsRefresh = useRef(false), openRef = useRef(false), composing = useRef(false)
46
+ useEffect(() => workbench.production.registerDraftView({ identity, kind: 'caption-timing', has: target => drafts.current.has(target),
47
+ blocked: () => composing.current || Boolean(request.current), clear: target => { drafts.current.delete(target); setSaved(false); setFailure(undefined); render(n => n + 1) } }), [workbench, identity])
48
+ useEffect(() => workbench.refreshAuthoringClientControls(), [workbench, open, busy, stepId, disabled])
46
49
  const latest = useRef({ stepId, onChanged }); latest.current = { stepId, onChanged }
47
- if (!drafts.current.has(stepId)) { const savedDraft = workbench.captionTimingDraft(stepId, identity); if (savedDraft) drafts.current.set(stepId, savedDraft) }
50
+ if (!drafts.current.has(stepId)) { const savedDraft = workbench.production.captionTimingDraft(stepId, identity); if (savedDraft) drafts.current.set(stepId, savedDraft) }
48
51
  const draft = drafts.current.get(stepId), value = draft && valueOf(draft), canonical = document?.production.captionTimings?.[stepId], hasDraft = Boolean(pendingSteps?.includes(stepId))
49
52
  const changed = draft && source?.version !== draft.version || draft && basis && (!same(draft.basis, basis) || draft.text !== (document && stepCaptionText(document, stepId)))
50
53
  const writable = Boolean(source?.version && source.fingerprint && !source.loading && !source.dirty && !source.saving && !source.composing && !source.restored && !source.recovering && !source.error && !disabled)
51
54
  useEffect(() => { alive.current = true; return () => { alive.current = false; request.current?.abort() } }, [])
52
55
  useEffect(() => { request.current?.abort(); openRef.current = false; setOpen(false); setBusy(false); setFailure(undefined); setSaved(false) }, [stepId])
53
- const pending = (next: Draft, changedByAuthor = true) => { drafts.current.set(stepId, next); if (changedByAuthor) workbench.setCaptionTimingDraft(stepId, next, identity); setSaved(false); setFailure(undefined); render(n => n + 1) }
56
+ const pending = (next: Draft, changedByAuthor = true) => { drafts.current.set(stepId, next); if (changedByAuthor) workbench.production.setCaptionTimingDraft(stepId, next, identity); setSaved(false); setFailure(undefined); render(n => n + 1) }
54
57
  const initialize = () => {
55
58
  if (!document || !source?.version || !basis) return
56
59
  const text = stepCaptionText(document, stepId), existing = document.production.captionTimings?.[stepId]
@@ -61,7 +64,7 @@ export function ProductionCaptionTiming({ identity, stepId, plan, current, loadi
61
64
  // A plan may arrive after opening. Step/close effects fence the original opening;
62
65
  // an existing target draft always wins over this passive initialization.
63
66
  if (open && openRef.current && !saved && current && basis && source?.identity === identity && !drafts.current.has(stepId)) initialize()
64
- }, [open, saved, current, basis, source?.identity, source?.version, identity, stepId])
67
+ }, [open, saved, current, basis, source?.identity, source?.version, identity, stepId, hasDraft])
65
68
  const close = () => {
66
69
  request.current?.abort(); setBusy(false); openRef.current = false; setOpen(false)
67
70
  if (needsRefresh.current) { needsRefresh.current = false; latest.current.onChanged() }
@@ -72,12 +75,12 @@ export function ProductionCaptionTiming({ identity, stepId, plan, current, loadi
72
75
  const action: DocumentCaptionTimingAction = automatic ? { type: 'caption.timing.reset', stepId } : { type: 'caption.timing.set', stepId, value: value! }
73
76
  request.current = controller; setBusy(true); setFailure(undefined)
74
77
  try {
75
- const answer = await workbench.applyDocumentCaptionTiming(action, crypto.randomUUID(), expected, controller.signal)
78
+ const answer = await workbench.production.applyCaptionTiming(action, randomUUID(), expected, controller.signal)
76
79
  needsRefresh.current = true
77
80
  if (!alive.current || workbench.getState().authoring?.identity !== identity) return
78
81
  const ownsInput = drafts.current.get(target) === sent
79
82
  if (ownsInput) {
80
- workbench.setCaptionTimingDraft(target, undefined, identity)
83
+ workbench.production.setCaptionTimingDraft(target, undefined, identity)
81
84
  if (automatic) drafts.current.delete(target)
82
85
  else if (sent) drafts.current.set(target, { ...sent, version: answer.version })
83
86
  }
@@ -94,7 +97,7 @@ export function ProductionCaptionTiming({ identity, stepId, plan, current, loadi
94
97
  <PmButton small onClick={close}>{saved ? t.done : t.cancel}</PmButton>
95
98
  <PmButton small variant="primary" loading={busy} disabled={!writable || !current || !value || Boolean(changed) || same(value, canonical)} onClick={() => void apply()}>{t.apply}</PmButton>
96
99
  </>}>
97
- <div className="pmw-caption-times" onCompositionStart={() => { composing.current = true }} onCompositionEnd={() => { composing.current = false }}>
100
+ <div className="pmw-caption-times" onCompositionStart={() => { composing.current = true; workbench.refreshAuthoringClientControls() }} onCompositionEnd={() => { composing.current = false; workbench.refreshAuthoringClientControls() }}>
98
101
  <span>{t.step}</span>
99
102
  {!saved && basis?.available === false && <PmNotice tone="warn">{t.unavailable}</PmNotice>}
100
103
  {!saved && !basis && <PmNotice>{loading ? t.loading : t.prepare}</PmNotice>}
@@ -111,7 +114,7 @@ export function ProductionCaptionTiming({ identity, stepId, plan, current, loadi
111
114
  <div className="pmw-caption-times__actions">
112
115
  <PmButton small disabled={!basis?.available || busy || !writable} onClick={() => { if (document && basis && source?.version) pending({ version: source.version, text: stepCaptionText(document, stepId), basis: structuredClone(basis), rows: lineRows(stepCaptionText(document, stepId)) }) }}>{t.split}</PmButton>
113
116
  <PmButton small disabled={!canonical || busy || !writable} onClick={() => void apply(true)}>{t.automatic}</PmButton>
114
- {hasDraft && <PmButton small disabled={busy} onClick={() => { workbench.setCaptionTimingDraft(stepId, undefined, identity); drafts.current.delete(stepId); initialize() }}>{t.discard}</PmButton>}
117
+ {hasDraft && <PmButton small disabled={busy} onClick={() => { if (workbench.production.discardCaptionTimingDraft(stepId, identity)) { drafts.current.delete(stepId); initialize() } }}>{t.discard}</PmButton>}
115
118
  </div>
116
119
  {storageFailure && <PmNotice tone="warn">{t.storageFailed}</PmNotice>}
117
120
  {saved && <PmNotice tone="ok">{t.saved}</PmNotice>}
@@ -1,9 +1,10 @@
1
1
  import { useEffect, useRef, useState } from 'react'
2
2
  import type { DocumentChangeAnswer, MediaClip, ProductionAssetInspection, ProductionBinding, TeachingDocument } from '@lincyaw/kernel'
3
+ import { randomUUID } from '@lincyaw/kernel'
3
4
  import { MediaClipEditor } from '../MediaClipEditor.tsx'
4
5
  import type { MediaClipDraft } from '../MediaClipEditor.tsx'
5
6
  import { useWorkbench, useWorkbenchState } from '../context.tsx'
6
- import { keepMediaDrafts, mediaDraftStorageFailed, readMediaDrafts } from '../media-drafts.ts'
7
+ import { mediaDraftStorageFailed, readMediaDrafts } from '../media-drafts.ts'
7
8
  import type { MediaDrafts } from '../media-drafts.ts'
8
9
  import { MEDIA_MESSAGES, mediaFailure } from '../media-messages.ts'
9
10
 
@@ -18,7 +19,7 @@ interface Props {
18
19
  disabled: boolean
19
20
  onChanged(): void
20
21
  }
21
- const newDraft = (version: string, stepId: string): MediaClipDraft => ({ version, clip: { id: `clip_${crypto.randomUUID().replaceAll('-', '')}`, assetId: '', sourceRange: { startMs: 0, endMs: 0 }, attachment: { stepId, offsetMs: 0 }, volume: 1, muted: false } })
22
+ const newDraft = (version: string, stepId: string): MediaClipDraft => ({ version, clip: { id: `clip_${randomUUID().replaceAll('-', '')}`, assetId: '', sourceRange: { startMs: 0, endMs: 0 }, attachment: { stepId, offsetMs: 0 }, volume: 1, muted: false } })
22
23
  const fromClip = (version: string, clip: MediaClip): MediaClipDraft => ({ version, clip: structuredClone(clip), baseClip: structuredClone(clip) })
23
24
  const same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b)
24
25
  const draftKey = (clipId?: string) => clipId === undefined ? 'new' : `clip:${clipId}`
@@ -41,9 +42,23 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
41
42
  snapshot.current = draft; selected.current = key; latest.current = session
42
43
  const assets = Object.values(document.assets).filter(asset => asset.kind === 'audio').map(asset => ({ id: asset.id, label: asset.title || asset.location.split('/').at(-1) || asset.id }))
43
44
  const active = () => owner.current.active && workbench.getState().authoring?.identity === identity
45
+ const interacting = useRef(false), unavailable = useRef(false)
46
+ unavailable.current = disabled || Boolean(busy)
47
+ useEffect(() => workbench.production.registerDraftView({ identity, kind: 'media-clip', has: target => {
48
+ const [ownerStep, name] = JSON.parse(target) as [string, string]
49
+ return active() && ownerStep === stepId && Object.hasOwn(latest.current.entries, name)
50
+ }, blocked: () => interacting.current || Boolean(request.current) || unavailable.current,
51
+ clear: () => {
52
+ owner.current.revision++
53
+ const value = readMediaDrafts(workbench.client, identity, stepId)
54
+ latest.current = value; setSession(value); setStorageFailed(false); setFailure(undefined); setStatus(undefined)
55
+ blank.current = newDraft(workbench.getState().authoring?.version ?? version, stepId)
56
+ } }), [workbench, identity, stepId])
57
+ useEffect(() => workbench.registerNavigationGuard(() => active() && (interacting.current || Boolean(request.current))), [workbench, identity])
58
+ useEffect(() => { workbench.refreshAuthoringClientControls() }, [workbench, disabled, busy])
44
59
  const remember = (value: MediaDrafts) => {
45
60
  latest.current = value; setSession(value)
46
- setStorageFailed(!keepMediaDrafts(workbench.client, identity, stepId, value))
61
+ setStorageFailed(!workbench.production.keepMediaDrafts(identity, stepId, value))
47
62
  }
48
63
  const edit = (value: MediaClipDraft) => {
49
64
  owner.current.revision++; setFailure(undefined); setStatus(undefined)
@@ -55,7 +70,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
55
70
  const assetId = draft.clip.assetId, controller = new AbortController(), requestKey = key
56
71
  if (!assetId || disabled || !version || inspection?.version === version && inspection.value.assetId === assetId) { setLoading(false); return }
57
72
  setLoading(true)
58
- void workbench.inspectDocumentAudio(assetId, { identity, version }, controller.signal).then(answer => {
73
+ void workbench.production.inspectAudio(assetId, { identity, version }, controller.signal).then(answer => {
59
74
  if (controller.signal.aborted || !active()) return
60
75
  setInspection({ version: answer.version, value: answer.inspection })
61
76
  const current = ownDraft(latest.current.entries, requestKey)
@@ -84,7 +99,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
84
99
  if (!sent) return
85
100
  file.current = value; setRetryImport(false)
86
101
  try {
87
- const answer = await workbench.ensureDocumentAudio(value, sent.expected, sent.controller.signal)
102
+ const answer = await workbench.production.ensureAudio(value, sent.expected, sent.controller.signal)
88
103
  if (!active() || sent.controller.signal.aborted) return
89
104
  const next = acknowledge(answer, sent.expected.version)
90
105
  if (owner.current.revision === sent.revision && selected.current === sent.key) {
@@ -102,7 +117,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
102
117
  const sent = start('apply')
103
118
  if (!sent) return
104
119
  try {
105
- const answer = await workbench.applyDocumentMediaClip(clip, { ...sent.expected, binding }, sent.controller.signal)
120
+ const answer = await workbench.production.applyMediaClip(clip, { ...sent.expected, binding }, sent.controller.signal)
106
121
  if (!active() || sent.controller.signal.aborted) return
107
122
  const next = acknowledge(answer, sent.expected.version), current = ownDraft(latest.current.entries, sent.key)
108
123
  if (sent.key === 'new') blank.current = newDraft(answer.version, stepId)
@@ -122,7 +137,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
122
137
  const sent = start('remove')
123
138
  if (!sent) return
124
139
  try {
125
- const answer = await workbench.removeDocumentMediaClip(canonical.id, sent.expected, sent.controller.signal)
140
+ const answer = await workbench.production.removeMediaClip(canonical.id, sent.expected, sent.controller.signal)
126
141
  if (!active() || sent.controller.signal.aborted) return
127
142
  const next = acknowledge(answer, sent.expected.version), current = ownDraft(latest.current.entries, sent.key)
128
143
  if (!current || same(current, sent.draft)) {
@@ -137,6 +152,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
137
152
  return <MediaClipEditor locale={locale} assets={assets} clips={clips} selectedClipId={selectedClipId} draft={draft} inspection={inspectCurrent} stepDurationMs={stepDurationMs}
138
153
  disabled={disabled} canApply={Boolean(binding && stepDurationMs !== undefined)} loading={loading} busy={busy} pending={Boolean(ownDraft(session.entries, key))} review={Boolean(ownDraft(session.entries, key) && draft.version !== version)}
139
154
  failure={failure} storageFailed={storageFailed} status={status} retryImport={retryImport}
155
+ onInteraction={value => { if (value === interacting.current) return; interacting.current = value; workbench.refreshAuthoringClientControls() }}
140
156
  onEditStart={pause} onChange={edit} onImport={value => void importAudio(value)} onRetryImport={() => { if (file.current) void importAudio(file.current) }}
141
157
  onRead={() => { setFailure(undefined); setInspection(undefined); setReload(value => value + 1) }}
142
158
  onReview={() => { if (inspectCurrent && (!draft.baseClip || canonical)) edit({ ...draft, version, ...canonical ? { baseClip: structuredClone(canonical) } : {} }) }}
@@ -6,12 +6,13 @@ import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
6
6
  import { DocumentStepNarration } from '../document-editor/DocumentStepNarration.tsx'
7
7
  import { PRODUCTION_MESSAGES, productionFailure } from '../production-messages.ts'
8
8
  import { SHORTCUTS } from '../shortcuts.ts'
9
- import { isAgentChanging } from '../workbench.ts'
10
- import type { PlaybackKey } from '../workbench.ts'
9
+ import { isAgentChanging } from '../workbench-state.ts'
10
+ import type { PlaybackKey } from '../workbench-state.ts'
11
11
  import { DocumentVoiceField } from './DocumentVoiceField.tsx'
12
12
  import { ExportPanel } from './ExportPanel.tsx'
13
13
  import { PreviewPanel } from './PreviewPanel.tsx'
14
14
  import { VoiceoverDialog } from './VoiceoverDialog.tsx'
15
+ import { ProductionCaptionSize } from './ProductionCaptionSize.tsx'
15
16
  import { ProductionCaptionTiming } from './ProductionCaptionTiming.tsx'
16
17
  import { ProductionTimeline } from './ProductionTimeline.tsx'
17
18
  import { ProductionMediaClips } from './ProductionMediaClips.tsx'
@@ -243,7 +244,7 @@ export function ProductionPanel({ onClose, closing, active = true }: { onClose()
243
244
  </div></PmTabPanel>
244
245
  <PmTabPanel value="voice" keepMounted><div className="pmw-production__fields">
245
246
  <DocumentVoiceField key={`${source.identity}:${stepId}`} stepId={stepId} disabled={blocked || closing} onGenerate={() => { voicePlayback.stop(); workbench.stopAuditions(); setGenerateStep(stepId) }} />
246
- <ProductionRecording key={source.identity} identity={source.identity} sectionId={sectionId} stepId={stepId} active={!outputsOpen && (wide || tab === 'properties') && inspectorTab === 'voice'} disabled={blocked || closing}
247
+ <ProductionRecording key={source.identity} identity={source.identity} sectionId={sectionId} stepId={stepId} active={!outputsOpen && (wide || tab === 'properties') && inspectorTab === 'voice'} available={active && !outputsOpen} onReveal={() => { setInspectorTab('voice'); setTab('properties') }} disabled={blocked || closing}
247
248
  onImportStarted={() => transcriptionSelection.current}
248
249
  onImported={(assetId, selection) => {
249
250
  setMediaRefresh(true)
@@ -254,7 +255,10 @@ export function ProductionPanel({ onClose, closing, active = true }: { onClose()
254
255
  selectedAsset={transcriptionAsset?.identity === source.identity ? transcriptionAsset : undefined}
255
256
  onSelectAsset={() => { transcriptionSelection.current++; setTranscriptionAsset(undefined) }} />
256
257
  </div></PmTabPanel>
257
- <PmTabPanel value="captions" keepMounted><ProductionCaptionTiming key={source.identity} identity={source.identity} stepId={stepId} plan={plan} current={planCurrent} loading={preparing || planBusy} disabled={blocked || closing} onChanged={() => setMediaRefresh(true)} /></PmTabPanel>
258
+ <PmTabPanel value="captions" keepMounted><div className="pmw-production__fields">
259
+ <ProductionCaptionSize identity={source.identity} document={document} disabled={blocked || closing} onChanged={() => setMediaRefresh(true)} />
260
+ <ProductionCaptionTiming key={source.identity} identity={source.identity} stepId={stepId} plan={plan} current={planCurrent} loading={preparing || planBusy} disabled={blocked || closing} onChanged={() => setMediaRefresh(true)} />
261
+ </div></PmTabPanel>
258
262
  </PmTabs>
259
263
  </PmSplitPanel>
260
264
  </PmSplitGroup>
@@ -8,13 +8,14 @@ import { AUDIO_RECORDING_MESSAGES } from '../audio-recording-messages.ts'
8
8
  import { PmButton, PmCard, PmDialog, PmNotice, PmSelect } from '../components.tsx'
9
9
  import { useWorkbench, useWorkbenchState } from '../context.tsx'
10
10
  import { mediaFailure } from '../media-messages.ts'
11
+ import type { AuthoringClientActionType } from '@lincyaw/kernel'
11
12
  import { ProductionRecordingRange } from './ProductionRecordingRange.tsx'
12
13
 
13
- interface Props { identity: string, sectionId: string, stepId: string, active: boolean, disabled: boolean, onImportStarted(): number, onImported(assetId: string, selection: number): void, onAdopted(): void }
14
+ interface Props { identity: string, sectionId: string, stepId: string, active: boolean, available: boolean, disabled: boolean, onReveal(): void, onImportStarted(): number, onImported(assetId: string, selection: number): void, onAdopted(): void }
14
15
  const elapsed = (ms: number) => `${String(Math.floor(ms / 60000)).padStart(2, '0')}:${String(Math.floor(ms / 1000) % 60).padStart(2, '0')}`
15
16
 
16
17
  /** Video-only microphone material. The document actor and existing binary transaction still own every save. */
17
- export function ProductionRecording({ identity, sectionId, stepId, active, disabled, onImportStarted, onImported, onAdopted }: Props) {
18
+ export function ProductionRecording({ identity, sectionId, stepId, active, available, disabled, onReveal, onImportStarted, onImported, onAdopted }: Props) {
18
19
  const workbench = useWorkbench(), locale = useWorkbenchState(state => state.locale), t = AUDIO_RECORDING_MESSAGES[locale]
19
20
  const source = useWorkbenchState(state => state.authoring)
20
21
  const [recording] = useState(() => documentRecording(workbench, identity))
@@ -36,14 +37,15 @@ export function ProductionRecording({ identity, sectionId, stepId, active, disab
36
37
  if (!active) { recording.stop(); audition.current?.stop() }
37
38
  if (candidate?.assetId && source?.identity === identity && source.content && !source.content.assets[candidate.assetId]) recording.forgetImport(candidate.assetId)
38
39
  }, [active, candidate?.assetId, source?.content, source?.identity, identity, recording])
39
- const start = () => {
40
+ const start = (signal?: AbortSignal) => {
40
41
  setFailure(undefined)
41
- void recording.start(async () => {
42
+ return recording.start(async signal => {
42
43
  workbench.stopAuditions()
43
44
  await workbench.pausePlayback(true)
45
+ signal.throwIfAborted()
44
46
  if (!current() || !active) throw new Error('recording-failed')
45
47
  return workbench.registerAudioCapture(() => recording.stop())
46
- })
48
+ }, signal)
47
49
  }
48
50
  const listen = () => {
49
51
  if (!candidate) return
@@ -54,9 +56,12 @@ export function ProductionRecording({ identity, sectionId, stepId, active, disab
54
56
  if (listening.status === 'playing' || listening.status === 'loading') audition.current.stop()
55
57
  else void audition.current.play(async () => ({ audio: candidate.file }))
56
58
  }
57
- const save = async () => {
59
+ const save = async (signal?: AbortSignal) => {
58
60
  if (!candidate || saving || !current()) return
59
61
  const file = candidate.file, selection = adoption.revision(), transcriptionSelection = onImportStarted(), controller = new AbortController()
62
+ const abort = () => controller.abort(signal?.reason)
63
+ signal?.addEventListener('abort', abort, { once: true })
64
+ if (signal?.aborted) abort()
60
65
  request.current = controller; setSaving(true); setFailure(undefined)
61
66
  const owns = () => current() && !controller.signal.aborted && request.current === controller && recording.snapshot().candidate?.file === file
62
67
  try {
@@ -64,15 +69,87 @@ export function ProductionRecording({ identity, sectionId, stepId, active, disab
64
69
  if (!owns()) return
65
70
  const currentSource = workbench.getState().authoring
66
71
  if (!currentSource?.version || currentSource.identity !== identity || currentSource.dirty || currentSource.saving || currentSource.composing || currentSource.restored || currentSource.error) throw new Error('production-source-changed')
67
- const answer = await workbench.ensureDocumentAudio(file, { identity, version: currentSource.version }, controller.signal)
72
+ const answer = await workbench.production.ensureAudio(file, { identity, version: currentSource.version }, controller.signal)
68
73
  if (!owns()) return
69
74
  recording.imported(file, answer.inspection.assetId); adoption.imported(answer.inspection.assetId, selection); onImported(answer.inspection.assetId, transcriptionSelection)
70
75
  } catch (error) {
71
76
  if (owns()) setFailure(`${t.saveFailed} ${mediaFailure(error, locale)}`)
72
77
  } finally {
78
+ signal?.removeEventListener('abort', abort)
73
79
  if (request.current === controller) { request.current = undefined; if (current()) setSaving(false) }
74
80
  }
75
81
  }
82
+ const controls = useRef({ start, save, disabled, saving, active, available, onReveal })
83
+ controls.current = { start, save, disabled, saving, active, available, onReveal }
84
+ useEffect(() => {
85
+ if (!available) return
86
+ const owns = () => current() && controls.current.available && workbench.getState().authoring?.identity === identity
87
+ return workbench.registerAuthoringClientControls({ identity,
88
+ actions: () => {
89
+ if (!owns()) return []
90
+ const actual = recording.snapshot(), take = actual.candidate, player = audition.current?.snapshot()
91
+ const capturing = ['requesting', 'recording', 'stopping'].includes(actual.phase)
92
+ const source = workbench.getState().authoring, clean = source && !source.loading && !source.dirty && !source.saving && !source.composing && !source.restored && !source.error
93
+ const actions: AuthoringClientActionType[] = []
94
+ if (capturing) actions.push('recording.cancel', 'recording.stop')
95
+ if (player?.status === 'playing' || player?.status === 'loading') actions.push('recording.pause')
96
+ if (!controls.current.disabled && !controls.current.saving && clean) {
97
+ if (!capturing && !recordingUnavailable()) actions.push('recording.start')
98
+ if (take && !capturing) actions.push('recording.discard', 'recording.listen', ...!take.assetId ? ['recording.save' as const] : [])
99
+ }
100
+ return actions
101
+ },
102
+ snapshot: () => {
103
+ const actual = recording.snapshot(), take = actual.candidate, player = audition.current?.snapshot()
104
+ return { recording: { phase: actual.phase, elapsedMs: actual.elapsedMs,
105
+ ...take ? { candidate: { byteLength: take.file.size, mime: take.file.type, ...take.assetId ? { assetId: take.assetId } : {} } } : {},
106
+ ...actual.error ? { error: actual.error } : {}, audition: player?.status ?? 'idle' } }
107
+ },
108
+ execute: async (action, _source, signal) => {
109
+ const owned = () => { signal.throwIfAborted(); if (!owns()) throw new Error('client-recording-unavailable') }
110
+ owned()
111
+ if (!controls.current.active) {
112
+ controls.current.onReveal()
113
+ await workbench.waitForAuthoringClientState(() => { owned(); return controls.current.active }, signal)
114
+ }
115
+ if (action.type === 'recording.start') {
116
+ await controls.current.start(signal); owned()
117
+ if (recording.snapshot().phase !== 'recording') throw new Error(`client-${recording.snapshot().error ?? 'recording-unavailable'}`)
118
+ return
119
+ }
120
+ if (action.type === 'recording.stop' || action.type === 'recording.cancel') {
121
+ action.type === 'recording.cancel' ? recording.cancelTake() : recording.stop()
122
+ await workbench.waitForAuthoringClientState(() => { owned(); return !['requesting', 'recording', 'stopping'].includes(recording.snapshot().phase) }, signal)
123
+ return
124
+ }
125
+ if (action.type === 'recording.discard') {
126
+ audition.current?.stop(); recording.discard(); setFailure(undefined)
127
+ return
128
+ }
129
+ if (action.type === 'recording.pause') { audition.current?.stop(); return }
130
+ const take = recording.snapshot().candidate
131
+ if (!take) throw new Error('client-recording-unavailable')
132
+ if (action.type === 'recording.save') {
133
+ await controls.current.save(signal); owned()
134
+ if (recording.snapshot().candidate?.file !== take.file || !recording.snapshot().candidate?.assetId) throw new Error('client-recording-save-unverified')
135
+ return
136
+ }
137
+ if (action.type === 'recording.listen') {
138
+ if (!audition.current) {
139
+ const player = audition.current = new Audition(workbench)
140
+ player.subscribe(() => { if (current()) setListening(player.snapshot()) })
141
+ }
142
+ const player = audition.current, stop = () => player.stop()
143
+ signal.addEventListener('abort', stop, { once: true })
144
+ try { await player.play(async () => ({ audio: take.file })); owned(); if (player.snapshot().status !== 'playing') throw new Error('client-recording-listen-unverified') }
145
+ finally { signal.removeEventListener('abort', stop) }
146
+ return
147
+ }
148
+ throw new Error('client-action-unavailable')
149
+ },
150
+ })
151
+ }, [workbench, identity, available, recording])
152
+ useEffect(() => workbench.refreshAuthoringClientControls(), [workbench, state.phase, state.error, candidate?.file, candidate?.assetId, saving, disabled, active, available, listening.status])
76
153
  return <PmCard className="pmw-audio-recording" data-recording={state.phase}>
77
154
  <strong>{t.title}</strong>
78
155
  {status && !(status === t.imported && adoption.adopted && candidate?.assetId === adoption.selected) && <span className="pm-ui-hint"><span role="status">{saving ? t.saving : status}</span>{state.phase === 'recording' && <span aria-hidden="true"> · {elapsed(state.elapsedMs)}</span>}</span>}
@@ -80,12 +157,12 @@ export function ProductionRecording({ identity, sectionId, stepId, active, disab
80
157
  {failure && <PmNotice tone="danger">{failure}</PmNotice>}
81
158
  {listening.status === 'failed' && <PmNotice tone="warn">{t.failures[listening.error ?? 'audition-request'] ?? t.failures['audition-request']}</PmNotice>}
82
159
  <div className="pmw-voice__actions">
83
- {!capturing && !candidate && <PmButton small variant="primary" disabled={disabled || saving || !active || Boolean(unavailable)} onClick={start}>{t.start}</PmButton>}
160
+ {!capturing && !candidate && <PmButton small variant="primary" disabled={disabled || saving || !active || Boolean(unavailable)} onClick={() => void start()}>{t.start}</PmButton>}
84
161
  {state.phase === 'requesting' && <PmButton small onClick={() => recording.cancelTake()}>{t.cancel}</PmButton>}
85
162
  {state.phase === 'recording' && <><PmButton small onClick={() => recording.stop()}>{t.stop}</PmButton><PmButton small onClick={() => recording.cancelTake()}>{t.cancelTake}</PmButton></>}
86
163
  {candidate && !capturing && <PmButton small disabled={!active || saving} loading={listening.status === 'loading'} onClick={listen}>{listening.status === 'playing' ? t.stopAudition : t.audition}</PmButton>}
87
164
  {candidate && !candidate.assetId && !capturing && <PmButton small variant="primary" disabled={disabled || !active} loading={saving} onClick={() => void save()}>{failure ? t.retry : t.save}</PmButton>}
88
- {candidate && !capturing && <PmButton small disabled={disabled || saving || !active || Boolean(unavailable)} onClick={start}>{t.rerecord}</PmButton>}
165
+ {candidate && !capturing && <PmButton small disabled={disabled || saving || !active || Boolean(unavailable)} onClick={() => void start()}>{t.rerecord}</PmButton>}
89
166
  {saving && <PmButton small onClick={() => { request.current?.abort(); setSaving(false) }}>{t.cancelSave}</PmButton>}
90
167
  {candidate && !capturing && !saving && <PmButton small onClick={() => setDiscard(true)}>{t.discard}</PmButton>}
91
168
  </div>