@lincyaw/workbench 0.2.0-rc.5 → 0.2.0-rc.50
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/package.json +5 -4
- package/src/MediaClipEditor.tsx +1 -1
- package/src/audio-recording.ts +27 -5
- package/src/authoring-client.ts +10 -10
- package/src/authoring-draft-fragment.ts +3 -1
- package/src/body-draft-actions.ts +60 -0
- package/src/component-property-drafts.ts +5 -5
- package/src/components.tsx +10 -28
- package/src/context.tsx +2 -1
- package/src/diagnostics.ts +1 -1
- package/src/document-draft-store.ts +45 -18
- package/src/document-drafts.ts +28 -19
- package/src/document-editing.ts +484 -0
- package/src/document-editor/BlockNoteSurface.tsx +25 -9
- package/src/document-editor/ComponentMaterials.tsx +3 -9
- package/src/document-editor/ComponentPropertiesDialog.tsx +4 -4
- package/src/document-editor/DocumentBlockPreview.tsx +4 -2
- package/src/document-editor/DocumentComments.tsx +58 -9
- package/src/document-editor/DocumentEditor.tsx +44 -7
- package/src/document-editor/DocumentStepNarration.tsx +30 -25
- package/src/document-editor/NarrationEditor.tsx +54 -20
- package/src/document-editor/NewCommentDrafts.tsx +4 -3
- package/src/document-editor/PlaceComment.tsx +150 -0
- package/src/document-editor/comment-drafts.ts +16 -14
- package/src/document-editor/comments.ts +30 -10
- package/src/document-editor/component-label.ts +11 -0
- package/src/document-editor/file-input.ts +2 -2
- package/src/document-editor/focus.ts +0 -2
- package/src/document-editor/insertion-place.ts +60 -0
- package/src/document-editor/messages.ts +3 -3
- package/src/document-editor/narration-schema.tsx +12 -6
- package/src/document-editor/narration.ts +19 -3
- package/src/document-editor/page-body.ts +60 -0
- package/src/document-editor/projection.ts +2 -2
- package/src/document-editor/rich-text.ts +3 -2
- package/src/document-editor/selection.ts +13 -0
- package/src/document-editor/style.css +12 -1
- package/src/document-editor/table-identities.ts +2 -1
- package/src/document-production.ts +331 -0
- package/src/document-session.ts +190 -51
- package/src/history.ts +3 -3
- package/src/index.ts +5 -5
- package/src/jobs.ts +1 -1
- package/src/messages.ts +19 -4
- package/src/panels/DocumentView.tsx +66 -26
- package/src/panels/DocumentVoiceDialog.tsx +2 -2
- package/src/panels/DocumentVoiceField.tsx +1 -1
- package/src/panels/ExportPanel.tsx +1 -6
- package/src/panels/HistoryPanel.tsx +1 -1
- package/src/panels/PageDeleteDialog.tsx +4 -4
- package/src/panels/PageRenameDialog.tsx +1 -1
- package/src/panels/PreviewPanel.tsx +1 -4
- package/src/panels/ProductionCaptionSize.tsx +20 -0
- package/src/panels/ProductionCaptionTiming.tsx +7 -7
- package/src/panels/ProductionMediaClips.tsx +6 -5
- package/src/panels/ProductionPanel.tsx +8 -4
- package/src/panels/ProductionRecording.tsx +86 -9
- package/src/panels/ProductionRecordingRange.tsx +4 -4
- package/src/panels/ProductionTimeline.tsx +6 -1
- package/src/panels/ProductionTranscription.tsx +5 -4
- package/src/panels/SourceDocumentPanel.tsx +12 -15
- package/src/panels/TranscriptionAdoption.tsx +9 -8
- package/src/panels/VoiceCloneDialog.tsx +2 -1
- package/src/panels/VoiceoverDialog.tsx +1 -1
- package/src/places.ts +1 -36
- package/src/preview-playback.ts +1 -1
- package/src/production-messages.ts +6 -0
- package/src/production-playback.ts +1 -1
- package/src/production-voice-playback.ts +3 -2
- package/src/sha256.ts +9 -0
- package/src/styles.css +16 -41
- package/src/use-recording-adoption.ts +2 -2
- package/src/voiceover-jobs.ts +1 -1
- package/src/workbench-state.ts +157 -0
- package/src/workbench.ts +177 -943
- package/src/workspace-client.ts +6 -5
- package/src/assistant-mascot.ts +0 -62
- package/src/mascot-preference.ts +0 -37
- package/src/panels/ChangeTrail.tsx +0 -79
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'
|
|
2
2
|
import type { ReactNode, RefObject } from 'react'
|
|
3
|
-
import { PmButton,
|
|
3
|
+
import { PmButton, PmDialog, PmIconButton, PmMenu, PmNotice, PmSkeleton, PmSortableList, PmToolbar, PmToolbarButton } from '../components.tsx'
|
|
4
4
|
import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
5
5
|
import { failureReason, timeAgo } from '../messages.ts'
|
|
6
6
|
import { SHORTCUTS } from '../shortcuts.ts'
|
|
7
7
|
import { DocumentOutline, DocumentWordCounter } from '../outline.ts'
|
|
8
|
-
import { isAgentChanging } from '../workbench.ts'
|
|
8
|
+
import { isAgentChanging } from '../workbench-state.ts'
|
|
9
9
|
import { ExportPanel } from './ExportPanel.tsx'
|
|
10
10
|
import { HistoryPanel } from './HistoryPanel.tsx'
|
|
11
11
|
import type { HistoryRevisionAction } from './HistoryPanel.tsx'
|
|
@@ -55,6 +55,7 @@ export function DocumentView({ active = true, framed = false, onBack, actions, h
|
|
|
55
55
|
const [commentsPortal, setCommentsPortal] = useState<HTMLDivElement | null>(null)
|
|
56
56
|
const t = useMessages()
|
|
57
57
|
const document = useWorkbenchState(state => state.document)
|
|
58
|
+
const sourceIdentity = useWorkbenchState(state => state.authoring?.identity)
|
|
58
59
|
const view = useWorkbenchState(state => state.webView)
|
|
59
60
|
const previousView = useRef({ document, workspace, view, active })
|
|
60
61
|
const currentScope = useRef({ document, active })
|
|
@@ -72,7 +73,7 @@ export function DocumentView({ active = true, framed = false, onBack, actions, h
|
|
|
72
73
|
setNavigationDocument(document)
|
|
73
74
|
if (navigation && typeof matchMedia === 'function' && !matchMedia(ROOMY).matches) setNavigation(false)
|
|
74
75
|
}
|
|
75
|
-
const compilePresentation = async (ready?: () => void, forReading = false): Promise<void> => {
|
|
76
|
+
const compilePresentation = async (ready?: () => void, forReading = false, signal?: AbortSignal, deadline?: number): Promise<void> => {
|
|
76
77
|
if (preparing.current || workbench.getState().isPreparingPresentation) return
|
|
77
78
|
preparing.current = true
|
|
78
79
|
const generation = ++transition.current, identity = workbench.getState().authoring?.identity
|
|
@@ -80,34 +81,39 @@ export function DocumentView({ active = true, framed = false, onBack, actions, h
|
|
|
80
81
|
setChangingView(true)
|
|
81
82
|
const current = () => generation === transition.current && currentScope.current.active && currentScope.current.document === document && workbench.getState().authoring?.identity === identity
|
|
82
83
|
try {
|
|
83
|
-
const prepared = await workbench.preparePresentation()
|
|
84
|
+
const prepared = await workbench.preparePresentation(signal, deadline)
|
|
85
|
+
signal?.throwIfAborted()
|
|
84
86
|
if (!current()) return
|
|
85
87
|
if (prepared) ready?.()
|
|
86
88
|
else setViewFailure(forReading ? t.readingFailed : workbench.getState().presentationFailure)
|
|
87
89
|
} catch { if (current()) setViewFailure(forReading ? t.readingFailed : t.presentationCompileFailed) }
|
|
88
90
|
finally { preparing.current = false; if (current()) setChangingView(false) }
|
|
89
91
|
}
|
|
90
|
-
const openProduction = async () => {
|
|
92
|
+
const openProduction = async (signal?: AbortSignal) => {
|
|
91
93
|
if (changingView || workbench.client.capabilities?.production === false) return
|
|
92
94
|
const generation = ++transition.current, identity = workbench.getState().authoring?.identity
|
|
93
95
|
const current = () => generation === transition.current && currentScope.current.active && currentScope.current.document === document && workbench.getState().authoring?.identity === identity
|
|
94
96
|
setChangingView(true); setViewFailure(undefined)
|
|
95
97
|
try {
|
|
98
|
+
signal?.throwIfAborted()
|
|
96
99
|
await workbench.pausePlayback()
|
|
97
|
-
await workbench.flushPendingEdits()
|
|
100
|
+
await workbench.flushPendingEdits(signal)
|
|
101
|
+
signal?.throwIfAborted()
|
|
98
102
|
if (current()) { workbench.setMode('editing'); setWorkspace('production') }
|
|
99
103
|
} catch { if (current()) setViewFailure(t.presentationPending) }
|
|
100
104
|
finally { if (current()) setChangingView(false) }
|
|
101
105
|
}
|
|
102
|
-
const exitPresent = (): Promise<void> => {
|
|
106
|
+
const exitPresent = (signal?: AbortSignal): Promise<void> => {
|
|
103
107
|
if (exiting.current) return exiting.current
|
|
104
108
|
const generation = ++transition.current, identity = workbench.getState().authoring?.identity
|
|
105
109
|
setChangingView(true); setViewFailure(undefined)
|
|
106
110
|
const current = () => generation === transition.current && currentScope.current.active && currentScope.current.document === document && workbench.getState().authoring?.identity === identity
|
|
107
111
|
const work = Promise.resolve().then(async () => {
|
|
108
112
|
try {
|
|
113
|
+
signal?.throwIfAborted()
|
|
109
114
|
// The child flushes its latest position before acknowledging this pause.
|
|
110
115
|
await workbench.pausePlayback()
|
|
116
|
+
signal?.throwIfAborted()
|
|
111
117
|
if (!current()) return
|
|
112
118
|
setWorkspace('document')
|
|
113
119
|
workbench.setMode('editing')
|
|
@@ -120,6 +126,40 @@ export function DocumentView({ active = true, framed = false, onBack, actions, h
|
|
|
120
126
|
exiting.current = work
|
|
121
127
|
return work
|
|
122
128
|
}
|
|
129
|
+
const controls = useRef({ workspace, changingView, viewFailure, generation: transition.current, compilePresentation, openProduction, exitPresent, setWorkspace })
|
|
130
|
+
controls.current = { workspace, changingView, viewFailure, generation: transition.current, compilePresentation, openProduction, exitPresent, setWorkspace }
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (!active || !sourceIdentity) return
|
|
133
|
+
return workbench.registerAuthoringClientControls({ identity: sourceIdentity,
|
|
134
|
+
actions: () => {
|
|
135
|
+
const state = workbench.getState(), source = state.authoring
|
|
136
|
+
return currentScope.current.active && source?.identity === sourceIdentity && !controls.current.changingView
|
|
137
|
+
&& !source.loading && !source.dirty && !source.saving && !source.composing && !source.restored && !source.error && !isAgentChanging(state)
|
|
138
|
+
&& !state.isCreatingPage && !state.isEditingPage && !state.isHistoryBusy && !state.isHistoryPreparing ? ['view.set'] : []
|
|
139
|
+
},
|
|
140
|
+
snapshot: () => ({ mode: controls.current.workspace }),
|
|
141
|
+
execute: async (action, _source, signal, deadline) => {
|
|
142
|
+
if (action.type !== 'view.set') throw new Error('client-action-unavailable')
|
|
143
|
+
if (preparing.current || controls.current.changingView) throw new Error('client-action-unavailable')
|
|
144
|
+
if (action.view !== controls.current.workspace) {
|
|
145
|
+
if (action.view === 'document') await controls.current.exitPresent(signal)
|
|
146
|
+
else if (action.view === 'production') await controls.current.openProduction(signal)
|
|
147
|
+
else await controls.current.compilePresentation(() => {
|
|
148
|
+
workbench.setMode('viewing'); workbench.setWebView(action.view === 'presentation' ? 'present' : 'document')
|
|
149
|
+
controls.current.setWorkspace(action.view)
|
|
150
|
+
}, action.view === 'reading', signal, deadline)
|
|
151
|
+
}
|
|
152
|
+
const generation = transition.current
|
|
153
|
+
await workbench.waitForAuthoringClientState(() => {
|
|
154
|
+
if (!currentScope.current.active || workbench.getState().authoring?.identity !== sourceIdentity) throw new Error('client-document-changed')
|
|
155
|
+
if (generation !== transition.current) throw new Error('client-view-changed')
|
|
156
|
+
if (controls.current.generation === generation && controls.current.viewFailure && controls.current.workspace !== action.view) throw new Error('client-view-not-verified')
|
|
157
|
+
return controls.current.workspace === action.view && !controls.current.changingView
|
|
158
|
+
}, signal)
|
|
159
|
+
},
|
|
160
|
+
})
|
|
161
|
+
}, [workbench, active, sourceIdentity])
|
|
162
|
+
useEffect(() => workbench.refreshAuthoringClientControls(), [workbench, active, sourceIdentity, workspace, changingView])
|
|
123
163
|
useEffect(() => {
|
|
124
164
|
transition.current++; exiting.current = undefined
|
|
125
165
|
setWorkspace('document')
|
|
@@ -198,7 +238,7 @@ export function DocumentView({ active = true, framed = false, onBack, actions, h
|
|
|
198
238
|
<DocumentNotices />
|
|
199
239
|
<div className="pmw-document__body" role="region" aria-label={producing ? PRODUCTION_MESSAGES[workbench.getState().locale].title : presenting ? t.presentationPreview : reading ? t.readDocument : t.documentEditor}>
|
|
200
240
|
{!presenting && !producing && !reading && navigation && <NavigationPane onClose={() => setNavigation(false)} onSelect={() => { if (matchMedia('(max-width: 1279px)').matches) setNavigation(false) }} />}
|
|
201
|
-
<div className="pmw-document__main"><div className="pmw-document__source" hidden={presenting || producing || reading}><SourceDocumentPanel commentsPortal={commentsPortal} onCommentDraftRestore={() => setAside(current => current === 'comments' ? null : current)} /></div>{producing && <ProductionPanel active={active} closing={changingView} onClose={() => void exitPresent()} />}{presenting && <PreviewPanel presentation active={active} onPresentationAction={action => { if (action === 'refresh') void compilePresentation(); else void exitPresent() }} />}{reading && <PreviewPanel active={active} />}</div>
|
|
241
|
+
<div className="pmw-document__main"><div className="pmw-document__source" hidden={presenting || producing || reading}><SourceDocumentPanel commentsPortal={commentsPortal} onCommentDraftRestore={() => setAside(current => current === 'comments' ? null : current)} onOpenComments={() => setAside('comments')} /></div>{producing && <ProductionPanel active={active} closing={changingView} onClose={() => void exitPresent()} />}{presenting && <PreviewPanel presentation active={active} onPresentationAction={action => { if (action === 'refresh') void compilePresentation(); else void exitPresent() }} />}{reading && <PreviewPanel active={active} />}</div>
|
|
202
242
|
{!presenting && !producing && !reading && aside && (
|
|
203
243
|
<aside className="pmw-document__aside pm-ui-block-editor" aria-label={{ narration: t.documentNarration, comments: t.comments, export: t.exportPane, history: t.versionHistory }[aside]}>
|
|
204
244
|
{aside === 'comments' ? <section className="pmw-pane"><header className="pmw-pane__header"><h2 className="pmw-pane__title">{t.comments}</h2><PmIconButton small icon="close" label={t.close} onClick={() => setAside(null)} /></header><div ref={setCommentsPortal} /></section> : aside === 'narration' ? <DocumentNarrationPanel onClose={() => setAside(null)} /> : aside === 'export' ? <ExportPanel documentOnly onClose={() => setAside(null)} /> : <HistoryPanel onClose={() => setAside(null)} revisionAction={historyRevisionAction} />}
|
|
@@ -238,7 +278,7 @@ function NavigationPane({ onClose, onSelect }: { onClose(): void, onSelect(): vo
|
|
|
238
278
|
const pages = editing || slides
|
|
239
279
|
const top = Math.min(...items.map(item => Math.max(1, item.depth)))
|
|
240
280
|
const pageActions = (item: typeof items[number], index: number) => {
|
|
241
|
-
const capability = workbench.
|
|
281
|
+
const capability = workbench.editing.pageCapability(item.id), previousPeer = index > 0, nextPeer = index < items.length - 1
|
|
242
282
|
return <PmMenu label={t.pageMore(item.title)} description={capability.reason} triggerRef={node => { if (node) menuTriggers.current.set(item.id, node); else menuTriggers.current.delete(item.id) }} items={[
|
|
243
283
|
{ id: 'rename', label: t.rename, icon: 'edit', disabled: !capability.rename || !canCreate || pageBusy || creating },
|
|
244
284
|
{ id: 'copy', label: t.pageCopy, icon: 'copy', disabled: !canCreate || pageBusy || creating },
|
|
@@ -246,19 +286,19 @@ function NavigationPane({ onClose, onSelect }: { onClose(): void, onSelect(): vo
|
|
|
246
286
|
{ id: 'down', label: t.movePageDown, disabled: !capability.move || !canCreate || pageBusy || creating || !nextPeer },
|
|
247
287
|
...(canDelete ? [{ id: 'delete', label: t.pageDelete, icon: 'trash' as const, danger: true, separator: true, disabled: !canCreate || pageBusy || creating }] : []),
|
|
248
288
|
]} onSelect={id => {
|
|
249
|
-
workbench.
|
|
289
|
+
workbench.editing.clearFailure()
|
|
250
290
|
if (id === 'rename') setRenaming({ id: item.id, title: item.title, trigger: menuTriggers.current.get(item.id) })
|
|
251
|
-
else if (id === 'copy') void workbench.duplicatePage(item.id)
|
|
291
|
+
else if (id === 'copy') void workbench.editing.duplicatePage(item.id)
|
|
252
292
|
else if (id === 'delete') setDeleting({ id: item.id, title: item.title, trigger: menuTriggers.current.get(item.id) })
|
|
253
|
-
else if (id === 'up' && index > 0) void workbench.movePage(item.id, items[index - 1]!.id)
|
|
254
|
-
else if (id === 'down') void workbench.movePage(item.id, items[index + 2]?.id ?? null)
|
|
293
|
+
else if (id === 'up' && index > 0) void workbench.editing.movePage(item.id, items[index - 1]!.id)
|
|
294
|
+
else if (id === 'down') void workbench.editing.movePage(item.id, items[index + 2]?.id ?? null)
|
|
255
295
|
}} />
|
|
256
296
|
}
|
|
257
297
|
return (
|
|
258
298
|
<nav className="pmw-navigation" aria-label={t.navigation}>
|
|
259
299
|
<header className="pmw-pane__header">
|
|
260
300
|
<h2 className="pmw-pane__title">{editing ? t.pages : slides ? t.renderers.slides : t.navigation}</h2>
|
|
261
|
-
{editing && <PmIconButton icon="plus" label={t.newPage} small loading={creating} disabled={!canCreate || pageBusy || !items.length} onClick={() => { if (workbench.createPage()) onSelect() }} />}
|
|
301
|
+
{editing && <PmIconButton icon="plus" label={t.newPage} small loading={creating} disabled={!canCreate || pageBusy || !items.length} onClick={() => { if (workbench.editing.createPage()) onSelect() }} />}
|
|
262
302
|
<PmIconButton icon="close" label={t.closeNavigation} small onClick={onClose} />
|
|
263
303
|
</header>
|
|
264
304
|
{failure && !renaming && !deleting && <PmNotice tone="danger">{failure}</PmNotice>}
|
|
@@ -266,13 +306,13 @@ function NavigationPane({ onClose, onSelect }: { onClose(): void, onSelect(): vo
|
|
|
266
306
|
: items.length === 0
|
|
267
307
|
? <p className="pmw-muted pmw-navigation__empty">{t.noSections}</p>
|
|
268
308
|
: editing ? <PmSortableList label={t.pages} scopeKey={JSON.stringify([identity, documentId, document])} resetKey={reset} className="pmw-navigation__list" locale={locale}
|
|
269
|
-
items={items.map((item, index) => ({ id: item.id, label: item.title, prefix: item.number, reorderDisabled: !workbench.
|
|
309
|
+
items={items.map((item, index) => ({ id: item.id, label: item.title, prefix: item.number, reorderDisabled: !workbench.editing.pageCapability(item.id).move, actions: pageActions(item, index) }))}
|
|
270
310
|
value={current} reorderDisabled={reorderDisabled} loading={pageBusy || creating}
|
|
271
311
|
onSelect={id => { workbench.goToSection(id); onSelect() }}
|
|
272
312
|
onMove={async (id, before) => {
|
|
273
313
|
const state = workbench.getState()
|
|
274
314
|
if (state.document !== document || state.authoring?.identity !== identity || state.authoring?.content?.id !== documentId) return
|
|
275
|
-
if (!await workbench.movePage(id, before)) throw new Error('page-reorder-failed')
|
|
315
|
+
if (!await workbench.editing.movePage(id, before)) throw new Error('page-reorder-failed')
|
|
276
316
|
}} /> : (
|
|
277
317
|
<ol className="pmw-navigation__list" data-kind={pages ? 'slides' : 'headings'}>
|
|
278
318
|
{items.map(item => (
|
|
@@ -291,8 +331,8 @@ function NavigationPane({ onClose, onSelect }: { onClose(): void, onSelect(): vo
|
|
|
291
331
|
))}
|
|
292
332
|
</ol>
|
|
293
333
|
)}
|
|
294
|
-
{renaming && <PageRenameDialog section={renaming.id} title={renaming.title} trigger={renaming.trigger} onClose={() => { setRenaming(undefined); workbench.
|
|
295
|
-
{deleting && <PageDeleteDialog section={deleting.id} title={deleting.title} trigger={deleting.trigger} onClose={() => { setDeleting(undefined); workbench.
|
|
334
|
+
{renaming && <PageRenameDialog section={renaming.id} title={renaming.title} trigger={renaming.trigger} onClose={() => { setRenaming(undefined); workbench.editing.clearFailure() }} />}
|
|
335
|
+
{deleting && <PageDeleteDialog section={deleting.id} title={deleting.title} trigger={deleting.trigger} onClose={() => { setDeleting(undefined); workbench.editing.clearFailure() }} />}
|
|
296
336
|
</nav>
|
|
297
337
|
)
|
|
298
338
|
}
|
|
@@ -409,10 +449,8 @@ function DocumentNotices() {
|
|
|
409
449
|
const askFailure = useWorkbenchState(state => (state.pointer ? undefined : state.askFailure))
|
|
410
450
|
return (
|
|
411
451
|
<div className="pmw-notices">
|
|
412
|
-
{review?.running && <PmNotice tone="accent"><PmMascot size="small" action={review.changes.length > 0 ? 'write' : 'read'} />{t.agentWorking}</PmNotice>}
|
|
413
452
|
{review && !review.running && review.changes.length > 0 && (
|
|
414
453
|
<PmNotice tone="accent">
|
|
415
|
-
<PmMascot size="small" action="ask" />
|
|
416
454
|
<span>{t.agentWaiting(review.changes.length)}</span>
|
|
417
455
|
<span className="pmw-notice__actions">
|
|
418
456
|
<PmButton small onClick={() => void workbench.rejectReview()}>{t.reject}</PmButton>
|
|
@@ -431,7 +469,7 @@ function DocumentNotices() {
|
|
|
431
469
|
)
|
|
432
470
|
}
|
|
433
471
|
|
|
434
|
-
/**
|
|
472
|
+
/** The document's problems in one line above the page, with the AI to fix them; the list itself opens in a dialog. */
|
|
435
473
|
function ProblemsNotice() {
|
|
436
474
|
const t = useMessages()
|
|
437
475
|
const workbench = useWorkbench()
|
|
@@ -440,23 +478,25 @@ function ProblemsNotice() {
|
|
|
440
478
|
const canRepair = useWorkbenchState(state => state.canRepairDiagnostics)
|
|
441
479
|
const repairing = useWorkbenchState(state => state.isRepairingDiagnostics)
|
|
442
480
|
const repairFailure = useWorkbenchState(state => state.diagnosticsRepairFailure)
|
|
481
|
+
const [open, setOpen] = useState(false)
|
|
443
482
|
if (workbench.client.capabilities?.diagnostics === 'none') return null
|
|
444
483
|
const problems = (snapshot?.diagnostics ?? []).filter(diagnostic => diagnostic.severity === 'error' && !diagnostic.checkId.startsWith('presmium.workbench.'))
|
|
445
484
|
if (unavailable) return <PmNotice tone="warn"><span>{t.diagnosticsUnavailable}</span><PmButton small onClick={() => workbench.retryDiagnostics()}>{t.retry}</PmButton></PmNotice>
|
|
446
485
|
if (problems.length === 0) return repairFailure ? <PmNotice tone="danger">{t.fixFailed(failureReason(t, repairFailure))}</PmNotice> : null
|
|
486
|
+
const repair = canRepair && <PmButton small variant="accent" icon="sparkle" disabled={repairing} onClick={() => void workbench.requestRepairDiagnostics()}>{repairing ? t.fixing : t.fixWithAi}</PmButton>
|
|
447
487
|
return (
|
|
448
488
|
<PmNotice tone="warn">
|
|
449
489
|
<div className="pmw-problems">
|
|
450
490
|
<div className="pmw-problems__summary">
|
|
451
491
|
<span>{t.problems(problems.length)}</span>
|
|
452
|
-
|
|
492
|
+
<PmButton small variant="ghost" onClick={() => setOpen(true)}>{t.details}</PmButton>
|
|
493
|
+
{repair}
|
|
453
494
|
</div>
|
|
454
495
|
{repairFailure && <p className="pmw-problems__failure">{t.fixFailed(failureReason(t, repairFailure))}</p>}
|
|
455
|
-
<details className="pmw-problems__details">
|
|
456
|
-
<summary>{t.details}</summary>
|
|
457
|
-
<ul>{problems.map(problem => <li key={problem.id}>{problem.message}</li>)}</ul>
|
|
458
|
-
</details>
|
|
459
496
|
</div>
|
|
497
|
+
<PmDialog open={open} label={t.problemsTitle} closeLabel={t.close} actions={repair || undefined} onClose={() => setOpen(false)}>
|
|
498
|
+
<ul className="pmw-problems__list">{problems.map(problem => <li key={problem.id}><p>{problem.message}</p>{problem.hint && <p className="pmw-problems__hint">{problem.hint}</p>}</li>)}</ul>
|
|
499
|
+
</PmDialog>
|
|
460
500
|
</PmNotice>
|
|
461
501
|
)
|
|
462
502
|
}
|
|
@@ -11,7 +11,7 @@ import { VOICE_CLONE_MESSAGES } from '../voice-clone-messages.ts'
|
|
|
11
11
|
import { VOICE_MESSAGES, voiceFailure } from '../voice-messages.ts'
|
|
12
12
|
import { prepareVoiceSnapshot, voiceSnapshotCurrent } from '../voice-snapshot.ts'
|
|
13
13
|
import type { VoiceSnapshot } from '../voice-snapshot.ts'
|
|
14
|
-
import { isAgentChanging } from '../workbench.ts'
|
|
14
|
+
import { isAgentChanging } from '../workbench-state.ts'
|
|
15
15
|
import { VoiceCloneDialog } from './VoiceCloneDialog.tsx'
|
|
16
16
|
import { VoicePreviewDialog } from './VoicePreviewDialog.tsx'
|
|
17
17
|
import { VoiceScopeField } from './VoiceScopeField.tsx'
|
|
@@ -84,7 +84,7 @@ export function DocumentVoiceDialog({ stepId, onClose }: { stepId: string, onClo
|
|
|
84
84
|
const confirmation = review, generation = ++owner.current.generation
|
|
85
85
|
setBusy(true); setFailure(undefined)
|
|
86
86
|
try {
|
|
87
|
-
const saved = await workbench.
|
|
87
|
+
const saved = await workbench.production.applyVoice(confirmation.draft.scope, confirmation.draft.source, { replaceOverrides: confirmation.draft.replaceOverrides }, confirmation.expected)
|
|
88
88
|
if (!current() || generation !== owner.current.generation) return
|
|
89
89
|
if (!saved) throw new Error('voice-context-changed')
|
|
90
90
|
if (!clearVoiceDraft(workbench.client, identity, stepId, confirmation.draft)) { setStorageFailed(true); setReview(undefined); return }
|
|
@@ -3,7 +3,7 @@ import { PmButton, PmField } from '../components.tsx'
|
|
|
3
3
|
import { useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
4
4
|
import { resolveDocumentStepVoice } from '../document-voices.ts'
|
|
5
5
|
import { PRODUCTION_MESSAGES } from '../production-messages.ts'
|
|
6
|
-
import { isAgentChanging } from '../workbench.ts'
|
|
6
|
+
import { isAgentChanging } from '../workbench-state.ts'
|
|
7
7
|
import { DocumentVoiceDialog } from './DocumentVoiceDialog.tsx'
|
|
8
8
|
|
|
9
9
|
/** One current voice and selector, shared by document captions and production. */
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react'
|
|
2
|
-
import type { CSSProperties } from 'react'
|
|
3
2
|
import type { CompileJob, OutputTarget } from '@lincyaw/kernel'
|
|
4
3
|
import type { IconName } from '@lincyaw/design'
|
|
5
|
-
import { PmBadge, PmButton, PmDialog, PmEmpty, PmIcon, PmIconButton,
|
|
4
|
+
import { PmBadge, PmButton, PmDialog, PmEmpty, PmIcon, PmIconButton, PmNotice } from '../components.tsx'
|
|
6
5
|
import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
7
6
|
import { failureReason, timeAgo } from '../messages.ts'
|
|
8
7
|
|
|
@@ -105,10 +104,6 @@ function JobItem({ job, label, current, onPlay }: { job: CompileJob, label: stri
|
|
|
105
104
|
</p>
|
|
106
105
|
{job.state === 'running' && progress && (
|
|
107
106
|
<div className="pmw-job__progress">
|
|
108
|
-
{/* the kitten runs along the bar to how far the job has come; with no total yet it walks at the start */}
|
|
109
|
-
<span className="pmw-job__runner" style={{ '--pmw-job-done': progress.total ? Math.min(1, (progress.done ?? 0) / progress.total) : 0 } as CSSProperties}>
|
|
110
|
-
<PmMascot size="small" action={progress.total ? 'run' : 'walk'} />
|
|
111
|
-
</span>
|
|
112
107
|
<progress max={progress.total ?? 1} value={progress.total ? progress.done ?? 0 : undefined} aria-label={label} />
|
|
113
108
|
<span>{t.jobProgress(t.jobPhases[progress.phase] ?? t.outputLabels[progress.phase] ?? progress.phase, progress.done, progress.total)}</span>
|
|
114
109
|
</div>
|
|
@@ -3,7 +3,7 @@ import { PmBadge, PmButton, PmEmpty, PmIcon, PmIconButton, PmNotice } from '../c
|
|
|
3
3
|
import type { IconName } from '@lincyaw/design'
|
|
4
4
|
import { useMessages, useWorkbench, useWorkbenchState } from '../context.tsx'
|
|
5
5
|
import { timeAgo } from '../messages.ts'
|
|
6
|
-
import { isAgentChanging } from '../workbench.ts'
|
|
6
|
+
import { isAgentChanging } from '../workbench-state.ts'
|
|
7
7
|
|
|
8
8
|
/** A host-owned operation on a version, such as restoring an entire saved snapshot. This never replaces selective undo. */
|
|
9
9
|
export interface HistoryRevisionAction {
|
|
@@ -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.
|
|
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.
|
|
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
|
|
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:
|
|
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
|
|
@@ -44,13 +44,13 @@ export function ProductionCaptionTiming({ identity, stepId, plan, current, loadi
|
|
|
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
46
|
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) }
|
|
47
|
+
if (!drafts.current.has(stepId)) { const savedDraft = workbench.production.captionTimingDraft(stepId, identity); if (savedDraft) drafts.current.set(stepId, savedDraft) }
|
|
48
48
|
const draft = drafts.current.get(stepId), value = draft && valueOf(draft), canonical = document?.production.captionTimings?.[stepId], hasDraft = Boolean(pendingSteps?.includes(stepId))
|
|
49
49
|
const changed = draft && source?.version !== draft.version || draft && basis && (!same(draft.basis, basis) || draft.text !== (document && stepCaptionText(document, stepId)))
|
|
50
50
|
const writable = Boolean(source?.version && source.fingerprint && !source.loading && !source.dirty && !source.saving && !source.composing && !source.restored && !source.recovering && !source.error && !disabled)
|
|
51
51
|
useEffect(() => { alive.current = true; return () => { alive.current = false; request.current?.abort() } }, [])
|
|
52
52
|
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) }
|
|
53
|
+
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
54
|
const initialize = () => {
|
|
55
55
|
if (!document || !source?.version || !basis) return
|
|
56
56
|
const text = stepCaptionText(document, stepId), existing = document.production.captionTimings?.[stepId]
|
|
@@ -72,12 +72,12 @@ export function ProductionCaptionTiming({ identity, stepId, plan, current, loadi
|
|
|
72
72
|
const action: DocumentCaptionTimingAction = automatic ? { type: 'caption.timing.reset', stepId } : { type: 'caption.timing.set', stepId, value: value! }
|
|
73
73
|
request.current = controller; setBusy(true); setFailure(undefined)
|
|
74
74
|
try {
|
|
75
|
-
const answer = await workbench.
|
|
75
|
+
const answer = await workbench.production.applyCaptionTiming(action, randomUUID(), expected, controller.signal)
|
|
76
76
|
needsRefresh.current = true
|
|
77
77
|
if (!alive.current || workbench.getState().authoring?.identity !== identity) return
|
|
78
78
|
const ownsInput = drafts.current.get(target) === sent
|
|
79
79
|
if (ownsInput) {
|
|
80
|
-
workbench.setCaptionTimingDraft(target, undefined, identity)
|
|
80
|
+
workbench.production.setCaptionTimingDraft(target, undefined, identity)
|
|
81
81
|
if (automatic) drafts.current.delete(target)
|
|
82
82
|
else if (sent) drafts.current.set(target, { ...sent, version: answer.version })
|
|
83
83
|
}
|
|
@@ -111,7 +111,7 @@ export function ProductionCaptionTiming({ identity, stepId, plan, current, loadi
|
|
|
111
111
|
<div className="pmw-caption-times__actions">
|
|
112
112
|
<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
113
|
<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>}
|
|
114
|
+
{hasDraft && <PmButton small disabled={busy} onClick={() => { workbench.production.setCaptionTimingDraft(stepId, undefined, identity); drafts.current.delete(stepId); initialize() }}>{t.discard}</PmButton>}
|
|
115
115
|
</div>
|
|
116
116
|
{storageFailure && <PmNotice tone="warn">{t.storageFailed}</PmNotice>}
|
|
117
117
|
{saved && <PmNotice tone="ok">{t.saved}</PmNotice>}
|
|
@@ -1,5 +1,6 @@
|
|
|
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'
|
|
@@ -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_${
|
|
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}`
|
|
@@ -55,7 +56,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
|
|
|
55
56
|
const assetId = draft.clip.assetId, controller = new AbortController(), requestKey = key
|
|
56
57
|
if (!assetId || disabled || !version || inspection?.version === version && inspection.value.assetId === assetId) { setLoading(false); return }
|
|
57
58
|
setLoading(true)
|
|
58
|
-
void workbench.
|
|
59
|
+
void workbench.production.inspectAudio(assetId, { identity, version }, controller.signal).then(answer => {
|
|
59
60
|
if (controller.signal.aborted || !active()) return
|
|
60
61
|
setInspection({ version: answer.version, value: answer.inspection })
|
|
61
62
|
const current = ownDraft(latest.current.entries, requestKey)
|
|
@@ -84,7 +85,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
|
|
|
84
85
|
if (!sent) return
|
|
85
86
|
file.current = value; setRetryImport(false)
|
|
86
87
|
try {
|
|
87
|
-
const answer = await workbench.
|
|
88
|
+
const answer = await workbench.production.ensureAudio(value, sent.expected, sent.controller.signal)
|
|
88
89
|
if (!active() || sent.controller.signal.aborted) return
|
|
89
90
|
const next = acknowledge(answer, sent.expected.version)
|
|
90
91
|
if (owner.current.revision === sent.revision && selected.current === sent.key) {
|
|
@@ -102,7 +103,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
|
|
|
102
103
|
const sent = start('apply')
|
|
103
104
|
if (!sent) return
|
|
104
105
|
try {
|
|
105
|
-
const answer = await workbench.
|
|
106
|
+
const answer = await workbench.production.applyMediaClip(clip, { ...sent.expected, binding }, sent.controller.signal)
|
|
106
107
|
if (!active() || sent.controller.signal.aborted) return
|
|
107
108
|
const next = acknowledge(answer, sent.expected.version), current = ownDraft(latest.current.entries, sent.key)
|
|
108
109
|
if (sent.key === 'new') blank.current = newDraft(answer.version, stepId)
|
|
@@ -122,7 +123,7 @@ export function ProductionMediaClips({ identity, version, document, sectionId, s
|
|
|
122
123
|
const sent = start('remove')
|
|
123
124
|
if (!sent) return
|
|
124
125
|
try {
|
|
125
|
-
const answer = await workbench.
|
|
126
|
+
const answer = await workbench.production.removeMediaClip(canonical.id, sent.expected, sent.controller.signal)
|
|
126
127
|
if (!active() || sent.controller.signal.aborted) return
|
|
127
128
|
const next = acknowledge(answer, sent.expected.version), current = ownDraft(latest.current.entries, sent.key)
|
|
128
129
|
if (!current || same(current, sent.draft)) {
|
|
@@ -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><
|
|
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>
|