Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Add project Looks and automatic timeline growth

Bittib69d19d3be43
diff --git a/docs/project-settings.md b/docs/project-settings.md
index 063c391..6fb4cec 100644
--- a/docs/project-settings.md
+++ b/docs/project-settings.md
@@ -1,12 +1,25 @@
# Project settings
+New projects ask for a name, resolution, aspect ratio, and **Default Look**.
+There is no length to define up front: the timeline grows as clips are added.
+The default Look includes the same presets as the scene Look selector and a
+**None** option. Scenes whose Look is **None** inherit the project Look; an
+explicit scene Look takes priority. Project **None** leaves the existing prompt
+style inference unchanged. The inherited Look is resolved for both prompt
+preview and generation, so changing it also marks affected renders out of date.
+
Click the project name in the open workspace to change its name, resolution,
-aspect ratio, or target length. The popup uses the same controls as New project
-and opens with the current values. **Save changes** saves the project; closing
+aspect ratio, default Look, or target length. The popup opens with the current
+values. **Save changes** saves the project; closing
the popup or pressing Escape before saving discards the pending form edits.
Resolution and aspect ratio update both the project settings and its brief.
-Target length updates the brief. New generation and export use the new canvas
+Target length updates the brief. Dropping media or Generator scenes, moving
+clips, and extending clip trims automatically grow it to cover the latest clip
+end, rounded up to whole seconds. Drops retain their chosen position even when
+the clip is longer than the project. Moving clips left or removing them does
+not shrink the saved length. Projects may extend beyond ten minutes.
+New generation and export use the new canvas
settings. Existing generated files, scene durations, and timeline clip trims
are preserved.
@@ -19,9 +32,10 @@ The AI agent can apply these settings with `project.set`:
Aspect ratios: `16:9`, `9:16`, `1:1`, `4:5`.
Resolution keys: `416p`, `544p`, `640p`, `768p`, `1088p`, `1344p`.
-Target length is a whole number from 0 to 600 seconds. The numeric field accepts
-any whole second. The slider uses one-second intervals through 60 seconds and
-ten-second intervals above that, with extra slider space for the first minute.
+Target length is a nonnegative whole number. The settings controls initially
+offer up to 600 seconds and expand to accommodate longer timelines. The slider
+uses one-second intervals through 60 seconds and ten-second intervals above
+that, with extra slider space for the first minute.
Omit fields that should
stay unchanged. Changing scene lengths or timeline clips uses the separate
`scene.set` and `clip.set` commands.
diff --git a/src-tauri/src/project/model.rs b/src-tauri/src/project/model.rs
index 1a8dd8b..db7c72e 100644
--- a/src-tauri/src/project/model.rs
+++ b/src-tauri/src/project/model.rs
@@ -45,6 +45,8 @@ pub(crate) struct ProjectConfig {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub(crate) struct ProjectSettings {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) default_look: Option<String>,
pub(crate) aspect_ratio: String,
pub(crate) resolution: String,
pub(crate) frame_rate: u32,
diff --git a/src-tauri/src/project/validation/settings.rs b/src-tauri/src/project/validation/settings.rs
index 1d77e7c..49f3217 100644
--- a/src-tauri/src/project/validation/settings.rs
+++ b/src-tauri/src/project/validation/settings.rs
@@ -60,11 +60,13 @@ pub(super) fn validate(config: &mut ProjectConfig) -> Result<(), String> {
config.brief.status
));
}
- if config.brief.target_duration_seconds > 600 {
- return Err(format!(
- "Target duration must be between 0 and 600 seconds, received {}.",
- config.brief.target_duration_seconds
- ));
+ if config
+ .settings
+ .default_look
+ .as_ref()
+ .is_some_and(|look| !is_shot_tag_id(look))
+ {
+ return Err("Project default Look has an invalid id.".into());
}
if !is_supported_aspect_ratio(&config.brief.aspect_ratio) {
return Err(format!(
diff --git a/src-tauri/src/tests/persistence.rs b/src-tauri/src/tests/persistence.rs
index f59898e..9df5365 100644
--- a/src-tauri/src/tests/persistence.rs
+++ b/src-tauri/src/tests/persistence.rs
@@ -208,6 +208,22 @@ fn video_effects_survive_save_and_reopen() {
.contains("video effects"));
}
+#[test]
+fn project_look_and_extended_duration_survive_save_and_reopen() {
+ let mut config = fixture();
+ config.settings.default_look = Some("watercolor".into());
+ config.brief.target_duration_seconds = 1800;
+ let config = without_derived_project_state(validate_and_normalize_config(config).unwrap());
+ let root = tempfile::tempdir().unwrap();
+ let created = create_project_in(root.path(), &config).unwrap();
+ let folder = PathBuf::from(&created.folder_path);
+ assert_eq!(read_project(&folder).unwrap().config, config);
+ let mut cleared = config;
+ cleared.settings.default_look = None;
+ write_project(&folder, &cleared).unwrap();
+ assert_eq!(read_project(&folder).unwrap().config, cleared);
+}
+
#[test]
fn deletion_refuses_a_different_project_identity_and_keeps_the_folder() {
let parent = tempfile::tempdir().unwrap();
diff --git a/src-tauri/src/tests/schema.rs b/src-tauri/src/tests/schema.rs
index d4f557c..7f0d43d 100644
--- a/src-tauri/src/tests/schema.rs
+++ b/src-tauri/src/tests/schema.rs
@@ -543,8 +543,8 @@ fn validator_rejects_what_the_frontend_schema_rejects() {
rejects("unsupported brief status", |config| {
config.brief.status = "done".into();
});
- rejects("target duration above 600 seconds", |config| {
- config.brief.target_duration_seconds = 900;
+ rejects("invalid project Look", |config| {
+ config.settings.default_look = Some("not a look id".into());
});
rejects("unsupported brief aspect ratio", |config| {
config.brief.aspect_ratio = "21:9".into();
@@ -649,7 +649,7 @@ fn validator_accepts_every_boundary_the_frontend_schema_allows() {
"rejected valid background color {background_color}"
);
}
- for seconds in [0u32, 1, 5, 60, 600] {
+ for seconds in [0u32, 1, 5, 60, 600, 900, 7200] {
let mut config = fixture();
config.brief.target_duration_seconds = seconds;
assert!(
diff --git a/src/App.test.tsx b/src/App.test.tsx
index 7888aa0..3be58b0 100644
--- a/src/App.test.tsx
+++ b/src/App.test.tsx
@@ -53,8 +53,8 @@ describe("project library controls", () => {
beforeEach(() => localStorage.clear());
afterEach(cleanup);
- it("uses a named New Project form with numeric length and a slider up to 10 minutes", async () => {
- const { container } = render(<App />);
+ it("uses a named New Project form with a default Look instead of a length", async () => {
+ render(<App />);
await screen.findByText("Northern Light — Brand Film");
fireEvent.click(screen.getByRole("button", { name: "New project" }));
expect(screen.getByRole("dialog", { name: "New project" })).not.toBeNull();
@@ -64,17 +64,12 @@ describe("project library controls", () => {
expect(screen.queryByText(/Add reference images/)).toBeNull();
expect(screen.queryByText(/Not sure where to start/)).toBeNull();
- const length = screen.getByRole("slider", { name: "Length slider" });
- expect(length).toHaveAttribute("aria-valuemin", "0");
- expect(length).toHaveAttribute("aria-valuemax", "600");
- expect(length).toHaveAttribute("step", "1");
- expect(length).toHaveAttribute("aria-valuetext", "30 seconds");
- const number = screen.getByRole("spinbutton", { name: "Length in seconds" });
- fireEvent.change(number, { target: { value: "137" } });
- expect(container.querySelector(".composer__options-value")!.textContent).toContain("2 minutes 17 seconds");
- expect(length).toHaveAttribute("aria-valuetext", "2 minutes 17 seconds");
- fireEvent.change(length, { target: { value: "114" } });
- expect(length).toHaveAttribute("aria-valuetext", "10 minutes");
+ expect(screen.queryByLabelText("Length in seconds")).toBeNull();
+ expect(screen.queryByLabelText("Length slider")).toBeNull();
+ const look = screen.getByRole("combobox", { name: "Default Look" });
+ expect(look).toHaveValue("");
+ fireEvent.change(look, { target: { value: "watercolor" } });
+ expect(look).toHaveValue("watercolor");
expect(screen.getByRole("button", { name: "Create project" })).toBeEnabled();
});
@@ -152,7 +147,7 @@ describe("project library controls", () => {
// The settings header says the same numbers as the always-visible fields.
fireEvent.change(size, { target: { value: "544p" } });
expect(document.querySelector(".composer__options-value")!.textContent)
- .toBe("Vertical 9:16 · 544 × 960 · 30 seconds");
+ .toBe("Vertical 9:16 · 544 × 960");
});
it("opens a newly named empty project on its Agent starting page", async () => {
diff --git a/src/components/ProjectSettings.test.tsx b/src/components/ProjectSettings.test.tsx
index 9c963a8..463de33 100644
--- a/src/components/ProjectSettings.test.tsx
+++ b/src/components/ProjectSettings.test.tsx
@@ -2,7 +2,7 @@
import "@testing-library/jest-dom/vitest";
import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { afterEach, expect, it, vi } from "vitest";
-import { createProjectConfig, type ProjectRecord } from "../lib/project";
+import { createProjectConfig, type CreateProjectInput, type ProjectRecord } from "../lib/project";
import { ProjectWorkspace } from "./ProjectWorkspace";
import { PromptComposer } from "./PromptComposer";
@@ -29,12 +29,13 @@ it("opens settings from the project name, saves both settings mirrors, and resto
fireEvent.change(dialog.getByLabelText("Aspect Ratio"), { target: { value: "9:16" } });
fireEvent.change(dialog.getByLabelText("Resolution"), { target: { value: "544p" } });
fireEvent.change(dialog.getByLabelText("Length in seconds"), { target: { value: "90" } });
+ fireEvent.change(dialog.getByLabelText("Default Look"), { target: { value: "watercolor" } });
fireEvent.click(dialog.getByRole("button", { name: "Save changes" }));
await waitFor(() => expect(screen.queryByRole("dialog", { name: "Project settings" })).not.toBeInTheDocument());
const saved = onSave.mock.calls[0][0].config;
expect(saved).toMatchObject({ name: "Updated", id: record.config.id,
brief: { prompt: "Keep this brief", aspectRatio: "9:16", resolution: "544p", targetDurationSeconds: 90 },
- settings: { aspectRatio: "9:16", resolution: "544p" },
+ settings: { aspectRatio: "9:16", resolution: "544p", defaultLook: "watercolor" },
});
expect(saved.timeline).toEqual(record.config.timeline);
expect(saved.generationJobs).toEqual(record.config.generationJobs);
@@ -42,6 +43,7 @@ it("opens settings from the project name, saves both settings mirrors, and resto
fireEvent.click(screen.getByRole("button", { name: "Edit project settings for Updated" }));
expect(screen.getByLabelText("Resolution")).toHaveValue("544p");
expect(screen.getByLabelText("Length in seconds")).toHaveValue(90);
+ expect(screen.getByLabelText("Default Look")).toHaveValue("watercolor");
});
it("cancels pending edits with Escape without saving", () => {
@@ -81,12 +83,12 @@ it("preserves legacy resolution and short project length when opening settings",
expect(onSubmit).toHaveBeenCalledWith(expect.objectContaining({ resolution: "1080p", targetDurationSeconds: 5 }));
});
-it.each([false, true])("supports exact numeric lengths and the two slider intervals (editing=%s)", (editing) => {
+it("supports exact numeric lengths and the two slider intervals in project settings", () => {
const onSubmit = vi.fn(async () => undefined);
- render(<PromptComposer project={editing ? project().config : undefined} busy={false} onClose={vi.fn()} onCreate={onSubmit} />);
+ render(<PromptComposer project={project().config} busy={false} onClose={vi.fn()} onCreate={onSubmit} />);
const slider = screen.getByRole("slider", { name: "Length slider" });
const number = screen.getByRole("spinbutton", { name: "Length in seconds" });
- const save = screen.getByRole("button", { name: editing ? "Save changes" : "Create project" });
+ const save = screen.getByRole("button", { name: "Save changes" });
for (const [position, seconds] of [[0, 0], [1, 1], [59, 59], [60, 60], [61, 70], [62, 80], [114, 600]]) {
fireEvent.change(slider, { target: { value: String(position) } });
expect(number).toHaveValue(seconds);
@@ -100,3 +102,24 @@ it.each([false, true])("supports exact numeric lengths and the two slider interv
expect(save).toBeDisabled();
}
});
+
+it.each(["", "claymation"])("creates a project with Look %s and an automatically sized timeline", (look) => {
+ const onCreate = vi.fn(async (_input: CreateProjectInput) => {});
+ render(<PromptComposer busy={false} onClose={vi.fn()} onCreate={onCreate} />);
+ expect(screen.queryByLabelText("Length in seconds")).not.toBeInTheDocument();
+ fireEvent.change(screen.getByLabelText("Default Look"), { target: { value: look } });
+ fireEvent.click(screen.getByRole("button", { name: "Create project" }));
+ expect(onCreate).toHaveBeenCalledWith(expect.objectContaining({ defaultLook: look || null, targetDurationSeconds: 0 }));
+ expect(createProjectConfig(onCreate.mock.calls[0][0]).settings.defaultLook ?? null).toBe(look || null);
+});
+
+it("preserves an automatically extended project and allows clearing its default Look", () => {
+ const config = project().config;
+ config.brief.targetDurationSeconds = 730;
+ config.settings.defaultLook = "watercolor";
+ const onSubmit = vi.fn(async (_input: CreateProjectInput) => {});
+ render(<PromptComposer project={config} busy={false} onClose={vi.fn()} onCreate={onSubmit} />);
+ fireEvent.change(screen.getByLabelText("Default Look"), { target: { value: "" } });
+ fireEvent.click(screen.getByRole("button", { name: "Save changes" }));
+ expect(onSubmit).toHaveBeenCalledWith(expect.objectContaining({ targetDurationSeconds: 730, defaultLook: null }));
+});
diff --git a/src/components/ProjectWorkspace.test.ts b/src/components/ProjectWorkspace.test.ts
index 0dbf689..5f8b7b4 100644
--- a/src/components/ProjectWorkspace.test.ts
+++ b/src/components/ProjectWorkspace.test.ts
@@ -619,6 +619,7 @@ describe("project workspace timecode", () => {
fireEvent.dragStart(cardFor(known.assets[0]), { dataTransfer: transfer });
fireEvent.drop(laneAt(first.container, 0), { dataTransfer: transfer });
expect(droppedClip(first.onChange, known).durationMs).toBe(40_000);
+ expect(wrote(first.onChange.mock.calls[0][0], known).brief.targetDurationSeconds).toBe(40);
expect(parseProjectConfig(wrote(first.onChange.mock.calls[0][0], known))).toBeTruthy();
cleanup();
@@ -632,6 +633,22 @@ describe("project workspace timecode", () => {
expect(droppedClip(second.onChange, unknown).durationMs).toBe(5_000);
});
+ it("keeps a long drop at the requested position and grows the saved project beyond ten minutes", () => {
+ const config = measuredVideo(projectWithMedia(), 700_000);
+ const view = mediaPanel(config);
+ const lane = laneAt(view.container, 0) as HTMLElement;
+ lane.getBoundingClientRect = () => ({ left: 100, width: 1000 } as DOMRect);
+ const dataTransfer = fakeDataTransfer();
+ fireEvent.dragStart(cardFor(config.assets[0]), { dataTransfer });
+ const drop = createEvent.drop(lane, { dataTransfer });
+ Object.defineProperty(drop, "clientX", { value: 1100 });
+ fireEvent(lane, drop);
+ const next = wrote(view.onChange.mock.calls[0][0], config);
+ expect(next.timeline.tracks.flatMap((track) => track.clips)[0]).toMatchObject({ startMs: 30_000, durationMs: 700_000 });
+ expect(next.brief.targetDurationSeconds).toBe(730);
+ expect(parseProjectConfig(next)).toBeTruthy();
+ });
+
it("uses an editable clip name as the inspector heading", () => {
const config = withClip(measuredVideo(projectWithMedia(), 40_000), {});
const onChange = vi.fn();
@@ -731,6 +748,16 @@ describe("project workspace timecode", () => {
stopHitTesting();
});
+ it("extends the project when an existing clip is dragged past its end", () => {
+ const config = withClips(measuredVideo(projectWithMedia(), 40_000), [{ startMs: 0, durationMs: 4_000 }]);
+ const view = timeline(config);
+ drag(view.container.querySelector(".timeline-clip")!, 20, 1220);
+ const moved = view.clipsOn(STORY_TRACK_ID)[0];
+ expect(moved.startMs).toBe(36_000);
+ expect(view.written()!.brief.targetDurationSeconds).toBe(40);
+ expect(parseProjectConfig(view.written()!)).toBeTruthy();
+ });
+
it("moves audio-only media from one audiovisual track to another", () => {
const measured = parseProjectConfig({
...projectWithMedia(),
diff --git a/src/components/ProjectWorkspace.tsx b/src/components/ProjectWorkspace.tsx
index b4b1145..9ba47ab 100644
--- a/src/components/ProjectWorkspace.tsx
+++ b/src/components/ProjectWorkspace.tsx
@@ -88,7 +88,7 @@ export function ProjectWorkspace({ project, initialView = "timeline", runtime =
session.update((current) => ({
...current, name: input.name,
brief: { ...current.brief, aspectRatio: input.aspectRatio, resolution: input.resolution, targetDurationSeconds: input.targetDurationSeconds },
- settings: { ...current.settings, aspectRatio: input.aspectRatio, resolution: input.resolution },
+ settings: { ...current.settings, aspectRatio: input.aspectRatio, resolution: input.resolution, defaultLook: input.defaultLook },
}));
await session.save();
setEditingProject(false);
diff --git a/src/components/PromptComposer.tsx b/src/components/PromptComposer.tsx
index 574f2ff..e2db71f 100644
--- a/src/components/PromptComposer.tsx
+++ b/src/components/PromptComposer.tsx
@@ -3,6 +3,7 @@ import { useEffect, useRef, useState } from "react";
import { outputDimensions, resolutionLabel } from "../lib/export";
import type { AspectRatio, CreateProjectInput, ProjectConfig, Resolution } from "../lib/project";
import { PROJECT_RESOLUTIONS } from "../lib/project";
+import { SHOT_TAG_GROUPS } from "../lib/shot-tags";
interface PromptComposerProps {
busy: boolean;
@@ -23,6 +24,7 @@ const aspectRatioLabels: Record<AspectRatio, string> = {
16:9 scene onto (1344×768), so a project made without opening this panel is
not one that has to be rescaled the moment a scene is generated. */
const DEFAULT_RESOLUTION: Resolution = "768p";
+const LOOKS = SHOT_TAG_GROUPS.find((group) => group.id === "visualStyle")!.options;
const durationLabel = (seconds: number) => {
if (seconds < 60) return `${seconds} seconds`;
@@ -35,12 +37,15 @@ export function PromptComposer({ busy, onCreate: onSubmit, onClose, project, err
const [name, setName] = useState(project?.name ?? "Untitled video");
const [aspectRatio, setAspectRatio] = useState<AspectRatio>(project?.settings.aspectRatio ?? "16:9");
const [resolution, setResolution] = useState<Resolution>(project?.settings.resolution ?? DEFAULT_RESOLUTION);
- const [durationInput, setDurationInput] = useState(String(project?.brief.targetDurationSeconds ?? 30));
+ const [defaultLook, setDefaultLook] = useState(project?.settings.defaultLook ?? "");
+ const [durationInput, setDurationInput] = useState(String(project?.brief.targetDurationSeconds ?? 0));
const duration = Number(durationInput);
const dialog = useRef<HTMLDivElement>(null);
const nameInput = useRef<HTMLInputElement>(null);
- const validDuration = durationInput.trim() !== "" && Number.isInteger(duration) && duration >= 0 && duration <= 600;
- const sliderPosition = Math.max(0, Math.min(114, duration <= 60 ? duration : 60 + (duration - 60) / 10));
+ const maxDuration = Math.max(600, Math.ceil((project?.brief.targetDurationSeconds ?? 0) / 10) * 10);
+ const validDuration = durationInput.trim() !== "" && Number.isInteger(duration) && duration >= 0 && duration <= maxDuration;
+ const sliderMax = 60 + (maxDuration - 60) / 10;
+ const sliderPosition = Math.max(0, Math.min(sliderMax, duration <= 60 ? duration : 60 + (duration - 60) / 10));
const resolutions: readonly Resolution[] = project && !PROJECT_RESOLUTIONS.some((value) => value === project.settings.resolution)
? [...PROJECT_RESOLUTIONS, project.settings.resolution] : PROJECT_RESOLUTIONS;
@@ -74,6 +79,7 @@ export function PromptComposer({ busy, onCreate: onSubmit, onClose, project, err
aspectRatio,
resolution,
targetDurationSeconds: duration,
+ defaultLook: defaultLook || null,
});
};
@@ -93,7 +99,7 @@ export function PromptComposer({ busy, onCreate: onSubmit, onClose, project, err
<section className="composer__options">
<div className="composer__options-head">
<span className="composer__options-title">Video settings</span>
- <span className="composer__options-value">{aspectRatioLabels[aspectRatio]} · {resolutionLabel(resolution, aspectRatio)} · {durationLabel(duration)}</span>
+ <span className="composer__options-value">{aspectRatioLabels[aspectRatio]} · {resolutionLabel(resolution, aspectRatio)}</span>
</div>
<div className="composer__options-body">
<div className="composer__options-grid">
@@ -119,22 +125,30 @@ export function PromptComposer({ busy, onCreate: onSubmit, onClose, project, err
})}
</select>
</label>
- <div className="composer__duration">
+ <label>
+ <span>Default Look</span>
+ <select aria-label="Default Look" disabled={busy} value={defaultLook} onChange={(event) => setDefaultLook(event.target.value)}>
+ <option value="">None</option>
+ {LOOKS.map((look) => <option key={look.id} value={look.id}>{look.label}</option>)}
+ </select>
+ <small>Used by scenes whose Look is set to None.</small>
+ </label>
+ {project && <div className="composer__duration">
<span>
<Clock3 size={15} /> Length
- <output htmlFor="project-duration">{validDuration ? durationLabel(duration) : "Enter 0–600 seconds"}</output>
+ <output htmlFor="project-duration">{validDuration ? durationLabel(duration) : `Enter 0–${maxDuration} seconds`}</output>
</span>
- <input id="project-duration" aria-label="Length in seconds" type="number" min={0} max={600} step={1} disabled={busy} value={durationInput} onChange={(event) => setDurationInput(event.target.value)} />
+ <input id="project-duration" aria-label="Length in seconds" type="number" min={0} max={maxDuration} step={1} disabled={busy} value={durationInput} onChange={(event) => setDurationInput(event.target.value)} />
<input
aria-label="Length slider"
aria-valuetext={durationLabel(duration)}
aria-valuemin={0}
- aria-valuemax={600}
+ aria-valuemax={maxDuration}
aria-valuenow={validDuration ? duration : 0}
type="range"
min={0}
disabled={busy}
- max={114}
+ max={sliderMax}
step={1}
value={Number.isFinite(sliderPosition) ? sliderPosition : 0}
onChange={(event) => {
@@ -142,8 +156,8 @@ export function PromptComposer({ busy, onCreate: onSubmit, onClose, project, err
setDurationInput(String(position <= 60 ? position : 60 + (position - 60) * 10));
}}
/>
- <small className="composer__duration-scale"><span>0 seconds</span><span>10 minutes</span></small>
- </div>
+ <small className="composer__duration-scale"><span>0 seconds</span><span>{durationLabel(maxDuration)}</span></small>
+ </div>}
</div>
</div>
</section>
diff --git a/src/components/workspace/GeneratorView.test.tsx b/src/components/workspace/GeneratorView.test.tsx
index 3d266c3..3f63582 100644
--- a/src/components/workspace/GeneratorView.test.tsx
+++ b/src/components/workspace/GeneratorView.test.tsx
@@ -174,6 +174,20 @@ async function finishFirst(state: ReturnType<typeof setup>) {
}
describe("Generator scene controls", () => {
+ it.each([["", "Watercolor"], ["claymation", "Claymation"]])("compiles scene Look %s with the project's default", async (sceneLook, expected) => {
+ const initial = project();
+ initial.settings.defaultLook = "watercolor";
+ const state = setup(initial);
+ const selector = screen.getByRole("combobox", { name: "The look of this scene" });
+ expect(selector).toHaveValue("");
+ expect(screen.getByText("Using project Look: Watercolor.")).toBeInTheDocument();
+ if (sceneLook) fireEvent.change(selector, { target: { value: sceneLook } });
+ fireEvent.click(within(screen.getByRole("region", { name: "First scene" })).getByRole("button", { name: "Generate" }));
+ await waitFor(() => expect(state.latest().generationJobs[0].generationSnapshot).toEqual(expect.any(String)));
+ expect(JSON.parse(state.latest().generationJobs[0].generationSnapshot!).prompt).toContain(expected);
+ if (!sceneLook) expect(sceneShots(state.latest().generationJobs[0])[0].settings?.visualStyle).toBeUndefined();
+ });
+
it("only shows debug prompts when enabled, in a closable popup outside the inspector", () => {
setup();
expect(screen.queryByRole("button", { name: "Debug Prompt" })).not.toBeInTheDocument();
diff --git a/src/components/workspace/GeneratorView.tsx b/src/components/workspace/GeneratorView.tsx
index e139bdc..fba7cf1 100644
--- a/src/components/workspace/GeneratorView.tsx
+++ b/src/components/workspace/GeneratorView.tsx
@@ -302,7 +302,7 @@ export function GeneratorView({ config, folderPath, runtime = null, generationCo
// retimed shot reach the engine, rather than sending a prompt frozen at
// draft-creation time. This is the ONE string slopfab is given, and it is
// the same string the compiled-prompt panel shows.
- prompt: animate ? "" : compileGenerationJobPrompt(inputs.job, bound),
+ prompt: animate ? "" : compileGenerationJobPrompt(inputs.job, bound, configRef.current.settings.defaultLook),
...(inputs.previousSceneId ? { previousSceneId: inputs.previousSceneId } : {}),
...(inputs.continuationRelativePath ? { continuationRelativePath: inputs.continuationRelativePath } : {}),
// The scene's own length, not a fixed six seconds.
@@ -563,6 +563,7 @@ export function GeneratorView({ config, folderPath, runtime = null, generationCo
job={selected}
shots={selectedShots}
defaultSteps={defaultGenerationSteps}
+ defaultLook={config.settings.defaultLook}
disabled={false}
references={config.references}
importAvailable={isTauri()}
@@ -589,7 +590,7 @@ export function GeneratorView({ config, folderPath, runtime = null, generationCo
{debugEnabled && showDebugPrompt && selected && !openShot && <DebugPromptDialog
sceneTitle={selected.title}
- segments={compileGenerationJobSegments(frameInputs?.job ?? selected, boundRefs)}
+ segments={compileGenerationJobSegments(frameInputs?.job ?? selected, boundRefs, config.settings.defaultLook)}
onClose={() => setShowDebugPrompt(false)}
/>}
diff --git a/src/components/workspace/SceneEditor.tsx b/src/components/workspace/SceneEditor.tsx
index a0cc51f..1fb1668 100644
--- a/src/components/workspace/SceneEditor.tsx
+++ b/src/components/workspace/SceneEditor.tsx
@@ -267,8 +267,9 @@ export function ShotInspector({ job, shots, shot, index, endsAt, duration, refer
/** Scene-wide render controls, the look the description opens with (base guide
* §4.1), and the two sound fields defined per prompt (§4.6, §4.7). Length
* lives in the scene header where it stays visible. */
-export function SceneInspector({ job, shots, references, previousScene, defaultSteps, disabled, importAvailable, importError, onAddStartFrame, onAddEndFrame, onChange, onShots, animate = false }: {
+export function SceneInspector({ job, shots, references, previousScene, defaultSteps, defaultLook, disabled, importAvailable, importError, onAddStartFrame, onAddEndFrame, onChange, onShots, animate = false }: {
animate?: boolean;
+ defaultLook?: string | null;
job: GenerationJob;
shots: SceneShot[];
references: ProjectReference[];
@@ -326,6 +327,7 @@ export function SceneInspector({ job, shots, references, previousScene, defaultS
<option value="">None</option>
{look.options.map((option) => <option key={option.id} value={option.id}>{option.label}</option>)}
</select>
+ {!chosen && defaultLook && <small>Using project Look: {look.options.find((option) => option.id === defaultLook)?.label ?? defaultLook}.</small>}
</label>}
<div className="scene-settings__field">
<span>{animate ? "Repainted scene frame" : "Start frame"}</span>
diff --git a/src/components/workspace/TimelineView.tsx b/src/components/workspace/TimelineView.tsx
index 93dc6d1..2706f92 100644
--- a/src/components/workspace/TimelineView.tsx
+++ b/src/components/workspace/TimelineView.tsx
@@ -20,7 +20,7 @@ import {
type TimelineTrack,
} from "../../lib/project";
import {
- clipEndMs, findClip, insertClip, moveClip, removeClip, snapTargets, sourceRoom, trimClip,
+ clipEndMs, findClip, insertClip, moveClip, removeClip, snapTargets, sourceRoom, trimClip, withTimelineTracks,
type SnapOptions, type SourceRoom,
} from "../../lib/timeline";
import { MediaThumbnail, type MeasuredMedia } from "./MediaThumbnail";
@@ -286,7 +286,7 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
seconds long would go back to being an unmeasured file, and the next drop
of it would be a 5-second stand-in. */
const updateTracks = (nextTracks: ProjectConfig["timeline"]["tracks"]) =>
- onChange((current) => ({ ...current, timeline: { tracks: nextTracks } }));
+ onChange((current) => withTimelineTracks(current, nextTracks));
const renameTrack = (trackId: string, name: string) => updateTracks(tracks.map((track) => track.id === trackId ? { ...track, name } : track));
const updateClip = (clipId: string, updates: Partial<TimelineClip>) => updateTracks(tracks.map((track) => ({ ...track, clips: track.clips.map((clip) => clip.id === clipId ? { ...clip, ...updates } : clip) })));
const updateTransform = (key: keyof NonNullable<TimelineClip["transform"]>, value: number) => {
@@ -495,15 +495,10 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
image and a file nothing could measure have no length to honour, so they
get the stated default — see DROPPED_CLIP_MS. */
const durationMs = asset.durationMs && asset.durationMs > 0 ? asset.durationMs : DROPPED_CLIP_MS;
- /* Clamp so a drop near the right edge still lands a whole clip on the
- ruler, against THIS clip's length rather than the 5s default — a long
- import dropped at the end used to run off the end of the canvas.
- Math.max last, because a clip longer than the whole canvas makes
- `duration - durationMs` negative and 0 is the only honest start.
- A non-finite ratio (a zero-width lane, a lane that has not been laid out
- yet) would carry NaN into startMs, which zod then refuses to save. */
+ /* Honor the drop position and grow the project to fit the entire clip.
+ A lane not yet laid out has no finite ratio; its drop starts at zero. */
const position = Number.isFinite(ratio) ? ratio * duration : 0;
- const startMs = Math.round(Math.max(0, Math.min(duration - durationMs, position)));
+ const startMs = Math.round(Math.max(0, position));
const clip: TimelineClip = {
id: `clip-${crypto.randomUUID()}`,
assetId: asset.id,
@@ -558,7 +553,7 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
};
const currentDuration = canvasDuration(current);
const position = Number.isFinite(ratio) ? ratio * currentDuration : 0;
- const startMs = Math.round(Math.max(0, Math.min(currentDuration - sceneLengthMs, position)));
+ const startMs = Math.round(Math.max(0, position));
const clip: TimelineClip = {
id: clipId,
assetId: asset.id,
@@ -577,7 +572,7 @@ export function TimelineView({ config, folderPath, generationCompletionTimes = {
const nextTracks = insertClip(current.timeline.tracks, trackId, clip, startMs, snap);
if (!nextTracks) return current;
const assets = existing ? current.assets : [...current.assets, asset];
- return { ...current, assets, timeline: { tracks: nextTracks } };
+ return withTimelineTracks({ ...current, assets }, nextTracks);
});
setSelectedId(clipId);
};
diff --git a/src/lib/project.test.ts b/src/lib/project.test.ts
index 808ff09..d047af8 100644
--- a/src/lib/project.test.ts
+++ b/src/lib/project.test.ts
@@ -54,6 +54,18 @@ import {
PROJECT_FILE_NAME,
type ProjectReference,
} from "./project";
+
+it("inherits the project Look only when the scene has no explicit Look", () => {
+ const config = createProjectConfig({ name: "Looks", prompt: "A forest", aspectRatio: "16:9", resolution: "768p", targetDurationSeconds: 0, defaultLook: "watercolor" });
+ const restored = parseProjectConfig(JSON.parse(JSON.stringify(config)));
+ const job = restored.generationJobs[0];
+ expect(compileGenerationJobPrompt(job, [], restored.settings.defaultLook)).toContain("Watercolor");
+ expect(sceneShots(job)[0].settings?.visualStyle).toBeUndefined();
+ const explicit = { ...job, shots: sceneShots(job).map((shot) => ({ ...shot, settings: { visualStyle: ["claymation"] } })) };
+ expect(compileGenerationJobPrompt(explicit, [], "watercolor")).toContain("Claymation");
+ expect(compileGenerationJobPrompt(explicit, [], "watercolor")).not.toContain("Watercolor");
+ expect(compileGenerationJobPrompt(job, [], null)).toBe(compileGenerationJobPrompt(job));
+});
/** Regenerated by `cargo test` from the Rust validator's real output. */
const wireFixtures = {
created: wireCreated,
diff --git a/src/lib/project.ts b/src/lib/project.ts
index 02c2ea7..c64dc61 100644
--- a/src/lib/project.ts
+++ b/src/lib/project.ts
@@ -234,7 +234,7 @@ export const generationBriefSchema = z.object({
/* Blank is a real empty project: no brief and no seeded scene. */
prompt: z.string(),
status: z.enum(["draft", "queued", "generating", "ready", "failed"]),
- targetDurationSeconds: z.number().int().min(0).max(600),
+ targetDurationSeconds: z.number().int().min(0).max(4_294_967_295),
aspectRatio: aspectRatioSchema,
resolution: resolutionSchema,
});
@@ -534,6 +534,7 @@ export const projectConfigSchema = z.object({
updatedAt: isoDateSchema,
thumbnail: projectRelativePathSchema.nullable(),
settings: z.object({
+ defaultLook: z.string().regex(SHOT_TAG_ID_PATTERN).nullish(),
aspectRatio: aspectRatioSchema,
resolution: resolutionSchema,
frameRate: z.union([z.literal(24), z.literal(25), z.literal(30), z.literal(60)]),
@@ -596,6 +597,7 @@ export interface CreateProjectInput {
aspectRatio: AspectRatio;
resolution: Resolution;
targetDurationSeconds: number;
+ defaultLook?: string | null;
projectDirectory?: string;
referenceImages?: PendingReferenceImage[];
}
@@ -964,12 +966,12 @@ export function compileMiniMaxH3PromptSegments(
);
}
-export function compileGenerationJobSegments(job: GenerationJob, references: ProjectReference[] = []): PromptSegment[] {
- return compileScenePromptSegments({ shots: sceneShots(job), startFrameReferenceId: job.startFrameReferenceId, endFrameReferenceId: job.endFrameReferenceId, soundscape: job.soundscape, music: job.music }, references);
+export function compileGenerationJobSegments(job: GenerationJob, references: ProjectReference[] = [], defaultLook?: string | null): PromptSegment[] {
+ return compileScenePromptSegments({ shots: sceneShots(job), startFrameReferenceId: job.startFrameReferenceId, endFrameReferenceId: job.endFrameReferenceId, soundscape: job.soundscape, music: job.music }, references, defaultLook);
}
-export function compileGenerationJobPrompt(job: GenerationJob, references: ProjectReference[] = []): string {
- return compileGenerationJobSegments(job, references).map((segment) => segment.value).join("");
+export function compileGenerationJobPrompt(job: GenerationJob, references: ProjectReference[] = [], defaultLook?: string | null): string {
+ return compileGenerationJobSegments(job, references, defaultLook).map((segment) => segment.value).join("");
}
/** What one shot contributes, already split by who wrote it. */
@@ -988,7 +990,7 @@ interface CompiledShot {
speechLanguage: SpeechLanguage;
}
-export function compileScenePromptSegments(scene: ScenePrompt, references: ProjectReference[] = []): PromptSegment[] {
+export function compileScenePromptSegments(scene: ScenePrompt, references: ProjectReference[] = [], defaultLook?: string | null): PromptSegment[] {
const shots = normalizeSceneShots(scene.shots.length > 0 ? scene.shots : [{ id: "shot-1", startSeconds: 0, action: "", settings: null }]);
// Same filter pair as `usableImageReferences`, in the same order — see the
// <Picture N> / reference_paths lockstep note on that function. An
@@ -1032,9 +1034,10 @@ export function compileScenePromptSegments(scene: ScenePrompt, references: Proje
// §4.1: the description opens with ONE overall style, so the first shot that
// carries one sets it for the scene — the picker marks that setting scene-wide
- // for the same reason. Without one, the guess from the user's own words
- // stands and is marked as Slopus's doing.
- const styleFromTag = compiled.map((shot) => shot.tags.style).find((style) => Boolean(style)) ?? null;
+ // for the same reason. Without one, use the project Look. When both are None,
+ // retain the guess from the user's own words, marked as Slopus's doing.
+ const styleFromTag = compiled.map((shot) => shot.tags.style).find((style) => Boolean(style))
+ ?? (defaultLook ? shotTagClauses({ visualStyle: [defaultLook] }).style : null);
const style = styleFromTag ?? deriveH3Style(compiled.map((shot) => shot.text).join(" "));
const styleSegment = styleFromTag ? tagged(style) : frame(style);
@@ -1358,7 +1361,7 @@ export function createProjectConfig(input: CreateProjectInput): ProjectConfig {
createdAt: now,
updatedAt: now,
thumbnail: null,
- settings: { aspectRatio: input.aspectRatio, resolution: input.resolution, frameRate: 24, backgroundColor: "#10131a" },
+ settings: { aspectRatio: input.aspectRatio, resolution: input.resolution, frameRate: 24, backgroundColor: "#10131a", ...(input.defaultLook ? { defaultLook: input.defaultLook } : {}) },
brief: {
prompt: brief, status: "draft", targetDurationSeconds: input.targetDurationSeconds,
aspectRatio: input.aspectRatio, resolution: input.resolution,
diff --git a/src/lib/runtime.test.ts b/src/lib/runtime.test.ts
index 59bea9a..437f7a3 100644
--- a/src/lib/runtime.test.ts
+++ b/src/lib/runtime.test.ts
@@ -25,7 +25,10 @@ describe("deterministic browser runtime", () => {
expect(next.brief).toMatchObject({ resolution: "544p", aspectRatio: "9:16", targetDurationSeconds: 90 });
expect(next.timeline).toEqual(record.config.timeline);
expect(record.config.brief.targetDurationSeconds).toBe(30);
- await expect(executeAgentCommands(record.config, [{ op: "project.set", targetSeconds: 601 }])).rejects.toThrow();
+ await expect(executeAgentCommands(record.config, [{ op: "project.set", targetSeconds: 900 }])).resolves.toMatchObject({
+ brief: { targetDurationSeconds: 900 },
+ });
+ await expect(executeAgentCommands(record.config, [{ op: "project.set", targetSeconds: -1 }])).rejects.toThrow();
await expect(executeAgentCommands(record.config, [{ op: "project.set", resolution: "8k" }])).rejects.toThrow();
await expect(executeAgentCommands(record.config, [{ op: "project.set", aspectRatio: "21:9" }])).rejects.toThrow();
});
diff --git a/src/lib/timeline.ts b/src/lib/timeline.ts
index 066d1f6..db19d2a 100644
--- a/src/lib/timeline.ts
+++ b/src/lib/timeline.ts
@@ -1,4 +1,11 @@
-import type { TimelineClip, TimelineTrack } from "./project";
+import type { ProjectConfig, TimelineClip, TimelineTrack } from "./project";
+
+/** Grow to contain an edit, retaining the existing length when clips move left or are removed. */
+export function withTimelineTracks(config: ProjectConfig, tracks: TimelineTrack[]): ProjectConfig {
+ const end = tracks.reduce((furthest, track) => track.clips.reduce((value, clip) => Math.max(value, clipEndMs(clip)), furthest), 0);
+ const targetDurationSeconds = Math.max(config.brief.targetDurationSeconds, Math.ceil(end / 1000));
+ return { ...config, brief: { ...config.brief, targetDurationSeconds }, timeline: { tracks } };
+}
/* Editing the timeline, as arithmetic.
*