AI media harness for planning, generating, and editing locally
TypeScript
One Saved notification, one preview size, two equal panels
Bittid4c55ded4396
diff --git a/src/components/SettingsView.test.tsx b/src/components/SettingsView.test.tsxindex d2fae75..220e5d3 100644--- a/src/components/SettingsView.test.tsx+++ b/src/components/SettingsView.test.tsx@@ -1,6 +1,7 @@// @vitest-environment jsdomimport { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";+import { readFileSync } from "node:fs";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { SettingsView } from "./SettingsView";@@ -12,6 +13,19 @@ afterEach(cleanup);const open = () => render(<SettingsView onClose={() => undefined} />);const tab = (name: string) => screen.getByRole("tab", { name: new RegExp(`^${name}`) });+/* jsdom does no layout, so the one thing that can be checked here is that the+ rule which makes the two tabs the same height is still in the sheet: the+ panels differ by hundreds of pixels, and a shrink-to-fit dialog moved the tab+ row out from under the pointer that had just clicked it. */+describe("the frame the tabs sit in", () => {+ it("gives the dialog a height of its own rather than letting the open tab set it", () => {+ const css = readFileSync("src/styles/shell.css", "utf8");+ const rule = css.slice(css.indexOf(".settings-view {"), css.indexOf(".settings-view__body"));+ expect(rule).toMatch(/^\s*height: min\(/m);+ expect(rule).not.toMatch(/^\s*max-height:/m);+ });+});+describe("the settings screen", () => {it("opens on the engine, because that is what has to be set before anything renders", async () => {open();diff --git a/src/components/workspace/ExportView.test.tsx b/src/components/workspace/ExportView.test.tsxindex 1ed46a3..e1f838e 100644--- a/src/components/workspace/ExportView.test.tsx+++ b/src/components/workspace/ExportView.test.tsx@@ -97,6 +97,48 @@ describe("the export view where nothing can encode", () => {});});+/* 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", () => {+ render(<ExportView config={project([clip("a", 0, 2_000)])} folderPath="/tmp/project" />);+ expect(screen.getByRole("heading", { name: "Video" })).toBeTruthy();+ expect(screen.getByRole("heading", { name: "Settings" })).toBeTruthy();+ expect(screen.queryByRole("heading", { name: "Preview" })).toBeNull();+ expect(screen.queryByRole("heading", { name: "Export Settings" })).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!;+ 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", () => {+ 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");+ });++ 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();+ });+});+/* The other half of the media policy: video is NOT copied into the project, soa 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 — thediff --git a/src/components/workspace/ExportView.tsx b/src/components/workspace/ExportView.tsxindex 5562c82..98a38bf 100644--- a/src/components/workspace/ExportView.tsx+++ b/src/components/workspace/ExportView.tsx@@ -1,4 +1,4 @@-import { CircleCheck, Download, FileVideo, Maximize, Minimize, Pause, Play, SkipBack, SkipForward, TriangleAlert, X } from "lucide-react";+import { CircleCheck, Download, Maximize, Minimize, Pause, Play, SkipBack, SkipForward, TriangleAlert, X } from "lucide-react";import { useCallback, useEffect, useMemo, useRef, useState } from "react";import {audioMixBytes,@@ -26,7 +26,6 @@ import {runExport,writeExportFile,type CodecProbe,- type CompositorKind,type CompositorProbe,type ExportProgress,} from "../../lib/exportPipeline";@@ -45,14 +44,15 @@ const resolutionChoices = (current: Resolution): Resolution[] =>const FRAME_RATES: FrameRate[] = [24, 25, 30, 60];const describe = (reason: unknown) => (reason instanceof Error ? reason.message : String(reason));-interface FinishedExport {- path: string;- bytes: number;- compositor: CompositorKind;- compositorDetail: string;- codecString: string;- audio: boolean;- audioDetail: string;+/** How long the Saved notification stays up before it takes itself away. */+const SAVED_NOTICE_MS = 4_000;++/* 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[];}@@ -79,7 +79,11 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; foldconst stageRef = useRef<HTMLDivElement>(null);const [progress, setProgress] = useState<ExportProgress | null>(null);- const [result, setResult] = useState<FinishedExport | 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);@@ -146,6 +150,15 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; foldreturn () => document.removeEventListener("fullscreenchange", sync);}, []);+ /* 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]);+const toggleFullscreen = () => {const stage = stageRef.current;if (!stage) return;@@ -175,7 +188,8 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; foldconst start = async () => {setError(null);- setResult(null);+ setSaved(false);+ setLeftOut(null);setCancelled(false);let destination: string | null = null;try {@@ -203,18 +217,9 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; foldframeCount: plan.frameCount,detail: `Writing ${formatBytes(outcome.bytes.byteLength)} to ${destination}…`,});- const written = await writeExportFile(destination, outcome.bytes);- setResult({- path: destination,- bytes: written,- compositor: outcome.compositor,- compositorDetail: outcome.compositorDetail,- codecString: outcome.codecString,- audio: outcome.audio,- audioDetail: outcome.audioDetail,- audioProblems: outcome.audioProblems,- audioShortfalls: outcome.audioShortfalls,- });+ 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));@@ -225,11 +230,7 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; foldconst summary: Array<[string, string, string?]> = [["Duration", formatDuration(plan.durationMs), `${plan.frameCount} frames at ${plan.frameRate} fps`],- [- "Estimated size",- formatBytes(estimatedBytes(bitrate, plan.durationMs)),- "target bitrate × duration, not a measurement",- ],+ ["Estimated size", formatBytes(estimatedBytes(bitrate, plan.durationMs))],["Sound",plan.audio.length === 0@@ -267,7 +268,16 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; foldscreen exists for. */}<header className="export-heading"><h1>Export</h1>- <div>+ {/* 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 && <buttonclassName="secondary-button"type="button"@@ -288,13 +298,22 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; fold<div className="export-layout"><section className="export-preview" aria-labelledby="export-preview-heading">- <h2 id="export-preview-heading">Preview</h2>+ <h2 id="export-preview-heading">Video</h2>{/* The same player the timeline uses, on the same cut: it decodes thereal files and plays them with their sound, rather than decoding onestill frame per scrub. What the export will contain is what thisplays — the picture is fitted inside the project's frame and therest is the project's background, exactly as the encoder does it. */}- <div className="export-stage" ref={stageRef}>+ {/* 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. */}+ <div+ className="export-stage"+ ref={stageRef}+ style={{ aspectRatio: `${plan.width} / ${plan.height}`, "--frame-aspect": plan.width / plan.height } as React.CSSProperties}+ ><ProgramMonitorconfig={config}folderPath={folderPath}@@ -353,7 +372,7 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; fold</section><section className="export-settings" aria-labelledby="export-settings-heading">- <h2 id="export-settings-heading">Export Settings</h2>+ <h2 id="export-settings-heading">Settings</h2><div className="export-fields"><label htmlFor="export-resolution">@@ -448,30 +467,21 @@ export function ExportView({ config, folderPath }: { config: ProjectConfig; fold<p>{error}</p></div>}- {result && <div className="export-outcome export-outcome--good" role="status">- <h3><CircleCheck size={16} aria-hidden="true" /> Saved</h3>- <p>- <FileVideo size={14} aria-hidden="true" /> <code>{result.path}</code>- </p>- <p>- {formatBytes(result.bytes)} written · {result.codecString} · composited with{" "}- {result.compositor === "webgpu" ? "WebGPU" : "a 2D canvas"}- {result.compositorDetail ? <> — {result.compositorDetail}</> : null}.- </p>- <p>{result.audio ? "Sound: " : ""}{result.audioDetail}</p>- {result.audioProblems.length > 0 && <>- {/* Named, not dropped in silence: a soundtrack that vanished without- a word is the failure worth shouting about. */}- <p><TriangleAlert size={14} aria-hidden="true" /> Left out of the soundtrack:</p>- <ul>{result.audioProblems.map((problem) => <li key={problem}>{problem}</li>)}</ul>- </>}- {result.audioShortfalls.length > 0 && <>- {/* 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. */}- <p><TriangleAlert size={14} aria-hidden="true" /> Ran out of sound before the clip ended:</p>- <ul>{result.audioShortfalls.map((shortfall) => <li key={shortfall}>{shortfall}</li>)}</ul>- </>}+ {/* 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></div>}</section></div>diff --git a/src/lib/theme.test.ts b/src/lib/theme.test.tsindex ad0af3a..dd3238f 100644--- a/src/lib/theme.test.ts+++ b/src/lib/theme.test.ts@@ -237,6 +237,9 @@ describe("every stylesheet resolves through the palette", () => {// The lane grid's interval, computed from the ruler's own tick step so the// lines under the clips fall where the timecodes above them are."--lane-grid": "src/components/workspace/TimelineView.tsx",+ // The project's frame shape, so the export stage keeps one size whatever is+ // under the playhead.+ "--frame-aspect": "src/components/workspace/ExportView.tsx",};for (const [token, source] of Object.entries(setByComponents)) {diff --git a/src/styles/export.css b/src/styles/export.cssindex 0ccb2b3..c49015b 100644--- a/src/styles/export.css+++ b/src/styles/export.css@@ -15,12 +15,15 @@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: flex;+ display: grid;+ grid-template-columns: 1fr auto 1fr;align-items: flex-end;- justify-content: space-between;gap: var(--space-5);}@@ -34,21 +37,63 @@/* Export, and Cancel while it runs — the same place the References screen putsAdd image. */-.export-heading > div {- flex: 0 0 auto;+.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);+ letter-spacing: var(--tracking-label);+ text-transform: uppercase;+ animation: export-toast-in 0.18s ease-out;+}++.export-toast svg {+ flex: 0 0 auto;+}++@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 ---------------------------------------------------------------- */+/* Two panels of the same width, and — because they stretch rather than sit at+ their own heights — the same height as each other. */.export-layout {max-width: var(--content-max);margin: 0 auto;display: grid;- grid-template-columns: minmax(0, 1fr) 420px;+ grid-template-columns: repeat(2, minmax(0, 1fr));gap: var(--space-5);- align-items: start;+ align-items: stretch;}@media (max-width: 1120px) {@@ -80,11 +125,18 @@/* --- 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. */.export-stage {position: relative;width: 100%;- max-height: 56vh;- margin-bottom: var(--space-3);+ max-width: calc(56vh * var(--frame-aspect, 1.7778));+ margin: 0 auto var(--space-3);display: grid;place-items: center;overflow: hidden;@@ -107,7 +159,7 @@/* Fullscreen paints the stage's own background behind the picture, so theblack bars stay black rather than showing the page through them. */.export-stage:fullscreen {- max-height: none;+ max-width: none;border: 0;border-radius: 0;background: var(--stage-bg);@@ -264,8 +316,7 @@line-height: var(--leading-normal);}-.export-field-note code,-.export-outcome code {+.export-field-note code {color: var(--text-primary);font-size: var(--text-2xs);word-break: break-all;@@ -390,46 +441,3 @@line-height: var(--leading-normal);}-.export-outcome--good {- border-color: var(--success-line);- background: var(--success-soft);-}--.export-outcome h3 {- margin: 0 0 var(--space-2);- display: flex;- align-items: center;- gap: var(--space-2);- color: var(--success);- font-size: var(--text-xs);- font-weight: var(--weight-semibold);- letter-spacing: var(--tracking-label);- text-transform: uppercase;-}--.export-outcome p {- margin: 0;- display: flex;- align-items: center;- gap: var(--space-2);-}--.export-outcome p + p {- margin-top: var(--space-2);- color: var(--text-muted);-}--/* The audio clips that did NOT make it into the file, named one per line. This- list is the difference between a soundtrack that failed and one that vanished- without a word, so it is not allowed to read as a footnote. */-.export-outcome ul {- margin: var(--space-2) 0 0;- padding-left: var(--space-4);- display: grid;- gap: var(--space-1);- color: var(--text-muted);-}--.export-outcome ul li {- line-height: var(--leading-normal);-}diff --git a/src/styles/shell.css b/src/styles/shell.cssindex 47b4b66..ab56ba6 100644--- a/src/styles/shell.css+++ b/src/styles/shell.css@@ -257,8 +257,13 @@does not know the unit. */.settings-view {width: min(880px, 100%);- max-height: calc(100vh - var(--space-7) * 2);- max-height: calc(100dvh - var(--space-7) * 2);+ /* ONE height, whichever tab is open. The two panels are nothing like the same+ length — five path fields against three theme cards — and a dialog that+ halved in height when the tab changed pulled the tab row itself out from+ under the pointer that had just clicked it. The viewport cap still wins on+ a short window, and the body scrolls inside whatever height that leaves. */+ height: min(860px, calc(100vh - var(--space-7) * 2));+ height: min(860px, calc(100dvh - var(--space-7) * 2));margin: 0 auto;display: grid;grid-template-rows: auto auto minmax(0, 1fr) auto;@@ -609,8 +614,8 @@}.settings-view {- max-height: calc(100vh - var(--space-4) * 2);- max-height: calc(100dvh - var(--space-4) * 2);+ height: min(860px, calc(100vh - var(--space-4) * 2));+ height: min(860px, calc(100dvh - var(--space-4) * 2));padding: var(--space-5) var(--space-4);}