AI media harness for planning, generating, and editing locally
TypeScript
Rebuild Export as a docked form with a background run
Bitti184ef2a33654
diff --git a/src/components/workspace/ExportView.test.tsx b/src/components/workspace/ExportView.test.tsxindex 5621546..27909b7 100644--- a/src/components/workspace/ExportView.test.tsx+++ b/src/components/workspace/ExportView.test.tsx@@ -1,15 +1,19 @@// @vitest-environment jsdom-import { act, cleanup, fireEvent, render, screen, within } from "@testing-library/react";+import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";import { afterEach, describe, expect, it, vi } from "vitest";import audioFixture from "../../../fixtures/project-v1-audio-mix.json";import externalFixture from "../../../fixtures/project-v1-external-media.json";import { createProjectConfig, parseProjectConfig, type ProjectConfig, type TimelineClip } from "../../lib/project";+import { resetExportJobForTests, setExportJobForTests } from "../../lib/exportJob";import { ExportView } from "./ExportView";vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));-afterEach(cleanup);+afterEach(() => {+ cleanup();+ act(() => resetExportJobForTests());+});const clip = (id: string, startMs: number, durationMs: number): TimelineClip => ({id, assetId: `asset-${id}`, trackId: "track-story", startMs, durationMs,@@ -33,13 +37,14 @@ function project(clips: TimelineClip[]): ProjectConfig {};}+const exportButton = () => screen.getByRole("button", { name: "Export" }) as HTMLButtonElement;+/* These run in jsdom, which has neither WebCodecs nor a Tauri shell — the exactconditions the view has to be honest about rather than paper over. */describe("the export view where nothing can encode", () => {it("refuses to offer an export it cannot perform, and says why", () => {render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);- const button = screen.getByRole("button", { name: /export video/i }) as HTMLButtonElement;- expect(button.disabled).toBe(true);+ expect(exportButton().disabled).toBe(true);const reasons = screen.getByRole("alert").textContent ?? "";expect(reasons).toContain("browser preview");expect(reasons).toContain("WebCodecs");@@ -47,23 +52,17 @@ describe("the export view where nothing can encode", () => {it("says why there is no picture rather than showing an empty stage as though it were one", () => {render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);- // The preview is the same player the timeline uses, and in a browser there- // is no project folder for it to read the footage from.expect(screen.getByText(/Playback needs the desktop app/i)).toBeTruthy();expect(document.querySelector("canvas")?.style.visibility).toBe("hidden");- // The controls are there and are honest about what they can do: there IS- // something on this timeline, so play is offered.expect((screen.getByRole("button", { name: "Play" }) as HTMLButtonElement).disabled).toBe(false);- expect(screen.getByRole("button", { name: "Watch fullscreen" })).toBeTruthy();+ expect(screen.getByRole("button", { name: "Full screen" })).toBeTruthy();});it("states the real duration of the planned file", () => {render(<ExportView config={project([clip("a", 0, 2_000), clip("b", 2_000, 1_000)])} folderPath="/tmp/project" />);expect(within(screen.getByText("Duration").parentElement!).getByText("00:03.000")).toBeTruthy();expect(screen.getByText("72 frames at 24 fps")).toBeTruthy();- /* The frame size is named where it is CHOSEN — in the resolution select —- rather than repeated in a summary row beside it. */- expect((screen.getByLabelText("Resolution") as HTMLSelectElement).selectedOptions[0].textContent).toBe("1920 × 1080");+ expect(screen.getByRole("combobox", { name: "Resolution" }).textContent).toContain("1920 × 1080");});it("says outright that a timeline with no audio clips produces no sound", () => {@@ -74,96 +73,132 @@ describe("the export view where nothing can encode", () => {it("blocks on an empty timeline rather than offering to render nothing", () => {render(<ExportView config={project([])} folderPath="/tmp/project" />);expect(screen.getByRole("alert").textContent).toContain("no video clips");- expect(screen.getByText(/nothing on the timeline yet/i)).toBeTruthy();- // Nothing to play, and the transport says so instead of sitting live.+ expect(screen.getByText("Nothing on the timeline yet")).toBeTruthy();expect((screen.getByRole("button", { name: "Play" }) as HTMLButtonElement).disabled).toBe(true);});- it("puts the one control the screen exists for beside its title", () => {- const { container } = render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);- const heading = container.querySelector(".export-heading")!;- expect(within(heading as HTMLElement).getByRole("button", { name: /export video/i })).toBeTruthy();- });-- it("says none of the prose it used to carry about how exporting works", () => {- const { container } = render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);- for (const gone of ["True of this export", "opens your computer", "this project’s original size"]) {- expect(container.textContent, gone).not.toContain(gone);- }- // And none of the summary rows that repeated a setting back at the user.- for (const row of ["Clips", "Frame", "Bitrate"]) {- expect(within(container.querySelector(".export-summary") as HTMLElement).queryByText(row)).toBeNull();- }+ it("changes a setting through its combo box", () => {+ render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);+ fireEvent.click(screen.getByRole("combobox", { name: "Frame rate" }));+ fireEvent.click(screen.getByRole("option", { name: "30 fps" }));+ expect(screen.getByText("60 frames at 30 fps")).toBeTruthy();});});-/* The screen used to size its own preview from whatever was under the playhead- and to confirm a finished export with a panel in the bottom corner naming the- path, the size, the codec and the compositor. */describe("the shape of the export screen", () => {- it("names its two panels after what they hold", () => {- const { container } = render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);- expect(screen.queryByRole("heading", { name: "Video" })).toBeNull();+ it("is a docked form: preview, a settings column, and a footer with the actions", () => {+ const { container } = render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" onClose={() => undefined} />);expect(screen.getByRole("region", { name: "Video preview" })).toBeTruthy();expect(screen.getByRole("heading", { name: "Settings" })).toBeTruthy();- expect(screen.queryByRole("heading", { name: "Preview" })).toBeNull();- expect(screen.queryByRole("heading", { name: "Export Settings" })).toBeNull();- expect(screen.queryByRole("heading", { name: "What this export will be" })).toBeNull();- expect(container.querySelector(".export-details > .export-summary")).toBeTruthy();+ const footer = container.querySelector(".export-footer") as HTMLElement;+ expect(within(footer).getAllByRole("button").map((button) => button.textContent)).toEqual(["Cancel", "Export"]);+ // No hero title on the page, and labels in sentence case.+ expect(container.querySelector("h1")?.classList.contains("sr-only")).toBe(true);+ expect(screen.getByText("Save to")).toBeTruthy();+ expect(screen.queryByText("Container & codec")).toBeNull();});it("gives the estimated size as a size and nothing else", () => {const { container } = render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);- const row = within(container.querySelector(".export-summary") as HTMLElement)- .getByText("Estimated size").parentElement!;+ const row = within(container.querySelector(".export-summary") as HTMLElement).getByText("Estimated size").parentElement!;expect(row.querySelector("dd")!.textContent).toMatch(/^[\d.]+ [KMG]?B$/);expect(row.querySelector("dd small")).toBeNull();});- /* A portrait still on the timeline used to make this box tall and the next- video clip shrank it back, because the stage had no size of its own and- took the intrinsic shape of whatever was playing. The export writes ONE- frame size for the whole file. */- it("sizes the stage from the export plan rather than from the media under the playhead", () => {+ it("sizes the picture from the export plan rather than from the media under the playhead", () => {const portrait = project([clip("a", 0, 2_000)]);portrait.assets[0] = { ...portrait.assets[0], kind: "image", mimeType: "image/png", width: 1080, height: 1920 };const { container } = render(<ExportView config={portrait} folderPath="/tmp/project" />);- const stage = container.querySelector(".export-stage") as HTMLElement;- // The project is 16:9 at 1080p; the picture inside it is not.- expect(stage.style.aspectRatio).toBe("1920 / 1080");+ expect((container.querySelector(".export-picture") as HTMLElement).style.aspectRatio).toBe("1920 / 1080");});- it("embeds playback controls over the video and hides them when the pointer rests", () => {+ it("puts a fixed transport bar under the picture while windowed", () => {vi.useFakeTimers();try {const { container } = render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);const stage = container.querySelector(".export-stage") as HTMLElement;const controls = screen.getByRole("group", { name: "Video playback controls" });- expect(stage.contains(controls)).toBe(true);- expect(stage.classList.contains("export-stage--controls-visible")).toBe(false);-+ expect(controls.previousElementSibling?.classList.contains("export-picture")).toBe(true);+ expect(Array.from(controls.querySelectorAll("button")).map((button) => button.getAttribute("aria-label")))+ .toEqual(["Go to start", "Previous frame", "Play", "Next frame", "Go to end", "Full screen"]);+ // Windowed, nothing hides: the pointer resting changes nothing.fireEvent.pointerMove(stage);- expect(stage.classList.contains("export-stage--controls-visible")).toBe(true);- act(() => vi.advanceTimersByTime(1_800));+ act(() => vi.advanceTimersByTime(2_000));expect(stage.classList.contains("export-stage--controls-visible")).toBe(false);+ expect(controls.textContent).toContain("00:00:00:00 / 00:00:02:00");} finally {vi.useRealTimers();}});- it("says nothing about a finished export until there is one", () => {- const { container } = render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);- expect(container.querySelector(".export-toast")).toBeNull();- // And the notification lives in the header, not at the foot of the settings- // column where the old panel sat.- expect(container.querySelector(".export-heading .export-toast-slot")).toBeTruthy();+ it("steps one frame at a time and prints the frame it landed on", () => {+ render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);+ fireEvent.click(screen.getByRole("button", { name: "Next frame" }));+ fireEvent.click(screen.getByRole("button", { name: "Next frame" }));+ expect(screen.getByRole("group", { name: "Video playback controls" }).textContent).toContain("00:00:00:02 /");+ fireEvent.click(screen.getByRole("button", { name: "Go to end" }));+ expect(screen.getByRole("group", { name: "Video playback controls" }).textContent).toContain("00:00:01:23 /");+ });+});++describe("a run in progress and a finished one", () => {+ it("shows percent, time remaining and the frame being encoded", () => {+ act(() => setExportJobForTests({+ folderPath: "/tmp/project",+ destination: "C:\\Videos\\Northern Light.mp4",+ progress: { phase: "rendering", framesDone: 30, frameCount: 72, detail: "Rendering frame 30 of 72." },+ remainingMs: 72_000,+ }));+ render(<ExportView config={project([clip("a", 0, 3_000)])} folderPath="/tmp/project" />);+ expect(screen.getByRole("status").textContent).toContain("42% · 1:12 remaining · Encoding frame 30 of 72");+ expect(screen.getByRole("progressbar")).toBeTruthy();+ expect(screen.getByRole("button", { name: "Exporting…" })).toHaveProperty("disabled", true);+ expect(screen.getByRole("button", { name: "Cancel" })).toBeTruthy();+ });++ it("keeps saying where the file went until it is dismissed", () => {+ act(() => setExportJobForTests({+ folderPath: "/tmp/project",+ outcome: { kind: "saved", path: "C:\\Videos\\Northern Light.mp4", bytes: 1_000, audioProblems: [], audioShortfalls: [] },+ }));+ render(<ExportView config={project([clip("a", 0, 3_000)])} folderPath="/tmp/project" />);+ expect(screen.getByText("Exported to C:\\Videos\\Northern Light.mp4")).toBeTruthy();+ expect(screen.getByRole("button", { name: "Open" })).toBeTruthy();+ expect(screen.getByRole("button", { name: "Show in folder" })).toBeTruthy();+ fireEvent.click(screen.getByRole("button", { name: "Close" }));+ expect(screen.queryByText(/Exported to/)).toBeNull();+ });++ it("does not claim another project's run", () => {+ act(() => setExportJobForTests({+ folderPath: "/tmp/other",+ progress: { phase: "rendering", framesDone: 1, frameCount: 10, detail: "" },+ }));+ render(<ExportView config={project([clip("a", 0, 3_000)])} folderPath="/tmp/project" />);+ expect(screen.queryByRole("status")).toBeNull();+ expect(screen.getByRole("alert").textContent).toContain("Another project is exporting");+ });+});++describe("where the file goes", () => {+ it("shows the default destination Rust proposes before any dialog", async () => {+ const { invoke } = await import("@tauri-apps/api/core");+ (window as unknown as Record<string, unknown>).__TAURI_INTERNALS__ = {};+ vi.mocked(invoke).mockImplementation(async (command: string) => (+ command === "default_export_destination" ? { path: "C:\\Users\\NN\\Videos\\Northern Light.mp4", exists: false } : null+ ) as never);+ try {+ render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);+ await waitFor(() => expect(screen.getByText("C:\\Users\\NN\\Videos\\Northern Light.mp4")).toBeTruthy());+ expect(vi.mocked(invoke)).toHaveBeenCalledWith("default_export_destination", { suggestedName: "Northern Light.mp4" });+ expect(screen.getByRole("button", { name: "Browse…" })).toBeTruthy();+ } finally {+ delete (window as unknown as Record<string, unknown>).__TAURI_INTERNALS__;+ vi.mocked(invoke).mockReset();+ }});});-/* The other half of the media policy: video is NOT copied into the project, so- a real timeline's clips carry an absolute source path and no relative one.- The page has to plan such a project exactly as it plans any other — the- previous build did, and then the run died on the first read. */describe("the export view on media the project does not contain", () => {const external = () => parseProjectConfig(externalFixture);@@ -177,14 +212,10 @@ describe("the export view on media the project does not contain", () => {});});-/* The mix is built whole in memory before the file is opened and held until the- last frame — 23 MB a minute, 1.4 GB for an hour — and the panel that states- bitrate, size estimate, compositor and codec said nothing at all about it. */describe("what the page says the soundtrack will cost", () => {const withAudioSupport = (body: () => void) => {const scope = globalThis as unknown as Record<string, unknown>;const saved = { AudioEncoder: scope.AudioEncoder, AudioData: scope.AudioData, OfflineAudioContext: scope.OfflineAudioContext };- // detectExportSupport asks for exactly these three; nothing here calls them.scope.AudioEncoder = class {};scope.AudioData = class {};scope.OfflineAudioContext = class {};@@ -201,15 +232,12 @@ describe("what the page says the soundtrack will cost", () => {it("states the memory the mix holds, next to the bitrate and the size estimate", () => {withAudioSupport(() => {render(<ExportView config={parseProjectConfig(audioFixture)} folderPath="D:\\tmp\\harbour" />);- // Two clips on an unmuted audio track; the third is on a muted one.expect(screen.getByText("AAC · 2 clips mixed")).toBeTruthy();expect(screen.getByText(/1\.5 MB of memory held while it renders/)).toBeTruthy();});});it("says nothing about a mix it is not going to make", () => {- // No AudioEncoder here, so there is no mix and no memory to disclose —- // stating a cost that will not be paid would be its own kind of lie.render(<ExportView config={parseProjectConfig(audioFixture)} folderPath="D:\\tmp\\harbour" />);expect(screen.getByText("this webview has no AudioEncoder")).toBeTruthy();expect(screen.queryByText(/of memory held while it renders/)).toBeNull();@@ -219,12 +247,8 @@ describe("what the page says the soundtrack will cost", () => {describe("what the page claims about the compositor", () => {it("does not promise WebGPU before anything has asked for an adapter", async () => {render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);- // jsdom has no navigator.gpu, so the settled answer is the 2D canvas with a- // stated reason. What must never appear is a bare WebGPU promise.expect(await screen.findByText(/no navigator\.gpu/i)).toBeTruthy();expect(screen.queryByText("WebGPU")).toBeNull();- // The heading no longer carries a prose paragraph; the compositor row is- // where the settled answer is stated now.expect(document.body.textContent).toContain("2D canvas");});});diff --git a/src/components/workspace/ExportView.tsx b/src/components/workspace/ExportView.tsxindex d10982a..fd4de16 100644--- a/src/components/workspace/ExportView.tsx+++ b/src/components/workspace/ExportView.tsx@@ -1,4 +1,4 @@-import { CircleCheck, Download, Maximize, Minimize, Pause, Play, SkipBack, SkipForward, TriangleAlert, X } from "lucide-react";+import { ChevronFirst, ChevronLast, Maximize, Minimize, Pause, Play, StepBack, StepForward } from "lucide-react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import {audioMixBytes,@@ -19,22 +19,31 @@ import {} from "../../lib/export";import {chooseExportDestination,+ defaultExportDestination,detectExportSupport,- ExportCancelled,+ exportDestinationExists,+ openExportFile,probeAllCodecs,probeCompositor,- runExport,- writeExportFile,type CodecProbe,type CompositorProbe,- type ExportProgress,} from "../../lib/exportPipeline";+import {+ cancelExportJob,+ dismissExportOutcome,+ exportFraction,+ startExportJob,+ useExportJob,+} from "../../lib/exportJob";+import { askNative, messageNative, revealInExplorer } from "../../lib/nativeShell";+import { formatTimecode, frameAt, frameStartMs } from "../../lib/timeline";import { ProgramMonitor } from "./ProgramMonitor";import { PROJECT_RESOLUTIONS, type ProjectConfig, type Resolution } from "../../lib/project";+import { ComboBox, InfoBar, ProgressBar, Slider, tooltipProps } from "../ui";/* The ladder a project can be created at, plus the project's own size when thatis one of the names from before the ladder was rebuilt. Dropping the legacy- rung outright would leave a 1080p project looking at a select that does not+ rung outright would leave a 1080p project looking at a list that does notcontain what the project IS, and the first touch of any other field wouldhave quietly resized the export. */const resolutionChoices = (current: Resolution): Resolution[] =>@@ -44,23 +53,38 @@ const resolutionChoices = (current: Resolution): Resolution[] =>const FRAME_RATES: FrameRate[] = [24, 25, 30, 60];const describe = (reason: unknown) => (reason instanceof Error ? reason.message : String(reason));-/** How long the Saved notification stays up before it takes itself away. */-const SAVED_NOTICE_MS = 4_000;-/** A moving pointer reveals the transport; once it rests, the picture gets the- * full frame again. Long enough to cross the controls without racing them. */+/** In fullscreen a moving pointer reveals the transport; once it rests, the+ * picture gets the whole screen again. Windowed, the bar is always there. */const PLAYER_CONTROLS_IDLE_MS = 1_800;-/* What the finished run left OUT of the soundtrack. Everything else an export- used to report on the page — path, size, codec, compositor — is gone: the- confirmation is a notification that says Saved and then leaves. These two- lists are not a confirmation, they are the failure worth shouting about, so- they stay until the next run replaces them. */-interface LeftOut {- audioProblems: string[];- audioShortfalls: string[];+/** "1:12" or "1:02:05" — how long is left, for the progress line. */+const clock = (ms: number) => {+ const total = Math.max(0, Math.round(ms / 1000));+ const hours = Math.floor(total / 3600);+ const minutes = Math.floor(total / 60) % 60;+ const seconds = String(total % 60).padStart(2, "0");+ return hours > 0 ? `${hours}:${String(minutes).padStart(2, "0")}:${seconds}` : `${minutes}:${seconds}`;+};++const fileName = (path: string) => path.split(/[\\/]/).pop() ?? path;+const folderOf = (path: string) => path.slice(0, Math.max(0, path.length - fileName(path).length - 1));++interface Destination {+ path: string;+ /** Chosen in the Save dialog, which already asked about replacing a file. */+ fromDialog: boolean;}-export function ExportView({ config, folderPath }: { config: ProjectConfig; folderPath: string }) {+/* A docked form, the way Clipchamp and Premiere's export page are laid out:+ the picture on the left, a 340px settings column on the right separated by a+ divider, and the actions at the bottom right. The run itself lives in+ lib/exportJob.ts, so leaving this screen no longer cancels it. */+export function ExportView({ config, folderPath, onClose }: {+ config: ProjectConfig;+ folderPath: string;+ /** Leaves the Export screen (the footer's Cancel while nothing is running). */+ onClose?: () => void;+}) {const [settings, setSettings] = useState<ExportSettings>(() => defaultExportSettings(config));const plan = useMemo(() => buildExportPlan(config, settings), [config, settings]);const bitrate = useMemo(@@ -83,16 +107,12 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; foldconst stageRef = useRef<HTMLDivElement>(null);const controlsTimerRef = useRef<number | null>(null);- const [progress, setProgress] = useState<ExportProgress | null>(null);- /* The finished run says one word, in the middle of the header, and stops- saying it. A panel that sat in the corner until the next export could not- tell "just saved" from "saved twenty minutes ago". */- const [saved, setSaved] = useState(false);- const [leftOut, setLeftOut] = useState<LeftOut | null>(null);- const [error, setError] = useState<string | null>(null);- const [cancelled, setCancelled] = useState(false);- const cancelRef = useRef(false);- const running = progress !== null;+ const [destination, setDestination] = useState<Destination | null>(null);+ const [destinationError, setDestinationError] = useState<string | null>(null);+ const job = useExportJob();+ const ours = job.folderPath === folderPath;+ const running = job.progress !== null;+ const runningHere = running && ours;/* The playhead is the view's, and the monitor drives it while it plays —these are handed down rather than declared inline because the monitor's@@ -118,13 +138,6 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; foldhideControlsAfterIdle();}, [hideControlsAfterIdle]);- /* Switching tabs unmounts this view, and an export that kept running would- finish and write a file with nothing on screen to say so. Leaving stops it- instead — nothing has been written yet at any point before the end. */- useEffect(() => () => {- cancelRef.current = true;- }, []);-useEffect(() => () => clearControlsTimer(), [clearControlsTimer]);useEffect(() => {@@ -137,6 +150,18 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; fold};}, []);+ /* Where the file goes, before anything is pressed: the project's name in the+ folder the last export went to (or Videos). Rust builds that path itself;+ Browse… replaces it with whatever the Save dialog returns. */+ useEffect(() => {+ let live = true;+ void defaultExportDestination(suggestedFileName(config.name)).then(+ (found) => { if (live && found) setDestination((current) => current ?? { path: found.path, fromDialog: false }); },+ (reason) => { if (live) setDestinationError(describe(reason)); },+ );+ return () => { live = false; };+ }, [config.name]);+// A scrub past the end of a shortened timeline would ask for a frame nothing// renders, so the playhead follows the content.useEffect(() => {@@ -170,21 +195,14 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; foldbutton reads the document rather than remembering what it did. */useEffect(() => {const sync = () => {- setFullscreen(document.fullscreenElement === stageRef.current);- revealControls();+ const now = document.fullscreenElement === stageRef.current;+ setFullscreen(now);+ if (now) revealControls();+ else { clearControlsTimer(); setControlsVisible(false); }};document.addEventListener("fullscreenchange", sync);return () => document.removeEventListener("fullscreenchange", sync);- }, [revealControls]);-- /* The notification takes itself away. Re-armed on every run, and cleared on- the way out so a saved export that is left behind does not fire into an- unmounted view. */- useEffect(() => {- if (!saved) return;- const timer = window.setTimeout(() => setSaved(false), SAVED_NOTICE_MS);- return () => window.clearTimeout(timer);- }, [saved]);+ }, [revealControls, clearControlsTimer]);const toggleFullscreen = () => {const stage = stageRef.current;@@ -193,10 +211,15 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; foldelse void stage.requestFullscreen?.().catch(() => undefined);};- const step = (deltaMs: number) => {+ const frameMs = 1000 / plan.frameRate;+ const lastFrame = Math.max(0, plan.frameCount - 1);+ /* Every transport step lands on the first millisecond of a frame, so the+ clock under the picture names the frame the encoder will write there. */+ const seekToFrame = (frame: number) => {setPlaying(false);- setPreviewTimeMs((current) => Math.round(Math.max(0, Math.min(Math.max(0, plan.durationMs - 1), current + deltaMs))));+ setPreviewTimeMs(frameStartMs(Math.max(0, Math.min(lastFrame, frame)), plan.frameRate));};+ const currentFrame = frameAt(previewTimeMs, plan.frameRate);const codecProbe = probes?.find((probe) => probe.id === settings.codec) ?? null;const blockers = [...plan.blockers];@@ -211,49 +234,51 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; foldif (codecProbe && !codecProbe.supported) {blockers.push(`This computer will not encode ${settings.codec.toUpperCase()} at ${plan.width}×${plan.height}: ${codecProbe.detail}`);}+ if (running && !ours) blockers.push("Another project is exporting. Wait for it to finish.");const canExport = blockers.length === 0 && !running;- const start = async () => {- setError(null);- setSaved(false);- setLeftOut(null);- setCancelled(false);- let destination: string | null = null;+ const browse = async (): Promise<Destination | null> => {+ setDestinationError(null);try {- destination = await chooseExportDestination(suggestedFileName(config.name));+ const chosen = await chooseExportDestination(suggestedFileName(config.name));+ if (!chosen) return null;+ const next = { path: chosen, fromDialog: true };+ setDestination(next);+ return next;} catch (reason) {- setError(describe(reason));- return;+ setDestinationError(describe(reason));+ return null;}- if (!destination) return; // The user closed the save dialog. Nothing to say.- setPlaying(false);- cancelRef.current = false;- setProgress({ phase: "preparing", framesDone: 0, frameCount: plan.frameCount, detail: "Starting…" });- try {- const outcome = await runExport({- folderPath,- config,- settings,- plan,- bitrate,- onProgress: setProgress,- cancelled: () => cancelRef.current,- });- setProgress({- phase: "writing",- framesDone: plan.frameCount,- frameCount: plan.frameCount,- detail: `Writing ${formatBytes(outcome.bytes.byteLength)} to ${destination}…`,- });- await writeExportFile(destination, outcome.bytes);- setLeftOut({ audioProblems: outcome.audioProblems, audioShortfalls: outcome.audioShortfalls });- setSaved(true);- } catch (reason) {- if (reason instanceof ExportCancelled) setCancelled(true);- else setError(describe(reason));- } finally {- setProgress(null);+ };++ const start = async () => {+ if (!canExport) return;+ dismissExportOutcome();+ const target = destination ?? await browse();+ if (!target) return; // The user closed the save dialog. Nothing to say.+ if (!target.fromDialog) {+ let exists = false;+ try { exists = await exportDestinationExists(target.path); } catch (reason) { setDestinationError(describe(reason)); return; }+ if (exists && !await askNative({+ title: "Replace file?",+ message: `${fileName(target.path)} already exists in ${folderOf(target.path)}. Replace it?`,+ kind: "warning",+ okLabel: "Replace",+ cancelLabel: "Cancel",+ })) return;}+ /* The dialog's own replace question covers one export; the next export to+ the same path is asked again, because by then the file is this one. */+ setDestination({ path: target.path, fromDialog: false });+ setPlaying(false);+ await startExportJob({ folderPath, config, settings, plan, bitrate, destination: target.path });+ };++ const openFile = (path: string) => {+ void openExportFile(path).catch((reason) => messageNative({ title: "Could not open the video", message: describe(reason), kind: "error" }));+ };+ const showInFolder = (path: string) => {+ void revealInExplorer(path).catch((reason) => messageNative({ title: "Could not show the file", message: describe(reason), kind: "error" }));};const summary: Array<[string, string, string?]> = [@@ -279,7 +304,7 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; fold],["Compositor",- compositor ? (compositor.kind === "webgpu" ? "WebGPU" : "2D canvas") : "asking this computer…",+ compositor ? (compositor.kind === "webgpu" ? "WebGPU" : "2D canvas") : "Checking…",compositor? compositor.kind === "webgpu"? "frames scaled without leaving the GPU"@@ -288,198 +313,167 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; fold],];- return <div className="export-view">- {/* The action lives beside the title, where every other screen in- Slopus puts its main button (see the References header). It used to- sit at the bottom of the right-hand column, below everything the page- had to say — which is a long way to scroll to press the one control the- screen exists for. */}- <header className="export-heading">- <h1>Export</h1>- {/* A notification, not a panel: it appears between the title and the- button that produced it, says the one thing there is to say, and goes.- The middle column is always there whether or not it holds anything, so- nothing on either side of it moves when it arrives or leaves. */}- <div className="export-toast-slot" aria-live="polite">- {saved && <p className="export-toast">- <CircleCheck size={16} aria-hidden="true" /> Saved- </p>}- </div>- <div className="export-heading__actions">- {running && <button- className="secondary-button"- type="button"- onClick={() => { cancelRef.current = true; }}- title="Stop encoding. Nothing has been written to disk yet."- ><X size={16} aria-hidden="true" /> Cancel</button>}- <button- className="primary-button"- type="button"- disabled={!canExport}- onClick={() => void start()}- title={canExport ? "Choose where to save, then render the timeline" : blockers[0] ?? "Export is running"}- >- <Download size={16} aria-hidden="true" /> {running ? "Exporting…" : "Export video"}- </button>- </div>- </header>+ const progress = runningHere ? job.progress : null;+ const percent = Math.round(exportFraction(progress) * 100);+ const progressLine = progress+ ? [+ `${percent}%`,+ job.remainingMs !== null ? `${clock(job.remainingMs)} remaining` : null,+ progress.phase === "rendering" && progress.framesDone > 0+ ? `Encoding frame ${progress.framesDone} of ${progress.frameCount}`+ : progress.detail.replace(/\.$/, ""),+ ].filter(Boolean).join(" · ")+ : null;+ const outcome = ours ? job.outcome : null;+ const empty = plan.frameCount === 0;+ const transportDisabled = empty;- <div className="export-layout">+ return <div className="export-view">+ <h1 className="sr-only">Export</h1>+ <div className="export-body"><section className="export-preview" aria-label="Video preview">{/* The same player the timeline uses, on the same cut: it decodes the- real files and plays them with their sound, rather than decoding one- still frame per scrub. What the export will contain is what this- plays — the picture is fitted inside the project's frame and the- rest is the project's background, exactly as the encoder does it. */}- {/* The stage IS the project's frame. Sized from the plan rather than- from whatever is under the playhead, or a portrait still on the- timeline would make the preview tall and the next video clip would- shrink it back — the export writes one frame size for the whole- file, and this shows that size the whole time. */}+ real files and plays them with their sound. What the export will+ contain is what this plays — the picture is fitted inside the+ project's frame and the rest is the project's background. */}<div- className={`export-stage${controlsVisible ? " export-stage--controls-visible" : ""}`}+ className={`export-stage${fullscreen ? " export-stage--fullscreen" : ""}${controlsVisible ? " export-stage--controls-visible" : ""}`}ref={stageRef}- style={{ aspectRatio: `${plan.width} / ${plan.height}`, "--frame-aspect": plan.width / plan.height } as React.CSSProperties}- onPointerEnter={revealControls}- onPointerMove={revealControls}- onPointerDown={revealControls}- onPointerLeave={() => {- clearControlsTimer();- if (!stageRef.current?.contains(document.activeElement)) setControlsVisible(false);- }}- onFocusCapture={() => {- clearControlsTimer();- setControlsVisible(true);- }}- onBlurCapture={(event) => {+ onPointerMove={fullscreen ? revealControls : undefined}+ onPointerDown={fullscreen ? revealControls : undefined}+ onFocusCapture={fullscreen ? () => { clearControlsTimer(); setControlsVisible(true); } : undefined}+ onBlurCapture={fullscreen ? (event) => {if (!event.currentTarget.contains(event.relatedTarget as Node | null)) hideControlsAfterIdle();- }}+ } : undefined}>- <ProgramMonitor- config={config}- folderPath={folderPath}- playheadMs={previewTimeMs}- playing={playing}- onSeek={seek}- onPlayingChange={changePlaying}- />+ {/* The frame IS the project's frame. Sized from the plan rather than+ from whatever is under the playhead: the export writes one frame+ size for the whole file, and this shows that size the whole time. */}+ <div className="export-picture" style={{ aspectRatio: `${plan.width} / ${plan.height}`, "--frame-aspect": plan.width / plan.height } as React.CSSProperties}>+ <ProgramMonitor+ config={config}+ folderPath={folderPath}+ playheadMs={previewTimeMs}+ playing={playing}+ onSeek={seek}+ onPlayingChange={changePlaying}+ />+ </div>+ {/* Windowed: a plain 36px bar under the picture. Fullscreen: the+ same bar over the picture's foot, hiding when the pointer rests. */}<div className="export-transport" role="group" aria-label="Video playback controls">+ <button type="button" className="export-transport__button" onClick={() => seekToFrame(0)} disabled={transportDisabled} aria-label="Go to start" {...tooltipProps("Go to start", "Home")}><ChevronFirst size={16} aria-hidden="true" /></button>+ <button type="button" className="export-transport__button" onClick={() => seekToFrame(currentFrame - 1)} disabled={transportDisabled} aria-label="Previous frame" {...tooltipProps("Previous frame", "Left")}><StepBack size={16} aria-hidden="true" /></button><buttontype="button"- onClick={() => step(-1000)}- disabled={plan.frameCount === 0}- aria-label="Back one second"- title="Back one second"- ><SkipBack size={18} aria-hidden="true" /></button>- <button- type="button"- className="export-transport__play"+ className="export-transport__button"onClick={() => setPlaying((value) => !value)}- disabled={running || plan.frameCount === 0}+ disabled={runningHere || transportDisabled}aria-label={playing ? "Pause" : "Play"}- title={plan.frameCount === 0 ? "There is nothing on the timeline to play" : playing ? "Pause" : "Play"}- >{playing ? <Pause size={20} fill="currentColor" aria-hidden="true" /> : <Play size={20} fill="currentColor" aria-hidden="true" />}</button>- <button- type="button"- onClick={() => step(1000)}- disabled={plan.frameCount === 0}- aria-label="Forward one second"- title="Forward one second"- ><SkipForward size={18} aria-hidden="true" /></button>- <input- id="export-scrub"- type="range"+ {...tooltipProps(empty ? "Nothing on the timeline to play" : playing ? "Pause" : "Play", empty ? undefined : "Space")}+ >{playing ? <Pause size={16} aria-hidden="true" /> : <Play size={16} aria-hidden="true" />}</button>+ <button type="button" className="export-transport__button" onClick={() => seekToFrame(currentFrame + 1)} disabled={transportDisabled} aria-label="Next frame" {...tooltipProps("Next frame", "Right")}><StepForward size={16} aria-hidden="true" /></button>+ <button type="button" className="export-transport__button" onClick={() => seekToFrame(lastFrame)} disabled={transportDisabled} aria-label="Go to end" {...tooltipProps("Go to end", "End")}><ChevronLast size={16} aria-hidden="true" /></button>+ <Slider+ className="export-transport__scrub"min={0}max={Math.max(0, plan.durationMs - 1)}- step={Math.max(1, Math.round(1000 / plan.frameRate))}+ step={Math.max(1, Math.round(frameMs))}value={previewTimeMs}- style={{ "--scrub-progress": `${plan.durationMs > 1 ? previewTimeMs / (plan.durationMs - 1) * 100 : 0}%` } as React.CSSProperties}- disabled={plan.frameCount === 0}+ disabled={transportDisabled}aria-label="Playhead"- onChange={(event) => { setPlaying(false); setPreviewTimeMs(Number(event.target.value)); }}+ onChange={(value) => { setPlaying(false); setPreviewTimeMs(value); }}/>- <output htmlFor="export-scrub"><span>{formatDuration(previewTimeMs)}</span><i aria-hidden="true">/</i><span>{formatDuration(plan.durationMs)}</span></output>+ <span className="export-transport__time">+ <span>{formatTimecode(previewTimeMs, plan.frameRate)}</span> / <span>{formatTimecode(plan.durationMs, plan.frameRate)}</span>+ </span><buttontype="button"+ className="export-transport__button"onClick={toggleFullscreen}- aria-label={fullscreen ? "Leave fullscreen" : "Watch fullscreen"}- title={fullscreen ? "Leave fullscreen" : "Watch fullscreen"}- >{fullscreen ? <Minimize size={19} aria-hidden="true" /> : <Maximize size={19} aria-hidden="true" />}</button>+ aria-label={fullscreen ? "Exit full screen" : "Full screen"}+ {...tooltipProps(fullscreen ? "Exit full screen" : "Full screen", fullscreen ? "Esc" : undefined)}+ >{fullscreen ? <Minimize size={16} aria-hidden="true" /> : <Maximize size={16} aria-hidden="true" />}</button></div></div>- {/* The one thing left to say under the picture: that there is no- picture. The frame-by-frame caption that used to live here named a- clip and an offset nobody was reading. */}- {plan.frameCount === 0 && <p className="export-stage__caption">There is nothing on the timeline yet.</p>}+ {empty && <p className="export-stage__caption">Nothing on the timeline yet</p>}</section><section className="export-settings" aria-labelledby="export-settings-heading">- <h2 id="export-settings-heading">Settings</h2>+ <h2 id="export-settings-heading" className="export-settings__heading">Settings</h2>+ <div className="export-form">+ <div className="export-row">+ <span className="export-row__label" id="export-destination-label">Save to</span>+ <div className="export-destination">+ <span className="export-destination__path" {...tooltipProps(destination?.path)}>+ {destination ? destination.path : support.desktop ? "Choose a file…" : "Available in the desktop app"}+ </span>+ <button+ type="button"+ className="secondary-button export-destination__browse"+ disabled={runningHere || !support.desktop}+ aria-describedby="export-destination-label"+ onClick={() => void browse()}+ >Browse…</button>+ </div>+ </div>- <div className="export-fields">- <label htmlFor="export-resolution">- <span>Resolution</span>- <select+ <div className="export-row">+ <label className="export-row__label" htmlFor="export-resolution">Resolution</label>+ <ComboBoxid="export-resolution"value={settings.resolution}- disabled={running}- onChange={(event) => setSettings({ ...settings, resolution: event.target.value as Resolution })}- >- {resolutionChoices(config.settings.resolution).map((resolution) => {+ disabled={runningHere}+ onChange={(value) => setSettings({ ...settings, resolution: value as Resolution })}+ options={resolutionChoices(config.settings.resolution).map((resolution) => {const size = outputDimensions(resolution, config.settings.aspectRatio);- return <option key={resolution} value={resolution}>{size.width} × {size.height}</option>;+ return { value: resolution, label: `${size.width} × ${size.height}` };})}- </select>- </label>+ />+ </div>- <label htmlFor="export-frame-rate">- <span>Frame rate</span>- <select+ <div className="export-row">+ <label className="export-row__label" htmlFor="export-frame-rate">Frame rate</label>+ <ComboBoxid="export-frame-rate"- value={settings.frameRate}- disabled={running}- onChange={(event) => setSettings({ ...settings, frameRate: Number(event.target.value) as FrameRate })}- >- {FRAME_RATES.map((rate) => <option key={rate} value={rate}>{rate} fps</option>)}- </select>- </label>-- <label htmlFor="export-codec">- <span>Container & codec</span>- <select+ value={String(settings.frameRate)}+ disabled={runningHere}+ onChange={(value) => setSettings({ ...settings, frameRate: Number(value) as FrameRate })}+ options={FRAME_RATES.map((rate) => ({ value: String(rate), label: `${rate} fps` }))}+ />+ </div>++ <div className="export-row">+ <label className="export-row__label" htmlFor="export-codec">Format</label>+ <ComboBoxid="export-codec"value={settings.codec}- disabled={running}- onChange={(event) => setSettings({ ...settings, codec: event.target.value as OutputCodecId })}- >- {OUTPUT_CODECS.map((codec) => {+ disabled={runningHere}+ onChange={(value) => setSettings({ ...settings, codec: value as OutputCodecId })}+ options={OUTPUT_CODECS.map((codec) => {const probe = probes?.find((candidate) => candidate.id === codec.id);const unsupported = probe ? !probe.supported : false;- return <option key={codec.id} value={codec.id} disabled={unsupported} title={probe?.detail ?? codec.detail}>- .mp4 · {codec.label}{unsupported ? " — not supported here" : ""}- </option>;+ return { value: codec.id, label: `MP4 · ${codec.label}${unsupported ? " (not supported here)" : ""}`, disabled: unsupported };})}- </select>- </label>+ />+ </div>- <label htmlFor="export-quality">- <span>Quality</span>- <select+ <div className="export-row">+ <label className="export-row__label" htmlFor="export-quality">Quality</label>+ <ComboBoxid="export-quality"value={settings.quality}- disabled={running}- onChange={(event) => setSettings({ ...settings, quality: event.target.value as QualityId })}- >- {QUALITY_PRESETS.map((preset) => <option key={preset.id} value={preset.id} title={preset.detail}>- {preset.label} · {(bitrateFor(plan.width, plan.height, plan.frameRate, preset.id) / 1_000_000).toFixed(1)} Mbit/s- </option>)}- </select>- </label>-+ disabled={runningHere}+ onChange={(value) => setSettings({ ...settings, quality: value as QualityId })}+ options={QUALITY_PRESETS.map((preset) => ({+ value: preset.id,+ label: `${preset.label} · ${(bitrateFor(plan.width, plan.height, plan.frameRate, preset.id) / 1_000_000).toFixed(1)} Mbit/s`,+ }))}+ />+ </div></div>- </section>- <section className="export-details" aria-label="Export details">+ <h2 className="export-settings__heading">Summary</h2><dl className="export-summary">{summary.map(([term, value, detail]) => <div key={term}><dt>{term}</dt>@@ -487,46 +481,59 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; fold</div>)}</dl>- {blockers.length > 0 && <div className="export-notice export-notice--bad" role="alert">- <h3><TriangleAlert size={16} aria-hidden="true" /> Not possible yet</h3>- <ul>{blockers.map((blocker) => <li key={blocker}>{blocker}</li>)}</ul>- </div>}+ <div className="export-messages">+ {destinationError && <InfoBar severity="error" title="Save location" message={destinationError} onClose={() => setDestinationError(null)} />}+ {blockers.length > 0 && <InfoBar severity="error" title="Can’t export yet">+ <ul className="export-reasons">{blockers.map((blocker) => <li key={blocker}>{blocker}</li>)}</ul>+ </InfoBar>}+ {outcome?.kind === "saved" && outcome.audioProblems.length > 0 && <InfoBar severity="warning" title="Left out of the soundtrack">+ <ul className="export-reasons">{outcome.audioProblems.map((problem) => <li key={problem}>{problem}</li>)}</ul>+ </InfoBar>}+ {/* These clips ARE in the file. Part of each one is silence because+ the sound behind it ran out. */}+ {outcome?.kind === "saved" && outcome.audioShortfalls.length > 0 && <InfoBar severity="warning" title="Sound ran out before the clip ended">+ <ul className="export-reasons">{outcome.audioShortfalls.map((shortfall) => <li key={shortfall}>{shortfall}</li>)}</ul>+ </InfoBar>}+ </div>+ </section>+ </div>+ <footer className="export-footer">+ <div className="export-footer__status" aria-live="polite">{progress && <div className="export-progress" role="status">- <div className="progress-track">- <i style={{ width: `${progress.frameCount === 0 ? 0 : Math.round((progress.framesDone / progress.frameCount) * 100)}%` }} />- </div>- <p>{progress.detail} <small>{progress.framesDone} / {progress.frameCount} frames</small></p>- <p><small>Nothing is written until the encode finishes. Leaving this tab cancels the run.</small></p>- </div>}-- {cancelled && <p className="export-outcome" role="status">- Export cancelled. Nothing was written — the file is only saved once the whole encode finishes.- </p>}-- {error && <div className="export-notice export-notice--bad" role="alert">- <h3><TriangleAlert size={16} aria-hidden="true" /> The export failed</h3>- {/* Verbatim. A rewritten error is an error nobody can act on. */}- <p>{error}</p>- </div>}-- {/* The export itself is confirmed by the notification in the header and- nowhere else. What stays on the page is only what went WRONG with the- sound — a soundtrack that vanished without a word is not something to- fade out after four seconds. */}- {leftOut && leftOut.audioProblems.length > 0 && <div className="export-notice" role="alert">- <h3><TriangleAlert size={16} aria-hidden="true" /> Left out of the soundtrack</h3>- <ul>{leftOut.audioProblems.map((problem) => <li key={problem}>{problem}</li>)}</ul>- </div>}-- {/* These clips ARE in the file. Part of each one is silence because the- sound behind it ran out, which is exactly as inaudible as a missing- clip and was previously reported nowhere. */}- {leftOut && leftOut.audioShortfalls.length > 0 && <div className="export-notice" role="alert">- <h3><TriangleAlert size={16} aria-hidden="true" /> Ran out of sound before the clip ended</h3>- <ul>{leftOut.audioShortfalls.map((shortfall) => <li key={shortfall}>{shortfall}</li>)}</ul>+ <span className="export-progress__line">{progressLine}</span>+ <ProgressBar value={percent} aria-label="Export progress" /></div>}- </section>- </div>+ {!progress && outcome?.kind === "saved" && <InfoBar+ severity="success"+ title="Exported"+ message={`Exported to ${outcome.path}`}+ action={<>+ <button type="button" className="secondary-button" onClick={() => openFile(outcome.path)}>Open</button>+ <button type="button" className="secondary-button" onClick={() => showInFolder(outcome.path)}>Show in folder</button>+ </>}+ onClose={dismissExportOutcome}+ />}+ {!progress && outcome?.kind === "cancelled" && <InfoBar+ severity="informational"+ title="Export cancelled"+ message="Nothing was written."+ onClose={dismissExportOutcome}+ />}+ {!progress && outcome?.kind === "failed" && <InfoBar severity="error" title="Export failed" message={outcome.message} onClose={dismissExportOutcome} />}+ </div>+ <div className="export-footer__actions">+ {runningHere+ ? <button type="button" className="secondary-button" onClick={cancelExportJob} {...tooltipProps("Stop encoding. Nothing has been written yet.")}>Cancel</button>+ : onClose && <button type="button" className="secondary-button" onClick={onClose}>Cancel</button>}+ <button+ type="button"+ className="primary-button"+ disabled={!canExport}+ onClick={() => void start()}+ {...tooltipProps(canExport ? undefined : runningHere ? "Export is running" : blockers[0])}+ >{runningHere ? "Exporting…" : "Export"}</button>+ </div>+ </footer></div>;}diff --git a/src/lib/exportJob.ts b/src/lib/exportJob.tsnew file mode 100644index 0000000..27a0806--- /dev/null+++ b/src/lib/exportJob.ts@@ -0,0 +1,153 @@+/* The export that is running — held here rather than in ExportView.++ The Export screen used to own its run, so leaving the tab unmounted the+ view and cancelled the encode. The run is a promise chain that needs no+ component at all (runExport reads the config snapshot it was given, and+ WebCodecs keeps going whatever React renders), so the state lives in this+ module and the view subscribes to it: switch to the timeline, come back, and+ the progress bar is where it was. One export at a time, app-wide.++ The taskbar button mirrors it (setTaskbarProgress): normal while encoding,+ cleared when the file is saved or the run is cancelled, red when it fails+ until the failure is dismissed or another run starts. */++import { useSyncExternalStore } from "react";+import type { ExportPlan, ExportSettings } from "./export";+import { ExportCancelled, runExport, writeExportFile, type ExportProgress } from "./exportPipeline";+import { setTaskbarProgress } from "./nativeShell";+import type { ProjectConfig } from "./project";++export type ExportOutcome =+ | { kind: "saved"; path: string; bytes: number; audioProblems: string[]; audioShortfalls: string[] }+ | { kind: "cancelled" }+ | { kind: "failed"; message: string };++export interface ExportJobState {+ /** The project folder the run (or its outcome) belongs to. */+ folderPath: string | null;+ destination: string | null;+ progress: ExportProgress | null;+ /** Milliseconds left, estimated from the frame rate so far. Null until+ * enough frames have been rendered to say. */+ remainingMs: number | null;+ outcome: ExportOutcome | null;+}++const IDLE: ExportJobState = { folderPath: null, destination: null, progress: null, remainingMs: null, outcome: null };++let state: ExportJobState = IDLE;+let cancelRequested = false;+const listeners = new Set<() => void>();++function set(next: Partial<ExportJobState>) {+ state = { ...state, ...next };+ listeners.forEach((listener) => listener());+}++export function getExportJob(): ExportJobState {+ return state;+}++export function subscribeExportJob(listener: () => void): () => void {+ listeners.add(listener);+ return () => { listeners.delete(listener); };+}++export function useExportJob(): ExportJobState {+ return useSyncExternalStore(subscribeExportJob, getExportJob, getExportJob);+}++export const isExportRunning = () => state.progress !== null;++/** Fraction done, 0…1, for the bar and the taskbar. */+export const exportFraction = (progress: ExportProgress | null) =>+ !progress || progress.frameCount === 0 ? 0 : Math.min(1, progress.framesDone / progress.frameCount);++/** Stops the running export before the next frame. Nothing has been written+ * at any point before the end, so there is nothing to clean up. */+export function cancelExportJob() {+ cancelRequested = true;+}++/** Forgets a finished run's outcome (and clears a red taskbar button). */+export function dismissExportOutcome() {+ if (state.progress) return;+ if (state.outcome?.kind === "failed") void setTaskbarProgress(null).catch(() => undefined);+ set({ outcome: null });+}++export interface StartExportOptions {+ folderPath: string;+ config: ProjectConfig;+ settings: ExportSettings;+ plan: ExportPlan;+ bitrate: number;+ destination: string;+}++/** Renders, encodes and writes one export. Resolves when it has finished,+ * failed or been cancelled; the outcome is in the store either way. */+export async function startExportJob(options: StartExportOptions): Promise<void> {+ if (isExportRunning()) throw new Error("An export is already running.");+ const { folderPath, config, settings, plan, bitrate, destination } = options;+ cancelRequested = false;+ /* The estimate starts once frames are coming out: mixing and encoder setup+ take their own time, and folding them in would promise hours at frame 1. */+ let clockStart: { at: number; frames: number } | null = null;+ let lastPercent = -1;+ const onProgress = (progress: ExportProgress) => {+ let remainingMs: number | null = null;+ if (progress.phase === "rendering" && progress.framesDone > 0) {+ const now = performance.now();+ clockStart ??= { at: now, frames: progress.framesDone };+ const frames = progress.framesDone - clockStart.frames;+ if (frames >= 5) remainingMs = ((now - clockStart.at) / frames) * (progress.frameCount - progress.framesDone);+ }+ set({ progress, remainingMs: remainingMs ?? (progress.phase === "rendering" ? state.remainingMs : null) });+ const percent = Math.round(exportFraction(progress) * 100);+ if (percent !== lastPercent) {+ lastPercent = percent;+ void setTaskbarProgress(percent / 100).catch(() => undefined);+ }+ };+ set({+ folderPath,+ destination,+ outcome: null,+ remainingMs: null,+ progress: { phase: "preparing", framesDone: 0, frameCount: plan.frameCount, detail: "Starting…" },+ });+ void setTaskbarProgress(0).catch(() => undefined);+ try {+ const outcome = await runExport({ folderPath, config, settings, plan, bitrate, onProgress, cancelled: () => cancelRequested });+ set({+ progress: { phase: "writing", framesDone: plan.frameCount, frameCount: plan.frameCount, detail: "Writing the file…" },+ remainingMs: null,+ });+ const bytes = await writeExportFile(destination, outcome.bytes);+ set({ progress: null, outcome: { kind: "saved", path: destination, bytes, audioProblems: outcome.audioProblems, audioShortfalls: outcome.audioShortfalls } });+ void setTaskbarProgress(null).catch(() => undefined);+ } catch (reason) {+ if (reason instanceof ExportCancelled) {+ set({ progress: null, outcome: { kind: "cancelled" } });+ void setTaskbarProgress(null).catch(() => undefined);+ } else {+ set({ progress: null, outcome: { kind: "failed", message: reason instanceof Error ? reason.message : String(reason) } });+ void setTaskbarProgress(1, "error").catch(() => undefined);+ }+ } finally {+ cancelRequested = false;+ }+}++/** Test hook: put the store in a given state. */+export function setExportJobForTests(next: Partial<ExportJobState>) {+ set(next);+}++/** Test hook: back to idle. */+export function resetExportJobForTests() {+ cancelRequested = false;+ state = IDLE;+ listeners.forEach((listener) => listener());+}diff --git a/src/lib/exportPipeline.ts b/src/lib/exportPipeline.tsindex 118febc..90b2a92 100644--- a/src/lib/exportPipeline.ts+++ b/src/lib/exportPipeline.ts@@ -1389,6 +1389,33 @@ export async function writeExportFile(path: string, bytes: Uint8Array): Promise<return invoke<number>("write_export_file", bytes, { headers: { "x-export-path": encodeURIComponent(path) } });}+/** The destination the Export screen shows before any dialog: the suggested+ * name in the last export folder, or in Videos. Rust builds the path itself+ * and allows the write to it. Null outside the desktop app. */+export async function defaultExportDestination(suggestedName: string): Promise<{ path: string; exists: boolean } | null> {+ if (!isTauri()) return null;+ return (await invoke<{ path: string; exists: boolean } | null>("default_export_destination", { suggestedName })) ?? null;+}++/** Whether the chosen destination already holds a file (so the page can ask+ * before replacing it). */+export async function exportDestinationExists(path: string): Promise<boolean> {+ if (!isTauri()) return false;+ return invoke<boolean>("export_destination_exists", { path });+}++/** Opens a finished export in the default video player. */+export async function openExportFile(path: string): Promise<void> {+ if (!isTauri()) return;+ await invoke("open_export_file", { path });+}++/** Reads a `.cube` LUT the user picked in the Open dialog (Rust checks the+ * extension and the 16 MB limit). */+export async function readLutFile(path: string): Promise<string> {+ return invoke<string>("read_lut_file", { path });+}+/* ---------------------------------------------------------------------------Preview--------------------------------------------------------------------------- */diff --git a/src/lib/timeline.ts b/src/lib/timeline.tsindex 25fcfb5..bf2d4cf 100644--- a/src/lib/timeline.ts+++ b/src/lib/timeline.ts@@ -295,8 +295,9 @@ export function insertClip(* (1000/30 × 3) is not read as the frame before. */export const frameAt = (ms: number, fps: number) => Math.floor(Math.max(0, ms) * fps / 1000 + 1e-6);-/** Milliseconds at the START of frame `frame`. */-export const frameStartMs = (frame: number, fps: number) => Math.round(frame * 1000 / fps);+/** The first whole millisecond inside frame `frame`, so that+ * `frameAt(frameStartMs(n)) === n` however the division rounds. */+export const frameStartMs = (frame: number, fps: number) => Math.max(0, Math.ceil(frame * 1000 / fps - 1e-9));const two = (value: number) => String(value).padStart(2, "0");diff --git a/src/styles/export.css b/src/styles/export.cssindex 8ab6561..d354c2f 100644--- a/src/styles/export.css+++ b/src/styles/export.css@@ -1,546 +1,361 @@/* ============================================================================- export.css — the Export screen: settings, preview, and the run itself.+ export.css — the Export screen: a docked form, not a page.- Sizing contract (see tokens.css): no literal px type sizes, nothing below- --text-2xs (12px), standard controls --control-md (32px), compact ones- --control-sm (24px).+ The layout every Windows editor uses for its export step (Clipchamp's export+ page, Premiere's Export tab): the picture on the left, a 340px settings+ column on the right separated from it by a divider, and a footer with the+ run's status on the left and Cancel / Export on the right. No hero title, no+ cards, no stat tiles — labels in sentence case, values beside them.++ Dense scale, shared with the timeline (see timeline.css): controls 24–32px,+ the transport bar 36px, 12px captions.========================================================================== */.export-view {height: 100%;min-height: 0;- overflow-y: auto;- padding: var(--space-6) var(--space-7) var(--space-7);- background: var(--bg);-}--/* Title, notification, action. The middle column holds its place whether or- not there is anything to say, so the Saved notice can arrive and leave- without the title or the button moving a pixel. */-.export-heading {- max-width: var(--content-max);- margin: 0 auto var(--space-5);display: grid;- grid-template-columns: 1fr auto 1fr;- align-items: flex-end;- gap: var(--space-5);-}--.export-heading h1 {- margin: 0;- font-size: var(--text-2xl);- font-weight: var(--weight-semibold);- line-height: var(--leading-tight);-}--/* Export, and Cancel while it runs — the same place the References screen puts- Add image. */-.export-heading__actions {- justify-self: end;- display: flex;- gap: var(--space-2);-}--.export-toast-slot {- justify-self: center;- align-self: center;-}--/* Says one word. No path, no size, no codec — the file was just chosen in a- save dialog, and everything else the panel used to list is either already- known or a warning, and warnings do not fade out (see .export-notice). */-.export-toast {- margin: 0;- display: flex;- align-items: center;- gap: var(--space-2);- padding: var(--space-2) var(--space-4);- border: 1px solid var(--success-line);- border-radius: var(--radius-md);- color: var(--success);- background: var(--success-soft);- font-size: var(--text-xs);- font-weight: var(--weight-semibold);- animation: export-toast-in var(--motion-normal) var(--ease-decelerate);-}--.export-toast svg {- flex: 0 0 auto;+ grid-template-rows: minmax(0, 1fr) auto;+ background: var(--layer);}-@keyframes export-toast-in {- from { opacity: 0; transform: translateY(-4px); }- to { opacity: 1; transform: none; }-}--@media (prefers-reduced-motion: reduce) {- .export-toast {- animation: none;- }-}--/* --- Layout ---------------------------------------------------------------- */--/* Video gets the wider working area on the left. Settings fill the full height- of the matching right-hand panel, and export facts span both below them. */-.export-layout {- max-width: var(--content-max);- margin: 0 auto;+.export-body {+ min-height: 0;display: grid;- grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.65fr);- grid-template-areas:- "preview settings"- "details details";- gap: var(--space-5);- align-items: stretch;+ grid-template-columns: minmax(0, 1fr) 340px;}-@media (max-width: 900px) {- .export-layout {- grid-template-columns: minmax(0, 1fr);- grid-template-areas:- "preview"- "settings"- "details";- }-}+/* --- Preview ----------------------------------------------------------------- */-.export-preview,-.export-settings,-.export-details {+.export-preview {min-width: 0;- padding: var(--space-5);- border: 1px solid var(--line-strong);- border-radius: var(--radius-lg);+ min-height: 0;+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ padding: var(--space-4);background: var(--panel);}-.export-preview { grid-area: preview; }-.export-settings { grid-area: settings; }-.export-details { grid-area: details; }--.export-preview h2,-.export-settings h2 {- margin: 0 0 var(--space-3);- font-size: var(--text-md);- font-weight: var(--weight-semibold);-}--.export-settings h2:not(:first-of-type) {- margin-top: var(--space-5);-}--/* --- Preview --------------------------------------------------------------- */--/* The project's frame, at the project's shape: `aspect-ratio` and- `--frame-aspect` are set inline from the export plan (see ExportView). The- max-width is what keeps the box on its aspect while obeying the height cap —- clamping the HEIGHT alone would leave a full-width box with the wrong shape.- Before this the stage had no height of its own and took the intrinsic shape- of whatever was under the playhead, so a portrait still made the preview tall- and the next video clip shrank it back. */+/* The stage is the frame plus its transport bar. It is also the element that+ goes fullscreen, so the bar comes along. */.export-stage {position: relative;width: 100%;- max-width: calc(68vh * var(--frame-aspect, 1.7778));- margin: 0 auto;- display: grid;- place-items: center;+ max-width: calc((100vh - 220px) * var(--frame-aspect, 1.7778));+ min-height: 0;+ display: flex;+ flex-direction: column;overflow: hidden;border: 1px solid var(--line);- border-radius: var(--radius-md);- /* Deliberately not the project background: the frame paints its own, and a- matching surround would hide where the picture actually ends. Because it- is black in BOTH themes, everything painted on it uses the --stage-*- tokens rather than the palette — see tokens.css. */+ border-radius: var(--radius-sm);+ /* Black in both themes: the frame paints the project's own background, and+ a matching surround would hide where the picture ends. Everything painted+ on it uses the --stage-* tokens. */background: var(--stage-bg);}-.export-stage:not(.export-stage--controls-visible):not(:focus-within) {- cursor: none;+/* The project's frame, at the project's shape: `aspect-ratio` and+ `--frame-aspect` are set inline from the export plan (see ExportView). It+ never takes the shape of whatever is under the playhead — the export writes+ ONE frame size for the whole file. */+.export-picture {+ position: relative;+ width: 100%;+ min-height: 0;+ display: grid;+ place-items: center;+ overflow: hidden;}-/* The player fills the stage; the letterboxing inside it is the project's own- frame shape, painted in the project's own background colour. */-.export-stage .program-picture {+.export-picture .program-picture {width: 100%;height: 100%;}-/* Fullscreen paints the stage's own background behind the picture, so the- black bars stay black rather than showing the page through them. */-.export-stage:fullscreen {- max-width: none;- border: 0;- border-radius: 0;- background: var(--stage-bg);-}--.export-stage:fullscreen .export-transport {- padding: 56px max(var(--space-5), env(safe-area-inset-right)) max(var(--space-5), env(safe-area-inset-bottom)) max(var(--space-5), env(safe-area-inset-left));-}--.export-stage__note {- max-width: 46ch;- margin: 0;- padding: var(--space-4);- color: var(--on-stage);- font-size: var(--text-xs);- line-height: var(--leading-normal);- text-align: center;-}--.export-stage__note--bad {- position: absolute;- inset: auto var(--space-3) var(--space-3);- display: flex;- align-items: center;- justify-content: center;- gap: var(--space-2);- border: 1px solid var(--stage-alert-line);- border-radius: var(--radius-sm);- color: var(--stage-alert-ink);- background: var(--stage-alert-bg);- text-align: left;-}--.export-stage__note--bad svg {- flex: 0 0 auto;-}-.export-stage__caption {- margin: var(--space-3) 0 0;+ margin: var(--space-2) 0 0;color: var(--text-muted);font-size: var(--text-xs);- line-height: var(--leading-normal);+ line-height: var(--leading-snug);}-/* A translucent playback surface over the picture. Pointer movement reveals- it; keyboard focus keeps it present independently of the idle timer. */+/* --- Transport ----------------------------------------------------------------+ Windowed: a static 36px bar under the picture — flat 28px buttons, a Fluent+ slider, and "00:00:12:05 / 00:01:30:00". No scrim, no shadows, no scale. */+.export-transport {- position: absolute;- z-index: 5;- inset: auto 0 0;- min-height: 76px;+ height: 36px;+ flex: none;display: flex;align-items: center;- gap: var(--space-1);- padding: 30px var(--space-3) var(--space-3);- color: var(--on-stage);- background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--stage-bg) 82%, transparent));- opacity: 0;- visibility: hidden;- transform: translateY(12px);- pointer-events: none;- transition:- opacity var(--motion-normal) linear,- transform var(--motion-panel) var(--ease-decelerate),- visibility 0s linear var(--motion-panel);-}--.export-stage--controls-visible .export-transport,-.export-stage:focus-within .export-transport {- opacity: 1;- visibility: visible;- transform: translateY(0);- pointer-events: auto;- transition-delay: 0s;+ gap: 2px;+ padding: 0 var(--space-2);+ border-top: 1px solid var(--line);+ color: var(--text-primary);+ background: var(--layer);}-.export-transport button {- flex: 0 0 auto;- width: var(--icon-button);- height: var(--icon-button);+.export-transport__button {+ width: 28px;+ height: 28px;+ flex: none;display: grid;place-items: center;padding: 0;border: 0;border-radius: var(--radius-sm);- color: var(--on-stage);+ color: var(--text-primary);background: transparent;- filter: drop-shadow(0 1px 2px color-mix(in srgb, var(--stage-bg) 55%, transparent));transition: var(--transition-control);}-.export-transport button:hover:not(:disabled) {- color: var(--on-stage);- background: color-mix(in srgb, var(--on-stage) 16%, transparent);-}+.export-transport__button:hover:not(:disabled) { background: var(--fill-subtle-hover); }+.export-transport__button:active:not(:disabled) { background: var(--fill-subtle-pressed); }+.export-transport__button:disabled { color: var(--text-disabled); }-.export-transport button:focus-visible {- outline: 2px solid var(--on-stage);- outline-offset: 1px;+.export-transport__scrub {+ flex: 1 1 auto;+ min-width: 0;+ margin: 0 var(--space-2);}-.export-transport button:disabled {- opacity: 0.42;+.export-transport__time {+ flex: none;+ color: var(--text-secondary);+ font-size: var(--text-xs);+ font-variant-numeric: tabular-nums;+ white-space: nowrap;}-.export-transport__play:not(:disabled) {- color: var(--on-stage);+.export-transport__time span:first-child {+ color: var(--text-primary);}-.export-transport__play:hover:not(:disabled) {- color: var(--on-stage);- background: color-mix(in srgb, var(--on-stage) 20%, transparent);+/* Fullscreen: the picture takes the screen and the same bar floats over its+ foot, revealed by a moving pointer and hidden again when it rests — the one+ place an auto-hiding overlay belongs. */+.export-stage:fullscreen {+ max-width: none;+ border: 0;+ border-radius: 0;+ background: var(--stage-bg);}-.export-transport input[type="range"] {- --scrub-progress: 0%;+.export-stage:fullscreen .export-picture {flex: 1 1 auto;- min-width: 0;- height: 24px;- margin: 0 var(--space-2);- appearance: none;- border: 0;- outline: 0;- background: transparent;+ aspect-ratio: auto !important;+ height: 100%;}-.export-transport input[type="range"]::-webkit-slider-runnable-track {- height: 4px;- border-radius: var(--radius-pill);- background: linear-gradient(to right, var(--accent-bright) 0 var(--scrub-progress), color-mix(in srgb, var(--on-stage) 38%, transparent) var(--scrub-progress) 100%);+.export-stage:fullscreen .export-transport {+ position: absolute;+ inset: auto 0 0;+ border-top: 0;+ color: var(--on-stage);+ background: color-mix(in srgb, var(--stage-bg) 72%, transparent);+ opacity: 0;+ visibility: hidden;+ transition: opacity var(--motion-normal) linear, visibility 0s linear var(--motion-normal);}-.export-transport input[type="range"]::-webkit-slider-thumb {- width: 14px;- height: 14px;- margin-top: -5px;- appearance: none;- border: 2px solid var(--on-stage);- border-radius: 50%;- background: var(--accent-bright);- box-shadow: 0 1px 4px color-mix(in srgb, var(--stage-bg) 55%, transparent);+.export-stage:fullscreen .export-transport__button,+.export-stage:fullscreen .export-transport__time,+.export-stage:fullscreen .export-transport__time span:first-child {+ color: var(--on-stage);}-.export-transport input[type="range"]::-moz-range-track {- height: 4px;- border-radius: var(--radius-pill);- background: color-mix(in srgb, var(--on-stage) 38%, transparent);+.export-stage--fullscreen.export-stage--controls-visible .export-transport,+.export-stage:fullscreen:focus-within .export-transport {+ opacity: 1;+ visibility: visible;+ transition-delay: 0s;}-.export-transport input[type="range"]::-moz-range-progress {- height: 4px;- border-radius: var(--radius-pill);- background: var(--accent-bright);+.export-stage--fullscreen:not(.export-stage--controls-visible):not(:focus-within) {+ cursor: none;}-.export-transport input[type="range"]::-moz-range-thumb {- width: 11px;- height: 11px;- border: 2px solid var(--on-stage);- border-radius: 50%;- background: var(--accent-bright);- box-shadow: 0 1px 4px color-mix(in srgb, var(--stage-bg) 55%, transparent);+@media (prefers-reduced-motion: reduce) {+ .export-stage:fullscreen .export-transport {+ transition: none;+ }}-.export-transport input[type="range"]:focus-visible::-webkit-slider-thumb {- box-shadow: 0 0 0 1px var(--stage-bg), 0 0 0 3px var(--on-stage);-}+/* --- Settings column ------------------------------------------------------------ */-.export-transport output {- flex: 0 0 auto;- min-width: 17ch;- display: flex;- justify-content: center;- gap: var(--space-1);- color: var(--on-stage);- font-family: var(--font-mono);- font-size: var(--text-2xs);- text-align: center;- text-shadow: 0 1px 2px var(--stage-bg);+.export-settings {+ min-width: 0;+ min-height: 0;+ overflow-y: auto;+ padding: var(--space-3) var(--space-4) var(--space-4);+ border-left: 1px solid var(--line);+ background: var(--layer);}-.export-transport output i {- color: color-mix(in srgb, var(--on-stage) 55%, transparent);- font-style: normal;+.export-settings__heading {+ margin: var(--space-2) 0 var(--space-2);+ color: var(--text-primary);+ font-size: var(--text-sm);+ font-weight: var(--weight-semibold);+ line-height: var(--leading-snug);}-@media (prefers-reduced-motion: reduce) {- .export-transport,- .export-transport button {- transition: none;- }+.export-settings__heading:not(:first-child) {+ margin-top: var(--space-4);+ padding-top: var(--space-3);+ border-top: 1px solid var(--line);}-/* --- Settings -------------------------------------------------------------- */--.export-fields {+.export-form {display: grid;- grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));- gap: var(--space-3);+ gap: var(--space-2);}-.export-fields label,-.export-field-note {+/* Label above the field, in sentence case: the Fluent form layout at 340px. */+.export-row {min-width: 0;- display: flex;- flex-direction: column;+ display: grid;gap: var(--space-1);}-.export-field-note {- grid-column: 1 / -1;-}--.export-fields label > span,-.export-field-note > span {- color: var(--text-muted);- font-size: var(--text-2xs);- font-weight: var(--weight-medium);+.export-row__label {+ color: var(--text-secondary);+ font-size: var(--text-xs);+ line-height: var(--leading-snug);}-.export-fields select {+.export-row .ui-combo {width: 100%;- height: var(--field-height);- padding: 0 var(--space-2);- border: 1px solid var(--line-strong);- border-radius: var(--radius-sm);- font-size: var(--text-sm);}-.export-fields select:disabled {- color: var(--text-faint);+.export-destination {+ min-width: 0;+ display: flex;+ align-items: center;+ gap: var(--space-2);}-.export-field-note p {- margin: 0;- color: var(--text-secondary);+.export-destination__path {+ flex: 1 1 auto;+ min-width: 0;+ overflow: hidden;+ color: var(--text-primary);font-size: var(--text-xs);- line-height: var(--leading-normal);+ line-height: var(--leading-snug);+ text-overflow: ellipsis;+ white-space: nowrap;+ direction: rtl;+ text-align: left;}-.export-field-note code {- color: var(--text-primary);- font-size: var(--text-2xs);- word-break: break-all;+.export-destination__browse {+ flex: none;}-/* --- Summary --------------------------------------------------------------- */-+/* The summary as a label/value list, one line per fact. */.export-summary {margin: 0;display: grid;- grid-template-columns: repeat(4, minmax(0, 1fr));- gap: 1px;- overflow: hidden;- border: 1px solid var(--line);- border-radius: var(--radius-md);- background: var(--line);+ gap: var(--space-2);}.export-summary > div {min-width: 0;- display: flex;- flex-direction: column;- gap: var(--space-3);- padding: var(--space-2) var(--space-3);- background: var(--panel-2);+ display: grid;+ grid-template-columns: 104px minmax(0, 1fr);+ gap: var(--space-2);}.export-summary dt {- flex: 0 0 auto;- color: var(--text-muted);- font-size: var(--text-2xs);- font-weight: var(--weight-medium);+ color: var(--text-secondary);+ font-size: var(--text-xs);+ line-height: var(--leading-snug);}.export-summary dd {min-width: 0;margin: 0;color: var(--text-primary);- font-size: var(--text-sm);- text-align: left;-}--@media (max-width: 760px) {- .export-summary {- grid-template-columns: repeat(2, minmax(0, 1fr));- }-}--@media (max-width: 480px) {- .export-summary {- grid-template-columns: minmax(0, 1fr);- }+ font-size: var(--text-xs);+ line-height: var(--leading-snug);+ font-variant-numeric: tabular-nums;}.export-summary dd small {display: block;- color: var(--text-faint);- font-size: var(--text-2xs);+ color: var(--text-muted);+ font-size: var(--text-xs);line-height: var(--leading-snug);}-/* --- Notices --------------------------------------------------------------- */+.export-messages {+ display: grid;+ gap: var(--space-2);+ margin-top: var(--space-3);+}-.export-notice {- margin-top: var(--space-4);- padding: var(--space-3) var(--space-4);- border: 1px solid var(--warning-line);- border-radius: var(--radius-md);- background: var(--warning-soft);+.export-reasons {+ margin: var(--space-1) 0 0;+ padding-left: var(--space-4);+ font-size: var(--text-xs);+ line-height: var(--leading-snug);}-.export-notice--bad {- border-color: var(--danger-line);- background: var(--danger-soft);+.export-reasons li + li {+ margin-top: var(--space-1);}-.export-notice h3 {- margin: 0 0 var(--space-2);+/* --- Footer ---------------------------------------------------------------------- */++.export-footer {+ min-height: 64px;display: flex;align-items: center;- gap: var(--space-2);- color: var(--warning);- font-size: var(--text-xs);- font-weight: var(--weight-semibold);+ gap: var(--space-4);+ padding: var(--space-3) var(--space-4);+ border-top: 1px solid var(--line);+ background: var(--layer-alt);}-.export-notice--bad h3 {- color: var(--danger);+.export-footer__status {+ flex: 1 1 auto;+ min-width: 0;}-.export-notice ul {- margin: 0;- padding-left: var(--space-4);+.export-footer__actions {+ flex: none;+ display: flex;+ gap: var(--space-2);}-.export-notice li,-.export-notice p {- margin: 0;- color: var(--text-secondary);- font-size: var(--text-xs);- line-height: var(--leading-normal);+.export-footer__actions .primary-button,+.export-footer__actions .secondary-button {+ min-width: 96px;}-.export-notice li + li {- margin-top: var(--space-1);+.export-progress {+ max-width: 560px;+ display: grid;+ gap: var(--space-2);}-/* --- Running and finishing ------------------------------------------------- */--.export-progress p {- margin: 0;- color: var(--text-secondary);+.export-progress__line {+ color: var(--text-primary);font-size: var(--text-xs);- line-height: var(--leading-normal);+ line-height: var(--leading-snug);+ font-variant-numeric: tabular-nums;}-.export-progress small {- color: var(--text-faint);- font-family: var(--font-mono);- font-size: var(--text-2xs);-}+@media (max-width: 900px) {+ .export-body {+ grid-template-columns: minmax(0, 1fr);+ grid-template-rows: auto minmax(0, 1fr);+ }-.export-outcome {- margin-top: var(--space-4);- padding: var(--space-3) var(--space-4);- border: 1px solid var(--line-strong);- border-radius: var(--radius-md);- color: var(--text-secondary);- background: var(--panel-2);- font-size: var(--text-xs);- line-height: var(--leading-normal);+ .export-settings {+ border-left: 0;+ border-top: 1px solid var(--line);+ }}