@lincyaw/workbench 0.2.0-rc.3 → 0.2.0-rc.31

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 (57) hide show
  1. package/package.json +5 -4
  2. package/src/MediaClipEditor.tsx +1 -1
  3. package/src/authoring-client.ts +3 -3
  4. package/src/authoring-draft-fragment.ts +3 -1
  5. package/src/component-property-drafts.ts +5 -5
  6. package/src/components.tsx +10 -28
  7. package/src/document-drafts.ts +6 -7
  8. package/src/document-editor/BlockNoteSurface.tsx +25 -9
  9. package/src/document-editor/ComponentMaterials.tsx +3 -9
  10. package/src/document-editor/ComponentPropertiesDialog.tsx +3 -3
  11. package/src/document-editor/DocumentBlockPreview.tsx +2 -0
  12. package/src/document-editor/DocumentComments.tsx +58 -9
  13. package/src/document-editor/DocumentEditor.tsx +44 -7
  14. package/src/document-editor/DocumentStepNarration.tsx +24 -19
  15. package/src/document-editor/NarrationEditor.tsx +54 -20
  16. package/src/document-editor/NewCommentDrafts.tsx +4 -3
  17. package/src/document-editor/PlaceComment.tsx +150 -0
  18. package/src/document-editor/comment-drafts.ts +16 -14
  19. package/src/document-editor/comments.ts +30 -10
  20. package/src/document-editor/component-label.ts +11 -0
  21. package/src/document-editor/file-input.ts +2 -2
  22. package/src/document-editor/focus.ts +0 -2
  23. package/src/document-editor/insertion-place.ts +60 -0
  24. package/src/document-editor/messages.ts +3 -3
  25. package/src/document-editor/narration-schema.tsx +12 -6
  26. package/src/document-editor/narration.ts +19 -3
  27. package/src/document-editor/page-body.ts +60 -0
  28. package/src/document-editor/projection.ts +2 -2
  29. package/src/document-editor/rich-text.ts +3 -2
  30. package/src/document-editor/selection.ts +13 -0
  31. package/src/document-editor/style.css +12 -1
  32. package/src/document-editor/table-identities.ts +2 -1
  33. package/src/document-session.ts +50 -16
  34. package/src/history.ts +2 -2
  35. package/src/index.ts +0 -3
  36. package/src/messages.ts +19 -4
  37. package/src/panels/DocumentView.tsx +10 -10
  38. package/src/panels/ExportPanel.tsx +1 -6
  39. package/src/panels/PreviewPanel.tsx +1 -4
  40. package/src/panels/ProductionCaptionSize.tsx +20 -0
  41. package/src/panels/ProductionCaptionTiming.tsx +3 -3
  42. package/src/panels/ProductionMediaClips.tsx +2 -1
  43. package/src/panels/ProductionPanel.tsx +5 -1
  44. package/src/panels/ProductionRecordingRange.tsx +2 -2
  45. package/src/panels/ProductionTimeline.tsx +6 -1
  46. package/src/panels/ProductionTranscription.tsx +2 -1
  47. package/src/panels/SourceDocumentPanel.tsx +3 -6
  48. package/src/panels/TranscriptionAdoption.tsx +7 -6
  49. package/src/places.ts +1 -36
  50. package/src/production-messages.ts +6 -0
  51. package/src/sha256.ts +9 -0
  52. package/src/styles.css +16 -41
  53. package/src/workbench.ts +124 -88
  54. package/src/workspace-client.ts +2 -1
  55. package/src/assistant-mascot.ts +0 -62
  56. package/src/mascot-preference.ts +0 -37
  57. package/src/panels/ChangeTrail.tsx +0 -79
@@ -1,8 +1,9 @@
1
- import { hasRole, validateDocument } from '@lincyaw/kernel'
1
+ import { hasRole, isRecord, randomUUID, validateDocument } from '@lincyaw/kernel'
2
2
  import type { DocumentAnswer, DocumentChangeAnswer, DocumentImageImportAnswer, DocumentIssue, Member, TeachingDocument } from '@lincyaw/kernel'
3
3
  import { WorkspaceServerError } from './workspace-client.ts'
4
4
  import type { WorkspaceClient } from './workspace-client.ts'
5
5
  import { DocumentDrafts } from './document-drafts.ts'
6
+ import { sha256 } from './sha256.ts'
6
7
  import type { DocumentDraftChoice, DocumentDraftCommit, DocumentDraftReference, StoredDocumentDraft } from './document-drafts.ts'
7
8
 
8
9
  export interface DocumentSessionState {
@@ -34,6 +35,7 @@ interface Slot {
34
35
  compositions: Set<string>
35
36
  input: number
36
37
  baseHash: string
38
+ baseContent: TeachingDocument
37
39
  storage: string
38
40
  drafts: DocumentDrafts
39
41
  backup?: DocumentDraftCommit
@@ -88,10 +90,21 @@ function keepsEditorContent(before: TeachingDocument, after: TeachingDocument):
88
90
  }
89
91
 
90
92
  async function digest(value: TeachingDocument): Promise<string> {
91
- const text = serialize(value)
92
- if (!globalThis.crypto?.subtle) return `json:${text}`
93
- const bytes = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text))
94
- return [...new Uint8Array(bytes)].map(value => value.toString(16).padStart(2, '0')).join('')
93
+ return sha256(serialize(value))
94
+ }
95
+
96
+ /** Replay pending author input on a newer saved document; an overlapping value belongs to the author. */
97
+ function rebaseDocument(base: TeachingDocument, local: TeachingDocument, remote: TeachingDocument): TeachingDocument {
98
+ const merge = (before: unknown, author: unknown, saved: unknown): unknown => {
99
+ if (serialize(author) === serialize(before)) return structuredClone(saved)
100
+ if (serialize(saved) === serialize(before) || serialize(author) === serialize(saved)) return structuredClone(author)
101
+ if (isRecord(before) && isRecord(author) && isRecord(saved)) return Object.fromEntries([...new Set([...Object.keys(before), ...Object.keys(author), ...Object.keys(saved)])]
102
+ .map(key => [key, merge(before[key], author[key], saved[key])] as const).filter(([, value]) => value !== undefined))
103
+ return structuredClone(author)
104
+ }
105
+ const merged = validateDocument(merge(base, local, remote))
106
+ // A structural conflict is one document operation: preserve the author's valid complete document.
107
+ return merged.document && !merged.issues.some(issue => issue.severity === 'error') ? merged.document : structuredClone(local)
95
108
  }
96
109
 
97
110
  /** One source actor per document. Runtime compilation and iframe lifecycle never own its input. */
@@ -142,7 +155,7 @@ export class DocumentSession {
142
155
  const baseHash = await digest(answer.content)
143
156
  if (this.#disposed || this.#active !== directory || opening !== this.#opening) return
144
157
  const drafts = new DocumentDrafts(() => { if (slot && !this.#disposed) void this.#readDrafts(slot) })
145
- slot = { input: 0, read: 0, compositions: new Set(), drafts, baseHash, storage: `presmium.document.v1:${JSON.stringify([info.root, answer.content.id])}`, state: { directory, member: info.member, identity: JSON.stringify([info.root, answer.content.id]), content: answer.content, version: answer.version, fingerprint: answer.fingerprint, loading: true, dirty: false, saving: false, restored: false, composing: false, storageFailure: false, reset: 0, issues: answer.issues } }
158
+ slot = { input: 0, read: 0, compositions: new Set(), drafts, baseHash, baseContent: structuredClone(answer.content), storage: `presmium.document.v1:${JSON.stringify([info.root, answer.content.id])}`, state: { directory, member: info.member, identity: JSON.stringify([info.root, answer.content.id]), content: answer.content, version: answer.version, fingerprint: answer.fingerprint, loading: true, dirty: false, saving: false, restored: false, composing: false, storageFailure: false, reset: 0, issues: answer.issues } }
146
159
  this.#slots.set(directory, slot)
147
160
  await this.#restore(slot, answer)
148
161
  } else {
@@ -235,11 +248,19 @@ export class DocumentSession {
235
248
  slot.baseHash = remoteHash; slot.pendingHash = undefined
236
249
  slot.state = { ...slot.state, version: answer.version, fingerprint: answer.fingerprint, error: undefined, issues: answer.issues }
237
250
  } else if (remoteHash === slot.baseHash) slot.state = { ...slot.state, version: answer.version, fingerprint: answer.fingerprint, issues: answer.issues }
238
- else slot.state = { ...slot.state, error: 'document-version-changed', issues: answer.issues }
251
+ else if (!slot.state.composing) {
252
+ const content = rebaseDocument(slot.baseContent, slot.state.content!, answer.content)
253
+ const reset = slot.state.reset + (keepsEditorContent(slot.state.content!, content) ? 0 : 1)
254
+ slot.baseHash = remoteHash
255
+ slot.pendingHash = undefined
256
+ slot.state = { ...slot.state, content, reset, version: answer.version, fingerprint: answer.fingerprint, error: undefined, dirty: true, issues: answer.issues }
257
+ }
258
+ if (slot.state.version === answer.version) slot.baseContent = structuredClone(answer.content)
239
259
  return
240
260
  }
241
261
  const reset = slot.state.reset + (keepsEditorContent(slot.state.content!, answer.content) ? 0 : 1)
242
262
  slot.baseHash = remoteHash
263
+ slot.baseContent = structuredClone(answer.content)
243
264
  slot.state = { ...slot.state, version: answer.version, fingerprint: answer.fingerprint, content: answer.content, reset, error: undefined, issues: answer.issues }
244
265
  }
245
266
 
@@ -288,7 +309,7 @@ export class DocumentSession {
288
309
  else if (slot.timer !== undefined) return
289
310
  if (this.#readOnly(slot) || slot.flight || slot.assetFlight || !slot.state.dirty || slot.state.composing || slot.state.restored || slot.state.error || !slot.state.content || !slot.state.version) return
290
311
  slot.read++
291
- const flight = { id: crypto.randomUUID(), input: slot.input, content: structuredClone(slot.state.content), baseVersion: slot.state.version, hash: undefined as string | undefined }
312
+ const flight = { id: randomUUID(), input: slot.input, content: structuredClone(slot.state.content), baseVersion: slot.state.version, hash: undefined as string | undefined }
292
313
  slot.flight = flight
293
314
  slot.state = { ...slot.state, saving: true }; this.#emit(slot)
294
315
  try {
@@ -299,7 +320,12 @@ export class DocumentSession {
299
320
  if (answer.changeId !== flight.id || answer.document !== slot.state.directory || answer.content.id !== flight.content.id) throw new Error('document-confirmation')
300
321
  this.#ack(slot, flight, answer)
301
322
  } catch (error) {
302
- slot.state = { ...slot.state, saving: false, error: this.#error(error), issues: this.#issues(error) }
323
+ if (this.#error(error) === 'document-version-changed' && !slot.state.composing) {
324
+ try {
325
+ await this.#adopt(slot, await this.#client.readDocument(slot.state.directory))
326
+ slot.state = { ...slot.state, saving: false }
327
+ } catch (refreshError) { slot.state = { ...slot.state, saving: false, error: this.#error(refreshError), issues: this.#issues(refreshError) } }
328
+ } else slot.state = { ...slot.state, saving: false, error: this.#error(error), issues: this.#issues(error) }
303
329
  } finally {
304
330
  if (slot.flight === flight) slot.flight = undefined
305
331
  this.#persist(slot); this.#emit(slot)
@@ -310,6 +336,7 @@ export class DocumentSession {
310
336
  }
311
337
  #ack(slot: Slot, flight: NonNullable<Slot['flight']>, answer: DocumentChangeAnswer): void {
312
338
  slot.baseHash = flight.hash!
339
+ slot.baseContent = structuredClone(answer.content)
313
340
  slot.pendingHash = undefined
314
341
  const same = slot.input === flight.input
315
342
  slot.state = { ...slot.state, version: answer.version, fingerprint: answer.fingerprint, ...(same ? { content: answer.content } : {}), dirty: !same, saving: false, error: undefined, issues: answer.issues }
@@ -328,6 +355,7 @@ export class DocumentSession {
328
355
  const same = slot.input === input, content = same ? answer.content : structuredClone(current)
329
356
  if (!same) for (const [id, asset] of added) content.assets[id] = structuredClone(asset)
330
357
  slot.baseHash = baseHash
358
+ slot.baseContent = structuredClone(answer.content)
331
359
  slot.state = { ...slot.state, content, version: answer.version, fingerprint: answer.fingerprint, dirty: !same, error: undefined, issues: answer.issues }
332
360
  return true
333
361
  }
@@ -342,6 +370,7 @@ export class DocumentSession {
342
370
  const checked = validateDocument(content)
343
371
  if (!checked.document || checked.issues.some(issue => issue.severity === 'error')) return false
344
372
  slot.baseHash = baseHash
373
+ slot.baseContent = structuredClone(answer.content)
345
374
  slot.pendingHash = undefined
346
375
  slot.state = { ...slot.state, content: structuredClone(checked.document), version: answer.version, fingerprint: answer.fingerprint,
347
376
  dirty: slot.input !== input || slot.state.composing || serialize(content) !== serialize(answer.content), error: undefined, issues: answer.issues }
@@ -406,7 +435,7 @@ export class DocumentSession {
406
435
  const before = structuredClone(slot.state.content), input = slot.input, version = slot.state.version
407
436
  let request = this.#imageImports.get(file)
408
437
  if (!request || request.identity !== identity || request.version !== version) {
409
- request = { identity, version, id: crypto.randomUUID() }
438
+ request = { identity, version, id: randomUUID() }
410
439
  this.#imageImports.set(file, request)
411
440
  }
412
441
  const read = ++slot.read
@@ -609,7 +638,12 @@ export class DocumentSession {
609
638
  const answer = await this.#client.readDocument(slot.state.directory)
610
639
  if (!current()) return
611
640
  if (answer.document !== slot.state.directory || answer.content.id !== documentId) { slot.state = { ...slot.state, error: 'document-identity-changed' }; return }
612
- const [localHash, remoteHash] = await Promise.all([digest(candidate.content), digest(answer.content)])
641
+ // Older LAN HTTP drafts stored canonical JSON in place of a SHA-256 fingerprint.
642
+ const [localHash, remoteHash, candidateBaseHash, pendingHash] = await Promise.all([
643
+ digest(candidate.content), digest(answer.content),
644
+ candidate.baseHash.startsWith('json:') ? sha256(candidate.baseHash.slice(5)) : candidate.baseHash,
645
+ candidate.pendingHash?.startsWith('json:') ? sha256(candidate.pendingHash.slice(5)) : candidate.pendingHash,
646
+ ])
613
647
  if (!current()) return
614
648
  const origins = [...new Map([...(candidate.origins ?? []), { id: candidate.id, revision: candidate.revision, token: candidate.token }].map(value => [JSON.stringify([value.id, value.revision, value.token]), value])).values()]
615
649
  if (localHash === remoteHash && !candidate.composing) {
@@ -618,16 +652,16 @@ export class DocumentSession {
618
652
  slot.persistFailure = !settled
619
653
  return
620
654
  }
621
- const conflict = answer.version !== candidate.baseVersion && remoteHash !== candidate.baseHash && remoteHash !== candidate.pendingHash
622
- const version = remoteHash === candidate.pendingHash || remoteHash === candidate.baseHash ? answer.version : candidate.baseVersion
623
- const baseHash = remoteHash === candidate.pendingHash ? remoteHash : candidate.baseHash
655
+ const conflict = answer.version !== candidate.baseVersion && remoteHash !== candidateBaseHash && remoteHash !== pendingHash
656
+ const version = remoteHash === pendingHash || remoteHash === candidateBaseHash ? answer.version : candidate.baseVersion
657
+ const baseHash = remoteHash === pendingHash ? remoteHash : candidateBaseHash
624
658
  const record = await slot.drafts.fork(identity, { content: candidate.content, baseVersion: version, baseHash, input: input + 1,
625
- pendingHash: candidate.pendingHash, composing: Boolean(candidate.composing), origins })
659
+ pendingHash, composing: Boolean(candidate.composing), origins })
626
660
  if (!current()) { if (record) slot.drafts.archive(record); return }
627
661
  if (!record) { slot.persistFailure = true; slot.state = { ...slot.state, storageFailure: true }; return }
628
662
  clearTimeout(slot.timer); slot.timer = undefined
629
663
  if (slot.draft) slot.drafts.archive(slot.draft)
630
- slot.input = input + 1; slot.baseHash = baseHash; slot.pendingHash = candidate.pendingHash; slot.draft = record; slot.draftOrigins = origins
664
+ slot.input = input + 1; slot.baseHash = baseHash; slot.pendingHash = pendingHash; slot.draft = record; slot.draftOrigins = origins
631
665
  slot.backup = undefined; slot.persistFailure = false
632
666
  adopted = true
633
667
  slot.compositions.clear()
package/src/history.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { errorMessage } from '@lincyaw/kernel'
1
+ import { errorMessage, randomUUID } from '@lincyaw/kernel'
2
2
  import type { RevertResult, ReviewChange, ReviewSnapshot, ReviewUpdate } from '@lincyaw/kernel'
3
3
  import type { WorkbenchStore } from './workbench.ts'
4
4
  import { WorkspaceServerError } from './workspace-client.ts'
@@ -129,7 +129,7 @@ export class DocumentHistory {
129
129
  #change(which: 'undo' | 'redo' | 'revertRevision', expect: string | undefined): Promise<boolean> {
130
130
  const binding = this.#store.state.history?.historyBinding
131
131
  if (!binding || !expect) return Promise.resolve(false)
132
- const request = { id: crypto.randomUUID(), ...binding, expect }
132
+ const request = { id: randomUUID(), ...binding, expect }
133
133
  return this.#run(dir => this.#client[which](dir, request))
134
134
  }
135
135
 
package/src/index.ts CHANGED
@@ -26,9 +26,6 @@ export { HistoryPanel } from './panels/HistoryPanel.tsx'
26
26
  export type { HistoryPanelProps, HistoryRevisionAction } from './panels/HistoryPanel.tsx'
27
27
  export { HomePanel } from './panels/HomePanel.tsx'
28
28
  export { WorkbenchApprovals } from './approvals.tsx'
29
- export { assistantMascotAction, useAssistantMascot } from './assistant-mascot.ts'
30
- export type { AssistantActivity } from './assistant-mascot.ts'
31
- export { mascotEnabled, setMascotEnabled, useMascotEnabled } from './mascot-preference.ts'
32
29
  export { PreviewPanel } from './panels/PreviewPanel.tsx'
33
30
  export { SpeechSettingsPanel } from './panels/SpeechSettingsPanel.tsx'
34
31
  export { SPEECH_SETTINGS_MESSAGES } from './speech-settings-messages.ts'
package/src/messages.ts CHANGED
@@ -12,6 +12,11 @@ export interface AgentPlace {
12
12
 
13
13
  // A Latin word or a number set after Chinese text is spaced from it (docs/glossary.md 2).
14
14
  const spaced = (text: string) => (/^[A-Za-z0-9]/.test(text) ? ` ${text}` : text)
15
+ // The start of a passage, enough to recognize it.
16
+ const excerpt = (text: string, length: number) => [...text].length > length ? `${[...text].slice(0, length).join('').trimEnd()}…` : text
17
+
18
+ /** Where on a page the author asks for new content: after a passage (its text, '' for content without text), at the start (none) or at the end. */
19
+ interface AgentInsertion { after?: string, end: boolean }
15
20
 
16
21
  // Names of commands follow Microsoft Word's (撤消/Undo, 新建批注/New Comment, 版本历史/Version History…).
17
22
  const zh = {
@@ -325,11 +330,11 @@ const zh = {
325
330
  'history-result-no-longer-current': '之前的结果已不是当前版本,请查看最新的历史。',
326
331
  'authoring-review-required': '有修改等待你审阅,请先接受或放弃。',
327
332
  } as Record<string, string>,
328
- agentWorking: 'AI 正在修改文稿…',
329
333
  agentWaiting: (n: number) => `AI 修改了 ${n} 处内容,要接受这些修改吗?`,
330
334
  accept: '接受',
331
335
  reject: '拒绝',
332
- problems: (n: number) => `有 ${n} 处内容无法正确显示。`,
336
+ problems: (n: number) => `文稿有 ${n} 个问题需要处理。`,
337
+ problemsTitle: '文稿中的问题',
333
338
  fixWithAi: '用 AI 修复',
334
339
  fixing: '正在发送给 AI…',
335
340
  fixFailed: (reason: string) => `无法发送给 AI。${reason}`,
@@ -356,6 +361,11 @@ const zh = {
356
361
  place.quote ? `\n原文:“${place.quote}”` : '',
357
362
  ].join('')).filter(Boolean),
358
363
  ].join('\n\n'),
364
+ animationRequest: (page: number, title: string, place: AgentInsertion) => {
365
+ const at = `第 ${page} 页${title ? `“${title}”` : ''}`
366
+ return place.end ? `在${at}的末尾加一个动画:` : place.after === undefined ? `在${at}的开头加一个动画:`
367
+ : place.after ? `在${at}中“${excerpt(place.after, 16)}”这一段之后加一个动画:` : `在${at}的这个位置加一个动画:`
368
+ },
359
369
  commentsRequest: (comments: (AgentPlace & { text: string })[]) => [
360
370
  comments.length === 1 ? '我在文稿上写了一条批注:' : `我在文稿上写了 ${comments.length} 条批注:`,
361
371
  ...comments.map((comment, i) => [
@@ -689,11 +699,11 @@ const en: WorkbenchMessages = {
689
699
  'history-result-no-longer-current': 'The earlier result is no longer the current version. Review the latest history.',
690
700
  'authoring-review-required': 'Changes are waiting for your review. Accept or discard them first.',
691
701
  },
692
- agentWorking: 'The AI is editing the document…',
693
702
  agentWaiting: (n: number) => `The AI changed ${n} file${n === 1 ? '' : 's'}. Accept the changes?`,
694
703
  accept: 'Accept',
695
704
  reject: 'Reject',
696
- problems: (n: number) => `${n} item${n === 1 ? '' : 's'} can’t be displayed correctly.`,
705
+ problems: (n: number) => `The document has ${n} problem${n === 1 ? '' : 's'} to fix.`,
706
+ problemsTitle: 'Problems in the Document',
697
707
  fixWithAi: 'Fix with AI',
698
708
  fixing: 'Sending to the AI…',
699
709
  fixFailed: (reason: string) => `Couldn’t send to the AI. ${reason}`,
@@ -720,6 +730,11 @@ const en: WorkbenchMessages = {
720
730
  place.quote ? `\nText: “${place.quote}”` : '',
721
731
  ].join('')).filter(Boolean),
722
732
  ].join('\n\n'),
733
+ animationRequest: (page: number, title: string, place: AgentInsertion) => {
734
+ const at = `page ${page}${title ? `, “${title}”` : ''}`
735
+ return place.end ? `Add an animation at the end of ${at}: ` : place.after === undefined ? `Add an animation at the start of ${at}: `
736
+ : place.after ? `Add an animation on ${at}, after the paragraph “${excerpt(place.after, 40)}”: ` : `Add an animation at this point on ${at}: `
737
+ },
723
738
  commentsRequest: (comments: (AgentPlace & { text: string })[]) => [
724
739
  comments.length === 1 ? 'I left a comment on the document:' : `I left ${comments.length} comments on the document:`,
725
740
  ...comments.map((comment, i) => [
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'
2
2
  import type { ReactNode, RefObject } from 'react'
3
- import { PmButton, PmIconButton, PmMascot, PmMenu, PmNotice, PmSkeleton, PmSortableList, PmToolbar, PmToolbarButton } from '../components.tsx'
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'
@@ -198,7 +198,7 @@ export function DocumentView({ active = true, framed = false, onBack, actions, h
198
198
  <DocumentNotices />
199
199
  <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
200
  {!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>
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)} 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
202
  {!presenting && !producing && !reading && aside && (
203
203
  <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
204
  {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} />}
@@ -409,10 +409,8 @@ function DocumentNotices() {
409
409
  const askFailure = useWorkbenchState(state => (state.pointer ? undefined : state.askFailure))
410
410
  return (
411
411
  <div className="pmw-notices">
412
- {review?.running && <PmNotice tone="accent"><PmMascot size="small" action={review.changes.length > 0 ? 'write' : 'read'} />{t.agentWorking}</PmNotice>}
413
412
  {review && !review.running && review.changes.length > 0 && (
414
413
  <PmNotice tone="accent">
415
- <PmMascot size="small" action="ask" />
416
414
  <span>{t.agentWaiting(review.changes.length)}</span>
417
415
  <span className="pmw-notice__actions">
418
416
  <PmButton small onClick={() => void workbench.rejectReview()}>{t.reject}</PmButton>
@@ -431,7 +429,7 @@ function DocumentNotices() {
431
429
  )
432
430
  }
433
431
 
434
- /** Content that did not display, said plainly, with the AI to fix it and the details for whoever wants them. */
432
+ /** The document's problems in one line above the page, with the AI to fix them; the list itself opens in a dialog. */
435
433
  function ProblemsNotice() {
436
434
  const t = useMessages()
437
435
  const workbench = useWorkbench()
@@ -440,23 +438,25 @@ function ProblemsNotice() {
440
438
  const canRepair = useWorkbenchState(state => state.canRepairDiagnostics)
441
439
  const repairing = useWorkbenchState(state => state.isRepairingDiagnostics)
442
440
  const repairFailure = useWorkbenchState(state => state.diagnosticsRepairFailure)
441
+ const [open, setOpen] = useState(false)
443
442
  if (workbench.client.capabilities?.diagnostics === 'none') return null
444
443
  const problems = (snapshot?.diagnostics ?? []).filter(diagnostic => diagnostic.severity === 'error' && !diagnostic.checkId.startsWith('presmium.workbench.'))
445
444
  if (unavailable) return <PmNotice tone="warn"><span>{t.diagnosticsUnavailable}</span><PmButton small onClick={() => workbench.retryDiagnostics()}>{t.retry}</PmButton></PmNotice>
446
445
  if (problems.length === 0) return repairFailure ? <PmNotice tone="danger">{t.fixFailed(failureReason(t, repairFailure))}</PmNotice> : null
446
+ const repair = canRepair && <PmButton small variant="accent" icon="sparkle" disabled={repairing} onClick={() => void workbench.requestRepairDiagnostics()}>{repairing ? t.fixing : t.fixWithAi}</PmButton>
447
447
  return (
448
448
  <PmNotice tone="warn">
449
449
  <div className="pmw-problems">
450
450
  <div className="pmw-problems__summary">
451
451
  <span>{t.problems(problems.length)}</span>
452
- {canRepair && <PmButton small variant="accent" icon="sparkle" disabled={repairing} onClick={() => void workbench.requestRepairDiagnostics()}>{repairing ? t.fixing : t.fixWithAi}</PmButton>}
452
+ <PmButton small variant="ghost" onClick={() => setOpen(true)}>{t.details}</PmButton>
453
+ {repair}
453
454
  </div>
454
455
  {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
456
  </div>
457
+ <PmDialog open={open} label={t.problemsTitle} closeLabel={t.close} actions={repair || undefined} onClose={() => setOpen(false)}>
458
+ <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>
459
+ </PmDialog>
460
460
  </PmNotice>
461
461
  )
462
462
  }
@@ -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, PmMascot, PmNotice } from '../components.tsx'
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>
@@ -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.setDocumentCaptionScale(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
@@ -72,7 +72,7 @@ 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.applyDocumentCaptionTiming(action, crypto.randomUUID(), expected, controller.signal)
75
+ const answer = await workbench.applyDocumentCaptionTiming(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
@@ -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_${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}`
@@ -12,6 +12,7 @@ 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'
@@ -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>
@@ -1,5 +1,5 @@
1
1
  import { useEffect, useId, useRef, useState } from 'react'
2
- import { recordingSourceRange } from '@lincyaw/kernel'
2
+ import { randomUUID, recordingSourceRange } from '@lincyaw/kernel'
3
3
  import type { DocumentRecordingAdoption, ProductionAssetInspection, TimeRange, VoiceSource } from '@lincyaw/kernel'
4
4
  import { PmButton, PmInput, PmNotice } from '../components.tsx'
5
5
  import { useWorkbench, useWorkbenchState } from '../context.tsx'
@@ -81,7 +81,7 @@ export function ProductionRecordingRange({ identity, sectionId, stepId, active,
81
81
  const controller = new AbortController(), proposed = { startMs: start!, endMs: end! }
82
82
  const previous = sent.current?.request
83
83
  const change: DocumentRecordingAdoption = previous && previous.source.version === source.version && previous.stepId === stepId && previous.assetId === voice.assetId && previous.sha256 === inspected.sha256 && same(previous.sourceRange, proposed)
84
- ? previous : { id: crypto.randomUUID(), source: { documentId: source.content.id, version: source.version, fingerprint: source.fingerprint }, stepId, assetId: voice.assetId, sha256: inspected.sha256, sourceRange: proposed }
84
+ ? previous : { id: randomUUID(), source: { documentId: source.content.id, version: source.version, fingerprint: source.fingerprint }, stepId, assetId: voice.assetId, sha256: inspected.sha256, sourceRange: proposed }
85
85
  const stored = drafts.current.get(key) ?? draft
86
86
  drafts.current.set(key, stored); sent.current = { key, draft: stored, request: change }; request.current = controller
87
87
  setBusy(true); setFailure(undefined)
@@ -36,6 +36,10 @@ export function ProductionTimeline({ plan, sectionId, stepId, active, current, s
36
36
  }, [workbench, directory, plan, sectionId, active, current])
37
37
  const document = source?.content, section = document?.sections[sectionId]
38
38
  const page = current ? plan?.pages.find(page => page.sectionId === sectionId) : undefined
39
+ // The current plan lists every page of the lecture; a page of the document it lacks is left out of the lecture.
40
+ const excluded = Boolean(current && plan && section && !page)
41
+ // On a page of the lecture, a step it leaves out is missing from the page's steps.
42
+ const stepLeftOut = Boolean(page && !page.steps.some(step => step.stepId === stepId))
39
43
  const start = page?.startMs, end = page?.endMs, duration = start !== undefined && end !== undefined ? Math.max(0, end - start) : undefined
40
44
  const position = plan && current && playback && sameProductionBinding(playback.binding, plan.binding) && playback.position?.sectionId === sectionId && start !== undefined ? Math.max(0, playback.position.timeMs - start) : undefined
41
45
  const tracks: TimelineTrack[] = page && plan ? plan.tracks.map(track => ({ id: track.kind, label: p.tracks[track.kind], segments: track.segments.filter(segment => segment.sectionId === sectionId).map(segment => {
@@ -49,9 +53,10 @@ export function ProductionTimeline({ plan, sectionId, stepId, active, current, s
49
53
  statusLabel: [status, track.kind === 'caption' && p.alignmentStatus[segment.alignment ?? 'none'], segment.audio && (wave === false ? p.waveformUnavailable : wave === undefined ? p.waveformLoading : undefined)].filter(Boolean).join(' · '),
50
54
  waveform: wave ? wave.peaks : undefined,
51
55
  }
52
- }) })) : [{ id: 'visual', label: p.tracks.visual, segments: section?.stepOrder.map((id, index) => ({ id, stepId: id, label: document?.steps[id]?.title ?? p.stepNumber(index), timing: 'unknown' as const })) ?? [] }, { id: 'voice', label: p.tracks.voice, segments: [] }, { id: 'caption', label: p.tracks.caption, segments: [] }]
56
+ }) })) : [{ id: 'visual', label: p.tracks.visual, segments: excluded ? [] : section?.stepOrder.map((id, index) => ({ id, stepId: id, label: document?.steps[id]?.title ?? p.stepNumber(index), timing: 'unknown' as const })) ?? [] }, { id: 'voice', label: p.tracks.voice, segments: [] }, { id: 'caption', label: p.tracks.caption, segments: [] }]
53
57
  const captionChoices = current ? plan?.tracks.find(track => track.kind === 'caption')?.segments.filter(segment => segment.stepId === stepId && (segment.alignment === 'words' || segment.alignment === 'manual') && segment.timing === 'confirmed').map(segment => segment.id) ?? [] : []
54
58
  return <PmTimeline variant="editor" label={p.timeline} tracks={tracks} labels={p.timelineLabels} durationMs={duration} durationStatus={page?.timing ?? 'unknown'} currentTimeMs={position} selectedStepId={stepId} showSteps={false}
59
+ excluded={excluded ? { status: p.notInLecture, notice: p.notInLectureHint } : undefined} notice={stepLeftOut ? p.notInLectureStep : undefined}
55
60
  segmentPicker={{ track: 'caption', ids: captionChoices, label: p.captionSegment, placeholder: p.chooseCaptionSegment }}
56
61
  zoom={zoom} onZoomChange={setZoom} disabled={disabled} loading={loading} seeking={seeking} seekDisabled={!seekEnabled || start === undefined}
57
62
  onSelectStep={onSelectStep} onSelectSegment={(track, selected) => {
@@ -1,5 +1,6 @@
1
1
  import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react'
2
2
  import type { DocumentTranscriptionRequest, TeachingDocument, TranscriptionCapabilities, TranscriptionListAnswer, TranscriptionRevision, TranscriptionTask } from '@lincyaw/kernel'
3
+ import { randomUUID } from '@lincyaw/kernel'
3
4
  import { PmBadge, PmButton, PmCard, PmDialog, PmField, PmIconButton, PmNotice, PmSelect } from '../components.tsx'
4
5
  import { useWorkbench, useWorkbenchState } from '../context.tsx'
5
6
  import { documentTranscriptionSession } from '../transcription-session.ts'
@@ -94,7 +95,7 @@ export function ProductionTranscription({ identity, directory, document, section
94
95
  try {
95
96
  const expected = { identity, version: now.version }, audio = await workbench.inspectDocumentAudio(assetId, expected, controller.signal)
96
97
  if (!current() || controller.signal.aborted) return
97
- const request: DocumentTranscriptionRequest = { intent: `transcription_${crypto.randomUUID()}`, source: { documentId: now.content.id, version: now.version, fingerprint: now.fingerprint }, assetId, audioSha256: audio.inspection.sha256, engine, lang: now.content.metadata.lang, confirmed: true }
98
+ const request: DocumentTranscriptionRequest = { intent: `transcription_${randomUUID()}`, source: { documentId: now.content.id, version: now.version, fingerprint: now.fingerprint }, assetId, audioSha256: audio.inspection.sha256, engine, lang: now.content.metadata.lang, confirmed: true }
98
99
  await session.start(request, () => workbench.startDocumentTranscription(request, expected))
99
100
  } catch (error) { if (current() && !controller.signal.aborted) setFailure(transcriptionFailure(error, locale)) }
100
101
  finally { if (inspectionRequest.current === controller) { inspectionRequest.current = undefined; if (current()) setInspecting(false) } }
@@ -10,10 +10,9 @@ import { nativeEditingCursor } from '../document-editor/selection.ts'
10
10
  import { hasBlockPreview } from '../document-editor/projection.ts'
11
11
  import type { NativeDocumentEditor } from '../document-editor/schema.tsx'
12
12
  import { isAgentChanging } from '../workbench.ts'
13
- import { EditorChangeTrail } from './ChangeTrail.tsx'
14
13
 
15
14
  /** Source editing is available before the first successful runtime compilation. */
16
- export function SourceDocumentPanel({ commentsPortal, onCommentDraftRestore }: { commentsPortal?: HTMLElement | null, onCommentDraftRestore?(): void }) {
15
+ export function SourceDocumentPanel({ commentsPortal, onCommentDraftRestore, onOpenComments }: { commentsPortal?: HTMLElement | null, onCommentDraftRestore?(): void, onOpenComments?(): void }) {
17
16
  const workbench = useWorkbench(), t = useMessages()
18
17
  const source = useWorkbenchState(state => state.authoring)
19
18
  const sourceAcknowledged = () => {
@@ -26,7 +25,6 @@ export function SourceDocumentPanel({ commentsPortal, onCommentDraftRestore }: {
26
25
  const navigation = useWorkbenchState(state => state.documentNavigation)
27
26
  const readOnly = useWorkbenchState(state => state.mode !== 'editing' || workbench.client.capabilities?.readOnly === true || Boolean(state.authoring?.member && !hasRole(state.authoring.member, 'editor')) || Boolean(state.authoring?.loading) || isAgentChanging(state))
28
27
  const container = useRef<HTMLElement>(null)
29
- const sheet = useRef<HTMLDivElement>(null)
30
28
  const consumedNavigation = useRef<string>()
31
29
  const bodyEditor = useRef<NativeDocumentEditor>()
32
30
  const editingPosition = useRef<{ nativeBlockId: string, sectionId: string, position: number, editor: NativeDocumentEditor, identity: string, reset: number | undefined }>()
@@ -176,9 +174,8 @@ export function SourceDocumentPanel({ commentsPortal, onCommentDraftRestore }: {
176
174
  {source?.issues.length ? <div className="pmw-source-document__diagnostics"><PmNotice tone="warn"><details><summary>{messages.diagnostics(source.issues.length)}</summary><ul>{source.issues.map((issue, index) => <li key={`${issue.path}:${index}`}><code>{issue.path}</code> {issue.message}</li>)}</ul></details></PmNotice></div> : null}
177
175
  {!source?.content || !source.identity ? source?.loading
178
176
  ? <div className="pmw-source-document__sheet pmw-source-document__sheet--loading"><PmSkeleton label={messages.loading} /></div>
179
- : <PmNotice tone="warn"><span>{messages.unavailable}</span><span className="pmw-notice__actions"><PmButton small onClick={() => void workbench.retryDocument()}>{t.retry}</PmButton></span></PmNotice> : <div ref={sheet} className="pmw-source-document__sheet">
180
- <EditorChangeTrail sheet={sheet} />
181
- <DocumentEditor acknowledged={sourceAcknowledged()} getDocumentAcknowledged={sourceAcknowledged} onCommentDraftRestore={onCommentDraftRestore} commentDrafts={workbench.documentCommentDrafts(source.identity)} identity={source.identity} document={source.content} version={source.version} member={source.member} getDocument={() => workbench.getDocument(source.identity)}
177
+ : <PmNotice tone="warn"><span>{messages.unavailable}</span><span className="pmw-notice__actions"><PmButton small onClick={() => void workbench.retryDocument()}>{t.retry}</PmButton></span></PmNotice> : <div className="pmw-source-document__sheet">
178
+ <DocumentEditor acknowledged={sourceAcknowledged()} getDocumentAcknowledged={sourceAcknowledged} onCommentDraftRestore={onCommentDraftRestore} onOpenComments={onOpenComments} commentDrafts={workbench.documentCommentDrafts(source.identity)} identity={source.identity} document={source.content} version={source.version} member={source.member} getDocument={() => workbench.getDocument(source.identity)}
182
179
  getDocumentVersion={() => { const current = workbench.getState().authoring; return current && current.identity === source.identity && current.reset === source.reset ? current.version : undefined }} reset={source.reset} locale={locale} readOnly={readOnly}
183
180
  uploadImage={(file, signal) => workbench.importDocumentImage(file, source.identity!, signal)}
184
181
  getPositionToken={() => workbench.getState().documentPositionToken}