AI media harness for planning, generating, and editing locally
TypeScript
Project-wide status bar: view facts, preview GPU and playback rate, sequence format, save state
Bittiea31f23db6c6
diff --git a/src/components/ProjectWorkspace.test.ts b/src/components/ProjectWorkspace.test.tsindex 30c4cf0..49f2d3f 100644--- a/src/components/ProjectWorkspace.test.ts+++ b/src/components/ProjectWorkspace.test.ts@@ -9,7 +9,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";import completeFixture from "../../fixtures/project-v1-complete.json";import { compileMiniMaxH3Prompt, createProjectConfig, parseProjectConfig, sceneShots, UNTITLED_SCENE, type GenerationJob, type ProjectConfig, type ProjectRecord } from "../lib/project";import { saveGeneratedScene } from "../lib/generatedVideo";-import { formatDurationTimecode, isGenerationOngoing } from "./ProjectWorkspace";+import { formatDurationTimecode, formatSavedAt, formatSequenceLength, isGenerationOngoing } from "./ProjectWorkspace";import { ProjectWorkspace } from "./ProjectWorkspace";import { GeneratorView } from "./workspace/GeneratorView";import { REFERENCE_DRAG_TYPE } from "./workspace/SceneEditor";@@ -155,6 +155,33 @@ describe("project workspace timecode", () => {expect(within(pane).getByRole("textbox", { name: "Ask Slop about this generation queue" })).toBeInTheDocument();});+ it("formats the status bar's sequence length and save time", () => {+ expect(formatSequenceLength(32_000)).toBe("32 s");+ expect(formatSequenceLength(2_500)).toBe("2.5 s");+ expect(formatSequenceLength(65_000)).toBe("1:05");+ expect(formatSavedAt(null)).toBe("Saved");+ const now = new Date(2026, 8, 26, 18, 42).getTime();+ expect(formatSavedAt(now, now)).toMatch(/^Saved .*42/);+ expect(formatSavedAt(new Date(2026, 8, 24, 9, 0).getTime(), now)).toMatch(/^Saved .*24/);+ });++ it("keeps one status bar on every view: the view's facts leading, format and save state trailing", async () => {+ const config = createProjectConfig({ name: "Ceramic lamp", prompt: "A quiet product film", aspectRatio: "16:9", resolution: "1080p", targetDurationSeconds: 30 });+ render(createElement(ProjectWorkspace, { project: { folderPath: "C:\Ceramic Lamp", config }, initialView: "references", onBack: () => undefined, onSave: async () => undefined }));+ const bar = screen.getByRole("region", { name: "References status" });+ expect(bar).toHaveTextContent("0 references");+ expect(bar).toHaveTextContent(`1920×1080 · ${config.settings.frameRate} fps · 0 s`);+ expect(bar).toHaveTextContent(/Saved/);++ const tabs = screen.getByRole("tablist", { name: "Project views" });+ fireEvent.click(within(tabs).getByRole("tab", { name: "Generator" }));+ const generatorBar = screen.getByRole("region", { name: "Generator status" });+ expect(generatorBar).toBe(bar);+ expect(within(generatorBar).getByRole("status")).toHaveTextContent(/scene/);+ expect(generatorBar).not.toHaveTextContent("references");+ expect(document.querySelectorAll(".ui-statusbar")).toHaveLength(1);+ });+it("surfaces native save failures in the workspace, inline under the title bar", async () => {const record = { folderPath: "C:\\Portable Launch Film", config: parseProjectConfig(completeFixture) };const queue = new WorkQueue(async () => { throw new Error("The original project file is locked."); });diff --git a/src/components/ProjectWorkspace.tsx b/src/components/ProjectWorkspace.tsxindex b369502..6d5d244 100644--- a/src/components/ProjectWorkspace.tsx+++ b/src/components/ProjectWorkspace.tsx@@ -14,7 +14,9 @@ import { TimelineView, type ConfigUpdate } from "./workspace/TimelineView";import { UnsavedProjectDialog } from "./UnsavedProjectDialog";import { PromptComposer } from "./PromptComposer";import { TitleBar } from "./TitleBar";-import { InfoBadge, InfoBar, SelectorBar, Splitter, usePaneSize } from "./ui";+import { InfoBadge, InfoBar, SelectorBar, Splitter, StatusBar, tooltipProps, usePaneSize } from "./ui";+import { ProjectStatusSlot } from "./workspace/ProjectStatus";+import { outputDimensions, videoDurationMs } from "../lib/export";import { invoke } from "@tauri-apps/api/core";import { isTauri } from "../lib/persistence";@@ -35,6 +37,24 @@ export function formatDurationTimecode(totalSeconds: number): string {return [hours, minutes, remainder].map((value) => String(value).padStart(2, "0")).join(":");}+/** A sequence's length as the status bar gives it: "32 s", "2.5 s", "1:05". */+export function formatSequenceLength(ms: number): string {+ const seconds = Math.max(0, ms) / 1000;+ if (seconds < 60) return `${Number(seconds.toFixed(seconds < 10 ? 1 : 0))} s`;+ const whole = Math.round(seconds);+ return `${Math.floor(whole / 60)}:${String(whole % 60).padStart(2, "0")}`;+}++/** "Saved 18:42" for today, "Saved 24 Sep" for an older save. */+export function formatSavedAt(savedAt: number | null, now = Date.now()): string {+ if (savedAt === null) return "Saved";+ const when = new Date(savedAt);+ const today = new Date(now).toDateString() === when.toDateString();+ return `Saved ${today+ ? when.toLocaleTimeString(undefined, { hour: "2-digit", minute: "2-digit" })+ : when.toLocaleDateString(undefined, { day: "numeric", month: "short" })}`;+}+const AGENT_PANE_KEY = "slopus.workspace.agentPane";const readAgentPane = (): boolean => {try { return localStorage.getItem(AGENT_PANE_KEY) !== "closed"; } catch { return true; }@@ -107,7 +127,7 @@ export function ProjectWorkspace({ project, initialView = "timeline", runtime =const [localQueue] = useState(() => new WorkQueue((record) => saveRef.current(record)));const queue = workQueue ?? localQueue;const session = useMemo(() => queue.project(project), [queue, project.folderPath, project.config.id]);- const { config, saving, dirty, saveError, canUndo, canRedo } = useSyncExternalStore(session.subscribe, session.getSnapshot);+ const { config, saving, dirty, saveError, canUndo, canRedo, savedAt } = useSyncExternalStore(session.subscribe, session.getSnapshot);const items = useSyncExternalStore(queue.subscribe, queue.getSnapshot);const imageProject = config.generationType === "image";const imageOutput = config.assets.find((asset) => asset.kind === "image" && asset.id === config.imageScene?.outputAssetId);@@ -138,6 +158,8 @@ export function ProjectWorkspace({ project, initialView = "timeline", runtime =const generationCompletionTimes = Object.fromEntries(projectItems.filter((item) => item.completionAt !== null).map((item) => [item.sceneId, item.completionAt as number]));const cancellingJobIds = new Set(projectItems.filter((item) => item.cancelling).map((item) => item.sceneId));const panelId = useId();+ /* The status bar's leading side is filled by the view through a portal. */+ const [statusSlot, setStatusSlot] = useState<HTMLElement | null>(null);useEffect(() => workQueue ? undefined : queue.start(), [queue, workQueue]);/* Every edit a view reports is an undo step. A view may pass a key tocoalesce a run of edits (a drag, typing) into one; the default key already@@ -175,6 +197,10 @@ export function ProjectWorkspace({ project, initialView = "timeline", runtime =knownSceneIds.current = current;}, [config.generationJobs, project.folderPath]);+ const { width: frameWidth, height: frameHeight } = outputDimensions(config.settings.resolution, config.settings.aspectRatio);+ const lengthMs = useMemo(() => videoDurationMs(config), [config]);+ const sequenceFormat = `${frameWidth}×${frameHeight} · ${config.settings.frameRate} fps · ${formatSequenceLength(lengthMs)}`;+const views: ShownView[] = imageProject ? ["editor", "references"] : ["timeline", "generator", "references", "export"];const running = config.generationJobs.filter(isGenerationOngoing).length;const toggleAgent = () => {@@ -264,6 +290,7 @@ export function ProjectWorkspace({ project, initialView = "timeline", runtime ={imageExportError && <InfoBar severity="error" title="Couldn’t export image" message={imageExportError} onClose={() => setImageExportError(null)} />}</div>}+ <ProjectStatusSlot.Provider value={statusSlot}><div className={`project-body${agentOpen ? " project-body--agent" : ""}`} style={agentPane.style}><div id={`${panelId}-view`} role="tabpanel" aria-label={VIEW_LABELS[view]} className={`project-content project-content--${view}`}>{view === "editor" && imageProject && <ImageEditor config={config} folderPath={project.folderPath} onChange={changeConfig} onGenerate={(template) => queue.enqueueImage(session, template)} onCancel={(id) => queue.cancel(id)} work={projectItems.filter((item) => item.kind === "image").at(-1)} />}@@ -294,5 +321,22 @@ export function ProjectWorkspace({ project, initialView = "timeline", runtime =/></aside></div>+ </ProjectStatusSlot.Provider>++ {/* One strip along the window's foot on every view: the view's own facts+ on the leading side, the sequence and whether it is on disk trailing. */}+ <StatusBar+ aria-label={`${VIEW_LABELS[view]} status`}+ className="project-status"+ end={<>+ {!imageProject && <span className="project-status__format" {...tooltipProps("Sequence format: frame size, frame rate and length")}>{sequenceFormat}</span>}+ <span+ className={`project-status__save project-status__save--${saving ? "saving" : dirty ? "unsaved" : "saved"}`}+ {...tooltipProps(!saving && !dirty && savedAt !== null ? `Saved ${new Date(savedAt).toLocaleString()}` : undefined)}+ >{saving ? "Saving…" : dirty ? "Unsaved changes" : formatSavedAt(savedAt)}</span>+ </>}+ >+ <span ref={setStatusSlot} className="project-status__view" />+ </StatusBar></div>;}diff --git a/src/components/workspace/ExportView.tsx b/src/components/workspace/ExportView.tsxindex 85f0861..7abf61d 100644--- a/src/components/workspace/ExportView.tsx+++ b/src/components/workspace/ExportView.tsx@@ -38,6 +38,7 @@ import {import { askNative, messageNative, revealInExplorer } from "../../lib/nativeShell";import { formatTimecode, frameAt, frameStartMs } from "../../lib/timeline";import { ProgramMonitor } from "./ProgramMonitor";+import { ProjectStatus } from "./ProjectStatus";import { PROJECT_RESOLUTIONS, type ProjectConfig, type Resolution } from "../../lib/project";import { ComboBox, InfoBar, ProgressBar, PropRow, PropSection, Slider, Splitter, tooltipProps, usePaneSize } from "../ui";@@ -541,5 +542,15 @@ export function ExportView({ config, folderPath, onClose }: {</div></section></div>+ {/* The encoder and compositor this export would run on, as this machine+ answered the probes above. Nothing is shown until they have answered. */}+ <ProjectStatus label="Export status">+ {codecProbe?.supported && <span className="project-status__fact" {...tooltipProps("The codec string this computer's WebCodecs encoder accepted")}>+ Encode <b>{OUTPUT_CODECS.find((codec) => codec.id === settings.codec)?.label ?? settings.codec}</b> · {codecProbe.codecString}+ </span>}+ {compositor && <span className="project-status__fact" {...tooltipProps(compositor.detail)}>+ {compositor.kind === "webgpu" ? <>GPU <b>{compositor.adapterName || "WebGPU"}</b></> : <>Compositor <b>2D canvas</b></>}+ </span>}+ </ProjectStatus></div>;}diff --git a/src/components/workspace/GeneratorView.tsx b/src/components/workspace/GeneratorView.tsxindex 572457a..ee65a35 100644--- a/src/components/workspace/GeneratorView.tsx+++ b/src/components/workspace/GeneratorView.tsx@@ -8,7 +8,8 @@ import { invoke } from "@tauri-apps/api/core";import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";import { useShortcut } from "../../lib/commands";import { askNative } from "../../lib/nativeShell";-import { CommandBar, CommandBarButton, CommandBarSeparator, ComboBox, EmptyState, ItemHeader, Splitter, StatusBar, tooltipProps, usePaneSize } from "../ui";+import { ProjectStatus } from "./ProjectStatus";+import { CommandBar, CommandBarButton, CommandBarSeparator, ComboBox, EmptyState, ItemHeader, Splitter, tooltipProps, usePaneSize } from "../ui";import { actionReferenceIds, compileGenerationJobPrompt, compileGenerationJobSegments, createDraftGenerationJob, danglingReferenceTokens, GENERATION_FRAME_RATE, RANDOM_GENERATION_SEED, sceneDurationSeconds, sceneFrameInputs, sceneGenerationReferences, sceneGenerationSeed, sceneGenerationSnapshot, sceneGenerationSteps, sceneShots, SCENE_MAX_SECONDS, SCENE_MIN_SECONDS, projectItemPath, usableReferenceImages, type GenerationJob, type ProjectConfig, type ProjectReference, type SceneShot } from "../../lib/project";import { generationDimensions } from "../../lib/export";import { isTauri } from "../../lib/persistence";@@ -572,15 +573,11 @@ export function GeneratorView({ config, folderPath, runtime = null, generationCo/>}</div>- <StatusBar- aria-label="Generator status"- className="generator-status"- end={runtimeError || (generatorRuntime && generatorRuntime.state !== "ready")- ? <span className="generator-status__runtime">{runtimeError ? "Generator unavailable" : runtimeHeadline(generatorRuntime)}</span>- : undefined}- >+ <ProjectStatus label="Generator status"><span role="status">{boardSummary(active.length, queued.length, jobs.length)}</span>- </StatusBar>+ {(runtimeError || (generatorRuntime && generatorRuntime.state !== "ready"))+ && <span className="generator-status__runtime">{runtimeError ? "Generator unavailable" : runtimeHeadline(generatorRuntime)}</span>}+ </ProjectStatus></main>{selected && <Splitter {...inspectorPane.splitterProps} reverse aria-label="Resize inspector" aria-controls="generator-inspector" />}diff --git a/src/components/workspace/PreviewEngineStatus.tsx b/src/components/workspace/PreviewEngineStatus.tsxnew file mode 100644index 0000000..7fa4d80--- /dev/null+++ b/src/components/workspace/PreviewEngineStatus.tsx@@ -0,0 +1,22 @@+import { useSyncExternalStore } from "react";+import { previewEngine } from "../../lib/previewEngine";+import { tooltipProps } from "../ui";++/** The program monitor's engine, in the status bar: the GPU it composites on+ * and, while playing, the rate pictures reach the screen. Only what the+ * preview has actually measured is shown; a fact it does not have is left+ * out rather than guessed. Re-renders at most once a second. */+export function PreviewEngineStatus() {+ const { gpu, playback } = useSyncExternalStore(previewEngine.subscribe, previewEngine.getSnapshot);+ return <>+ {gpu?.kind === "webgpu" && <span className="project-status__fact" {...tooltipProps("The GPU the program monitor composites on (WebGPU)")}>+ GPU <b>{gpu.name || "WebGPU"}</b>+ </span>}+ {gpu?.kind === "none" && <span className="project-status__fact" {...tooltipProps(gpu.reason)}>+ GPU <b>unavailable</b>+ </span>}+ {playback && <span className="project-status__fact" {...tooltipProps("Pictures the monitor showed in the last second, and redraws since Play that kept the previous picture because a decoder was still loading or seeking")}>+ Playback <b>{playback.fps.toFixed(1)}</b> fps · <b>{playback.dropped}</b> dropped+ </span>}+ </>;+}diff --git a/src/components/workspace/ProgramMonitor.tsx b/src/components/workspace/ProgramMonitor.tsxindex 7b75dcd..40b88a8 100644--- a/src/components/workspace/ProgramMonitor.tsx+++ b/src/components/workspace/ProgramMonitor.tsx@@ -9,6 +9,7 @@ import { clipEndMs } from "../../lib/timeline";import { PreviewSources } from "../../lib/exportPipeline";import { preparedPreviewClips, previewSegmentIndex, previewSegments } from "../../lib/timelinePreview";import { PreviewMedia } from "../../lib/previewPresentation";+import { PLAYBACK_SAMPLE_MS, previewEngine } from "../../lib/previewEngine";/* The monitor owns a continuous timeline clock. Each visible or upcoming clip* owns a persistent media element: loading, decoding the first frame and seeking@@ -213,6 +214,19 @@ export function ProgramMonitor({ config, folderPath, playheadMs, playing, rate =frame = requestAnimationFrame(step);return () => cancelAnimationFrame(frame);}, [playing, rate, contentEndMs, report]);+ /* The status bar's playback rate: counted by the picture on every tick,+ published once a second, never through this component's state. */+ useEffect(() => {+ if (!playing) return;+ previewEngine.start();+ let last = performance.now();+ const timer = window.setInterval(() => {+ const now = performance.now();+ previewEngine.sample(now - last);+ last = now;+ }, PLAYBACK_SAMPLE_MS);+ return () => { window.clearInterval(timer); previewEngine.stop(); };+ }, [playing]);/* Media plays forward only. In reverse the elements stay paused and followthe clock by seeking, which ProgramLayer does for any paused layer. */const mediaPlaying = playing && rate > 0;diff --git a/src/components/workspace/ProgramPicture.tsx b/src/components/workspace/ProgramPicture.tsxindex 4c2bf19..0081837 100644--- a/src/components/workspace/ProgramPicture.tsx+++ b/src/components/workspace/ProgramPicture.tsx@@ -1,6 +1,7 @@import { useEffect, useLayoutEffect, useRef, useState } from "react";import { createPreviewCompositor, type Compositor } from "../../lib/exportPipeline";import { presentPreviewFrame, type PreviewMedia } from "../../lib/previewPresentation";+import { previewEngine } from "../../lib/previewEngine";import type { TimelineClip } from "../../lib/project";/** A persistent presentation surface: media elements may come and go, but a@@ -17,19 +18,24 @@ export function ProgramPicture({ media, layers, playheadMs, width, height, backgconst canvas = useRef<HTMLCanvasElement>(null);const current = useRef({ layers, playheadMs, onAvailable });current.current = { layers, playheadMs, onAvailable };- const redraw = useRef<(() => void) | null>(null);+ const redraw = useRef<((tick?: boolean) => void) | null>(null);const [available, setAvailable] = useState(false);const [error, setError] = useState<string | null>(null);useEffect(() => {if (!canvas.current) return;let live = true;let compositor: Compositor | null = null;- const draw = () => {+ /* A playhead tick (not a media event) is what playback is measured by:+ did the new moment reach the screen, or did the old picture stay? */+ const draw = (tick = false) => {if (!live || !compositor) return;- try { presentPreviewFrame(compositor, media, current.current.layers, current.current.playheadMs); }+ try {+ const presented = presentPreviewFrame(compositor, media, current.current.layers, current.current.playheadMs);+ if (tick) previewEngine.tick(presented);+ }catch (reason) { setError(String(reason)); }};- const unsubscribe = media.subscribe(draw);+ const unsubscribe = media.subscribe(() => draw());redraw.current = draw;setError(null);void createPreviewCompositor(canvas.current, width, height, background).then((created) => {@@ -49,7 +55,7 @@ export function ProgramPicture({ media, layers, playheadMs, width, height, backgcompositor?.dispose();};}, [media, width, height, background]);- useLayoutEffect(() => redraw.current?.(), [layers, playheadMs]);+ useLayoutEffect(() => redraw.current?.(true), [layers, playheadMs]);return <><canvas ref={canvas} className="program-composited-picture" aria-label="Video preview" style={{ visibility: available ? "visible" : "hidden" }} />{available && error && <div className="program-note program-note--error" role="alert">{error}</div>}diff --git a/src/components/workspace/ProjectStatus.tsx b/src/components/workspace/ProjectStatus.tsxnew file mode 100644index 0000000..4ad4d34--- /dev/null+++ b/src/components/workspace/ProjectStatus.tsx@@ -0,0 +1,28 @@+import { createContext, useContext, type ReactNode } from "react";+import { createPortal } from "react-dom";+import { StatusBar } from "../ui";++/* The project window has ONE status bar, along its bottom, on every tab. Its+ trailing side (sequence format, save state) belongs to the workspace; its+ leading side belongs to whichever view is showing. A view says what goes+ there with <ProjectStatus>, which is portalled into the shared bar — the+ items stay the view's own components, rendered from its own state.++ A view rendered on its own (outside a project window) has no shared bar, so+ it gets a strip of its own at its foot instead, with the same label. */++/** The shared bar's leading slot: the element to portal into, null while it+ * mounts, undefined outside a project window. */+export const ProjectStatusSlot = createContext<HTMLElement | null | undefined>(undefined);++export function ProjectStatus({ label, className, children }: {+ /** The view's name for its status ("Generator status"), used when the view+ * stands alone. */+ label: string;+ className?: string;+ children: ReactNode;+}) {+ const slot = useContext(ProjectStatusSlot);+ if (slot === undefined) return <StatusBar aria-label={label} className={className}>{children}</StatusBar>;+ return slot ? createPortal(children, slot) : null;+}diff --git a/src/components/workspace/ReferencesView.tsx b/src/components/workspace/ReferencesView.tsxindex 869e8e7..01a49f9 100644--- a/src/components/workspace/ReferencesView.tsx+++ b/src/components/workspace/ReferencesView.tsx@@ -27,13 +27,14 @@ import { ReferenceIconGenerationDialog } from "../ReferenceIconGenerationDialog"import { builtinIconRevision, refreshBuiltinIcons, subscribeBuiltinIcons } from "../../lib/builtinReferenceIcons";import { builtinIconVisitAction, saveBuiltinIconChoice } from "../../lib/referenceIconSettings";import { ReferenceVideo } from "./ReferenceVideo";+import { ProjectStatus } from "./ProjectStatus";import { MediaThumbnail } from "./MediaThumbnail";import { inspectReferenceVideo } from "../../lib/referenceVideo";import { DebugPromptDialog } from "./DebugPromptDialog";import { referenceIconPrompt } from "../../lib/referenceIcons";import { loadDebugOptionsEnabled, subscribeDebugOptions } from "../../lib/settings";import {- CommandBar, CommandBarButton, CommandBarSeparator, ComboBox, ContentDialog, EmptyState, InfoBar, ItemHeader, PropRow, PropSection, SelectorBar, Splitter, StatusBar,+ CommandBar, CommandBarButton, CommandBarSeparator, ComboBox, ContentDialog, EmptyState, InfoBar, ItemHeader, PropRow, PropSection, SelectorBar, Splitter,tooltipProps, useContextMenu, usePaneSize, type MenuEntry,} from "../ui";import { isMenuKey } from "./SceneBoard";@@ -485,10 +486,10 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,</table></div>}</section>- <StatusBar aria-label="References status" className="references-status">+ <ProjectStatus label="References status"><span>{config.references.length === 1 ? "1 reference" : `${config.references.length} references`}</span>{selection.length > 1 && <span>{selection.length} selected</span>}- </StatusBar>+ </ProjectStatus>{menu.element}</main>diff --git a/src/components/workspace/TimelineView.tsx b/src/components/workspace/TimelineView.tsxindex b10fc5f..5a35e7e 100644--- a/src/components/workspace/TimelineView.tsx+++ b/src/components/workspace/TimelineView.tsx@@ -1,4 +1,6 @@import { clipEffectCount, ClipEffects } from "./ClipEffects";+import { ProjectStatus } from "./ProjectStatus";+import { PreviewEngineStatus } from "./PreviewEngineStatus";import {AudioLines, ChevronFirst, ChevronLast, Clapperboard, Copy, Ellipsis, Film, Image as ImageIcon, LayoutGrid, List, Lock, LockOpen,MousePointerClick, PanelLeft, PanelRight, Pause, Play, Plus, Scan, Scissors, Sparkles, StepBack, StepForward, Trash2, Type, Upload,@@ -1561,6 +1563,7 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {<Splitter {...trackPane.splitterProps} className="timeline-track-splitter" aria-label="Resize track headers" /></div></section>+ <ProjectStatus label="Timeline status"><PreviewEngineStatus /></ProjectStatus>{menu.element}</div>);diff --git a/src/lib/exportPipeline.ts b/src/lib/exportPipeline.tsindex 90b2a92..f2aa17d 100644--- a/src/lib/exportPipeline.ts+++ b/src/lib/exportPipeline.ts@@ -38,6 +38,7 @@ import type { ProjectAsset, ProjectConfig } from "./project";import { applyChromaKey, keyColor, KEY_FEATHER, RGB_DISTANCE_SCALE } from "./chromaKey";import { hasVideoEffects } from "./effectSettings";import { createVideoEffectsProcessor } from "./videoEffectsGpu";+import { previewEngine } from "./previewEngine";/* ---------------------------------------------------------------------------What this machine can do@@ -211,7 +212,16 @@ fn fs(@location(0) uv: vec2f) -> @location(0) vec4f {/** Either a working GPU compositor, or the reason there is none. Never a bare* null: "WebGPU was unavailable" with no cause is what the last round shipped,* and it is unactionable. */-type GpuAttempt = { compositor: Compositor; reason: null } | { compositor: null; reason: string };+type GpuAttempt = { compositor: Compositor; reason: null; adapterName: string } | { compositor: null; reason: string };++/** What an adapter calls itself, from `adapter.info`. Often partial (a vendor+ * and an architecture) and sometimes empty, when the webview withholds it. */+export function adapterName(info: GPUAdapterInfo | undefined): string {+ return [info?.description, info?.device, info?.vendor, info?.architecture]+ .filter((part) => Boolean(part))+ .join(" ")+ .trim();+}const NO_GPU_API = "This webview exposes no navigator.gpu at all.";const NO_ADAPTER =@@ -349,14 +359,21 @@ async function createWebGpuCompositor(width: number, height: number, background:device.destroy();},};- return { compositor, reason: null };+ return { compositor, reason: null, adapterName: adapterName(adapter.info) };}/** The monitor presents through one canvas for its entire lifetime. Sharing* the export compositor keeps VideoFrames in GPU memory and applies the same* transforms, transitions and effects without swapping browser video surfaces. */export async function createPreviewCompositor(canvas: HTMLCanvasElement, width: number, height: number, background: string): Promise<Compositor | null> {- return (await createWebGpuCompositor(width, height, background, canvas)).compositor;+ let attempt: GpuAttempt;+ try { attempt = await createWebGpuCompositor(width, height, background, canvas); }+ catch (reason) {+ previewEngine.setGpu({ kind: "none", reason: `Starting the GPU compositor failed: ${reason instanceof Error ? reason.message : String(reason)}` });+ throw reason;+ }+ previewEngine.setGpu(attempt.compositor ? { kind: "webgpu", name: attempt.adapterName } : { kind: "none", reason: attempt.reason });+ return attempt.compositor;}function createCanvasCompositor(width: number, height: number, background: string): Compositor {@@ -420,6 +437,8 @@ export interface CompositorProbe {/** Why, in this machine's own terms. For canvas2d that is the reason the GPU* path is out; for webgpu it is what the adapter calls itself. */detail: string;+ /** The adapter's own name (webgpu only; empty when the webview withholds it). */+ adapterName?: string;}/** Asks the GPU for an adapter, exactly as the export will.@@ -438,12 +457,8 @@ export async function probeCompositor(): Promise<CompositorProbe> {if (!adapter) return { kind: "canvas2d", detail: NO_ADAPTER };/* Nothing is kept: this adapter is dropped here and the export requests itsown. The probe is a question, not a reservation. */- const info: GPUAdapterInfo | undefined = adapter.info;- const named = [info?.description, info?.device, info?.vendor, info?.architecture]- .filter((part) => Boolean(part))- .join(" ")- .trim();- return { kind: "webgpu", detail: named ? `GPU adapter: ${named}.` : "This computer offered a GPU adapter." };+ const named = adapterName(adapter.info);+ return { kind: "webgpu", detail: named ? `GPU adapter: ${named}.` : "This computer offered a GPU adapter.", adapterName: named };} catch (reason) {return {kind: "canvas2d",diff --git a/src/lib/previewEngine.test.ts b/src/lib/previewEngine.test.tsnew file mode 100644index 0000000..b7a1315--- /dev/null+++ b/src/lib/previewEngine.test.ts@@ -0,0 +1,34 @@+import { describe, expect, it } from "vitest";+import { PreviewEngine } from "./previewEngine";++describe("the preview engine's status", () => {+ it("publishes playback once per sample, counting kept pictures as dropped, and forgets it on stop", () => {+ const engine = new PreviewEngine();+ let published = 0;+ engine.subscribe(() => { published += 1; });+ engine.tick(true); // not playing: ignored+ engine.start();+ for (let index = 0; index < 58; index++) engine.tick(true);+ engine.tick(false); engine.tick(false);+ expect(published).toBe(0);+ engine.sample(1000);+ expect(engine.getSnapshot().playback).toEqual({ fps: 58, dropped: 2 });+ engine.tick(false);+ engine.sample(1000);+ expect(engine.getSnapshot().playback).toEqual({ fps: 0, dropped: 3 });+ expect(published).toBe(2);+ engine.stop();+ expect(engine.getSnapshot().playback).toBeNull();+ });++ it("says nothing about a monitor that drew no ticks, and keeps one GPU answer", () => {+ const engine = new PreviewEngine();+ engine.start();+ engine.sample(1000);+ expect(engine.getSnapshot().playback).toBeNull();+ engine.setGpu({ kind: "webgpu", name: "nvidia ampere" });+ const snapshot = engine.getSnapshot();+ engine.setGpu({ kind: "webgpu", name: "nvidia ampere" });+ expect(engine.getSnapshot()).toBe(snapshot);+ });+});diff --git a/src/lib/previewEngine.ts b/src/lib/previewEngine.tsnew file mode 100644index 0000000..6d9176f--- /dev/null+++ b/src/lib/previewEngine.ts@@ -0,0 +1,77 @@+/* What the program monitor's engine is actually doing, for the status bar.++ Only facts the preview already has in hand are kept here — nothing is probed+ for the bar's sake:+ • the GPU: the adapter the preview compositor was created on (its+ `adapter.info`), or the reason there is none;+ • playback: while playing, how many playhead ticks per second reached the+ screen as a new picture, and how many kept the previous picture because a+ decoder was still loading or seeking (a dropped frame, as the viewer sees+ it).++ The monitor counts ticks into plain fields; the snapshot readers subscribe to+ is replaced at most once a second, so the bar re-renders on that cadence and+ never per frame. */++export type PreviewGpu = { kind: "webgpu"; name: string } | { kind: "none"; reason: string };+export interface PreviewPlayback { fps: number; dropped: number }+export interface PreviewEngineSnapshot { gpu: PreviewGpu | null; playback: PreviewPlayback | null }++/** How often a playing monitor publishes its rate. */+export const PLAYBACK_SAMPLE_MS = 1000;++export class PreviewEngine {+ private snapshot: PreviewEngineSnapshot = { gpu: null, playback: null };+ private listeners = new Set<() => void>();+ private shown = 0;+ private held = 0;+ private dropped = 0;+ private sampling = false;++ getSnapshot = () => this.snapshot;+ subscribe = (listener: () => void) => { this.listeners.add(listener); return () => { this.listeners.delete(listener); }; };+ private publish(patch: Partial<PreviewEngineSnapshot>) {+ this.snapshot = { ...this.snapshot, ...patch };+ this.listeners.forEach((listener) => listener());+ }++ setGpu(gpu: PreviewGpu) {+ if (JSON.stringify(this.snapshot.gpu) === JSON.stringify(gpu)) return;+ this.publish({ gpu });+ }++ /** One playhead tick at the monitor: a new picture, or the previous one kept. */+ tick(presented: boolean) {+ if (!this.sampling) return;+ if (presented) this.shown += 1;+ else this.held += 1;+ }++ /** Playback started: count from zero. Nothing is published until a full+ * sample has been measured. */+ start() {+ this.sampling = true;+ this.shown = 0; this.held = 0; this.dropped = 0;+ }++ /** Publishes the rate over the last `elapsedMs`. A window with no ticks at+ * all (a monitor without the GPU picture) says nothing rather than "0 fps". */+ sample(elapsedMs: number) {+ if (!this.sampling || elapsedMs <= 0) return;+ const ticks = this.shown + this.held;+ this.dropped += this.held;+ const fps = (this.shown * 1000) / elapsedMs;+ this.shown = 0; this.held = 0;+ if (ticks === 0) return;+ this.publish({ playback: { fps, dropped: this.dropped } });+ }++ /** Playback stopped: a rate for a paused monitor would be stale. */+ stop() {+ this.sampling = false;+ if (this.snapshot.playback) this.publish({ playback: null });+ }+}++/** The one program monitor's engine. */+export const previewEngine = new PreviewEngine();diff --git a/src/lib/projectSession.ts b/src/lib/projectSession.tsindex ffedf2e..e6a2133 100644--- a/src/lib/projectSession.ts+++ b/src/lib/projectSession.ts@@ -13,6 +13,10 @@ export interface ProjectSessionState {saveError: string | null;canUndo: boolean;canRedo: boolean;+ /** When the file on disk last matched a save: this session's last successful+ * save, or the document's own `updatedAt` (stamped when it was written) for+ * a project that has not been saved since it was opened. Null if unknown. */+ savedAt: number | null;}/* ── Undo ──────────────────────────────────────────────────────────────────@@ -65,7 +69,8 @@ export class ProjectSession {constructor(readonly record: ProjectRecord, private writer: ProjectWriter) {this.savedConfig = record.config;const config = saveImageDraft(record.config);- this.state = { config, dirty: config !== record.config, saving: false, saveError: null, canUndo: false, canRedo: false };+ const stamped = Date.parse(record.config.updatedAt);+ this.state = { config, dirty: config !== record.config, saving: false, saveError: null, canUndo: false, canRedo: false, savedAt: Number.isFinite(stamped) ? stamped : null };this.history.subscribe(() => {if (this.history.canUndo !== this.state.canUndo || this.history.canRedo !== this.state.canRedo) {this.publish({ canUndo: this.history.canUndo, canRedo: this.history.canRedo });@@ -147,7 +152,7 @@ export class ProjectSession {this.writes = write.then(() => undefined, () => undefined);return write.then(() => {this.savedConfig = record.config;- if (this.revision === revision) this.publish({ dirty: false });+ this.publish(this.revision === revision ? { dirty: false, savedAt: Date.now() } : { savedAt: Date.now() });}).catch((reason) => {const detail = describeDiagnosticError(reason);this.publish({ saveError: detail });diff --git a/src/styles/generator.css b/src/styles/generator.cssindex 6bba55d..ab31e84 100644--- a/src/styles/generator.css+++ b/src/styles/generator.css@@ -78,10 +78,6 @@background: var(--surface-well);}-.generator-status {- flex: 0 0 auto;-}-.generator-status__runtime {color: var(--warning);}diff --git a/src/styles/references.css b/src/styles/references.cssindex df29acd..988c4ab 100644--- a/src/styles/references.css+++ b/src/styles/references.css@@ -56,10 +56,6 @@background: var(--surface-well);}-.references-status {- flex: 0 0 auto;-}-/* --- Icons view ---------------------------------------------------------------Auto-filling 120px tiles: a square picture and a 12px name. Rest, hover andselection are the shared selectable-card rule (.ui-selectable--card): adiff --git a/src/styles/workspace.css b/src/styles/workspace.cssindex 1fc4e47..f7e3f12 100644--- a/src/styles/workspace.css+++ b/src/styles/workspace.css@@ -137,6 +137,58 @@min-height: 0;}+/* --- Status bar ------------------------------------------------------------------+ One StatusBar along the window's foot on every view. The view portals its+ own facts into the leading slot (display: contents, so they sit in the+ strip's own gap rhythm); the sequence format and save state trail. Values+ are the ink, labels the secondary text around them. */++.project-status__view {+ display: contents;+}++.project-status b {+ color: var(--text-primary);+ font-weight: var(--weight-semibold);+}++.project-status__fact,+.project-status__format {+ font-variant-numeric: tabular-nums;+}++.project-status__fact {+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+}++.project-status__save {+ display: inline-flex;+ align-items: center;+ gap: var(--space-1);+}++.project-status__save::before {+ content: "";+ width: 6px;+ height: 6px;+ border-radius: 50%;+ background: currentColor;+}++.project-status__save--saved {+ color: var(--success);+}++.project-status__save--unsaved {+ color: var(--warning);+}++.project-status__save--saving::before {+ opacity: 0.5;+}+/* --- Narrow windows ---------------------------------------------------------The window minimum is 900px (tauri.conf.json). The project name gives upwidth first, then the tab icons go, so the tabs, Save and the caption