From 50b9bcb3b30cc014d3e75385fd084b3eeb837725 Mon Sep 17 00:00:00 2001 From: Weiming Liao Date: Wed, 25 Nov 2026 17:17:49 +0800 Subject: [PATCH 1/2] [feat] canvas: Support multi-window project preview Signed-off-by: Weiming Liao --- apps/api/src/opendirector_api/creation.py | 30 +- docs/guides/user-guide.md | 6 + docs/guides/user-guide.zh-CN.md | 6 + .../infrastructure/creation_projects.py | 37 ++- .../infrastructure/local_projects.py | 60 ++++ src/backend/creationClient.ts | 11 +- src/backend/editSession.ts | 47 +++ src/backend/projects.ts | 27 +- src/backend/workspace.ts | 3 +- src/canvas/AssistantPanel.tsx | 8 +- src/canvas/CanvasActionsContext.ts | 1 + src/canvas/CanvasNodeView.tsx | 2 + src/canvas/CanvasWorkspace.tsx | 22 +- src/canvas/NodeVersionHistory.tsx | 4 +- src/canvas/ProjectSelector.tsx | 27 +- src/canvas/TimelineEditor.tsx | 301 +++++++++--------- src/canvas/library/AssetLibraryDialog.tsx | 9 +- src/canvas/useAssistantChat.ts | 31 +- src/canvas/workspace/EditSession.tsx | 106 ++++++ src/canvas/workspace/WorkspaceView.tsx | 93 ++++-- src/canvas/workspace/edit-session.css | 53 +++ src/canvas/workspace/useWorkspaceDocument.ts | 33 +- src/canvas/workspace/useWorkspaceEditor.ts | 21 +- .../workspace/useWorkspaceGeneration.ts | 10 +- .../workspace/useWorkspaceInteraction.tsx | 20 +- src/canvas/workspace/useWorkspaceTransfer.ts | 4 +- src/i18n/messages/en-US/canvasWorkspace.ts | 8 + src/i18n/messages/zh-CN/canvasWorkspace.ts | 8 + tests/browser/manifest.json | 2 +- tests/browser/session_lease.mjs | 94 +++++- 30 files changed, 827 insertions(+), 257 deletions(-) create mode 100644 src/backend/editSession.ts create mode 100644 src/canvas/workspace/EditSession.tsx create mode 100644 src/canvas/workspace/edit-session.css diff --git a/apps/api/src/opendirector_api/creation.py b/apps/api/src/opendirector_api/creation.py index 4f0fa0cab..73fae7d30 100644 --- a/apps/api/src/opendirector_api/creation.py +++ b/apps/api/src/opendirector_api/creation.py @@ -36,6 +36,11 @@ from opendirector_api.localization import localized_error_for_language +class EditHandoffDecision(BaseModel): + requester: UUID + accept: bool + + class FontCoverageResponse(BaseModel): fingerprint: str = Field(pattern=r'^sha256:[0-9a-f]{64}$') # One bit per Unicode scalar position: fixed 139,264 bytes / 185,688 base64 chars. @@ -131,14 +136,33 @@ def open_project(project_id: UUID, x_opendirector_session: UUID = Header()): return projects.open(project_id, str(x_opendirector_session)) @router.post('/projects/{project_id}/open-canvas') - def open_project_canvas(project_id: UUID, x_opendirector_session: UUID = Header()): + def open_project_canvas(project_id: UUID, x_opendirector_session: UUID = Header(), + x_opendirector_allow_preview: bool = Header(default=False)): # The canvas needs its reference edges and text on first render too. Reuse the # single snapshot this open read already published instead of making the # page read the same project again through GET /canvas. The no-flag # route above still returns a bare ProjectSnapshot. - snapshot = projects.open(project_id, str(x_opendirector_session)) + session = str(x_opendirector_session) + editing = {} + if x_opendirector_allow_preview: + snapshot, state = projects.open_canvas(project_id, session) + editing['editing'] = state + else: + snapshot = projects.open(project_id, session) return {'snapshot': snapshot, 'edges': canvas.reference_edges(project_id, snapshot), - 'texts': canvas.text_contents(snapshot)} + 'texts': canvas.text_contents(snapshot), **editing} + + @router.get('/projects/{project_id}/edit-session') + def edit_session(project_id: UUID, x_opendirector_session: UUID = Header()): + return projects.editing_state(project_id, str(x_opendirector_session)) + + @router.post('/projects/{project_id}/edit-session') + def request_edit_session(project_id: UUID, x_opendirector_session: UUID = Header()): + return projects.request_edit(project_id, str(x_opendirector_session)) + + @router.put('/projects/{project_id}/edit-session') + def resolve_edit_session(project_id: UUID, value: EditHandoffDecision, x_opendirector_session: UUID = Header()): + return projects.resolve_edit(project_id, str(x_opendirector_session), str(value.requester), value.accept) @router.put('/sessions/{session_id}') def heartbeat(session_id: UUID, value: Session): diff --git a/docs/guides/user-guide.md b/docs/guides/user-guide.md index 328b650c3..dfef578da 100644 --- a/docs/guides/user-guide.md +++ b/docs/guides/user-guide.md @@ -2,6 +2,12 @@ [English](user-guide.md) · [简体中文](user-guide.zh-CN.md) · [Back to README](../../README.md) +## Preview the same project in another browser window + +Open the project menu and select **Open in new tab** next to the project. The preview uses the same workspace and disables editing controls. You can pan the canvas, inspect media, and play a saved timeline while the editing window stays open. Saved changes appear automatically. + +Select **Edit in this window** to request edit access. In the editing window, select **Save and hand off** to switch roles or **Keep editing here** to decline. If the editing window is already closed, edit access is granted as soon as its lease is released. + ## Connect models On the welcome screen, select **Get started**. Set up a language model for the built-in assistant or choose an existing harness. Then check one or more tasks. Each checked task shows its saved models or opens its setup form if you have none. **Start creating** places a node for each checked task on the same canvas. **Import media** opens the file picker. **Open an example canvas** opens an editable example project directly, with download progress in step two. Cancelling keeps your task selections. You can add more models in Settings anytime. diff --git a/docs/guides/user-guide.zh-CN.md b/docs/guides/user-guide.zh-CN.md index 43aa920c7..d26e3400d 100644 --- a/docs/guides/user-guide.zh-CN.md +++ b/docs/guides/user-guide.zh-CN.md @@ -2,6 +2,12 @@ [English](user-guide.md) · [简体中文](user-guide.zh-CN.md) · [返回首页](../../README.zh-CN.md) +## 在多个浏览器窗口查看同一项目 + +打开项目菜单,点项目右侧的「在新标签页打开」。两个窗口使用同一套工作区,预览窗口中的编辑控件会禁用。你可以平移缩放画布、查看素材、播放已保存的时间线。编辑窗口保存后,预览会自动更新。 + +需要在预览窗口修改时,点「在此编辑」。在原窗口点「保存并交接」就会交换两个窗口的角色,也可以点「继续在此编辑」拒绝。如果原窗口已关闭,等编辑权释放后即可直接接手。 + ## 接入模型 首次打开时,在欢迎页选择「开始设置」。为内置助手配置一个语言模型,或选择已有的 Harness。接着勾选一项或多项任务。每个勾选项可以选用已有模型,缺模型时直接显示对应的配置表单。点击「开始创作」后,画布会为每项任务添加一个节点。点「导入素材」可直接选文件,点「打开示例画布」可直接进入可编辑的示例项目,下载进度在第二步显示。取消时会保留已勾选的任务。之后可随时在设置中添加其他模型。 diff --git a/packages/core/src/opendirector/infrastructure/creation_projects.py b/packages/core/src/opendirector/infrastructure/creation_projects.py index 2f1e2e0aa..b08279dc5 100644 --- a/packages/core/src/opendirector/infrastructure/creation_projects.py +++ b/packages/core/src/opendirector/infrastructure/creation_projects.py @@ -121,17 +121,48 @@ def view(self, project_id, client_id, value=None, *, session=None, missing_ok=Fa return ViewState.model_validate(read_json(file)) return None if missing_ok else ViewState(projectId=project_id, clientId=client_id) - def open(self, project_id, session): + def _open_canvas(self, project_id, session, *, allow_preview=False): with self.local.transaction() as db: self._recover() path, manifest = self._find(db, project_id) - self.local._open(db, dict(id=str(project_id), path=str(path)), session) + project = dict(id=str(project_id), path=str(path)) + if allow_preview: + editor = self.local.editor(db, str(project_id)) + if editor and editor['id'] != session: + self.local.clear_other_edit_requests(db, str(project_id), session) + db.execute("DELETE FROM sessions WHERE id=?", (session,)) + else: + self.local._open(db, project, session) + else: + self.local._open(db, project, session) + state = self.local.editing_state(db, str(project_id), session) record, validated = self._current_record(db, project_id, path, manifest) if not validated: # The canvas is open now; prove the ancestry in the background # so the first autosave does not replay it under the lock. self._schedule_warm(path, manifest) - return record.snapshot.model_copy(deep=True) + return record.snapshot.model_copy(deep=True), state + + def open(self, project_id, session): + snapshot, _ = self._open_canvas(project_id, session) + return snapshot + + def open_canvas(self, project_id, session): + return self._open_canvas(project_id, session, allow_preview=True) + + def editing_state(self, project_id, session): + with self.local.transaction() as db: + return self.local.editing_state(db, str(project_id), session) + + def request_edit(self, project_id, session): + with self.local.transaction() as db: + path, _ = self._find(db, project_id) + return self.local.request_edit(db, dict(id=str(project_id), path=str(path)), session) + + def resolve_edit(self, project_id, session, requester, accept): + with self.local.transaction() as db: + path, _ = self._find(db, project_id) + return self.local.resolve_edit(db, dict(id=str(project_id), path=str(path)), session, requester, accept) def heartbeat(self, session, project_id): self.open(project_id, session) diff --git a/packages/core/src/opendirector/infrastructure/local_projects.py b/packages/core/src/opendirector/infrastructure/local_projects.py index cab63bffa..d21a5cc24 100644 --- a/packages/core/src/opendirector/infrastructure/local_projects.py +++ b/packages/core/src/opendirector/infrastructure/local_projects.py @@ -76,6 +76,8 @@ class LocalProjects: # separate key lets browsers open or release their own editing session. _AGENT_SESSION_PREFIX = "agent:" + HANDOFF_SECONDS = 120 + def __init__(self, repository: Path): self.repository = repository.resolve() self.root = self.repository / "projects" @@ -89,6 +91,10 @@ def __init__(self, repository: Path): id TEXT PRIMARY KEY, project_id TEXT NOT NULL, expires REAL NOT NULL, path TEXT NOT NULL DEFAULT '' ); + CREATE TABLE IF NOT EXISTS edit_handoffs ( + project_id TEXT PRIMARY KEY, owner TEXT NOT NULL, + requester TEXT NOT NULL, expires REAL NOT NULL + ); """) db.execute("DELETE FROM sessions WHERE expires<=?", (time.time(),)) @@ -125,6 +131,7 @@ def _conflict(parent: Path, name: str, source: Path | None = None): def _open(self, db, project: dict, session: str): identifier(session) project_id = project["id"] + self.clear_other_edit_requests(db, project_id, session) if db.execute("SELECT 1 FROM sessions WHERE project_id=? AND id<>? AND id NOT LIKE ? AND expires>?", (project_id, session, self._AGENT_SESSION_PREFIX + "%", time.time())).fetchone(): raise ProjectError("该项目正在其他窗口中打开,请先关闭后再试。", 409, code="project_open_elsewhere") @@ -134,6 +141,58 @@ def _open(self, db, project: dict, session: str): db.execute("INSERT INTO sessions(id,project_id,expires,path) VALUES (?,?,?,?) ON CONFLICT(id) DO UPDATE SET project_id=excluded.project_id,expires=excluded.expires,path=excluded.path", (session, project_id, time.time() + self.LEASE_SECONDS, project["path"])) + def clear_other_edit_requests(self, db, project_id, session): + db.execute( + "DELETE FROM edit_handoffs WHERE project_id!=? AND (owner=? OR requester=?)", + (project_id, session, session), + ) + + def editor(self, db, project_id, *, now=None): + return db.execute( + "SELECT id FROM sessions WHERE project_id=? AND id NOT LIKE ? AND expires>?", + (project_id, self._AGENT_SESSION_PREFIX + "%", time.time() if now is None else now), + ).fetchone() + + def editing_state(self, db, project_id, session, *, now=None): + now = time.time() if now is None else now + editor = self.editor(db, project_id, now=now) + if editor is None: + return {'mode': 'preview', 'handoff': 'available'} + owner = editor['id'] + pending = db.execute( + "SELECT requester FROM edit_handoffs WHERE project_id=? AND owner=? AND expires>?", + (project_id, owner, now), + ).fetchone() + if owner == session: + return {'mode': 'edit', 'requester': pending['requester'] if pending else None} + return {'mode': 'preview', 'handoff': ( + 'requested' if pending and pending['requester'] == session + else 'busy' if pending else 'occupied' + )} + + def request_edit(self, db, project, session): + project_id = project['id'] + now = time.time() + state = self.editing_state(db, project_id, session, now=now) + if state == {'mode': 'preview', 'handoff': 'available'}: + self._open(db, project, session) + elif state == {'mode': 'preview', 'handoff': 'occupied'}: + db.execute(""" + INSERT INTO edit_handoffs(project_id,owner,requester,expires) VALUES (?,?,?,?) + ON CONFLICT(project_id) DO UPDATE SET owner=excluded.owner, + requester=excluded.requester, expires=excluded.expires + """, (project_id, self.editor(db, project_id, now=now)['id'], session, now + self.HANDOFF_SECONDS)) + return self.editing_state(db, project_id, session) + + def resolve_edit(self, db, project, session, requester, accept): + project_id = project['id'] + if self.editing_state(db, project_id, session) == {'mode': 'edit', 'requester': requester}: + db.execute("DELETE FROM edit_handoffs WHERE project_id=?", (project_id,)) + if accept: + db.execute("DELETE FROM sessions WHERE id=?", (session,)) + self._open(db, project, requester) + return self.editing_state(db, project_id, session) + def agent_session_key(self, session: str) -> str: return self._AGENT_SESSION_PREFIX + identifier(session) @@ -156,4 +215,5 @@ def release_agent_session(self, session: str): def release(self, session: str): with self.transaction() as db: + db.execute("DELETE FROM edit_handoffs WHERE owner=? OR requester=?", (session, session)) db.execute("DELETE FROM sessions WHERE id=?", (session,)) diff --git a/src/backend/creationClient.ts b/src/backend/creationClient.ts index 5ece5164d..679643d45 100644 --- a/src/backend/creationClient.ts +++ b/src/backend/creationClient.ts @@ -1,3 +1,4 @@ +import { installEditingState, parseEditingState } from "./editSession.ts"; import type { Asset, AssetRef, @@ -164,13 +165,21 @@ export class CreationClient { state: "used" | "pending" | "unknown" | "unavailable"; }[]; texts?: Record; + editing?: unknown; } - >(`${creationPath(this.id)}/open-canvas`, { method: "POST" }); + >(`${creationPath(this.id)}/open-canvas`, { + method: "POST", + headers: { "X-OpenDirector-Allow-Preview": "true" }, + }); // The open-canvas response carries the one authoritative snapshot plus // the reference evidence the canvas draws; a bare snapshot response is // still accepted for compatibility and falls back to a canvas read. // Listeners re-project during install and read referenceStates, so the // map is installed first, the same order as refresh(). + if ("editing" in opened) + installEditingState(this.id, parseEditingState(opened.editing)); + else + installEditingState(this.id, { mode: "edit", requester: null }); canvas = "snapshot" in opened ? opened : undefined; if (canvas) this.referenceStates = new Map( diff --git a/src/backend/editSession.ts b/src/backend/editSession.ts new file mode 100644 index 000000000..6b2588854 --- /dev/null +++ b/src/backend/editSession.ts @@ -0,0 +1,47 @@ +import { json, request } from "./api.ts"; + +export type EditingState = + | { mode: "edit"; requester: string | null } + | { mode: "preview"; handoff: "available" | "occupied" | "requested" | "busy" }; + +export function parseEditingState(value: unknown): EditingState { + if (typeof value === "object" && value !== null && "mode" in value) { + if (value.mode === "edit" && "requester" in value && + (value.requester === null || typeof value.requester === "string")) + return { mode: value.mode, requester: value.requester }; + if (value.mode === "preview" && "handoff" in value && + (value.handoff === "available" || value.handoff === "occupied" || + value.handoff === "requested" || value.handoff === "busy")) + return { mode: value.mode, handoff: value.handoff }; + } + throw new TypeError("Invalid editing session response"); +} + +let current: { projectId: string; state: EditingState } | undefined; +const listeners = new Set<() => void>(); + +export function subscribeEditingState(listener: () => void) { + listeners.add(listener); + return () => { listeners.delete(listener); }; +} + +export function getEditingState(projectId: string) { + return current?.projectId === projectId ? current.state : undefined; +} + +export function installEditingState(projectId: string, state: EditingState) { + const previous = getEditingState(projectId); + if (previous?.mode === "edit" && state.mode === "edit" && previous.requester === state.requester || + previous?.mode === "preview" && state.mode === "preview" && previous.handoff === state.handoff) + return; + current = { projectId, state }; + for (const listener of listeners) listener(); +} + +export async function readEditingState(projectId: string, init?: RequestInit) { + return parseEditingState(await request(`/creation/projects/${projectId}/edit-session`, init)); +} + +export const requestEditing = (projectId: string) => readEditingState(projectId, { method: "POST" }); +export const resolveEditing = (projectId: string, requester: string, accept: boolean) => + readEditingState(projectId, json("PUT", { requester, accept })); diff --git a/src/backend/projects.ts b/src/backend/projects.ts index eb59b69f5..d5e9bcf57 100644 --- a/src/backend/projects.ts +++ b/src/backend/projects.ts @@ -1,3 +1,4 @@ +import { getEditingState, installEditingState } from "./editSession.ts"; import { ApiError, errorMessage, @@ -47,7 +48,7 @@ let recovering: { projectId: string; renewed: Promise } | null = null; setLeaseRecovery((projectId) => { if (recovering?.projectId === projectId) return recovering.renewed; const renewed = serializeSessionChange(async () => { - if (active !== projectId) return false; + if (active !== projectId || getEditingState(projectId)?.mode === "preview") return false; await renewLease(projectId); return active === projectId; }); @@ -64,10 +65,13 @@ setLeaseRecovery((projectId) => { function keepAlive() { if (heartbeat !== undefined) return; heartbeat = window.setInterval(() => { - if (active && !opening) { + if (active && !opening && getEditingState(active)?.mode !== "preview") { const projectId = active; // A pending renewal must finish before an explicit close or project switch. - void serializeSessionChange(() => renewLease(projectId)).catch(() => {}); + void serializeSessionChange(async () => { + if (active !== projectId || getEditingState(projectId)?.mode === "preview") return; + await renewLease(projectId); + }).catch(() => {}); } }, 15000); window.addEventListener("pagehide", () => { @@ -83,7 +87,7 @@ function closeProjectSession(keepalive = false) { }); } -function serializeSessionChange(operation: () => Promise): Promise { +export function serializeSessionChange(operation: () => Promise): Promise { const task = (opening ?? Promise.resolve()).catch(() => {}).then(operation); opening = task; return task.finally(() => { @@ -100,7 +104,7 @@ export function requireActiveBackendProject( const id = backendProjectId(documentId); return serializeSessionChange(async () => { signal.throwIfAborted(); - if (active !== id) + if (active !== id || getEditingState(id)?.mode === "preview") throw new DOMException(tNow("errors.backend.selectionAborted"), "AbortError"); return id; }); @@ -114,6 +118,7 @@ function activateBackendProject( const id = backendProjectId(documentId); return serializeSessionChange(async () => { const previous = active; + const previousMode = previous ? getEditingState(previous) : undefined; const switching = previous && previous !== id; if (switching) { await closeProjectSession(); @@ -123,7 +128,8 @@ function activateBackendProject( try { value = await activate(); } catch (failure) { - if (switching) { + if (switching && previousMode?.mode === "preview") active = previous; + if (switching && previousMode?.mode !== "preview") { try { await request(`/creation/projects/${previous}/open`, { method: "POST", @@ -152,6 +158,7 @@ export function openBackendProject(documentId: string, _title: string) { const id = backendProjectId(documentId); return activateBackendProject(id, async () => { await request(`/creation/projects/${id}/open`, { method: "POST" }); + installEditingState(id, { mode: "edit", requester: null }); return id; }); } @@ -180,11 +187,12 @@ export function openBackendProjectCanvas( const id = backendProjectId(documentId); return serializeSessionChange(async () => { const previous = active; + const previousMode = previous ? getEditingState(previous) : undefined; const startedAt = Date.now(); let value: T; try { value = await read(); - if (Date.now() - startedAt >= LEASE_RECONFIRM_MS) + if (Date.now() - startedAt >= LEASE_RECONFIRM_MS && getEditingState(id)?.mode !== "preview") // Hydration kept the normal heartbeat from running. Renewing here keeps // the lease alive when it outlived the 60 s grant; if another window has // taken over the expired lease the server rejects this renewal and the @@ -197,7 +205,10 @@ export function openBackendProjectCanvas( // rejected until a heartbeat. Move the session back, as a failed switch // does. A renewal rejected because another window took `id` restores // `previous` without taking `id` back. - if (previous && previous !== id) { + if (previous && previous !== id && previousMode?.mode === "preview") { + await closeProjectSession(); + installEditingState(previous, previousMode); + } else if (previous && previous !== id) { try { await request(`/creation/projects/${previous}/open`, { method: "POST", diff --git a/src/backend/workspace.ts b/src/backend/workspace.ts index 96e713d8a..0bedc730a 100644 --- a/src/backend/workspace.ts +++ b/src/backend/workspace.ts @@ -1,3 +1,4 @@ +import { getEditingState } from "./editSession.ts"; import { type CanvasDocument } from "../canvas/model.ts"; import type { CommandReceipt, @@ -280,7 +281,7 @@ export function initializeWorkspace() { const document = await openWorkspaceProject( projects.find((project) => project.id === selected) ?? projects[0]!, ); - await saveWorkspaceDocument(document); + if (getEditingState(document.id)?.mode !== "preview") await saveWorkspaceDocument(document); return document; })().finally(() => { initialization = undefined; diff --git a/src/canvas/AssistantPanel.tsx b/src/canvas/AssistantPanel.tsx index 89cad4bc6..1adf4db51 100644 --- a/src/canvas/AssistantPanel.tsx +++ b/src/canvas/AssistantPanel.tsx @@ -57,6 +57,7 @@ function kindOf(asset: ChatAsset) { /** OpenDirector conversation tools in an OpenDirector floating canvas window. */ export function AssistantPanel({ documentId, + readOnly = false, documentTitle, catalog, nodes, @@ -73,6 +74,7 @@ export function AssistantPanel({ onPrepareReferences, }: { documentId: string; + readOnly?: boolean; documentTitle: string; catalog: BackendModels; nodes: CanvasNode[]; @@ -90,7 +92,7 @@ export function AssistantPanel({ onPrepareReferences: () => Promise; }) { const t = useT(); - const chat = useAssistantChat(documentId, catalog, onTurnEnd, t, open); + const chat = useAssistantChat(documentId, catalog, onTurnEnd, t, open, readOnly); const { value } = chat; const [deepseekLabels, setDeepseekLabels] = useState>({}); const hasDeepseekMessages = value.messages.some((message) => message.runtime === "deepseek"); @@ -141,6 +143,7 @@ export function AssistantPanel({ }, [documentId, chat.loaded, chat.changing, chat.agent?.id, value.runtime, value.runtimeModel, value.thinking, value.builtinModelThinking, onAgentModel]); const locked = + readOnly || !chat.loaded || chat.adding || checkingReferences || @@ -154,7 +157,7 @@ export function AssistantPanel({ const missingAgentModel = needsAgentModel(chat.loaded, currentRuntime, !!chat.agent); const referenceDisabled = !chat.loaded || chat.adding || checkingReferences || chat.sending; - const sessionDisabledReason = chat.changing + const sessionDisabledReason = readOnly ? t("canvas.workspace.preview.mode") : chat.changing ? t("assistant.sessions.disabled.switching") : !chat.loaded ? t("assistant.sessions.disabled.loading") @@ -549,6 +552,7 @@ export function AssistantPanel({
{ event.preventDefault(); pendingReferences.cancel(); diff --git a/src/canvas/CanvasActionsContext.ts b/src/canvas/CanvasActionsContext.ts index 8832d756a..98c360f9c 100644 --- a/src/canvas/CanvasActionsContext.ts +++ b/src/canvas/CanvasActionsContext.ts @@ -5,6 +5,7 @@ import type { TextSelections } from "./TextNodeEditor"; import type { SubjectMediaSlot } from "./subjectMedia.ts"; export interface CanvasActions { + readOnly?: boolean; select: (id: string, event: MouseEvent) => void; reopenComposer: (id: string, event: MouseEvent) => void; update: (id: string, data: Partial) => void; diff --git a/src/canvas/CanvasNodeView.tsx b/src/canvas/CanvasNodeView.tsx index 6dbe5c00e..a09fd9029 100644 --- a/src/canvas/CanvasNodeView.tsx +++ b/src/canvas/CanvasNodeView.tsx @@ -148,6 +148,7 @@ function CanvasNodeContents({ id, data, selected }: NodeProps) { + + + {timeLabel(position)} / {timeLabel(duration)} + + + + seek(Number(event.target.value))} + disabled={!duration} + /> + + ); + return ( void applyTimeline()} - disabled={busy || node.locked || !textInputValid || gesturePending} + disabled={readOnly || busy || node.locked || !textInputValid || gesturePending} error={error} actions={ - <> +
{onPreparePackageImport && ( <> - +
} > {hasTextResources && ( @@ -1361,7 +1509,7 @@ export function TimelineEditor({ } > {libraryShown && ( -