@lincyaw/workbench 0.2.0-rc.10 → 0.2.0-rc.100
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/AgentActivityBar.tsx +25 -0
- package/src/MediaClipEditor.tsx +4 -3
- package/src/StepProductionEditor.tsx +13 -4
- package/src/agent-activity-messages.ts +14 -0
- package/src/agent-activity.ts +38 -0
- package/src/approvals.tsx +6 -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/authoring-window.ts +100 -0
- package/src/body-draft-actions.ts +60 -0
- package/src/caption-timing-drafts.ts +18 -1
- package/src/component-property-drafts.ts +5 -5
- package/src/components.tsx +34 -36
- package/src/container-layout.ts +21 -0
- package/src/context.tsx +5 -3
- 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/CommentComposer.tsx +24 -0
- package/src/document-editor/ComponentMaterials.tsx +3 -9
- package/src/document-editor/ComponentPropertiesDialog.tsx +4 -4
- package/src/document-editor/DocumentBlockPreview.tsx +11 -4
- package/src/document-editor/DocumentComments.tsx +85 -14
- package/src/document-editor/DocumentEditor.tsx +56 -7
- package/src/document-editor/DocumentStepNarration.tsx +37 -26
- package/src/document-editor/NarrationEditor.tsx +54 -20
- package/src/document-editor/NewCommentDrafts.tsx +120 -37
- package/src/document-editor/PlaceComment.tsx +252 -0
- package/src/document-editor/agent-targets.ts +34 -0
- package/src/document-editor/blocknote-messages.ts +2 -0
- package/src/document-editor/comment-draft-actions.ts +40 -20
- package/src/document-editor/comment-draft-inspection.ts +2 -2
- package/src/document-editor/comment-drafts.ts +73 -25
- 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/popover.tsx +4 -2
- 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 +7 -1
- package/src/document-editor/table-identities.ts +2 -1
- package/src/document-production.ts +491 -0
- package/src/document-session.ts +202 -56
- package/src/document-timing-drafts.ts +22 -2
- package/src/history.ts +5 -5
- package/src/index.ts +8 -5
- package/src/jobs.ts +1 -1
- package/src/media-drafts.ts +43 -1
- package/src/messages.ts +31 -14
- package/src/panels/DocumentNarrationPanel.tsx +2 -2
- package/src/panels/DocumentView.tsx +93 -61
- package/src/panels/DocumentVoiceDialog.tsx +25 -9
- package/src/panels/DocumentVoiceField.tsx +1 -1
- package/src/panels/ExportPanel.tsx +2 -10
- package/src/panels/HistoryPanel.tsx +34 -7
- package/src/panels/HomePanel.tsx +3 -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 +12 -9
- package/src/panels/ProductionMediaClips.tsx +23 -7
- package/src/panels/ProductionPanel.tsx +16 -13
- package/src/panels/ProductionRecording.tsx +86 -9
- package/src/panels/ProductionRecordingRange.tsx +21 -19
- package/src/panels/ProductionTimeline.tsx +6 -1
- package/src/panels/ProductionTranscription.tsx +5 -4
- package/src/panels/SourceDocumentPanel.tsx +18 -36
- package/src/panels/TranscriptionAdoption.tsx +40 -34
- 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-draft-actions.ts +37 -0
- 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 +43 -79
- package/src/transcription-drafts.ts +124 -0
- package/src/use-recording-adoption.ts +2 -2
- package/src/voice-drafts.ts +32 -8
- package/src/voiceover-jobs.ts +1 -1
- package/src/workbench-state.ts +159 -0
- package/src/workbench.ts +294 -951
- package/src/workspace-client.ts +23 -11
- package/src/assistant-mascot.ts +0 -62
- package/src/mascot-preference.ts +0 -37
- package/src/panels/ChangeTrail.tsx +0 -79
|
@@ -40,9 +40,10 @@ function RecordingSlot({ label, hint, value, disabled, onChange }: { label: stri
|
|
|
40
40
|
const capturing = ['requesting', 'recording', 'stopping'].includes(state.phase)
|
|
41
41
|
const start = () => {
|
|
42
42
|
setFailure(undefined)
|
|
43
|
-
void recording.start(async
|
|
43
|
+
void recording.start(async signal => {
|
|
44
44
|
workbench.stopAuditions()
|
|
45
45
|
await workbench.pausePlayback()
|
|
46
|
+
signal.throwIfAborted()
|
|
46
47
|
return workbench.registerAudioCapture(() => recording.stop())
|
|
47
48
|
})
|
|
48
49
|
}
|
|
@@ -8,7 +8,7 @@ import type { DocumentVoiceScope } from '../document-voices.ts'
|
|
|
8
8
|
import { VOICE_MESSAGES, voiceFailure } from '../voice-messages.ts'
|
|
9
9
|
import { prepareVoiceSnapshot, runtimeVoiceScope, voiceSnapshotCurrent } from '../voice-snapshot.ts'
|
|
10
10
|
import type { VoiceSnapshot } from '../voice-snapshot.ts'
|
|
11
|
-
import { isAgentChanging } from '../workbench.ts'
|
|
11
|
+
import { isAgentChanging } from '../workbench-state.ts'
|
|
12
12
|
import { VoiceScopeField } from './VoiceScopeField.tsx'
|
|
13
13
|
|
|
14
14
|
interface CheckedVoice { snapshot: VoiceSnapshot, document: TeachingDocument }
|
package/src/places.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { irBlocks } from '@lincyaw/kernel'
|
|
2
|
-
import type { IRDocument, PreviewAnchor, ReviewChange, SourcePos
|
|
2
|
+
import type { IRDocument, PreviewAnchor, ReviewChange, SourcePos } from '@lincyaw/kernel'
|
|
3
3
|
|
|
4
4
|
const CHANGED_PLACES = 100
|
|
5
5
|
|
|
@@ -65,38 +65,3 @@ export function changedPlaces(doc: IRDocument, changes: readonly ReviewChange[])
|
|
|
65
65
|
}
|
|
66
66
|
return [...places.values()].slice(0, CHANGED_PLACES)
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* The places that differ between two versions of a document: each block whose content changed or that is new (with
|
|
71
|
-
* its page), each page whose title changed or that is new, and the block of each step whose narration or settings
|
|
72
|
-
* changed, at most CHANGED_PLACES.
|
|
73
|
-
*/
|
|
74
|
-
export function changedBlocks(before: TeachingDocument, after: TeachingDocument): PreviewAnchor[] {
|
|
75
|
-
const places: PreviewAnchor[] = []
|
|
76
|
-
const visit = (section: string, ids: readonly string[]) => {
|
|
77
|
-
for (const id of ids) {
|
|
78
|
-
const block = after.blocks[id]
|
|
79
|
-
if (!block) continue
|
|
80
|
-
if (JSON.stringify(block) !== JSON.stringify(before.blocks[id])) places.push({ section, block: id })
|
|
81
|
-
if ('children' in block && Array.isArray(block.children)) visit(section, block.children as string[])
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
for (const id of after.sectionOrder) {
|
|
85
|
-
const section = after.sections[id]
|
|
86
|
-
if (!section) continue
|
|
87
|
-
if (before.sections[id]?.title !== section.title) places.push({ section: id })
|
|
88
|
-
visit(id, section.children)
|
|
89
|
-
}
|
|
90
|
-
// A changed step, or a changed narration of it, shows at the block the step plays (else at its page).
|
|
91
|
-
const seen = new Set(places.map(place => `${place.section}\0${place.block ?? ''}`))
|
|
92
|
-
for (const step of Object.values(after.steps)) {
|
|
93
|
-
const narrated = step.narrationIds.some(id => JSON.stringify(after.narrations[id]) !== JSON.stringify(before.narrations[id]))
|
|
94
|
-
if (!narrated && JSON.stringify(step) === JSON.stringify(before.steps[step.id])) continue
|
|
95
|
-
// the component the step plays, where its narration shows, else any block it shows
|
|
96
|
-
const block = step.visuals.find(visual => after.blocks[visual.blockId]?.type === 'component')?.blockId ?? step.visuals.find(visual => visual.visible)?.blockId ?? step.visuals[0]?.blockId
|
|
97
|
-
const place = { section: step.sectionId, ...block ? { block } : {} }
|
|
98
|
-
const key = `${place.section}\0${place.block ?? ''}`
|
|
99
|
-
if (!seen.has(key)) { seen.add(key); places.push(place) }
|
|
100
|
-
}
|
|
101
|
-
return places.slice(0, CHANGED_PLACES)
|
|
102
|
-
}
|
package/src/preview-playback.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PreviewReport } from '@lincyaw/kernel'
|
|
2
|
-
import type { PreviewSink } from './workbench.ts'
|
|
2
|
+
import type { PreviewSink } from './workbench-state.ts'
|
|
3
3
|
|
|
4
4
|
interface PlaybackContext { document?: string, scope: number, sinks: ReadonlySet<PreviewSink> }
|
|
5
5
|
interface PendingPause {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { AuthoringClientAction, AuthoringClientActionResult } from '@lincyaw/kernel'
|
|
2
|
+
import { authoringDraftFragment, draftContentHash } from './authoring-draft-fragment.ts'
|
|
3
|
+
import type { DocumentProduction } from './document-production.ts'
|
|
4
|
+
|
|
5
|
+
/** Explicit reads use the native pending values; discard never submits production changes. */
|
|
6
|
+
export async function executeProductionDraftAction(owner: DocumentProduction, action: Extract<AuthoringClientAction, { type: `production-drafts.${string}` }>, signal: AbortSignal, owned: () => void, fits: (value: AuthoringClientActionResult) => boolean): Promise<AuthoringClientActionResult> {
|
|
7
|
+
const snapshot = owner.productionDraftSnapshot()
|
|
8
|
+
const guard = () => { signal.throwIfAborted(); owned(); snapshot.guard() }
|
|
9
|
+
const values = await Promise.all(snapshot.candidates.map(async candidate => ({ candidate, metadata: { ...candidate.metadata, draft: await draftContentHash(JSON.stringify([snapshot.stamp, candidate.key])) } })))
|
|
10
|
+
guard()
|
|
11
|
+
if (action.type === 'production-drafts.inspect') {
|
|
12
|
+
const token = await draftContentHash(JSON.stringify([snapshot.coverage, values.map(value => value.metadata)]))
|
|
13
|
+
guard()
|
|
14
|
+
if (action.cursor && action.cursor.token !== token) throw new Error('client-production-drafts-changed')
|
|
15
|
+
const start = action.cursor ? values.findIndex(value => value.metadata.draft === action.cursor!.after) + 1 : 0
|
|
16
|
+
if (action.cursor && !start) throw new Error('client-production-drafts-changed')
|
|
17
|
+
const result: Extract<AuthoringClientActionResult, { type: 'production-drafts.inspect' }> = { type: action.type, family: 'production', coverage: snapshot.coverage, token, drafts: [] }
|
|
18
|
+
for (const value of values.slice(start, start + (action.limit ?? 10))) {
|
|
19
|
+
const next = { ...result, drafts: [...result.drafts, value.metadata], ...start + result.drafts.length + 1 < values.length ? { next: { after: value.metadata.draft, token } } : {} }
|
|
20
|
+
if (!fits(next)) break
|
|
21
|
+
result.drafts.push(value.metadata)
|
|
22
|
+
}
|
|
23
|
+
if (start < values.length && !result.drafts.length) throw new Error('client-production-metadata-too-large')
|
|
24
|
+
if (start + result.drafts.length < values.length) result.next = { after: result.drafts.at(-1)!.draft, token }
|
|
25
|
+
if (!fits(result)) throw new Error('client-production-metadata-too-large')
|
|
26
|
+
guard(); return result
|
|
27
|
+
}
|
|
28
|
+
const selected = values.filter(value => value.metadata.draft === action.draft)
|
|
29
|
+
if (selected.length !== 1) throw new Error('client-production-drafts-changed')
|
|
30
|
+
const candidate = selected[0]!.candidate
|
|
31
|
+
if (action.type === 'production-drafts.read') return authoringDraftFragment({ text: JSON.stringify({ kind: candidate.metadata.kind, stepId: candidate.metadata.stepId, ...candidate.metadata.field ? { field: candidate.metadata.field } : {}, value: candidate.value }),
|
|
32
|
+
base: { type: action.type, family: 'production', draft: action.draft, format: 'presmium-production-draft-json-v1' }, offset: action.offset, maxChars: action.maxChars }, guard, fits)
|
|
33
|
+
const result: AuthoringClientActionResult = { type: action.type, family: 'production', draft: action.draft, discarded: true }
|
|
34
|
+
if (!fits(result)) throw new Error('client-production-result-too-large')
|
|
35
|
+
guard(); candidate.discard(); signal.throwIfAborted(); owned()
|
|
36
|
+
return result
|
|
37
|
+
}
|
|
@@ -57,6 +57,9 @@ const zh = {
|
|
|
57
57
|
alignmentStatus: { manual: '手动时间', words: '词时码', proportional: '比例估时', none: '未对齐' },
|
|
58
58
|
segmentStatus: { recorded: '原音频', cached: '已有配音', silent: '静音', missing: '配音待生成', blocked: '暂不可用' },
|
|
59
59
|
waveformLoading: '正在加载波形…', waveformUnavailable: '波形不可用', stepNumber: (index: number) => `步骤 ${index + 1}`,
|
|
60
|
+
notInLecture: '不在讲授中', notInLectureHint: '这一页的内容都限定在其他形态,又没有讲稿与音频,讲授视频中没有这一页。',
|
|
61
|
+
notInLectureStep: '这一步不在讲授中:它的内容都限定在其他形态,又没有讲稿与音频。',
|
|
62
|
+
captionSize: '字幕大小', captionSizeHint: '整个文稿的字幕:放映中显示的与导出视频中烧录的都按这个大小。',
|
|
60
63
|
timelineLabels: { position: '位置', seconds: '秒', seek: '播放头位置', zoomIn: '放大时间线', zoomOut: '缩小时间线', fit: '适配本页', estimated: '估计时长', unknown: '时长未知', loading: '正在加载时间线…', empty: '当前页暂无时间线片段', seekHint: '选择步骤,或用时间尺、方向键和精确时间定位;定位会先暂停播放。', invalidPosition: '请输入本页时长范围内的秒数。' },
|
|
61
64
|
failures: {
|
|
62
65
|
'production-source-changed': '文稿已更新,旧播放请求已停止。请重新准备当前版本。',
|
|
@@ -129,6 +132,9 @@ export const PRODUCTION_MESSAGES: Record<Locale, typeof zh> = {
|
|
|
129
132
|
alignmentStatus: { manual: 'Manual timing', words: 'Word timing', proportional: 'Proportional timing', none: 'Unaligned' },
|
|
130
133
|
segmentStatus: { recorded: 'Original audio', cached: 'Voiceover cached', silent: 'Silent', missing: 'Voiceover needed', blocked: 'Unavailable' },
|
|
131
134
|
waveformLoading: 'Loading waveform…', waveformUnavailable: 'Waveform unavailable', stepNumber: index => `Step ${index + 1}`,
|
|
135
|
+
notInLecture: 'Not in the lecture', notInLectureHint: 'Everything on this page is limited to other forms and it has no script or audio, so the lecture video leaves it out.',
|
|
136
|
+
notInLectureStep: 'This step is not in the lecture: everything on it is limited to other forms and it has no script or audio.',
|
|
137
|
+
captionSize: 'Caption size', captionSizeHint: 'For the whole document: captions shown in the presentation and burned into an exported video use this size.',
|
|
132
138
|
timelineLabels: { position: 'Position', seconds: 'seconds', seek: 'Playhead position', zoomIn: 'Zoom In Timeline', zoomOut: 'Zoom Out Timeline', fit: 'Fit Page', estimated: 'Estimated duration', unknown: 'Unknown duration', loading: 'Loading the timeline…', empty: 'This page has no timeline segments', seekHint: 'Select a step, or use the ruler, arrow keys, or an exact time to seek. Seeking pauses playback first.', invalidPosition: 'Enter a time in seconds within this page’s duration.' },
|
|
133
139
|
failures: {
|
|
134
140
|
'production-source-changed': 'The document changed and the old playback request stopped. Prepare the current version.',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PreviewReport, ProductionBinding, ProductionPlaybackCommand, ProductionPlaybackState } from '@lincyaw/kernel'
|
|
2
2
|
import { sameProductionBinding } from '@lincyaw/kernel'
|
|
3
|
-
import type { PreviewSink } from './workbench.ts'
|
|
3
|
+
import type { PreviewSink } from './workbench-state.ts'
|
|
4
4
|
|
|
5
5
|
interface Context {
|
|
6
6
|
document?: string
|
|
@@ -4,8 +4,9 @@ import type { ProductionPlan, ProductionPlaybackPosition, VoiceoverJob } from '@
|
|
|
4
4
|
import { useWorkbench, useWorkbenchState } from './context.tsx'
|
|
5
5
|
import { prepareVoiceSnapshot, voiceSnapshotCurrent } from './voice-snapshot.ts'
|
|
6
6
|
import { voiceFailure } from './voice-messages.ts'
|
|
7
|
-
import type { Workbench
|
|
8
|
-
import {
|
|
7
|
+
import type { Workbench } from './workbench.ts'
|
|
8
|
+
import type { WorkbenchState } from './workbench-state.ts'
|
|
9
|
+
import { isAgentChanging } from './workbench-state.ts'
|
|
9
10
|
|
|
10
11
|
const running = (job: VoiceoverJob) => ['queued', 'running', 'cancelling'].includes(job.state)
|
|
11
12
|
|
package/src/sha256.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { sha256 as hash } from '@noble/hashes/sha2.js'
|
|
2
|
+
import { bytesToHex } from '@noble/hashes/utils.js'
|
|
3
|
+
|
|
4
|
+
/** The same SHA-256 fingerprint on HTTPS, localhost and LAN HTTP. */
|
|
5
|
+
export async function sha256(value: string | ArrayBuffer): Promise<string> {
|
|
6
|
+
const bytes = typeof value === 'string' ? new TextEncoder().encode(value) : new Uint8Array(value)
|
|
7
|
+
const subtle = globalThis.crypto?.subtle
|
|
8
|
+
return bytesToHex(subtle ? new Uint8Array(await subtle.digest('SHA-256', bytes)) : hash(bytes))
|
|
9
|
+
}
|
package/src/styles.css
CHANGED
|
@@ -171,15 +171,7 @@
|
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
.pmw-toolbar {
|
|
174
|
-
display: flex;
|
|
175
|
-
flex: none;
|
|
176
|
-
align-items: center;
|
|
177
|
-
gap: var(--pm-space-px);
|
|
178
|
-
min-height: var(--pm-toolbar-height);
|
|
179
|
-
padding: var(--pm-space-1) var(--pm-space-2);
|
|
180
174
|
overflow-x: auto;
|
|
181
|
-
border-bottom: var(--pm-size-hairline) solid var(--pm-color-line);
|
|
182
|
-
background: var(--pm-color-chrome);
|
|
183
175
|
scrollbar-width: none;
|
|
184
176
|
}
|
|
185
177
|
|
|
@@ -188,8 +180,8 @@
|
|
|
188
180
|
max-width: calc(var(--pm-navigation-width) * 1.5);
|
|
189
181
|
margin: 0 var(--pm-space-2) 0 var(--pm-space-1);
|
|
190
182
|
overflow: hidden;
|
|
191
|
-
font-size: var(--pm-text-
|
|
192
|
-
font-weight:
|
|
183
|
+
font-size: var(--pm-text-sm);
|
|
184
|
+
font-weight: var(--pm-weight-semibold);
|
|
193
185
|
text-overflow: ellipsis;
|
|
194
186
|
white-space: nowrap;
|
|
195
187
|
}
|
|
@@ -265,20 +257,24 @@
|
|
|
265
257
|
color: var(--pm-color-danger);
|
|
266
258
|
}
|
|
267
259
|
|
|
268
|
-
.pmw-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
.pmw-problems__details ul {
|
|
275
|
-
margin: var(--pm-space-1) 0 0;
|
|
260
|
+
.pmw-problems__list {
|
|
261
|
+
display: flex;
|
|
262
|
+
flex-direction: column;
|
|
263
|
+
gap: var(--pm-space-3);
|
|
264
|
+
margin: 0;
|
|
276
265
|
padding-left: var(--pm-space-4);
|
|
277
|
-
font-family: var(--pm-font-mono);
|
|
278
|
-
font-size: var(--pm-text-xs);
|
|
279
266
|
overflow-wrap: anywhere;
|
|
280
267
|
}
|
|
281
268
|
|
|
269
|
+
.pmw-problems__list p {
|
|
270
|
+
margin: 0;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.pmw-problems__hint {
|
|
274
|
+
color: var(--pm-color-muted);
|
|
275
|
+
font-size: var(--pm-text-sm);
|
|
276
|
+
}
|
|
277
|
+
|
|
282
278
|
.pmw-document__body {
|
|
283
279
|
display: flex;
|
|
284
280
|
flex: 1;
|
|
@@ -551,13 +547,6 @@
|
|
|
551
547
|
position: sticky;
|
|
552
548
|
top: 0;
|
|
553
549
|
z-index: 1;
|
|
554
|
-
display: flex;
|
|
555
|
-
flex: none;
|
|
556
|
-
align-items: center;
|
|
557
|
-
gap: var(--pm-space-2);
|
|
558
|
-
min-height: var(--pm-pane-header-height);
|
|
559
|
-
padding: 0 var(--pm-space-2) 0 var(--pm-space-3);
|
|
560
|
-
background: var(--pm-color-chrome);
|
|
561
550
|
}
|
|
562
551
|
|
|
563
552
|
.pmw-pane__title {
|
|
@@ -717,6 +706,11 @@
|
|
|
717
706
|
justify-self: start;
|
|
718
707
|
}
|
|
719
708
|
|
|
709
|
+
.pmw-version__actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: var(--pm-space-2); }
|
|
710
|
+
.pmw-history-group { display: grid; gap: var(--pm-space-2); }
|
|
711
|
+
.pmw-history-group__header { display: flex; align-items: center; gap: var(--pm-space-2); padding-inline: var(--pm-space-3); }
|
|
712
|
+
.pmw-toolbar__history { display: inline-flex; align-items: center; gap: var(--pm-space-1); }
|
|
713
|
+
|
|
720
714
|
/* Above the video: its file. */
|
|
721
715
|
|
|
722
716
|
|
|
@@ -820,17 +814,6 @@
|
|
|
820
814
|
accent-color: var(--pm-color-accent);
|
|
821
815
|
}
|
|
822
816
|
|
|
823
|
-
/* The kitten above the bar, as far along it as the job has come (`--pmw-job-done`, 0 to 1), never past its ends. */
|
|
824
|
-
.pmw-job__runner {
|
|
825
|
-
display: block;
|
|
826
|
-
margin-left: calc((100% - var(--pm-size-mascot-sm)) * var(--pmw-job-done));
|
|
827
|
-
line-height: 0;
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
.pmw-job__runner:empty {
|
|
831
|
-
display: none;
|
|
832
|
-
}
|
|
833
|
-
|
|
834
817
|
.pmw-job__error {
|
|
835
818
|
margin: 0;
|
|
836
819
|
color: var(--pm-color-danger);
|
|
@@ -888,25 +871,21 @@
|
|
|
888
871
|
|
|
889
872
|
/* Narrow: labels go, icons stay; the side pane covers the document. */
|
|
890
873
|
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
.pmw-document__body { position: relative; }
|
|
894
|
-
.pmw-navigation {
|
|
874
|
+
.pmw-document:not([data-roomy]) .pmw-document__body { position: relative; }
|
|
875
|
+
.pmw-document:not([data-roomy]) .pmw-navigation {
|
|
895
876
|
position: absolute;
|
|
896
877
|
inset: 0 auto 0 0;
|
|
897
878
|
z-index: 6;
|
|
898
879
|
width: min(100%, var(--pm-navigation-width));
|
|
899
880
|
box-shadow: var(--pm-shadow-float);
|
|
900
881
|
}
|
|
901
|
-
|
|
882
|
+
.pmw-document:not([data-roomy]) .pmw-document__aside {
|
|
902
883
|
position: absolute;
|
|
903
884
|
inset: 0 0 0 auto;
|
|
904
885
|
z-index: 6;
|
|
905
886
|
width: min(100%, 24rem);
|
|
906
887
|
box-shadow: var(--pm-shadow-float);
|
|
907
888
|
}
|
|
908
|
-
}
|
|
909
|
-
|
|
910
889
|
/* Per-step speech: compact step strip and two tracks, alongside either document or presentation. */
|
|
911
890
|
.pmw-narration { min-height: 0; overflow: auto; }
|
|
912
891
|
.pmw-narration__body { display: grid; gap: var(--pm-space-3); padding: var(--pm-space-3); }
|
|
@@ -928,10 +907,9 @@
|
|
|
928
907
|
.pmw-document__source[hidden] { display: none; }
|
|
929
908
|
.pmw-source-document { flex: 1; min-width: 0; min-height: 0; overflow: auto; padding: var(--pm-space-5); background: var(--pm-color-canvas); }
|
|
930
909
|
.pmw-source-document__notices { position: sticky; inset-block-start: 0; z-index: var(--pm-z-site-header); display: grid; gap: var(--pm-space-3); margin-block-end: var(--pm-space-3); }
|
|
931
|
-
.pmw-source-document__recovery { display: grid; gap: var(--pm-space-2); min-width: 0; }
|
|
932
|
-
.pmw-source-document__recovery-actions { display: flex; flex-wrap: wrap; gap: var(--pm-space-2); }
|
|
933
910
|
.pmw-source-document__diagnostics { margin-block-end: var(--pm-space-3); }
|
|
934
|
-
|
|
911
|
+
/* Its end margin is the editor's own end area, which fills the rest of the sheet and takes the presses below the last block. */
|
|
912
|
+
.pmw-source-document__sheet { display: flex; flex-direction: column; max-width: var(--pm-sheet-width); min-height: 100%; margin-inline: auto; padding-block-start: var(--pm-space-4); background: var(--pm-color-surface); box-shadow: var(--pm-shadow-page); }
|
|
935
913
|
/* Opening: the page's own margins, so that the placeholder lines sit where the text will. */
|
|
936
914
|
.pmw-source-document__sheet--loading { box-sizing: border-box; padding: var(--pm-space-10) var(--pm-space-12); }
|
|
937
915
|
.pmw-voice__filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--pm-space-3); }
|
|
@@ -945,19 +923,17 @@
|
|
|
945
923
|
.pmw-step-timeline__steps { display: flex; gap: var(--pm-space-1); overflow-x: auto; padding: var(--pm-space-1); }
|
|
946
924
|
.pmw-step-timeline__steps > * { flex: none; }
|
|
947
925
|
.pmw-toolbar--present { justify-content: flex-end; }
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
.pmw-step-timeline { padding: var(--pm-space-2); }
|
|
960
|
-
}
|
|
926
|
+
.pmw-document[data-narrow] .pmw-source-document { padding: var(--pm-space-2); }
|
|
927
|
+
.pmw-document[data-narrow] .pmw-toolbar--document { flex-wrap: wrap; }
|
|
928
|
+
.pmw-document[data-narrow] .pmw-toolbar--document .pmw-toolbar__document { display: flex; flex: 1 0 100%; align-items: center; gap: var(--pm-space-px); min-width: 0; }
|
|
929
|
+
.pmw-document[data-narrow] .pmw-toolbar--document .pmw-toolbar__title { flex: 1; max-width: none; }
|
|
930
|
+
.pmw-document[data-narrow] .pmw-toolbar--document .pmw-toolbar__status { flex: 1 1 0; }
|
|
931
|
+
.pmw-document[data-narrow] .pmw-toolbar--document > .pmw-spacer { display: none; }
|
|
932
|
+
.pmw-document[data-narrow] .pmw-toolbar__status { flex: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
|
|
933
|
+
.pmw-document[data-narrow] .pmw-toolbar__status-full:has(+ .pmw-toolbar__status-short) { display: none; }
|
|
934
|
+
.pmw-document[data-narrow] .pmw-toolbar__status-short { display: inline; }
|
|
935
|
+
.pmw-document[data-narrow] .pmw-document__aside { width: 100%; }
|
|
936
|
+
.pmw-document[data-narrow] .pmw-step-timeline { padding: var(--pm-space-2); }
|
|
961
937
|
|
|
962
938
|
/* Production owns pane layout; controls and dock chrome live in the shared design layer. */
|
|
963
939
|
.pmw-speech-settings { min-width: 0; }
|
|
@@ -1004,22 +980,10 @@
|
|
|
1004
980
|
.pmw-approvals .pmw-muted { margin: 0; }
|
|
1005
981
|
.pmw-approvals__detail { max-height: 30vh; margin: 0; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
1006
982
|
.pmw-approvals__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--pm-space-2); }
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
left: 0;
|
|
1013
|
-
z-index: 1;
|
|
1014
|
-
pointer-events: none;
|
|
1015
|
-
transform: translate(calc(var(--pmw-trail-x) - 45%), calc(var(--pmw-trail-y) - 89%));
|
|
1016
|
-
transition: transform var(--pm-duration-walk) linear, opacity var(--pm-duration-slow);
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
.pmw-change-trail[data-phase='done'] {
|
|
1020
|
-
opacity: 0.9;
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
.pmw-change-trail__facing[data-facing='left'] {
|
|
1024
|
-
transform: scaleX(-1);
|
|
983
|
+
.pmw-agent-activity {
|
|
984
|
+
display: inline-flex;
|
|
985
|
+
align-items: center;
|
|
986
|
+
flex: none;
|
|
987
|
+
gap: var(--pm-space-1);
|
|
1025
988
|
}
|
|
989
|
+
.pmw-agent-activity__label { min-width: 0; }
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { isRecord, randomUUID } from '@lincyaw/kernel'
|
|
2
|
+
import type { NarrationNode, TranscriptionAdoptionDraft } from '@lincyaw/kernel'
|
|
3
|
+
|
|
4
|
+
export interface TranscriptionCorrection { id: string, revision: number, nodes?: NarrationNode[], discarded: string[], shared: 'fork' | 'edit-shared', baseVersion?: string, applied?: boolean }
|
|
5
|
+
export interface TranscriptionCorrectionTarget { identity: string, candidate: TranscriptionAdoptionDraft['candidate'], stepId: string, narrationId?: string, segmentIds: string[] }
|
|
6
|
+
interface Entry { target: TranscriptionCorrectionTarget, draft?: TranscriptionCorrection, raw?: string | null, failed: boolean, corrupt: boolean }
|
|
7
|
+
const prefix = 'presmium.transcription-draft.v1:'
|
|
8
|
+
export const transcriptionCorrectionKey = (target: TranscriptionCorrectionTarget): string => JSON.stringify([target.identity, target.candidate.id, target.candidate.revision, target.stepId, target.narrationId ?? null, target.segmentIds])
|
|
9
|
+
const fresh = (): TranscriptionCorrection => ({ id: randomUUID(), revision: 0, discarded: [], shared: 'fork' })
|
|
10
|
+
function valid(value: unknown): value is TranscriptionCorrection {
|
|
11
|
+
return isRecord(value) && typeof value.id === 'string' && Number.isSafeInteger(value.revision) && Number(value.revision) >= 0 && Array.isArray(value.discarded) && value.discarded.every(key => typeof key === 'string') && ['fork', 'edit-shared'].includes(String(value.shared))
|
|
12
|
+
&& (value.baseVersion === undefined || typeof value.baseVersion === 'string') && (value.applied === undefined || typeof value.applied === 'boolean')
|
|
13
|
+
&& (value.nodes === undefined || Array.isArray(value.nodes) && value.nodes.every(node => isRecord(node) && (node.type === 'text' && typeof node.text === 'string' || node.type === 'pronunciation' && typeof node.display === 'string' && typeof node.spoken === 'string' || node.type === 'cue' && typeof node.id === 'string' && typeof node.action === 'string')))
|
|
14
|
+
}
|
|
15
|
+
function parseTarget(key: string): TranscriptionCorrectionTarget | undefined {
|
|
16
|
+
try {
|
|
17
|
+
const value: unknown = JSON.parse(key)
|
|
18
|
+
if (!Array.isArray(value) || value.length !== 6) return
|
|
19
|
+
const [identity, id, revision, stepId, narrationId, segmentIds] = value
|
|
20
|
+
if (typeof identity !== 'string' || typeof id !== 'string' || typeof revision !== 'string' || typeof stepId !== 'string' || narrationId !== null && typeof narrationId !== 'string' || !Array.isArray(segmentIds) || !segmentIds.every(id => typeof id === 'string')) return
|
|
21
|
+
return { identity, candidate: { id, revision }, stepId, ...narrationId !== null ? { narrationId } : {}, segmentIds }
|
|
22
|
+
} catch { return }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** The native correction bank uses its existing localStorage keys; no MCP copy or provider result is changed. */
|
|
26
|
+
export class TranscriptionCorrections {
|
|
27
|
+
readonly #entries = new Map<string, Entry>()
|
|
28
|
+
#load(target: TranscriptionCorrectionTarget): Entry {
|
|
29
|
+
const key = transcriptionCorrectionKey(target), known = this.#entries.get(key)
|
|
30
|
+
if (known) return known
|
|
31
|
+
const entry: Entry = { target: structuredClone(target), failed: false, corrupt: false }
|
|
32
|
+
this.#entries.set(key, entry)
|
|
33
|
+
try {
|
|
34
|
+
entry.raw = localStorage.getItem(prefix + key)
|
|
35
|
+
if (entry.raw !== null) {
|
|
36
|
+
const value: unknown = JSON.parse(entry.raw)
|
|
37
|
+
if (!valid(value)) throw new Error('invalid-draft')
|
|
38
|
+
entry.draft = value
|
|
39
|
+
}
|
|
40
|
+
} catch { entry.failed = true; entry.corrupt = entry.raw != null }
|
|
41
|
+
return entry
|
|
42
|
+
}
|
|
43
|
+
read(target: TranscriptionCorrectionTarget): { draft: TranscriptionCorrection, failed: boolean } {
|
|
44
|
+
const entry = this.#load(target)
|
|
45
|
+
// A reopened native form adopts another window's saved value, retaining failed local input.
|
|
46
|
+
try {
|
|
47
|
+
const raw = localStorage.getItem(prefix + transcriptionCorrectionKey(target))
|
|
48
|
+
if (raw !== entry.raw && !(entry.failed && entry.draft)) {
|
|
49
|
+
const value: unknown = raw === null ? undefined : JSON.parse(raw)
|
|
50
|
+
if (value !== undefined && !valid(value)) throw new Error('invalid-draft')
|
|
51
|
+
entry.raw = raw; entry.draft = value as TranscriptionCorrection | undefined; entry.failed = false; entry.corrupt = false
|
|
52
|
+
} else if (raw !== entry.raw) entry.failed = true
|
|
53
|
+
} catch { entry.failed = true }
|
|
54
|
+
return { draft: entry.draft ? structuredClone(entry.draft) : fresh(), failed: entry.failed }
|
|
55
|
+
}
|
|
56
|
+
keep(target: TranscriptionCorrectionTarget, draft: TranscriptionCorrection): boolean {
|
|
57
|
+
if (!valid(draft)) throw new Error('invalid-draft')
|
|
58
|
+
const entry = this.#load(target), key = prefix + transcriptionCorrectionKey(target)
|
|
59
|
+
entry.draft = structuredClone(draft)
|
|
60
|
+
try {
|
|
61
|
+
if (entry.raw === undefined || localStorage.getItem(key) !== entry.raw) throw new Error('changed-draft')
|
|
62
|
+
if (entry.corrupt && entry.raw != null) localStorage.setItem(key + ':unreadable', entry.raw)
|
|
63
|
+
const raw = JSON.stringify(draft)
|
|
64
|
+
localStorage.setItem(key, raw)
|
|
65
|
+
entry.raw = raw; entry.failed = false; entry.corrupt = false
|
|
66
|
+
return true
|
|
67
|
+
} catch { entry.failed = true; return false }
|
|
68
|
+
}
|
|
69
|
+
/** A completed native adoption cannot retire input changed in another form/window while it ran. */
|
|
70
|
+
complete(target: TranscriptionCorrectionTarget, expected: TranscriptionCorrection, next: TranscriptionCorrection): boolean {
|
|
71
|
+
const key = transcriptionCorrectionKey(target), entry = this.#entries.get(key)
|
|
72
|
+
if (!entry || entry.corrupt || JSON.stringify(entry.draft) !== JSON.stringify(expected)) return false
|
|
73
|
+
try {
|
|
74
|
+
if (entry.raw === undefined || localStorage.getItem(prefix + key) !== entry.raw) return false
|
|
75
|
+
const raw = JSON.stringify(next)
|
|
76
|
+
localStorage.setItem(prefix + key, raw)
|
|
77
|
+
entry.raw = raw; entry.draft = structuredClone(next); entry.failed = false
|
|
78
|
+
return true
|
|
79
|
+
} catch { entry.failed = true; return false }
|
|
80
|
+
}
|
|
81
|
+
discard(key: string, expected: TranscriptionCorrection): boolean {
|
|
82
|
+
const entry = this.#entries.get(key)
|
|
83
|
+
if (!entry || entry.corrupt || JSON.stringify(entry.draft) !== JSON.stringify(expected)) return false
|
|
84
|
+
try {
|
|
85
|
+
if (entry.raw === undefined || localStorage.getItem(prefix + key) !== entry.raw) return false
|
|
86
|
+
localStorage.removeItem(prefix + key)
|
|
87
|
+
this.#entries.delete(key)
|
|
88
|
+
return true
|
|
89
|
+
} catch { entry.failed = true; return false }
|
|
90
|
+
}
|
|
91
|
+
snapshot(identity: string) {
|
|
92
|
+
const keys = new Set([...this.#entries].filter(([, entry]) => entry.target.identity === identity).map(([key]) => key))
|
|
93
|
+
let partial = false
|
|
94
|
+
const head = prefix + JSON.stringify([identity]).slice(0, -1) + ','
|
|
95
|
+
try {
|
|
96
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
97
|
+
const key = localStorage.key(i)
|
|
98
|
+
if (key?.startsWith(head) && !key.endsWith(':unreadable')) keys.add(key.slice(prefix.length))
|
|
99
|
+
}
|
|
100
|
+
} catch { partial = true }
|
|
101
|
+
const entries: { key: string, target: TranscriptionCorrectionTarget, draft: TranscriptionCorrection, persisted: boolean }[] = [], observed: [string, string | null][] = []
|
|
102
|
+
for (const key of keys) {
|
|
103
|
+
const target = parseTarget(key)
|
|
104
|
+
if (!target || target.identity !== identity) { partial = true; continue }
|
|
105
|
+
const entry = this.#load(target)
|
|
106
|
+
let persisted = false
|
|
107
|
+
try {
|
|
108
|
+
const raw = localStorage.getItem(prefix + key)
|
|
109
|
+
observed.push([key, raw])
|
|
110
|
+
persisted = !entry.failed && !entry.corrupt && raw === entry.raw
|
|
111
|
+
if (raw !== entry.raw) partial = true
|
|
112
|
+
} catch { partial = true }
|
|
113
|
+
if (entry.corrupt || entry.raw === undefined) partial = true
|
|
114
|
+
if (entry.draft && !entry.draft.applied) entries.push({ key, target: structuredClone(target), draft: structuredClone(entry.draft), persisted })
|
|
115
|
+
}
|
|
116
|
+
return { entries, partial, guard: () => {
|
|
117
|
+
for (const [key, raw] of observed) {
|
|
118
|
+
try { if (localStorage.getItem(prefix + key) === raw) continue } catch { /* Cannot verify the same persisted input. */ }
|
|
119
|
+
throw new Error('client-production-drafts-changed')
|
|
120
|
+
}
|
|
121
|
+
} }
|
|
122
|
+
}
|
|
123
|
+
close(): void { this.#entries.clear() }
|
|
124
|
+
}
|
|
@@ -58,13 +58,13 @@ export function useRecordingAdoption({ identity, sectionId, stepId, active, disa
|
|
|
58
58
|
if (!owns()) return
|
|
59
59
|
const source = workbench.getState().authoring
|
|
60
60
|
if (!source?.version || !source.fingerprint || !source.content || source.identity !== identity || source.dirty || source.saving || source.composing || source.restored || source.error) throw new Error('production-source-changed')
|
|
61
|
-
const expected = { identity, version: source.version }, inspection = await workbench.
|
|
61
|
+
const expected = { identity, version: source.version }, inspection = await workbench.production.inspectAudio(target.assetId, expected, controller.signal)
|
|
62
62
|
if (!owns()) return
|
|
63
63
|
const canonical = { documentId: source.content.id, version: source.version, fingerprint: source.fingerprint }, previous = retry.current
|
|
64
64
|
sent = previous && previous.source.documentId === canonical.documentId && previous.source.version === canonical.version && previous.source.fingerprint === canonical.fingerprint && previous.stepId === target.stepId && previous.assetId === target.assetId && previous.sha256 === inspection.inspection.sha256
|
|
65
65
|
? previous : { id: requestId(), source: canonical, stepId: target.stepId, assetId: target.assetId, sha256: inspection.inspection.sha256 }
|
|
66
66
|
retry.current = sent; submitted.current = sent
|
|
67
|
-
await workbench.
|
|
67
|
+
await workbench.production.adoptRecording(sent, expected, controller.signal)
|
|
68
68
|
if (!owns()) return
|
|
69
69
|
if (retry.current === sent) retry.current = undefined
|
|
70
70
|
setFailure(undefined)
|
package/src/voice-drafts.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { WorkspaceClient } from './workspace-client.ts'
|
|
|
5
5
|
|
|
6
6
|
export interface VoiceDraft { version: string, scope: DocumentVoiceScope, source: VoiceSource | null, replaceOverrides: boolean, rateInput?: string }
|
|
7
7
|
export type VoiceDraftStorageStatus = 'available' | 'unavailable' | 'corrupt'
|
|
8
|
-
interface StoredDraft { draft?: VoiceDraft, status: VoiceDraftStorageStatus, unreadable?: string }
|
|
8
|
+
interface StoredDraft { draft?: VoiceDraft, status: VoiceDraftStorageStatus, unreadable?: string, raw?: string | null }
|
|
9
9
|
const drafts = new WeakMap<WorkspaceClient, Map<string, StoredDraft>>()
|
|
10
10
|
const keyOf = (identity: string, stepId: string) => JSON.stringify([identity, stepId])
|
|
11
11
|
const storageKey = (key: string) => `presmium.voice-draft.v2:${key}`
|
|
@@ -36,6 +36,7 @@ function load(client: WorkspaceClient, key: string): StoredDraft {
|
|
|
36
36
|
known.set(key, entry)
|
|
37
37
|
try {
|
|
38
38
|
const raw = sessionStorage.getItem(storageKey(key))
|
|
39
|
+
entry.raw = raw
|
|
39
40
|
if (raw !== null) {
|
|
40
41
|
entry.unreadable = raw
|
|
41
42
|
const value: unknown = JSON.parse(raw)
|
|
@@ -64,7 +65,9 @@ export function keepVoiceDraft(client: WorkspaceClient, identity: string, stepId
|
|
|
64
65
|
entry.draft = structuredClone(value)
|
|
65
66
|
try {
|
|
66
67
|
if (entry.unreadable !== undefined) sessionStorage.setItem(`${storageKey(key)}:unreadable`, entry.unreadable)
|
|
67
|
-
|
|
68
|
+
const raw = JSON.stringify(entry.draft)
|
|
69
|
+
sessionStorage.setItem(storageKey(key), raw)
|
|
70
|
+
entry.raw = raw
|
|
68
71
|
entry.status = 'available'; delete entry.unreadable
|
|
69
72
|
return true
|
|
70
73
|
} catch { entry.status = 'unavailable'; return false }
|
|
@@ -76,14 +79,35 @@ export function clearVoiceDraft(client: WorkspaceClient, identity: string, stepI
|
|
|
76
79
|
if (expected && JSON.stringify(entry.draft) !== JSON.stringify(expected)) return false
|
|
77
80
|
try {
|
|
78
81
|
const raw = sessionStorage.getItem(storageKey(key))
|
|
79
|
-
if (expected && raw !==
|
|
80
|
-
let persisted: unknown
|
|
81
|
-
try { persisted = JSON.parse(raw) } catch { entry.status = 'corrupt'; entry.unreadable = raw; return false }
|
|
82
|
-
if (!valid(persisted)) { entry.status = 'corrupt'; entry.unreadable = raw; return false }
|
|
83
|
-
if (JSON.stringify(persisted) !== JSON.stringify(expected)) return false
|
|
84
|
-
}
|
|
82
|
+
if (expected && (entry.unreadable !== undefined || raw !== entry.raw)) return false
|
|
85
83
|
sessionStorage.removeItem(storageKey(key))
|
|
84
|
+
entry.raw = null
|
|
86
85
|
delete entry.draft; delete entry.unreadable; entry.status = 'available'
|
|
87
86
|
return true
|
|
88
87
|
} catch { entry.status = 'unavailable'; return false }
|
|
89
88
|
}
|
|
89
|
+
|
|
90
|
+
/** Enumerate this native bank, including offscreen forms; callers receive no second persisted copy. */
|
|
91
|
+
export function voiceDraftSnapshot(client: WorkspaceClient, identity: string): { entries: { stepId: string, value: VoiceDraft, persisted: boolean }[], partial: boolean } {
|
|
92
|
+
const keys = new Set([...store(client).keys()].filter(key => key.startsWith(`${JSON.stringify([identity]).slice(0, -1)},`)))
|
|
93
|
+
let partial = false
|
|
94
|
+
try {
|
|
95
|
+
const prefix = `presmium.voice-draft.v2:${JSON.stringify([identity]).slice(0, -1)},`
|
|
96
|
+
for (let index = 0; index < sessionStorage.length; index++) {
|
|
97
|
+
const key = sessionStorage.key(index)
|
|
98
|
+
if (key?.startsWith(prefix) && !key.endsWith(':unreadable')) keys.add(key.slice('presmium.voice-draft.v2:'.length))
|
|
99
|
+
}
|
|
100
|
+
} catch { partial = true }
|
|
101
|
+
const entries: { stepId: string, value: VoiceDraft, persisted: boolean }[] = []
|
|
102
|
+
for (const key of keys) {
|
|
103
|
+
let target: unknown
|
|
104
|
+
try { target = JSON.parse(key) } catch { partial = true; continue }
|
|
105
|
+
if (!Array.isArray(target) || target.length !== 2 || target[0] !== identity || typeof target[1] !== 'string') { partial = true; continue }
|
|
106
|
+
const entry = load(client, key)
|
|
107
|
+
let persisted = false
|
|
108
|
+
try { const raw = sessionStorage.getItem(storageKey(key)); persisted = entry.status === 'available' && raw === entry.raw; if (raw !== entry.raw) partial = true } catch { partial = true }
|
|
109
|
+
if (entry.status === 'corrupt' || entry.raw === undefined) partial = true
|
|
110
|
+
if (entry.draft) entries.push({ stepId: target[1], value: structuredClone(entry.draft), persisted })
|
|
111
|
+
}
|
|
112
|
+
return { entries, partial }
|
|
113
|
+
}
|
package/src/voiceover-jobs.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { errorMessage } from '@lincyaw/kernel'
|
|
2
2
|
import type { VoiceoverJob } from '@lincyaw/kernel'
|
|
3
|
-
import type { WorkbenchStore } from './workbench.ts'
|
|
3
|
+
import type { WorkbenchStore } from './workbench-state.ts'
|
|
4
4
|
import type { WorkspaceClient } from './workspace-client.ts'
|
|
5
5
|
|
|
6
6
|
const active = (job: VoiceoverJob) => ['queued', 'running', 'cancelling'].includes(job.state)
|