@lincyaw/workbench 0.2.0-rc.33 → 0.2.0-rc.34

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 (34) hide show
  1. package/package.json +4 -4
  2. package/src/context.tsx +2 -1
  3. package/src/diagnostics.ts +1 -1
  4. package/src/document-editing.ts +484 -0
  5. package/src/document-editor/ComponentPropertiesDialog.tsx +1 -1
  6. package/src/document-editor/DocumentBlockPreview.tsx +2 -2
  7. package/src/document-editor/DocumentStepNarration.tsx +8 -8
  8. package/src/document-production.ts +331 -0
  9. package/src/history.ts +1 -1
  10. package/src/index.ts +5 -2
  11. package/src/jobs.ts +1 -1
  12. package/src/panels/DocumentView.tsx +11 -11
  13. package/src/panels/DocumentVoiceDialog.tsx +2 -2
  14. package/src/panels/DocumentVoiceField.tsx +1 -1
  15. package/src/panels/HistoryPanel.tsx +1 -1
  16. package/src/panels/PageDeleteDialog.tsx +4 -4
  17. package/src/panels/PageRenameDialog.tsx +1 -1
  18. package/src/panels/ProductionCaptionSize.tsx +1 -1
  19. package/src/panels/ProductionCaptionTiming.tsx +5 -5
  20. package/src/panels/ProductionMediaClips.tsx +4 -4
  21. package/src/panels/ProductionPanel.tsx +2 -2
  22. package/src/panels/ProductionRecording.tsx +1 -1
  23. package/src/panels/ProductionRecordingRange.tsx +2 -2
  24. package/src/panels/ProductionTranscription.tsx +3 -3
  25. package/src/panels/SourceDocumentPanel.tsx +9 -9
  26. package/src/panels/TranscriptionAdoption.tsx +2 -2
  27. package/src/panels/VoiceoverDialog.tsx +1 -1
  28. package/src/preview-playback.ts +1 -1
  29. package/src/production-playback.ts +1 -1
  30. package/src/production-voice-playback.ts +3 -2
  31. package/src/use-recording-adoption.ts +2 -2
  32. package/src/voiceover-jobs.ts +1 -1
  33. package/src/workbench-state.ts +157 -0
  34. package/src/workbench.ts +56 -923
@@ -64,7 +64,7 @@ export function ProductionRecording({ identity, sectionId, stepId, active, disab
64
64
  if (!owns()) return
65
65
  const currentSource = workbench.getState().authoring
66
66
  if (!currentSource?.version || currentSource.identity !== identity || currentSource.dirty || currentSource.saving || currentSource.composing || currentSource.restored || currentSource.error) throw new Error('production-source-changed')
67
- const answer = await workbench.ensureDocumentAudio(file, { identity, version: currentSource.version }, controller.signal)
67
+ const answer = await workbench.production.ensureAudio(file, { identity, version: currentSource.version }, controller.signal)
68
68
  if (!owns()) return
69
69
  recording.imported(file, answer.inspection.assetId); adoption.imported(answer.inspection.assetId, selection); onImported(answer.inspection.assetId, transcriptionSelection)
70
70
  } catch (error) {
@@ -63,7 +63,7 @@ export function ProductionRecordingRange({ identity, sectionId, stepId, active,
63
63
  const version = source?.version, assetId = voice?.assetId, controller = new AbortController()
64
64
  if (!active || !version || !assetId || disabled) { setLoading(false); return }
65
65
  setLoading(true)
66
- void workbench.inspectDocumentAudio(assetId, { identity, version }, controller.signal).then(answer => {
66
+ void workbench.production.inspectAudio(assetId, { identity, version }, controller.signal).then(answer => {
67
67
  if (!controller.signal.aborted && current() && latest.current.key === key) setInspection({ version: answer.version, value: answer.inspection })
68
68
  }, error => { if (!controller.signal.aborted && current() && latest.current.key === key) setFailure(failureText(error)) })
69
69
  .finally(() => { if (!controller.signal.aborted && current() && latest.current.key === key) setLoading(false) })
@@ -85,7 +85,7 @@ export function ProductionRecordingRange({ identity, sectionId, stepId, active,
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)
88
- try { await workbench.adoptDocumentRecording(change, { identity, version: source.version }, controller.signal); if (current()) settle() }
88
+ try { await workbench.production.adoptRecording(change, { identity, version: source.version }, controller.signal); if (current()) settle() }
89
89
  catch (error) { if (current() && request.current === controller && !settle() && !controller.signal.aborted) setFailure(failureText(error)) }
90
90
  finally { if (request.current === controller) { request.current = undefined; if (current()) setBusy(false) } }
91
91
  }
@@ -82,7 +82,7 @@ export function ProductionTranscription({ identity, directory, document, section
82
82
  const controller = new AbortController(); importRequest.current = controller; setImporting(true); setFailure(undefined)
83
83
  pendingFile.current = value
84
84
  try {
85
- const answer = await workbench.ensureDocumentAudio(value, { identity, version: now.version }, controller.signal)
85
+ const answer = await workbench.production.ensureAudio(value, { identity, version: now.version }, controller.signal)
86
86
  if (current() && !controller.signal.aborted) { setAssetId(answer.inspection.assetId); pendingFile.current = undefined }
87
87
  } catch (error) { if (current() && !controller.signal.aborted) setFailure(transcriptionFailure(error, locale)) }
88
88
  finally { if (importRequest.current === controller) { importRequest.current = undefined; if (current()) setImporting(false) } }
@@ -93,10 +93,10 @@ export function ProductionTranscription({ identity, directory, document, section
93
93
  const controller = new AbortController(); inspectionRequest.current = controller; setInspecting(true)
94
94
  setFailure(undefined)
95
95
  try {
96
- const expected = { identity, version: now.version }, audio = await workbench.inspectDocumentAudio(assetId, expected, controller.signal)
96
+ const expected = { identity, version: now.version }, audio = await workbench.production.inspectAudio(assetId, expected, controller.signal)
97
97
  if (!current() || controller.signal.aborted) return
98
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 }
99
- await session.start(request, () => workbench.startDocumentTranscription(request, expected))
99
+ await session.start(request, () => workbench.production.startTranscription(request, expected))
100
100
  } catch (error) { if (current() && !controller.signal.aborted) setFailure(transcriptionFailure(error, locale)) }
101
101
  finally { if (inspectionRequest.current === controller) { inspectionRequest.current = undefined; if (current()) setInspecting(false) } }
102
102
  }
@@ -9,7 +9,7 @@ import { DocumentBlockPreview } from '../document-editor/DocumentBlockPreview.ts
9
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
- import { isAgentChanging } from '../workbench.ts'
12
+ import { isAgentChanging } from '../workbench-state.ts'
13
13
 
14
14
  /** Source editing is available before the first successful runtime compilation. */
15
15
  export function SourceDocumentPanel({ commentsPortal, onCommentDraftRestore, onOpenComments }: { commentsPortal?: HTMLElement | null, onCommentDraftRestore?(): void, onOpenComments?(): void }) {
@@ -37,10 +37,10 @@ export function SourceDocumentPanel({ commentsPortal, onCommentDraftRestore, onO
37
37
  const recoveryDisabled = readOnly || source?.saving || source?.composing || source?.recovering
38
38
  useEffect(() => {
39
39
  const element = container.current
40
- if (element && source?.identity && source.content) return workbench.attachDocumentViewport(element, source.identity)
40
+ if (element && source?.identity && source.content) return workbench.editing.attachViewport(element, source.identity)
41
41
  }, [workbench, source?.identity, Boolean(source?.content)])
42
42
  // The editor applies `readOnly` while committing, so it is editable by the time this runs.
43
- useEffect(() => { if (!readOnly) workbench.documentEditorEditable() }, [workbench, readOnly])
43
+ useEffect(() => { if (!readOnly) workbench.editing.editorEditable() }, [workbench, readOnly])
44
44
  useEffect(() => {
45
45
  if (!navigation) return
46
46
  const request = JSON.stringify([source?.identity, navigation.request])
@@ -69,7 +69,7 @@ export function SourceDocumentPanel({ commentsPortal, onCommentDraftRestore, onO
69
69
  const viewport = measure(), state = workbench.getState()
70
70
  if (gesture.generation !== state.documentPositionToken || !sameGeometry(gesture.viewport, viewport) || gesture.viewport.top !== viewport.top) return
71
71
  if (!state.authoring?.loading && !isAgentChanging(state)) {
72
- const field = workbench.focusedDocumentField(), root = field?.editor.prosemirrorView.dom.getRootNode()
72
+ const field = workbench.editing.focusedField(), root = field?.editor.prosemirrorView.dom.getRootNode()
73
73
  if (field && root instanceof ShadowRoot && element.contains(root.host)) {
74
74
  try {
75
75
  const point = field.editor.prosemirrorView.coordsAtPos(field.editor.prosemirrorState.selection.head), bounds = element.getBoundingClientRect()
@@ -113,17 +113,17 @@ export function SourceDocumentPanel({ commentsPortal, onCommentDraftRestore, onO
113
113
  const scroll = (event: Event) => {
114
114
  const viewport = measure(), previous = baseline
115
115
  baseline = viewport
116
- if (workbench.consumeDocumentReturnScroll(element)) { cancel(); return }
116
+ if (workbench.editing.consumeReturnScroll(element)) { cancel(); return }
117
117
  // Native scroll chaining from an iframe has no parent wheel event.
118
118
  if (!event.isTrusted) return
119
119
  if (!sameGeometry(previous, viewport)) { cancel(); return }
120
120
  if (viewport.top === previous.top) return
121
- workbench.documentInteraction()
121
+ workbench.editing.interact()
122
122
  queue(viewport)
123
123
  }
124
124
  const interact = (event: Event) => {
125
125
  if (!event.isTrusted) return
126
- workbench.documentInteraction()
126
+ workbench.editing.interact()
127
127
  baseline = measure()
128
128
  queue(baseline)
129
129
  }
@@ -134,7 +134,7 @@ export function SourceDocumentPanel({ commentsPortal, onCommentDraftRestore, onO
134
134
  if (['Home', 'End'].includes(event.key) && target instanceof HTMLElement && target.isContentEditable && !event.ctrlKey && !event.metaKey) return
135
135
  interact(event)
136
136
  }
137
- const pointer = () => { cancel(); workbench.documentInteraction() }
137
+ const pointer = () => { cancel(); workbench.editing.interact() }
138
138
  element.addEventListener('scroll', scroll, { passive: true })
139
139
  element.addEventListener('wheel', interact, { passive: true })
140
140
  element.addEventListener('touchmove', interact, { passive: true })
@@ -197,7 +197,7 @@ export function SourceDocumentPanel({ commentsPortal, onCommentDraftRestore, onO
197
197
  commentsPortal={commentsPortal} onChange={document => workbench.recordDocument(document)} onReady={(editor, commands) => {
198
198
  bodyEditor.current = editor
199
199
  editingPosition.current = undefined
200
- workbench.attachDocumentEditor(editor, commands, { identity: source.identity!, reset: source.reset })
200
+ workbench.editing.attachEditor(editor, commands, { identity: source.identity!, reset: source.reset })
201
201
  }}
202
202
  onEditingPosition={(position, editor) => {
203
203
  const state = workbench.getState(), current = state.authoring
@@ -91,7 +91,7 @@ function AdoptionTarget({ identity, candidate, document, sectionId, stepId, disa
91
91
  const sent: TranscriptionAdoptionDraft = { id: value.id, source: { documentId: document.id, version: now.version, fingerprint: now.fingerprint }, candidate: { id: candidate.transcriptionId, revision: candidate.revision }, draftRevision: value.revision, targets: [{ ...target, content: normalized.parts, discardAtoms: value.discarded.filter(key => atoms.some(atom => atom.key === key)) }], ...removeCueTimings.length ? { removeCueTimings } : {} }
92
92
  setReviewing(true); setFailure(undefined)
93
93
  try {
94
- const answer = await workbench.planDocumentTranscription(sent, { identity, version: now.version })
94
+ const answer = await workbench.production.planTranscription(sent, { identity, version: now.version })
95
95
  if (request !== generation.current || latest.current.revision !== sent.draftRevision) return
96
96
  setPlan(answer); setOpen(true)
97
97
  } catch { if (request === generation.current) setFailure(t.previewFailed) }
@@ -102,7 +102,7 @@ function AdoptionTarget({ identity, candidate, document, sectionId, stepId, disa
102
102
  const sent = plan, planId = plan.planId
103
103
  setApplying(true); setFailure(undefined)
104
104
  try {
105
- const answer = await workbench.adoptDocumentTranscription({ planId, source: sent.source, candidate: sent.candidate, draftRevision: sent.draftRevision }, { identity, version: sent.source.version })
105
+ const answer = await workbench.production.adoptTranscription({ planId, source: sent.source, candidate: sent.candidate, draftRevision: sent.draftRevision }, { identity, version: sent.source.version })
106
106
  if (latest.current.id === sent.changeId && latest.current.revision === sent.draftRevision) {
107
107
  const next: Draft = { ...latest.current, id: randomUUID(), revision: 0, discarded: [], baseVersion: answer.version, applied: true }
108
108
  latest.current = next; setDraft(next)
@@ -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 }
@@ -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 {
@@ -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, WorkbenchState } from './workbench.ts'
8
- import { isAgentChanging } from './workbench.ts'
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
 
@@ -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.inspectDocumentAudio(target.assetId, expected, controller.signal)
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.adoptDocumentRecording(sent, expected, controller.signal)
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)
@@ -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)
@@ -0,0 +1,157 @@
1
+ import type { CanonicalSource, DiagnosticSnapshot, DocumentsAnswer, FocusReport, IrAnswer, JobsAnswer, PreviewAnchor, PreviewAnswer, PreviewCommand, PreviewPoint, PreviewPosition, PreviewRect, PreviewRenderer, ProductionPlan, ProductionPlaybackState, ReviewSnapshot, RevisionsAnswer, UncommittedFile, VoiceoverJob } from '@lincyaw/kernel'
2
+ import type { DocumentSessionState } from './document-session.ts'
3
+ import type { Locale } from './messages.ts'
4
+
5
+ /** `editing`: the canonical document is edited in the parent; `viewing`: a derived snapshot is presented. */
6
+ export type WorkbenchMode = 'editing' | 'viewing'
7
+
8
+ /**
9
+ * How the web form is shown: as a page or as its presentation, whose controls can play a configured lecture.
10
+ * Both share one preview page and switch in place with `go.view`.
11
+ */
12
+ export type WebView = 'document' | 'present'
13
+
14
+ /** A playback key pressed in a preview that the workbench plays: Space, and the left and right arrows. */
15
+ export type PlaybackKey = 'play-pause' | 'previous' | 'next'
16
+
17
+ /** What the author points at in the document: a block (or a section), or a passage selected in it. */
18
+ export interface Pointer {
19
+ target: PreviewAnchor
20
+ step?: number
21
+ /** The selected passage. */
22
+ quote?: string
23
+ /** Its box in the preview's viewport; none while it is out of sight. */
24
+ rect?: PreviewRect
25
+ obstacles?: PreviewRect[]
26
+ point?: PreviewPoint
27
+ /** Its text can be edited in place. */
28
+ isEditable: boolean
29
+ }
30
+
31
+ export type SaveState =
32
+ | { kind: 'idle' }
33
+ | { kind: 'saving' }
34
+ | { kind: 'saved', at: string }
35
+ | { kind: 'locked' }
36
+ | { kind: 'failed', message: string }
37
+
38
+ /** A request for the agent of the conversation: its text and what it is about. */
39
+ export interface AgentRequest {
40
+ text: string
41
+ focus: FocusReport[]
42
+ }
43
+
44
+ /** A request for the author to finish and send in the conversation, and what it is about: the host only shows it. */
45
+ export interface AgentDraft {
46
+ text: string
47
+ focus: FocusReport[]
48
+ }
49
+
50
+ /** Where the host put a request: the conversation's session and the request's id, which its user message carries. */
51
+ export interface AgentAnswer {
52
+ session: string
53
+ request: string
54
+ }
55
+
56
+ export interface WorkbenchState {
57
+ locale: Locale
58
+ authoring?: DocumentSessionState
59
+ /** Unaccepted numeric form input is retained separately from saved canonical timing. */
60
+ hasDocumentTimingDrafts?: boolean
61
+ documentTimingDraftStorageFailure?: boolean
62
+ captionTimingDraftSteps?: string[]
63
+ captionTimingDraftStorageFailure?: boolean
64
+ isDark: boolean
65
+ documents?: DocumentsAnswer
66
+ documentsFailure?: string
67
+ /** The workspace's routes answer 404: `@lincyaw/dsh` is turned off on the plugins page. */
68
+ isBundleDisabled?: boolean
69
+ document?: string
70
+ ir?: IrAnswer
71
+ mode: WorkbenchMode
72
+ previewRenderer: PreviewRenderer
73
+ /** In the web form: the page or the presentation, both in the same page, switched without loading it again. */
74
+ webView: WebView
75
+ previewReload: number
76
+ preview?: PreviewAnswer
77
+ previewFailure?: string
78
+ /** The IR revision the preview shows. */
79
+ previewIrRevision?: string
80
+ isPreparingPresentation?: boolean
81
+ presentationFailure?: string
82
+ presentationSnapshot?: { version: string, fingerprint: string, revision: string, project: number }
83
+ productionPlan?: ProductionPlan
84
+ productionPlayback?: ProductionPlaybackState
85
+ productionFailure?: string
86
+ voiceoverJobs?: VoiceoverJob[]
87
+ voiceoverJobsFailure?: string
88
+ /** A cache refresh that actually changed the current production binding; it never starts playback. */
89
+ voiceoverCacheRefresh?: { source: CanonicalSource, revision: string, sequence: number }
90
+ /** Changes when an acknowledged preview connection is attached or detached, including same-revision reloads. */
91
+ previewConnection: number
92
+ /** Where the preview is: the section the author reads, or the slide and its step. */
93
+ position?: PreviewPosition
94
+ /** Changes on every position intent, including A → B → A, without changing the source. */
95
+ documentPositionToken: string
96
+ /** Explicit author navigation, distinct from the player's passive cursor and frame reload reports. */
97
+ productionNavigationVersion: number
98
+ documentPositionIntent: 'seek' | 'pause'
99
+ /** An explicit source navigation request; scrolling updates position without issuing another request. */
100
+ documentNavigation?: { section: string, block?: string, request: string }
101
+ documentPositionFailure?: 'removed'
102
+ isCreatingPage?: boolean
103
+ isEditingPage?: boolean
104
+ editorHistory?: EditorHistoryState
105
+ isHistoryPreparing?: boolean
106
+ pageEditFailure?: string
107
+ diagnostics?: DiagnosticSnapshot
108
+ isDiagnosticsUnavailable: boolean
109
+ canRepairDiagnostics: boolean
110
+ isRepairingDiagnostics: boolean
111
+ diagnosticsRepairFailure?: string
112
+ pointer?: Pointer
113
+ save: SaveState
114
+ /** What the conversation's agent is told the author points at. */
115
+ focus: FocusReport[]
116
+ isFocusPending: boolean
117
+ focusFailure?: string
118
+ review?: ReviewSnapshot
119
+ history?: RevisionsAnswer
120
+ /** Files changed elsewhere and not yet in the history. */
121
+ outside?: UncommittedFile[]
122
+ historyFailure?: string
123
+ isHistoryBusy: boolean
124
+ isAsking: boolean
125
+ askFailure?: string
126
+ /** What the document can be made into, and its builds and exports (the author's and the AI's). */
127
+ jobs?: JobsAnswer
128
+ jobsFailure?: string
129
+ voiceServiceVersion?: number
130
+ jobPreparing?: { target: string, canCancel: boolean }
131
+ }
132
+
133
+ export interface PreviewSink {
134
+ readonly generation?: number
135
+ readonly capabilities?: readonly PreviewCommand['type'][]
136
+ send(command: PreviewCommand): void
137
+ }
138
+
139
+ export interface EditorHistoryState { section: string, undo: boolean, redo: boolean, field?: boolean }
140
+
141
+
142
+ /** The workbench's state as its parts read and change it. */
143
+ export interface WorkbenchStore {
144
+ readonly state: WorkbenchState
145
+ set(patch: Partial<WorkbenchState>): void
146
+ }
147
+
148
+ /** The document the conversation works on: none when no document is open. */
149
+ export function selectedDocument(state: WorkbenchState): string | null {
150
+ return state.document ?? null
151
+ }
152
+
153
+ /** Whether the AI is changing the workspace now, or its change waits for the author. */
154
+ export function isAgentChanging(state: WorkbenchState): boolean {
155
+ return Boolean(state.review?.engine === 'git' && (state.review.running || state.review.changes.length > 0))
156
+ }
157
+