Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Track scene edits

Bittifefc3d5adddb
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 1d87bd1..ccef398 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -207,6 +207,10 @@ struct GenerationJob {
provider_id: Option<String>,
creative_brief: String,
compiled_prompt: String,
+ /// Exact inputs of the latest generation attempt. Missing on drafts that
+ /// have never been sent to the renderer and on older project files.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ generation_snapshot: Option<String>,
#[serde(default)]
reference_ids: Vec<String>,
/// The H3 vocabulary tags this shot was built from: group id -> option ids.
diff --git a/src/components/ProjectWorkspace.test.ts b/src/components/ProjectWorkspace.test.ts
index 12da464..87a8d1b 100644
--- a/src/components/ProjectWorkspace.test.ts
+++ b/src/components/ProjectWorkspace.test.ts
@@ -953,7 +953,7 @@ describe("project workspace timecode", () => {
project: { folderPath: "C:\\Ceramic Lamp", config }, initialView: "generator",
onBack: () => undefined, onSave: async () => undefined,
}));
- const line = () => screen.getByRole("textbox", { name: "What happens in shot 1" }) as HTMLTextAreaElement;
+ const line = () => screen.getByRole("textbox", { name: "Describe shot 1" }) as HTMLTextAreaElement;
openShot(1);
fireEvent.change(line(), { target: { value: "a slow push across the launch pad" } });
fireEvent.click(screen.getByRole("button", { name: "Timeline" }));
@@ -1139,10 +1139,10 @@ describe("project workspace timecode", () => {
// It opens on the scene: the thing with a state, a prompt and a Generate
// button.
expect(screen.getByRole("textbox", { name: "Rename First scene" })).not.toBeNull();
- expect(screen.queryByRole("textbox", { name: "What happens in shot 1" })).toBeNull();
+ expect(screen.queryByRole("textbox", { name: "Describe shot 1" })).toBeNull();
openShot(1);
- expect(screen.getByRole("textbox", { name: "What happens in shot 1" })).not.toBeNull();
+ expect(screen.getByRole("textbox", { name: "Describe shot 1" })).not.toBeNull();
// The shared scene header stays visible, while the right panel edits only
// the shot.
expect(screen.getByRole("slider", { name: "First scene length in seconds" })).not.toBeNull();
@@ -1164,10 +1164,10 @@ describe("project workspace timecode", () => {
fireEvent.click(screen.getByRole("button", { name: "Add Scene" }));
const next = onChange.mock.calls.at(-1)![0];
- // It goes to the head of the list and does not disturb the scene already there.
+ // It goes to the bottom and does not disturb the scene already there.
expect(next.generationJobs).toHaveLength(2);
- expect(next.generationJobs[1]).toEqual(config.generationJobs[0]);
- const added = next.generationJobs[0];
+ expect(next.generationJobs[0]).toEqual(config.generationJobs[0]);
+ const added = next.generationJobs[1];
expect(added.status).toBe("draft");
// One shot with nothing in it, and a name that says so rather than a phrase
// PolStudio made up out of words the user never typed.
@@ -1212,7 +1212,7 @@ describe("project workspace timecode", () => {
fireEvent.change(screen.getByRole("spinbutton", { name: `Shot ${shotNumber} starts at, in seconds` }), { target: { value: String(startSeconds) } });
next = onChange.mock.calls.at(-1)![0];
rerender(createElement(GeneratorView, { config: parseProjectConfig(next), folderPath: "C:\\Ceramic Lamp", onChange, onOpenTimeline: () => undefined, selectedJobId: config.generationJobs[0].id }));
- fireEvent.change(screen.getByRole("textbox", { name: `What happens in shot ${shotNumber}` }), { target: { value: line } });
+ fireEvent.change(screen.getByRole("textbox", { name: `Describe shot ${shotNumber}` }), { target: { value: line } });
next = onChange.mock.calls.at(-1)![0];
rerender(createElement(GeneratorView, { config: parseProjectConfig(next), folderPath: "C:\\Ceramic Lamp", onChange, onOpenTimeline: () => undefined, selectedJobId: config.generationJobs[0].id }));
}
@@ -1306,10 +1306,10 @@ describe("project workspace timecode", () => {
// One shot, holding the words and the tags the file already had.
openShot(1);
- expect((screen.getByRole("textbox", { name: "What happens in shot 1" }) as HTMLTextAreaElement).value).toBe("A quiet product film");
+ expect((screen.getByRole("textbox", { name: "Describe shot 1" }) as HTMLTextAreaElement).value).toBe("A quiet product film");
// The legacy per-job tag now reads as a setting ON the shot.
expect(screen.getByRole("button", { name: "Remove Lens: Macro from shot 1" })).not.toBeNull();
- expect(screen.queryByRole("textbox", { name: "What happens in shot 2" })).toBeNull();
+ expect(screen.queryByRole("textbox", { name: "Describe shot 2" })).toBeNull();
// Only one card, because a legacy scene is read as a single-shot scene.
expect(screen.queryByRole("button", { name: "Shot 2 of First scene" })).toBeNull();
openScene();
@@ -1335,7 +1335,7 @@ describe("project workspace timecode", () => {
render(createElement(GeneratorView, { config, folderPath: "C:\\Ceramic Lamp", onChange: () => undefined, onOpenTimeline: () => undefined, selectedJobId: config.generationJobs[0].id }));
expect((screen.getByRole("slider", { name: "First scene length in seconds" }) as HTMLInputElement).disabled).toBe(true);
openShot(1);
- expect((screen.getByRole("textbox", { name: "What happens in shot 1" }) as HTMLTextAreaElement).disabled).toBe(true);
+ expect((screen.getByRole("textbox", { name: "Describe shot 1" }) as HTMLTextAreaElement).disabled).toBe(true);
expect((screen.getByRole("combobox", { name: "Add a setting to shot 1" }) as HTMLSelectElement).disabled).toBe(true);
expect(screen.getByText(/It can be changed once it finishes/)).not.toBeNull();
});
@@ -1355,7 +1355,7 @@ describe("project workspace timecode", () => {
// Dragged out of the palette and dropped onto the line.
const drop = (referenceId: string) => {
- const field = screen.getByRole("textbox", { name: "What happens in shot 1" });
+ const field = screen.getByRole("textbox", { name: "Describe shot 1" });
const event = createEvent.drop(field);
Object.defineProperty(event, "dataTransfer", { value: { getData: (type: string) => type === REFERENCE_DRAG_TYPE ? referenceId : "", types: [REFERENCE_DRAG_TYPE] } });
fireEvent(field, event);
@@ -1367,7 +1367,7 @@ describe("project workspace timecode", () => {
expect(next.generationJobs[0].referenceIds).toEqual(["ref-woman"]);
show(next);
- fireEvent.change(screen.getByRole("textbox", { name: "What happens in shot 1" }), { target: { value: "[Reference 1] walks towards the camera on " } });
+ fireEvent.change(screen.getByRole("textbox", { name: "Describe shot 1" }), { target: { value: "[Reference 1] walks towards the camera on " } });
next = onChange.mock.calls.at(-1)![0];
show(next);
drop("ref-street");
@@ -1377,7 +1377,7 @@ describe("project workspace timecode", () => {
// What the user reads in the field is "Reference N"; what is stored is the
// reference's id, so a rename or a reorder cannot re-point the sentence.
- expect((screen.getByRole("textbox", { name: "What happens in shot 1" }) as HTMLTextAreaElement).value)
+ expect((screen.getByRole("textbox", { name: "Describe shot 1" }) as HTMLTextAreaElement).value)
.toBe("[Reference 1] walks towards the camera on [Reference 2]");
expect(next.generationJobs[0].shots[0].action).toBe("@[ref:ref-woman] walks towards the camera on @[ref:ref-street]");
openScene();
@@ -1425,7 +1425,7 @@ describe("project workspace timecode", () => {
const view = () => createElement(GeneratorView, { config, folderPath: "C:\\Ceramic Lamp", onChange, onOpenTimeline: () => undefined, selectedJobId: start.generationJobs[0].id });
const app = render(view());
openShot(1);
- const field = screen.getByRole("textbox", { name: "What happens in shot 1" }) as HTMLTextAreaElement;
+ const field = screen.getByRole("textbox", { name: "Describe shot 1" }) as HTMLTextAreaElement;
field.setSelectionRange(caret, caret);
const event = createEvent.drop(field);
Object.defineProperty(event, "dataTransfer", { value: { getData: (type: string) => type === REFERENCE_DRAG_TYPE ? "ref-woman" : "", types: [REFERENCE_DRAG_TYPE] } });
@@ -1474,7 +1474,7 @@ describe("project workspace timecode", () => {
const shot = (shotNumber: number) => { openShot(shotNumber, "First scene"); show(); };
const scene = () => { openScene("First scene"); show(); };
const dropReference = (referenceId: string, shotNumber: number) => {
- const field = screen.getByRole("textbox", { name: `What happens in shot ${shotNumber}` });
+ const field = screen.getByRole("textbox", { name: `Describe shot ${shotNumber}` });
const event = createEvent.drop(field);
Object.defineProperty(event, "dataTransfer", { value: { getData: (type: string) => type === REFERENCE_DRAG_TYPE ? referenceId : "", types: [REFERENCE_DRAG_TYPE] } });
fireEvent(field, event);
@@ -1491,13 +1491,13 @@ describe("project workspace timecode", () => {
shot(1);
dropReference("ref-street", 1);
dropReference("ref-woman", 1);
- set("textbox", "What happens in shot 1", "[Reference 1] walks towards the camera on [Reference 2]");
+ set("textbox", "Describe shot 1", "[Reference 1] walks towards the camera on [Reference 2]");
shot(2);
set("spinbutton", "Shot 2 starts at, in seconds", "4.5");
- set("textbox", "What happens in shot 2", "she stops at a doorway and looks up");
+ set("textbox", "Describe shot 2", "she stops at a doorway and looks up");
shot(3);
set("spinbutton", "Shot 3 starts at, in seconds", "9");
- set("textbox", "What happens in shot 3", "the door opens and light spills across [Reference 2]");
+ set("textbox", "Describe shot 3", "the door opens and light spills across [Reference 2]");
shot(1);
set("combobox", "Add a setting to shot 1", "cameraMovement");
@@ -1515,7 +1515,7 @@ describe("project workspace timecode", () => {
// What the field shows is "Reference N"; what is stored is the id, so a
// rename or a reorder cannot re-point the sentence.
shot(1);
- expect((screen.getByRole("textbox", { name: "What happens in shot 1" }) as HTMLTextAreaElement).value)
+ expect((screen.getByRole("textbox", { name: "Describe shot 1" }) as HTMLTextAreaElement).value)
.toBe("[Reference 1] walks towards the camera on [Reference 2]");
expect(config.generationJobs[0].shots![0].action).toBe("@[ref:ref-woman] walks towards the camera on @[ref:ref-street]");
expect(config.generationJobs[0].durationSeconds).toBe(12);
diff --git a/src/components/workspace/GeneratorView.test.tsx b/src/components/workspace/GeneratorView.test.tsx
index 8782260..7a60f50 100644
--- a/src/components/workspace/GeneratorView.test.tsx
+++ b/src/components/workspace/GeneratorView.test.tsx
@@ -1,7 +1,7 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
-import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
+import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { useState } from "react";
import { afterEach, describe, expect, it } from "vitest";
import { createDraftGenerationJob, createProjectConfig, parseProjectConfig, sceneShots, type ProjectConfig } from "../../lib/project";
@@ -58,11 +58,13 @@ const transfer = (): DataTransfer => {
return value as unknown as DataTransfer;
};
-function setup() {
- let latest = project();
+function setup(initial = project()) {
+ let latest = initial;
+ let replace: (next: ProjectConfig) => void = () => undefined;
function Harness() {
const [config, setConfig] = useState(latest);
latest = config;
+ replace = (next) => setConfig(next);
return <GeneratorView
config={config}
folderPath="C:\\project"
@@ -72,7 +74,24 @@ function setup() {
/>;
}
render(<Harness />);
- return { latest: () => latest };
+ return {
+ latest: () => latest,
+ replace: (next: ProjectConfig) => act(() => replace(next)),
+ };
+}
+
+async function finishFirst(state: ReturnType<typeof setup>) {
+ fireEvent.click(screen.getByRole("button", { name: "Generate All" }));
+ await waitFor(() => expect(state.latest().generationJobs[0].generationSnapshot).toEqual(expect.any(String)));
+ state.replace({
+ ...state.latest(),
+ generationJobs: state.latest().generationJobs.map((job, index) => index === 0 ? {
+ ...job,
+ status: "completed",
+ stage: "completed",
+ progress: 1,
+ } : job),
+ });
}
describe("Generator scene controls", () => {
@@ -113,6 +132,7 @@ describe("Generator scene controls", () => {
fireEvent.change(screen.getByRole("slider", { name: "First scene length in seconds" }), { target: { value: "10" } });
expect(state.latest().generationJobs[0].durationSeconds).toBe(10);
+ expect(screen.queryByText("CHANGED")).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Remove scene First scene" }));
expect(screen.getByRole("alertdialog", { name: "Remove scene?" })).toBeInTheDocument();
@@ -121,6 +141,53 @@ describe("Generator scene controls", () => {
expect(state.latest().generationJobs.map((job) => job.id)).toEqual(["scene-second"]);
});
+ it("adds new scenes at the bottom", () => {
+ const state = setup();
+ fireEvent.click(screen.getByRole("button", { name: "Add Scene" }));
+ expect(state.latest().generationJobs.slice(0, 2).map((job) => job.id)).toEqual(["scene-first", "scene-second"]);
+ expect(state.latest().generationJobs.at(-1)?.title).toBe("Untitled scene");
+ });
+
+ it("marks a finished scene yellow when scene settings change", async () => {
+ const state = setup();
+ await finishFirst(state);
+ const scene = screen.getByRole("region", { name: "First scene" });
+ expect(within(scene).getByText("FINISHED")).toBeInTheDocument();
+ expect(scene.querySelector(".scene-rule__status--completed")).not.toBeNull();
+
+ fireEvent.change(screen.getByRole("textbox", { name: "The sound of this scene" }), { target: { value: "Soft rain." } });
+ expect(within(scene).getByText("CHANGED")).toBeInTheDocument();
+ expect(scene.querySelector(".scene-rule__status--changed")).not.toBeNull();
+ });
+
+ it("marks a finished scene changed when shot settings or order change", async () => {
+ const state = setup();
+ await finishFirst(state);
+ const scene = screen.getByRole("region", { name: "First scene" });
+
+ fireEvent.click(screen.getByRole("button", { name: "Shot 1 of First scene" }));
+ expect(screen.getByText("Describe the shot")).toBeInTheDocument();
+ fireEvent.change(screen.getByRole("combobox", { name: "Add a setting to shot 1" }), { target: { value: "shotSize" } });
+ fireEvent.change(screen.getByRole("combobox", { name: "Value for Shot size on shot 1" }), { target: { value: "close-up" } });
+ expect(within(scene).getByText("CHANGED")).toBeInTheDocument();
+
+ fireEvent.click(within(scene).getByRole("button", { name: "Generate" }));
+ await waitFor(() => expect(state.latest().generationJobs[0].status).toBe("queued"));
+ const regenerated = state.latest().generationJobs[0];
+ state.replace({
+ ...state.latest(),
+ generationJobs: state.latest().generationJobs.map((job, index) => index === 0
+ ? { ...regenerated, status: "completed", stage: "completed", progress: 1 }
+ : job),
+ });
+ expect(within(scene).getByText("FINISHED")).toBeInTheDocument();
+
+ const shotTransfer = transfer();
+ fireEvent.dragStart(screen.getByRole("button", { name: "Shot 1 of First scene" }), { dataTransfer: shotTransfer });
+ fireEvent.drop(screen.getByRole("button", { name: "Add a shot to First scene" }).parentElement!, { dataTransfer: shotTransfer });
+ expect(within(scene).getByText("CHANGED")).toBeInTheDocument();
+ });
+
it("renames a shot and confirms before removing it", () => {
const state = setup();
fireEvent.click(screen.getByRole("button", { name: "Shot 2 of First scene" }));
@@ -143,5 +210,7 @@ describe("Generator scene controls", () => {
const state = setup();
fireEvent.click(screen.getByRole("button", { name: "Generate All" }));
await waitFor(() => expect(state.latest().generationJobs.map((job) => job.status)).toEqual(["queued", "queued"]));
+ expect(state.latest().generationJobs.every((job) => Boolean(job.generationSnapshot))).toBe(true);
+ expect(parseProjectConfig(state.latest())).toBeTruthy();
});
});
diff --git a/src/components/workspace/GeneratorView.tsx b/src/components/workspace/GeneratorView.tsx
index ccd57f7..07aa865 100644
--- a/src/components/workspace/GeneratorView.tsx
+++ b/src/components/workspace/GeneratorView.tsx
@@ -1,6 +1,6 @@
import { Plus, Sparkles, WandSparkles } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
-import { actionReferenceIds, compileGenerationJobPrompt, compileGenerationJobSegments, createDraftGenerationJob, danglingReferenceTokens, sceneDurationSeconds, sceneShots, SCENE_MAX_SECONDS, SCENE_MIN_SECONDS, projectItemPath, usableImageReferences, type GenerationJob, type ProjectConfig, type ProjectReference, type PromptSegment, type SceneShot } from "../../lib/project";
+import { actionReferenceIds, compileGenerationJobPrompt, compileGenerationJobSegments, createDraftGenerationJob, danglingReferenceTokens, sceneDurationSeconds, sceneGenerationSnapshot, sceneShots, SCENE_MAX_SECONDS, SCENE_MIN_SECONDS, projectItemPath, usableImageReferences, type GenerationJob, type ProjectConfig, type ProjectReference, type PromptSegment, type SceneShot } from "../../lib/project";
import { cancelVidfabGeneration, enqueueVidfabGeneration, resolveVidfabPlan, type VidfabGenerationRequest, type VidfabStatus } from "../../lib/runtime";
import { SceneBoard, type GeneratorSelection } from "./SceneBoard";
import { SceneInspector, ShotInspector, STEP_SECONDS, writeShots } from "./SceneEditor";
@@ -212,6 +212,9 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
};
};
+ const snapshotFor = (job: GenerationJob, request = requestFor(job)): string =>
+ sceneGenerationSnapshot(job, request);
+
/* The engine's own events are listened for by the project screen
(useGenerationEvents), not here: a render outlives this view, and the
encode that turns its frames into a file has to happen wherever the user
@@ -220,8 +223,16 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
const prepareOrRetry = async (job: GenerationJob) => {
const now = new Date().toISOString();
- updateJob(job.id, { status: runtimeReady ? "queued" : "draft", stage: "queued", progress: 0, error: runtimeReady ? null : runtime?.detail ?? "The video engine isn’t available on this computer right now.", updatedAt: now });
- if (runtimeReady) await enqueueVidfabGeneration(requestFor(job), configRef.current);
+ const request = requestFor(job);
+ updateJob(job.id, {
+ status: runtimeReady ? "queued" : "draft",
+ stage: "queued",
+ progress: 0,
+ error: runtimeReady ? null : runtime?.detail ?? "The video engine isn’t available on this computer right now.",
+ generationSnapshot: runtimeReady ? snapshotFor(job, request) : job.generationSnapshot,
+ updatedAt: now,
+ });
+ if (runtimeReady) await enqueueVidfabGeneration(request, configRef.current);
};
/* A scene now starts EMPTY. There is no box that turns a sentence into a
@@ -237,7 +248,7 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
references already named by its shots. */
const newScene = () => {
const job = createDraftGenerationJob("");
- onChange({ ...config, generationJobs: [job, ...jobs] });
+ onChange({ ...config, generationJobs: [...jobs, job] });
setSelection({ jobId: job.id, shotId: null });
};
@@ -256,14 +267,20 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
const startDraft = async (job: GenerationJob) => {
if (!runtimeReady) return;
- updateJob(job.id, { status: "queued", stage: "queued", error: null, updatedAt: new Date().toISOString() });
+ const request = requestFor(job);
+ updateJob(job.id, {
+ status: "queued",
+ stage: "queued",
+ error: null,
+ generationSnapshot: snapshotFor(job, request),
+ updatedAt: new Date().toISOString(),
+ });
try {
/* Resolved before the job is handed over, so "What actually happened"
reports the real frame count and canvas this run was planned as. The
composer used to do this for a scene it had just created; a scene is
now created empty and generated from here, so the plan is resolved
here or nobody ever sees it. */
- const request = requestFor(job);
const plan = await resolveVidfabPlan(request, configRef.current);
setPlanNotes((current) => ({ ...current, [job.id]: `Planned as ${plan.alignedFrames} frames at ${plan.canvasWidth}×${plan.canvasHeight}. ${plan.boundary}` }));
await enqueueVidfabGeneration(request, configRef.current);
@@ -282,18 +299,18 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
const generateAll = async () => {
if (!runtimeReady || draftScenesReady.length === 0) return;
const current = configRef.current;
- const ids = new Set(draftScenesReady.map((job) => job.id));
+ const requests = draftScenesReady.map((job) => ({ job, request: requestFor(job) }));
+ const ids = new Map(requests.map(({ job, request }) => [job.id, snapshotFor(job, request)]));
const now = new Date().toISOString();
onChange({
...current,
generationJobs: current.generationJobs.map((job) => ids.has(job.id)
- ? { ...job, status: "queued", stage: "queued", progress: 0, error: null, updatedAt: now }
+ ? { ...job, status: "queued", stage: "queued", progress: 0, error: null, generationSnapshot: ids.get(job.id), updatedAt: now }
: job),
});
- for (const job of draftScenesReady) {
+ for (const { job, request } of requests) {
try {
- const request = requestFor(job);
const plan = await resolveVidfabPlan(request, current);
setPlanNotes((notes) => ({ ...notes, [job.id]: `Planned as ${plan.alignedFrames} frames at ${plan.canvasWidth}×${plan.canvasHeight}. ${plan.boundary}` }));
await enqueueVidfabGeneration(request, current);
@@ -311,6 +328,13 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
return sendBlocker(job, config.references);
};
+ const changedJobIds = new Set(jobs
+ .filter((job) => job.status === "completed"
+ && Boolean(job.generationSnapshot)
+ && job.generationSnapshot !== snapshotFor(job))
+ .map((job) => job.id));
+ const selectedIndicator = selected && changedJobIds.has(selected.id) ? "changed" : selected?.status;
+
return <div className={`generator-view ${selected ? "" : "generator-view--empty"}`}>
<main className="generator-main">
<header className="generator-heading">
@@ -355,6 +379,7 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
onRemoveScene={(job) => setRemovalTarget({ kind: "scene", job })}
onGenerate={generateScene}
generationBlocker={generationBlocker}
+ changedJobIds={changedJobIds}
onMoveScene={moveScene}
onMoveShot={moveShot}
/>}
@@ -417,7 +442,7 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
: <>
<header className="panel-head">
<div className="job-title">
- {selected.status !== "draft" && <span className={`status-icon status-icon--${selected.status}`}>{statusIcon(selected.status)}</span>}
+ {selected.status !== "draft" && selectedIndicator && <span className={`status-icon status-icon--${selectedIndicator}`}>{statusIcon(selectedIndicator)}</span>}
<div>
{/* The badge is on the scene's own line on the board, where the
eye compares one scene against the next. A second copy of it
diff --git a/src/components/workspace/SceneBoard.tsx b/src/components/workspace/SceneBoard.tsx
index f800a65..90324cb 100644
--- a/src/components/workspace/SceneBoard.tsx
+++ b/src/components/workspace/SceneBoard.tsx
@@ -54,6 +54,7 @@ export function SceneBoard({
onRemoveScene,
onGenerate,
generationBlocker,
+ changedJobIds,
onMoveScene,
onMoveShot,
}: {
@@ -67,6 +68,7 @@ export function SceneBoard({
onRemoveScene: (job: GenerationJob) => void;
onGenerate: (job: GenerationJob) => void;
generationBlocker: (job: GenerationJob) => string | null;
+ changedJobIds: ReadonlySet<string>;
onMoveScene: (jobId: string, beforeJobId: string | null) => void;
onMoveShot: (sourceJobId: string, shotId: string, targetJobId: string, beforeShotId: string | null) => void;
}) {
@@ -79,6 +81,7 @@ export function SceneBoard({
const sceneOpen = selection.jobId === job.id && selection.shotId === null;
const locked = job.status === "queued" || job.status === "generating";
const blocker = generationBlocker(job);
+ const indicator = changedJobIds.has(job.id) ? "changed" : job.status;
const dropScene = (event: React.DragEvent<HTMLElement>) => {
if (!hasDragType(event.dataTransfer.types, SCENE_DRAG_TYPE)) return;
@@ -124,11 +127,11 @@ export function SceneBoard({
><GripVertical size={17} aria-hidden="true" /></span>
<div className="scene-rule__summary">
- {job.status !== "draft" && <span className={`scene-rule__status scene-rule__status--${job.status}`}>{statusIcon(job.status, 15)}</span>}
+ {job.status !== "draft" && <span className={`scene-rule__status scene-rule__status--${indicator}`}>{statusIcon(indicator, 15)}</span>}
<span className="scene-rule__text">
<b>{job.title}</b>
</span>
- {job.status !== "draft" && <span className="scene-rule__badge">{STATUS_BADGE[job.status]}</span>}
+ {job.status !== "draft" && <span className="scene-rule__badge">{STATUS_BADGE[indicator]}</span>}
</div>
<label className="scene-rule__length">
diff --git a/src/components/workspace/SceneEditor.tsx b/src/components/workspace/SceneEditor.tsx
index 279da24..ff91932 100644
--- a/src/components/workspace/SceneEditor.tsx
+++ b/src/components/workspace/SceneEditor.tsx
@@ -176,14 +176,13 @@ export function ShotInspector({ job, shots, shot, index, endsAt, duration, refer
><Trash2 size={15} /> Remove</button>}
</div>
- {/* The line is the point of this screen, so it is the biggest thing on it. */}
<label className="shot-card__action">
- <span className="shot-card__sublabel">What happens, in your own words</span>
+ <span className="shot-card__sublabel">Describe the shot</span>
<textarea
ref={fieldRef}
value={display}
disabled={disabled}
- aria-label={`What happens in shot ${shotNumber}`}
+ aria-label={`Describe shot ${shotNumber}`}
placeholder="Example: she walks towards the camera and stops under the awning."
onChange={(event) => onChange({ action: store(event.target.value) })}
onDragOver={(event) => { if (event.dataTransfer.types.includes(REFERENCE_DRAG_TYPE)) event.preventDefault(); }}
diff --git a/src/components/workspace/sceneStatus.tsx b/src/components/workspace/sceneStatus.tsx
index 1bcd2f1..f90999e 100644
--- a/src/components/workspace/sceneStatus.tsx
+++ b/src/components/workspace/sceneStatus.tsx
@@ -1,4 +1,4 @@
-import { AlertCircle, Ban, Check, Clock3, LoaderCircle } from "lucide-react";
+import { AlertCircle, Ban, Check, Clock3, LoaderCircle, RefreshCw } from "lucide-react";
import { sceneDurationSeconds, sceneShots, type GenerationJob } from "../../lib/project";
/* What a scene's status is CALLED, in one place.
@@ -9,8 +9,9 @@ import { sceneDurationSeconds, sceneShots, type GenerationJob } from "../../lib/
* the bug this file exists to make impossible. */
export type JobStatus = GenerationJob["status"];
+export type SceneIndicatorStatus = JobStatus | "changed";
-export const STATUS_BADGE: Record<JobStatus, string> = {
+export const STATUS_BADGE: Record<SceneIndicatorStatus, string> = {
draft: "DRAFT",
queued: "IN QUEUE",
generating: "RENDERING",
@@ -18,6 +19,7 @@ export const STATUS_BADGE: Record<JobStatus, string> = {
completed: "FINISHED",
failed: "FAILED",
cancelled: "CANCELLED",
+ changed: "CHANGED",
};
export const STATUS_WORD: Record<JobStatus, string> = {
@@ -32,11 +34,12 @@ export const STATUS_WORD: Record<JobStatus, string> = {
/* Encoding turns the same spinner as rendering: it is the app working, not the
app waiting, and a tick beside "saving" would say it was already done. */
-export const statusIcon = (status: JobStatus, size = 16) =>
+export const statusIcon = (status: SceneIndicatorStatus, size = 16) =>
status === "generating" || status === "ready" ? <LoaderCircle size={size} />
: status === "completed" ? <Check size={size} />
: status === "failed" ? <AlertCircle size={size} />
: status === "cancelled" ? <Ban size={size} />
+ : status === "changed" ? <RefreshCw size={size} />
: <Clock3 size={size} />;
/** The shape of a scene — how long it runs and how many shots it is cut into. */
diff --git a/src/lib/project.ts b/src/lib/project.ts
index f9bbc97..9516ebb 100644
--- a/src/lib/project.ts
+++ b/src/lib/project.ts
@@ -321,6 +321,9 @@ export const generationJobSchema = z.object({
// time, so this copy goes stale as soon as the brief or the bound references
// change. Never treat it as the authoritative prompt.
compiledPrompt: z.string().min(1),
+ /** Exact render inputs from the most recently started generation. Absent on
+ * drafts that have never run and on projects saved before change tracking. */
+ generationSnapshot: z.string().min(1).nullish(),
referenceIds: z.array(idSchema).default([]),
// `.nullish()` because Rust holds it as an Option — see the note on
// projectAssetSchema.durationMs. Every project written before shot tags
@@ -664,6 +667,35 @@ export function sceneDurationSeconds(job: GenerationJob): number {
return Math.min(SCENE_MAX_SECONDS, Math.max(SCENE_MIN_SECONDS, stored));
}
+export interface SceneGenerationInput {
+ prompt: string;
+ frames: number;
+ steps: number;
+ seed: number;
+ aspectRatio: string;
+ referencePaths: readonly string[];
+}
+
+/** A stable record of everything sent to the renderer. Shot ids are retained
+ * separately because swapping otherwise identical shots is still an edit. */
+export function sceneGenerationSnapshot(job: GenerationJob, input: SceneGenerationInput): string {
+ const shots = sceneShots(job).map((shot) => ({
+ id: shot.id,
+ settings: Object.entries(shot.settings ?? {})
+ .sort(([left], [right]) => left.localeCompare(right))
+ .map(([group, values]) => [group, [...values].sort()]),
+ }));
+ return JSON.stringify({
+ prompt: input.prompt,
+ frames: input.frames,
+ steps: input.steps,
+ seed: input.seed,
+ aspectRatio: input.aspectRatio,
+ referencePaths: input.referencePaths,
+ shots,
+ });
+}
+
/** The mirror written back into `prompt` and `creativeBrief`. Nothing but the
* user's own lines, joined — no connective words, no summary. */
export function sceneBriefText(shots: readonly SceneShot[]): string {
diff --git a/src/styles/generator.css b/src/styles/generator.css
index 59288a7..93ebc17 100644
--- a/src/styles/generator.css
+++ b/src/styles/generator.css
@@ -198,6 +198,11 @@
background: color-mix(in srgb, var(--success) 16%, var(--panel-3));
}
+.scene-rule__status--changed {
+ color: var(--warning);
+ background: var(--warning-soft);
+}
+
.scene-rule__status--failed,
.scene-rule__status--cancelled {
color: var(--danger);
@@ -729,7 +734,7 @@
color: var(--text-primary);
background: var(--panel-2);
font-family: var(--font-sans);
- font-size: var(--text-md);
+ font-size: var(--text-base);
line-height: var(--leading-normal);
resize: vertical;
}
@@ -1340,6 +1345,11 @@
background: color-mix(in srgb, var(--success) 16%, var(--panel-3));
}
+.status-icon--changed {
+ color: var(--warning);
+ background: var(--warning-soft);
+}
+
.status-icon--failed,
.status-icon--cancelled {
color: var(--danger);