Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(cli): export projects saved by the editor
EtienneLescot766770026449
diff --git a/electron/cli/projectCommands.test.ts b/electron/cli/projectCommands.test.tsindex 0748ad44d..ee09a9261 100644--- a/electron/cli/projectCommands.test.ts+++ b/electron/cli/projectCommands.test.ts@@ -2,6 +2,11 @@ import fs from "node:fs/promises";import os from "node:os";import path from "node:path";import { afterEach, beforeEach, describe, expect, it } from "vitest";+import {+ normalizeProjectEditor,+ PROJECT_VERSION,+} from "../../src/components/video-editor/projectPersistence";+import { migrateProjectDataToAxcutDocument } from "../../src/lib/ai-edition/document/migrate";import { type PackedProjectData, runInfoCommand, runPackCommand } from "./projectCommands";let root = "";@@ -18,6 +23,27 @@ async function writeProject(relative: string, data: PackedProjectData): Promise<return make(relative, JSON.stringify(data));}+/**+ * A project file as the editor saves it: the AxcutDocument itself, one zoom on the timeline, an+ * export format a migrated v2 project left in `legacyEditor`, and a speed region where the editor+ * keeps them (`legacyEditor.speedRegions`).+ */+async function writeDocument(relative: string, screenVideoPath: string): Promise<string> {+ const doc = migrateProjectDataToAxcutDocument({+ version: PROJECT_VERSION,+ media: { screenVideoPath },+ editor: normalizeProjectEditor({+ exportFormat: "gif",+ zoomRegions: [{ id: "z1", startMs: 0, endMs: 1000, depth: 3, focus: { cx: 0.5, cy: 0.5 } }],+ }),+ });+ const speedRegions = [{ id: "s1", startMs: 0, endMs: 500, speed: 2 }];+ return make(+ relative,+ JSON.stringify({ ...doc, legacyEditor: { ...doc.legacyEditor, speedRegions } }),+ );+}+const readProject = async (file: string): Promise<PackedProjectData> =>JSON.parse(await fs.readFile(file, "utf8"));@@ -137,3 +163,38 @@ describe("runInfoCommand", () => {});});});++describe("a project the editor saved", () => {+ it("is described by info from its primary asset", async () => {+ const screen = await make("rec/clip.mp4");+ const project = await writeDocument("saved.openscreen", screen);++ const out = recorder();+ expect(await runInfoCommand(project, true, out.write)).toBe(0);+ expect(JSON.parse(out.text())).toMatchObject({+ version: 8,+ screenVideoPath: screen,+ screenVideoExists: true,+ exportFormat: "gif",+ zoomRegions: 1,+ trimRegions: 0,+ speedRegions: 1,+ });+ });++ it("is reported MISSING by info when its media is gone", async () => {+ const project = await writeDocument("saved.openscreen", path.join(root, "gone", "clip.mp4"));++ const out = recorder();+ expect(await runInfoCommand(project, false, out.write)).toBe(1);+ expect(out.text()).toContain("[MISSING]");+ });++ it("is refused by pack with a reason, not as a project without video", async () => {+ const project = await writeDocument("saved.openscreen", await make("rec/clip.mp4"));++ await expect(+ runPackCommand(project, path.join(root, "packed"), false, recorder().write),+ ).rejects.toThrow("pack does not support projects saved by the editor yet");+ });+});diff --git a/electron/cli/projectCommands.ts b/electron/cli/projectCommands.tsindex 30e211e8c..6866eb92a 100644--- a/electron/cli/projectCommands.ts+++ b/electron/cli/projectCommands.ts@@ -5,6 +5,7 @@import fs from "node:fs/promises";import path from "node:path";+import { isAxcutDocumentFile, parseDocumentFile } from "../../src/lib/ai-edition/schema";/** Writes one already-newline-terminated chunk of CLI output. */export type CliWriter = (text: string) => void;@@ -34,7 +35,16 @@ export async function runPackCommand(};const raw = await fs.readFile(projectPath, "utf8");- const data = JSON.parse(raw) as PackedProjectData;+ const parsed: unknown = JSON.parse(raw);+ // A document can hold several assets, a camera track and imported audio, each with its own+ // path, and the loader's sibling fallback only covers the v2 shape. Say so rather than+ // report that it has no video.+ if (isAxcutDocumentFile(parsed)) {+ throw new Error(+ "pack does not support projects saved by the editor yet, only legacy v2 project files",+ );+ }+ const data = parsed as PackedProjectData;const media = data.media ?? (data.videoPath ? { screenVideoPath: data.videoPath } : undefined);const screenVideoPath = media?.screenVideoPath;if (!screenVideoPath) {@@ -128,11 +138,11 @@ export async function runInfoCommand(out: CliWriter,): Promise<number> {const raw = await fs.readFile(projectPath, "utf8");- const data = JSON.parse(raw) as PackedProjectData;- const editor = data.editor ?? {};- const count = (key: string) =>- Array.isArray(editor[key]) ? (editor[key] as unknown[]).length : 0;- const screenVideoPath = data.media?.screenVideoPath ?? data.videoPath ?? null;+ const parsed: unknown = JSON.parse(raw);+ const fields = isAxcutDocumentFile(parsed)+ ? documentInfoFields(parseDocumentFile(parsed))+ : legacyInfoFields(parsed as PackedProjectData);+ const screenVideoPath = fields.screenVideoPath;const mediaExists = screenVideoPath? await fs.access(screenVideoPath)@@ -142,18 +152,18 @@ export async function runInfoCommand(const summary = {projectPath,- version: data.version ?? null,+ version: fields.version,screenVideoPath,screenVideoExists: mediaExists,- webcamVideoPath: data.media?.webcamVideoPath ?? null,- cursorCaptureMode: data.media?.cursorCaptureMode ?? null,- exportFormat: (editor.exportFormat as string) ?? null,- exportQuality: (editor.exportQuality as string) ?? null,- aspectRatio: (editor.aspectRatio as string) ?? null,- zoomRegions: count("zoomRegions"),- trimRegions: count("trimRegions"),- speedRegions: count("speedRegions"),- annotationRegions: count("annotationRegions"),+ webcamVideoPath: fields.webcamVideoPath,+ cursorCaptureMode: fields.cursorCaptureMode,+ exportFormat: fields.exportFormat,+ exportQuality: fields.exportQuality,+ aspectRatio: fields.aspectRatio,+ zoomRegions: fields.zoomRegions,+ trimRegions: fields.trimRegions,+ speedRegions: fields.speedRegions,+ annotationRegions: fields.annotationRegions,};if (json) {@@ -172,3 +182,65 @@ export async function runInfoCommand(}return summary.screenVideoPath && !mediaExists ? 1 : 0;}++/** What `openscreen info` reports, read off either shape of project file. */+interface ProjectInfoFields {+ /** The v2 `version`, or a document's `schemaVersion`. */+ version: number | null;+ screenVideoPath: string | null;+ webcamVideoPath: string | null;+ cursorCaptureMode: string | null;+ exportFormat: string | null;+ exportQuality: string | null;+ aspectRatio: string | null;+ zoomRegions: number;+ trimRegions: number;+ speedRegions: number;+ annotationRegions: number;+}++const stringOrNull = (value: unknown): string | null => (typeof value === "string" ? value : null);++function legacyInfoFields(data: PackedProjectData): ProjectInfoFields {+ const editor = data.editor ?? {};+ const count = (key: string) =>+ Array.isArray(editor[key]) ? (editor[key] as unknown[]).length : 0;+ return {+ version: data.version ?? null,+ screenVideoPath: data.media?.screenVideoPath ?? data.videoPath ?? null,+ webcamVideoPath: data.media?.webcamVideoPath ?? null,+ cursorCaptureMode: data.media?.cursorCaptureMode ?? null,+ exportFormat: stringOrNull(editor.exportFormat),+ exportQuality: stringOrNull(editor.exportQuality),+ aspectRatio: stringOrNull(editor.aspectRatio),+ zoomRegions: count("zoomRegions"),+ trimRegions: count("trimRegions"),+ speedRegions: count("speedRegions"),+ annotationRegions: count("annotationRegions"),+ };+}++/**+ * A project the editor saved. Its media is the primary asset; the export settings are only+ * there when a migrated v2 project left them in `legacyEditor` (the ExportDialog keeps its own).+ * Speed regions live in `legacyEditor.speedRegions`, not `timeline.speedRanges`: that is where+ * the editor writes them and where the scene reads them (`sceneDescription.ts`).+ */+function documentInfoFields(doc: ReturnType<typeof parseDocumentFile>): ProjectInfoFields {+ const primary =+ doc.assets.find((asset) => asset.id === doc.project.primaryAssetId) ?? doc.assets[0];+ const editor = doc.legacyEditor ?? {};+ return {+ version: doc.schemaVersion,+ screenVideoPath: primary?.originalPath ?? null,+ webcamVideoPath: primary?.cameraTrack?.sourcePath ?? null,+ cursorCaptureMode: null,+ exportFormat: stringOrNull(editor.exportFormat),+ exportQuality: stringOrNull(editor.exportQuality),+ aspectRatio: stringOrNull(editor.aspectRatio),+ zoomRegions: doc.zoomRanges.length,+ trimRegions: doc.timeline.trimRanges.length,+ speedRegions: Array.isArray(editor.speedRegions) ? editor.speedRegions.length : 0,+ annotationRegions: doc.annotations.length,+ };+}diff --git a/electron/ipc/handlers.ts b/electron/ipc/handlers.tsindex fe60a1534..24fcaadb8 100644--- a/electron/ipc/handlers.ts+++ b/electron/ipc/handlers.ts@@ -16,7 +16,11 @@ import {shell,systemPreferences,} from "electron";-import type { AxcutDocument } from "../../src/lib/ai-edition/schema";+import {+ type AxcutDocument,+ isAxcutDocumentFile,+ parseDocumentFile,+} from "../../src/lib/ai-edition/schema";import {type NativeLinuxRecordingRequest,portalCursorMode,@@ -4489,6 +4493,17 @@ export function registerIpcHandlers(const content = await fs.readFile(filePath, "utf-8");const project = await relinkProjectMedia(JSON.parse(content), RECORDINGS_DIR);currentProjectPath = filePath;+ // A document the editor saved grants the media it declares, as when the editor opens+ // it (`approveDocumentMedia`, through `DocumentService.getProject`): this is how the+ // CLI export reads one. A legacy v2 project's media is approved below instead, within+ // the trusted dirs.+ if (isAxcutDocumentFile(project)) {+ try {+ approveDocumentMedia(parseDocumentFile(project));+ } catch {+ // Not a valid document: nothing is granted, and the caller reports the parse error.+ }+ }// Approve session paths but tolerate failures (e.g. video moved outside trusted// dirs) so the project still loads and the renderer can show "video not found".diff --git a/src/cli/CliExportRunner.tsx b/src/cli/CliExportRunner.tsxindex 66fa1d106..653c5ea27 100644--- a/src/cli/CliExportRunner.tsx+++ b/src/cli/CliExportRunner.tsx@@ -7,6 +7,7 @@import { useEffect, useRef, useState } from "react";import {+ type EditorProjectData,normalizeProjectEditor,resolveProjectMedia,toFileUrl,@@ -16,12 +17,11 @@ import type { CursorTelemetryPoint } from "@/components/video-editor/types";import { migrateProjectDataToAxcutDocument } from "@/lib/ai-edition/document/migrate";import {collectEffectiveClipDims,- type Dims,pickExtremeDims,resolveAspectRatioValue,} from "@/lib/ai-edition/document/outputFormat";import { applyProbedDuration } from "@/lib/ai-edition/document/timeline";-import type { AxcutDocument } from "@/lib/ai-edition/schema";+import { type AxcutDocument, isAxcutDocumentFile } from "@/lib/ai-edition/schema";import { getEditorSettings } from "@/lib/ai-edition/store/editorSettings";import { assetCameraSource } from "@/lib/ai-edition/timeline/camera";import { resolveClipSourceEndSec } from "@/lib/ai-edition/timeline/clipDuration";@@ -35,6 +35,7 @@ import { mixVoiceoverIntoVideo } from "@/lib/exporter/voiceoverMix";import { exportGifNative, exportMultiNative, nativeBridgeClient } from "@/native";import type { CompositorClipInput } from "@/native/contracts";import { buildSceneDescription, resolveVisibleClips } from "@/native/sceneDescription";+import { type ExportProject, loadDocumentProject } from "./exportProject";import { clampZoomFocus } from "./vendor/zoomHelpers";const MP4_EXPORT_FPS = 60;@@ -142,15 +143,11 @@ function appendAutoZoomRanges(return suggestions.length;}-async function runExport(request: CliExportRequest): Promise<CliDoneResult> {- const loaded = await nativeBridgeClient.project.loadProjectFileFromPath(request.projectPath);- if (!loaded.success || loaded.project === undefined) {- throw new Error(loaded.error ?? loaded.message ?? "Failed to load project file");- }- if (!validateProjectData(loaded.project)) {- throw new Error("Project file is not a valid .openscreen project");- }- const project = loaded.project;+/**+ * A legacy v2 project (`{ version, media, editor }`), as written before the editor saved the+ * document itself: migrated to an AxcutDocument, with what the migration cannot know probed.+ */+async function loadLegacyProject(project: EditorProjectData): Promise<ExportProject> {const media = resolveProjectMedia(project);if (!media) {throw new Error("Project file does not reference any recorded media");@@ -171,28 +168,6 @@ async function runExport(request: CliExportRequest): Promise<CliDoneResult> {}const editor = normalizeProjectEditor(project.editor ?? {});- const format = request.format ?? editor.exportFormat;- if (request.audioPath && format === "gif") {- throw new Error(- "--audio is only supported for MP4 exports (this project's stored format is gif; pass --format mp4)",- );- }- const quality = request.quality ?? editor.exportQuality;- const gifFrameRate = request.gifFrameRate ?? editor.gifFrameRate;- const gifSizePreset = request.gifSizePreset ?? editor.gifSizePreset;- const outPath =- request.outPath ?? replaceExtension(request.projectPath, format === "gif" ? ".gif" : ".mp4");- // Cursor telemetry: only needed to compute --auto-zoom suggestions. The- // native compositor discovers the `<video>.cursor.json` sidecar itself.- let cursorTelemetry: CursorTelemetryPoint[] = [];- if (request.autoZoom) {- try {- cursorTelemetry = await nativeBridgeClient.cursor.getTelemetry(media.screenVideoPath);- } catch {- cursorTelemetry = [];- }- }-const probed = await probeVideoDimensions(toFileUrl(media.screenVideoPath));// Migrate the .openscreen project onto the AxcutDocument the native@@ -263,16 +238,63 @@ async function runExport(request: CliExportRequest): Promise<CliDoneResult> {}}+ return {+ document: axcutDocument,+ editor,+ screenVideoPath: media.screenVideoPath,+ durationMs: probed.durationMs,+ sourceDims: { width: probed.width, height: probed.height },+ };+}++async function runExport(request: CliExportRequest): Promise<CliDoneResult> {+ const loaded = await nativeBridgeClient.project.loadProjectFileFromPath(request.projectPath);+ if (!loaded.success || loaded.project === undefined) {+ throw new Error(loaded.error ?? loaded.message ?? "Failed to load project file");+ }+ let project: ExportProject;+ if (isAxcutDocumentFile(loaded.project)) {+ project = await loadDocumentProject(loaded.project, (videoPath) =>+ probeVideoDimensions(toFileUrl(videoPath)),+ );+ } else if (validateProjectData(loaded.project)) {+ project = await loadLegacyProject(loaded.project);+ } else {+ throw new Error("Project file is not a valid .openscreen project");+ }+ const { editor, document: axcutDocument } = project;++ const format = request.format ?? editor.exportFormat;+ if (request.audioPath && format === "gif") {+ throw new Error(+ "--audio is only supported for MP4 exports (this project's stored format is gif; pass --format mp4)",+ );+ }+ const quality = request.quality ?? editor.exportQuality;+ const gifFrameRate = request.gifFrameRate ?? editor.gifFrameRate;+ const gifSizePreset = request.gifSizePreset ?? editor.gifSizePreset;+ const outPath =+ request.outPath ?? replaceExtension(request.projectPath, format === "gif" ? ".gif" : ".mp4");+ // Cursor telemetry: only needed to compute --auto-zoom suggestions. The+ // native compositor discovers the `<video>.cursor.json` sidecar itself.+ let cursorTelemetry: CursorTelemetryPoint[] = [];+ if (request.autoZoom) {+ try {+ cursorTelemetry = await nativeBridgeClient.cursor.getTelemetry(project.screenVideoPath);+ } catch {+ cursorTelemetry = [];+ }+ }+if (request.autoZoom) {- const added = appendAutoZoomRanges(axcutDocument, cursorTelemetry, probed.durationMs);+ const added = appendAutoZoomRanges(axcutDocument, cursorTelemetry, project.durationMs);window.electronAPI.cliLog("info", `Auto-zoom: added ${added} region(s) from cursor telemetry`);}// Output sizing mirrors the ExportDialog: crop-aware smallest clip on the// timeline, normalized to the document's aspect ratio.const smallestSource =- pickExtremeDims(collectEffectiveClipDims(axcutDocument), "smallest") ??- ({ width: probed.width, height: probed.height } as Dims);+ pickExtremeDims(collectEffectiveClipDims(axcutDocument), "smallest") ?? project.sourceDims;const aspectRatioValue = resolveAspectRatioValue(axcutDocument,getEditorSettings(axcutDocument).aspectRatio,diff --git a/src/cli/exportProject.test.ts b/src/cli/exportProject.test.tsnew file mode 100644index 000000000..da4156882--- /dev/null+++ b/src/cli/exportProject.test.ts@@ -0,0 +1,102 @@+import { describe, expect, it, vi } from "vitest";+import {+ normalizeProjectEditor,+ PROJECT_VERSION,+ validateProjectData,+} from "@/components/video-editor/projectPersistence";+import { migrateProjectDataToAxcutDocument } from "@/lib/ai-edition/document/migrate";+import { isAxcutDocumentFile } from "@/lib/ai-edition/schema";+import { loadDocumentProject, type VideoProbe } from "./exportProject";++const SCREEN = "/recordings/screen.mp4";++const v2Project = (editor: Record<string, unknown> = {}) => ({+ version: PROJECT_VERSION,+ media: { screenVideoPath: SCREEN },+ editor,+});++/**+ * A project file as the editor writes it: the AxcutDocument itself, JSON round-tripped, its+ * primary asset carrying the dimensions and duration the editor probed on import, and `settings`+ * written straight into `legacyEditor`, where the editor keeps them.+ */+function savedDocument(settings: Record<string, unknown> = {}, schemaVersion?: number) {+ const migrated = migrateProjectDataToAxcutDocument({+ ...v2Project(),+ editor: normalizeProjectEditor({}),+ });+ const doc = { ...migrated, legacyEditor: { ...migrated.legacyEditor, ...settings } };+ const assets = doc.assets.map((asset) => ({+ ...asset,+ durationSec: 12,+ video: { codec: "h264", fps: 60, width: 1920, height: 1080 },+ }));+ const raw = JSON.parse(JSON.stringify({ ...doc, assets })) as Record<string, unknown>;+ if (schemaVersion !== undefined) raw.schemaVersion = schemaVersion;+ return raw;+}++const noProbe: VideoProbe = () =>+ Promise.reject(new Error("probed a video the document describes"));++describe("the project file shapes the CLI export reads", () => {+ it("tells a saved document from a legacy v2 project", () => {+ expect(isAxcutDocumentFile(savedDocument())).toBe(true);+ expect(isAxcutDocumentFile(v2Project())).toBe(false);+ // The v2 validator is what rejected every document before: it must stay out of their way.+ expect(validateProjectData(savedDocument())).toBe(false);+ expect(validateProjectData(v2Project())).toBe(true);+ expect(isAxcutDocumentFile(null)).toBe(false);+ expect(isAxcutDocumentFile({ schemaVersion: 8 })).toBe(false);+ });+});++describe("loadDocumentProject", () => {+ it("reads the media, length and size off the document without probing", async () => {+ const project = await loadDocumentProject(savedDocument(), noProbe);+ expect(project.screenVideoPath).toBe(SCREEN);+ expect(project.durationMs).toBe(12_000);+ expect(project.sourceDims).toEqual({ width: 1920, height: 1080 });+ expect(project.document.assets[0]?.originalPath).toBe(SCREEN);+ });++ it("keeps what the editor saved, the frame included", async () => {+ const project = await loadDocumentProject(+ savedDocument({ frame: "phone", padding: 30, exportFormat: "gif", exportQuality: "source" }),+ noProbe,+ );+ expect(project.document.legacyEditor).toMatchObject({ frame: "phone", padding: 30 });+ expect(project.editor).toMatchObject({ exportFormat: "gif", exportQuality: "source" });+ });++ it("upgrades an older schemaVersion the way the editor does on open", async () => {+ const raw = savedDocument({}, 7);+ delete (raw.legacyEditor as Record<string, unknown>).aspectRatio;+ const project = await loadDocumentProject(raw, noProbe);+ expect(project.document.schemaVersion).toBe(8);+ expect(project.document.legacyEditor?.aspectRatio).toBe("16:9");+ });++ it("probes the recording only when the document lacks its size or length", async () => {+ const raw = savedDocument();+ const assets = raw.assets as Record<string, unknown>[];+ raw.assets = assets.map(({ video: _video, ...asset }) => asset);+ const probe = vi+ .fn<VideoProbe>()+ .mockResolvedValue({ width: 1280, height: 720, durationMs: 4000 });+ const project = await loadDocumentProject(raw, probe);+ expect(probe).toHaveBeenCalledWith(SCREEN);+ expect(project.sourceDims).toEqual({ width: 1280, height: 720 });+ expect(project.durationMs).toBe(4000);+ });++ it("refuses a document with no media, and one that does not validate", async () => {+ await expect(loadDocumentProject({ ...savedDocument(), assets: [] }, noProbe)).rejects.toThrow(+ "does not reference any recorded media",+ );+ await expect(+ loadDocumentProject({ ...savedDocument(), project: null }, noProbe),+ ).rejects.toThrow();+ });+});diff --git a/src/cli/exportProject.ts b/src/cli/exportProject.tsnew file mode 100644index 000000000..ad762becf--- /dev/null+++ b/src/cli/exportProject.ts@@ -0,0 +1,61 @@+// What `openscreen export` reads from a project file, and the loader for the shape the editor+// saves (the AxcutDocument itself). Kept out of CliExportRunner.tsx so it is testable without a+// renderer: the one thing it needs from the DOM, reading a video's metadata, is passed in.++import {+ normalizeProjectEditor,+ type ProjectEditorState,+} from "@/components/video-editor/projectPersistence";+import type { Dims } from "@/lib/ai-edition/document/outputFormat";+import { type AxcutDocument, parseDocumentFile } from "@/lib/ai-edition/schema";++/** Reads a video file's dimensions and duration. */+export type VideoProbe = (+ videoPath: string,+) => Promise<{ width: number; height: number; durationMs: number }>;++/** What the export reads from a project file, whichever shape it was saved in. */+export interface ExportProject {+ document: AxcutDocument;+ /** The v2 editor fields the export reads: format, quality and the GIF settings. */+ editor: ProjectEditorState;+ /** The primary screen recording, where `--auto-zoom` looks up the cursor telemetry. */+ screenVideoPath: string;+ /** Its length in ms, the span `--auto-zoom` suggests zooms over. */+ durationMs: number;+ /** The output size when no clip on the timeline reports one. */+ sourceDims: Dims;+}++/**+ * A project the editor saved: the AxcutDocument itself, at any `schemaVersion`, upgraded and+ * validated as the editor's "Browse files…" does. The main process has already relinked moved+ * media and granted the paths the document declares, as when the editor opens it. Its assets+ * carry their own dimensions and duration, so nothing is migrated and nothing is probed unless+ * an asset lacks them.+ *+ * The ExportDialog keeps format, quality and the GIF settings in its own state, not in the+ * document: they are read from `legacyEditor` when a migrated v2 project left them there, and+ * otherwise take the same defaults as a v2 project. The command-line flags win either way.+ */+export async function loadDocumentProject(raw: unknown, probe: VideoProbe): Promise<ExportProject> {+ const document = parseDocumentFile(raw);+ const primary =+ document.assets.find((asset) => asset.id === document.project.primaryAssetId) ??+ document.assets[0];+ if (!primary?.originalPath) {+ throw new Error("Project file does not reference any recorded media");+ }+ const { video, durationSec } = primary;+ const known = video && video.width > 0 && video.height > 0 && (durationSec ?? 0) > 0;+ const probed = known ? null : await probe(primary.originalPath);+ return {+ document,+ editor: normalizeProjectEditor((document.legacyEditor ?? {}) as Partial<ProjectEditorState>),+ screenVideoPath: primary.originalPath,+ durationMs: probed ? probed.durationMs : (durationSec ?? 0) * 1000,+ sourceDims: probed+ ? { width: probed.width, height: probed.height }+ : { width: video?.width ?? 0, height: video?.height ?? 0 },+ };+}diff --git a/src/lib/ai-edition/schema/index.ts b/src/lib/ai-edition/schema/index.tsindex 8f1484151..8bdc08bf2 100644--- a/src/lib/ai-edition/schema/index.ts+++ b/src/lib/ai-edition/schema/index.ts@@ -1030,6 +1030,21 @@ export function migrateRawDocumentToCurrent(raw: unknown): unknown {// single `z.literal(8)` + shape check.export const documentSchema = documentSchemaShape;+/**+ * Whether a parsed `.openscreen` file is an AxcutDocument — what the editor saves, at any+ * `schemaVersion` — rather than a legacy v2 `{ version, media, editor }` project, which must go+ * through `migrateProjectDataToAxcutDocument` instead (it reads `.media` / `.editor` and would+ * yield an empty document from a current one).+ */+export function isAxcutDocumentFile(raw: unknown): raw is Record<string, unknown> {+ return typeof raw === "object" && raw !== null && "schemaVersion" in raw && "timeline" in raw;+}++/** A document read from a file, at any supported `schemaVersion`: upgraded, then validated. */+export function parseDocumentFile(raw: unknown): AxcutDocument {+ return documentSchema.parse(migrateRawDocumentToCurrent(raw));+}+export const createProjectInputSchema = z.object({title: z.string().trim().min(1).default("Untitled Project"),});diff --git a/technical-documentation/testing/manual-e2e-checklist.md b/technical-documentation/testing/manual-e2e-checklist.mdindex 4988ad2ac..9f5461637 100644--- a/technical-documentation/testing/manual-e2e-checklist.md+++ b/technical-documentation/testing/manual-e2e-checklist.md@@ -638,3 +638,4 @@ The mask comes from the native compositor (ONNX Runtime + the vendored selfie-se| 2026-09-25 | `claude/ratio-auto-screen-studio-df6b2e` (Auto format), tree of `ace7af33` + `972f8cf3` before the default flip; the test projects state `auto` explicitly, so the flip does not change them. `compositor_view.node` not rebuilt (no Rust change in the PR): the 2026-09-24 22:17 build from `zoom-speed-adjustment-fb8abd`, its whole `bin/win32-x64` directory copied aside and loaded through `OPENSCREEN_COMPOSITOR_VIEW_NODE`; renderer rebuilt with `npm run build-vite` | Windows 11 26200, NVENC export | Partial — no defect | **Auto format, preview geometry and real export.** Preview: the renderer in browser mode (`vite-dev`, `?windowType=editor`), 4:3 fixture `tests/fixtures/sample.webm` with `website/static/video/webcam.mp4` as camera, padding 50, geometry read from the DOM. Fixed 16:9 + top / bottom left 265 px empty per side against 42 px on top; Auto gave a portrait 259×418 frame, square 207×207 camera, 26 px on all four sides. Side by side, padding 0 → 100: frame 2.36 → 1.82, border 0 → 84 px, camera square throughout. Fixed 16:9 side by side gave a 4:5 camera and the block at 80 % of the width, which is the old formula's answer (computed, not re-measured on the old build). Export: `electron . export <project> -o <mp4> --quality source`, synthetic 1280×720 blue screen and 640×480 green camera, wallpaper `#303030`, padding 50, roundness and shadow 0, frame at 1.5 s parsed as PPM. Top / bottom 858×1258, camera 687×686, margins 86/86/85/86; side by side 1240×506, camera 405×406, margins 50 on all sides; PiP 1194×736, screen margins 74/74/74/76. **Not run:** the real Electron editor window (preview checked in browser mode only), the native live preview, the default flip on a fresh recording (unit tests only), a non-English Format menu, macOS and Linux. || 2026-09-25 | worktree `zoom-overflow-layouts-698eb0`, `claude/zoom-overflow-layouts-698eb0` on `ff3c3f51` + the slot-mask change; `compositor_view.node` rebuilt from this tree (`cargo build -p compositor-view-napi --release`), baseline addon built the same way from `ff3c3f51`; ffmpeg DLLs hash-identical to the vendored SDK; renderer rebuilt with `npm run build-vite` | Windows 11 26200, NVENC export | Partial — no defect | **The block layouts' screen slot masks the zoom and the 3D (overflow hidden), through the app's real export (`electron . export <project> -o <mp4>`).** Source: synthetic 1920×1080 `testsrc2` screen and 1280×720 bars webcam, 4 s. Legacy 16:9 projects, padding 50 %, a depth-4 (2.2×) zoom at focus (0.3, 0.6) on [0.5 s, 3.5 s], frame at 2 s. `dual-frame`: the baseline addon spills the zoomed screen under the camera and off the frame; the new one crops it to its rounded slot, camera and gap untouched. `dual-frame` + `iso`: the footage tilts as in any layout and the slot, which stays upright, crops it; where the tilted footage leaves the slot, the wallpaper shows and the shadow follows the visible part. `picture-in-picture`: the whole export is bit-identical between the two addons (PSNR inf on all 240 frames). D3D11 frames through `live::Player`, the preview engine, also checked `vertical-stack`, the `right` preset and the `follow-cursor` camera. **Not covered:** the GUI editor preview (same `plan_frame`, not driven), a window or device frame in a block layout (left unmasked), privacy blur and click impacts in a slot (unit-tested only), macOS and Linux rendering (WGSL validated with naga, Metal not compiled). || 2026-09-26 | worktree `motion-blur-padding-issue-11befb`, `claude/motion-blur-padding-issue-11befb` on `1a669c22` (#794); `compositor_view.node` built from this tree (`cargo build -p compositor-view-napi --release`), baseline addon built the same way from `218bdbb0` (`main`); ffmpeg DLLs hash-identical to the vendored SDK; renderer rebuilt with `npm run build-vite`, plus a local, uncommitted pass-through of `editor.frame` in `normalizeProjectEditor` (the v2 CLI path drops it) | Windows 11 26200, NVENC export | Partial — one defect found and fixed | **Motion blur of the framed screen, through the app's real export (`electron . export <project> -o <mp4>`).** Legacy 16:9 project: phone frame, padding 50, motion blur 1, shadow 0.6, a depth-3 zoom on [3 s, 8 s]; sources: synthetic 1920×1080 `testsrc2`, then solid red and solid green to isolate the footage (red/green difference). Static frames: only encoder noise between the two addons. Ramps (60 fps frames 132 and 501): the baseline keeps the shell's rim and bezel razor-sharp around a smeared picture; the new addon smears them with it (87–109k px of shell and shadow change that are never footage). Footage outside the union of the sharp apertures at n−1 and n, +2 px: **1,185 px** on one frame at first (a ~20 % tint over the bezel in the four output corners, where the phone overflows the output), fixed in `1a669c22`, then **0 px over all 55 moving frames**. **Not covered:** the GUI editor preview (same compositor path, not driven), window chrome and laptop/monitor frames on this machine (window chrome covered by the Linux lavapipe test), macOS (Metal not compiled here). |+| 2026-09-26 | worktree `motion-blur-padding-issue-11befb`, branch `claude/cli-export-documents` on `218bdbb0` + this change; renderer rebuilt with `npm run build-vite`; `compositor_view.node` the one in the worktree's `electron/native/bin/win32-x64` (loading, not rendering, was under test) | Windows 11 26200, NVENC export | Partial — no defect | **`openscreen export` on a project saved by the editor, through the app's real CLI (`electron . export <project> -o <mp4> --json`).** Before: a copy of a real schema-7 editor project (`%APPDATA%/openscreen/projects/proj_741d2d06…`, monitor frame, 2 zooms with a 3D camera, 2 trims, speed regions ×5 and ×2 in `legacyEditor`) failed at once with `Project file is not a valid .openscreen project`. After: exported in 34 s, 1920×1080 60 fps, **21.62 s against 21.58 s expected** (38.25 s − 4.60 s of trims − 9.44 s and 2.63 s taken by the two speed regions); the frame at 2 s shows the zoomed, tilted screen inside the monitor bezel. `info` on the same copy: version 8 after the load-time upgrade, the recording found, 2 zooms, 2 trims (its speed count, read from `legacyEditor.speedRegions`, was fixed after this run and is covered by `projectCommands.test.ts`). `pack` refuses it with `pack does not support projects saved by the editor yet`. A legacy v2 project (synthetic 4 s `testsrc2`, one zoom) still exports: 4.00 s. The original project file was only copied, hash-identical afterwards. **Not covered:** `pack` for documents (refused, not implemented), `captions` (its runner still reads v2 only), a document whose media moved (relink is the editor's own, unit-tested there), macOS and Linux. |