Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Improve scene generation

Bitti3c8d72297719
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index e028afd..846b9b6 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -2290,6 +2290,7 @@ dependencies = [
name = "pol-studio"
version = "0.1.0"
dependencies = [
+ "getrandom 0.3.4",
"libloading 0.8.9",
"serde",
"serde_json",
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index 8d19b86..f485e0e 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -21,10 +21,10 @@ serde_json = "1"
tauri = { version = "2", features = [] }
tauri-plugin-dialog = "2"
libloading = "0.8"
+getrandom = "0.3"
[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.59", features = ["Win32_Foundation", "Win32_Storage_FileSystem"] }
[dev-dependencies]
tempfile = "3"
-
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index 3b30832..84540a1 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -166,8 +166,8 @@ struct ReusableReference {
/// `startSeconds` and `action` are REQUIRED on the zod side and are plain
/// (non-`Option`) fields here, so they are always written — a `#[serde(default)]`
/// covers a file that predates them without ever producing a key zod refuses.
-/// `settings` is the only optional one and carries `skip_serializing_if`,
-/// because zod spells it `.nullish()` for the same reason `shotTags` is.
+/// Later optional fields carry `skip_serializing_if`, because zod spells them
+/// `.nullish()` and older project files must not grow keys just by being saved.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
struct SceneShot {
@@ -182,6 +182,12 @@ struct SceneShot {
/// added has nothing written in it, and this layer never fills it in.
#[serde(default)]
action: String,
+ /// Spoken text is kept separate so the frontend compiler can place it
+ /// inside MiniMax H3's dialogue tags without trying to parse prose.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ speech: Option<String>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ speech_language: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
settings: Option<BTreeMap<String, Vec<String>>>,
}
@@ -225,17 +231,22 @@ struct GenerationJob {
/// dropped on the next save.
#[serde(default, skip_serializing_if = "Option::is_none")]
shot_tags: Option<BTreeMap<String, Vec<String>>>,
- /// The shots this scene holds, in playing order. Every one of the four
- /// fields below is an `Option` with `skip_serializing_if`, because every
- /// project written before scenes existed has none of these keys and must
- /// round-trip byte-for-byte: zod spells all four `.nullish()`, so `null`
- /// would also be readable, but an absent key is what the old files have.
+ /// The shots this scene holds, in playing order. Optional scene settings
+ /// use `skip_serializing_if`, because older projects have none of these keys
+ /// and must round-trip byte-for-byte. Zod spells them `.nullish()`, so null
+ /// is readable too, but absence is what those old files contain.
#[serde(default, skip_serializing_if = "Option::is_none")]
shots: Option<Vec<SceneShot>>,
/// How long the whole scene runs, 0-15 seconds. Absent means the length
/// every shot was generated at before this was settable.
#[serde(default, skip_serializing_if = "Option::is_none")]
duration_seconds: Option<f64>,
+ /// Renderer controls added after scenes. Missing values retain the UI's
+ /// defaults without making old project files grow new keys on open.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ steps: Option<i32>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ seed: Option<i64>,
/// Base guide §4.6 and §4.7 — per-prompt fields, so they sit on the scene
/// rather than on a shot. Absent means the compiler writes its own
/// content-neutral line and marks it as PolStudio's own words.
@@ -817,6 +828,27 @@ fn validate_and_normalize_config(mut config: ProjectConfig) -> Result<ProjectCon
shot.id, job.id, shot.start_seconds
));
}
+ if shot.speech_language.as_deref().is_some_and(|language| {
+ !matches!(
+ language,
+ "Arabic"
+ | "Chinese"
+ | "English"
+ | "French"
+ | "German"
+ | "Italian"
+ | "Japanese"
+ | "Korean"
+ | "Portuguese"
+ | "Russian"
+ | "Spanish"
+ )
+ }) {
+ return Err(format!(
+ "Shot '{}' in scene '{}' has an unsupported speech language.",
+ shot.id, job.id
+ ));
+ }
shot.settings = normalize_shot_tags(shot.settings.take())
.map_err(|reason| format!("Shot '{}' {reason}", shot.id))?;
}
@@ -832,6 +864,21 @@ fn validate_and_normalize_config(mut config: ProjectConfig) -> Result<ProjectCon
));
}
}
+ if job.steps.is_some_and(|steps| steps < 2) {
+ return Err(format!(
+ "Scene '{}' must use at least 2 generation steps.",
+ job.id
+ ));
+ }
+ if job.seed.is_some_and(|seed| seed < -1) {
+ return Err(format!("Scene '{}' has a seed below -1.", job.id));
+ }
+ if job.seed.is_some_and(|seed| seed > 9_007_199_254_740_991) {
+ return Err(format!(
+ "Scene '{}' has a seed too large to preserve exactly.",
+ job.id
+ ));
+ }
// Blank is the same as unset for both of these; the compiler falls back
// to its own line, and writing `""` would be a key zod has to tolerate
// for no gain.
@@ -3640,12 +3687,23 @@ mod tests {
let job = &opened.generation_jobs[0];
assert_eq!(job.shots, None, "{name}");
assert_eq!(job.duration_seconds, None, "{name}");
+ assert_eq!(job.steps, None, "{name}");
+ assert_eq!(job.seed, None, "{name}");
assert_eq!(job.soundscape, None, "{name}");
assert_eq!(job.music, None, "{name}");
let json = serde_json::to_string_pretty(&opened).unwrap();
- for key in ["shots", "durationSeconds", "soundscape", "music"] {
+ let value: serde_json::Value = serde_json::from_str(&json).unwrap();
+ let serialized_job = object_of(&value["generationJobs"][0], "generationJobs[0]");
+ for key in [
+ "shots",
+ "durationSeconds",
+ "steps",
+ "seed",
+ "soundscape",
+ "music",
+ ] {
assert!(
- !json.contains(&format!("\"{key}\"")),
+ !serialized_job.contains_key(key),
"the {name} fixture grew a {key} key it never had: {json}"
);
}
@@ -3730,6 +3788,8 @@ mod tests {
name: None,
start_seconds: 0.0,
action: String::new(),
+ speech: None,
+ speech_language: None,
settings: None,
}]);
@@ -3755,6 +3815,28 @@ mod tests {
);
}
+ #[test]
+ fn shot_speech_and_its_supported_language_survive_the_project_round_trip() {
+ let mut config = scene_fixture();
+ let shot = &mut config.generation_jobs[0].shots.as_mut().unwrap()[0];
+ shot.speech = Some("行こう! Keep this punctuation.".into());
+ shot.speech_language = Some("Japanese".into());
+
+ let normalized =
+ validate_and_normalize_config(config).expect("documented H3 speech is valid");
+ let shot = &normalized.generation_jobs[0].shots.as_ref().unwrap()[0];
+ assert_eq!(
+ shot.speech.as_deref(),
+ Some("行こう! Keep this punctuation.")
+ );
+ assert_eq!(shot.speech_language.as_deref(), Some("Japanese"));
+
+ let mut invalid = scene_fixture();
+ invalid.generation_jobs[0].shots.as_mut().unwrap()[0].speech_language =
+ Some("Klingon".into());
+ assert!(validate_and_normalize_config(invalid).is_err());
+ }
+
#[test]
fn a_scene_is_bounded_to_fifteen_seconds_on_both_the_length_and_the_cuts() {
// The frontend spells this `z.number().min(0).max(15)` on both fields.
@@ -3787,6 +3869,23 @@ mod tests {
assert!(validate_and_normalize_config(twins).is_err());
}
+ #[test]
+ fn scene_generation_controls_match_the_frontend_boundaries() {
+ for (steps, seed) in [(2, -1), (20, 0), (50, 9_007_199_254_740_991)] {
+ let mut config = scene_fixture();
+ config.generation_jobs[0].steps = Some(steps);
+ config.generation_jobs[0].seed = Some(seed);
+ assert!(validate_and_normalize_config(config).is_ok());
+ }
+
+ for (steps, seed) in [(1, -1), (20, -2), (20, 9_007_199_254_740_992)] {
+ let mut config = scene_fixture();
+ config.generation_jobs[0].steps = Some(steps);
+ config.generation_jobs[0].seed = Some(seed);
+ assert!(validate_and_normalize_config(config).is_err());
+ }
+ }
+
#[test]
fn validator_accepts_every_boundary_the_frontend_schema_allows() {
for aspect_ratio in ["16:9", "9:16", "1:1", "4:5"] {
diff --git a/src-tauri/src/vidfab.rs b/src-tauri/src/vidfab.rs
index 9c02921..205993f 100644
--- a/src-tauri/src/vidfab.rs
+++ b/src-tauri/src/vidfab.rs
@@ -3,6 +3,7 @@
//! All ABI declarations and `unsafe` calls live in `ffi`; the rest of the
//! application only handles owned Rust status, plan, progress, and metadata.
use crate::{rendered, ProviderOption, ProviderSetting};
+use getrandom::fill as fill_random;
use serde::{Deserialize, Serialize};
use std::{
collections::{BTreeMap, HashMap},
@@ -66,7 +67,8 @@ pub struct GenerationRequest {
pub prompt: String,
pub frames: i32,
pub steps: i32,
- pub seed: u64,
+ /// -1 asks the host to draw a fresh seed for this generation.
+ pub seed: i64,
pub aspect_ratio: String,
#[serde(default)]
pub reference_paths: Vec<String>,
@@ -180,6 +182,7 @@ impl VidfabRuntime {
if request.job_id.trim().is_empty() || request.prompt.trim().is_empty() {
return Err("Generation job id and prompt cannot be empty.".into());
}
+ validate_generation_controls(&request)?;
let cancel = Arc::new(AtomicBool::new(false));
let mut flags = self
.cancellations
@@ -332,6 +335,7 @@ pub fn resolve_plan(
request: &GenerationRequest,
settings: &BTreeMap<String, ProviderSetting>,
) -> Result<ResolvedPlan, String> {
+ validate_generation_controls(request)?;
let configuration = Configuration::from_settings(settings);
let api = ffi::Api::load(&configuration.dll_path)?;
api.version()?;
@@ -354,6 +358,27 @@ pub fn resolve_plan(
})
}
+fn validate_generation_controls(request: &GenerationRequest) -> Result<(), String> {
+ if request.steps < 2 {
+ return Err("Generation step count must be at least 2.".into());
+ }
+ if request.seed < -1 {
+ return Err("Generation seed must be -1 or greater.".into());
+ }
+ Ok(())
+}
+
+fn generation_seed(value: i64) -> Result<u64, String> {
+ if value == -1 {
+ let mut bytes = [0_u8; 8];
+ fill_random(&mut bytes)
+ .map_err(|error| format!("Could not create a random generation seed: {error}"))?;
+ Ok(u64::from_ne_bytes(bytes))
+ } else {
+ u64::try_from(value).map_err(|_| "Generation seed must be -1 or greater.".to_string())
+ }
+}
+
fn configure_request(
api: &ffi::Api,
handle: *mut ffi::Request,
@@ -364,7 +389,7 @@ fn configure_request(
api.set_prompt(handle, &request.prompt)?;
api.set_frames(handle, request.frames)?;
api.set_steps(handle, request.steps)?;
- api.set_seed(handle, request.seed)?;
+ api.set_seed(handle, generation_seed(request.seed)?)?;
let (width, height) = match request.aspect_ratio.as_str() {
"9:16" => (9, 16),
"1:1" => (1, 1),
@@ -973,4 +998,11 @@ mod tests {
assert_eq!(stage_name(4), "denoising");
assert_eq!(stage_name(99), "unknown");
}
+ #[test]
+ fn generation_seed_accepts_random_and_non_negative_values() {
+ assert!(generation_seed(-1).is_ok());
+ assert_eq!(generation_seed(0).unwrap(), 0);
+ assert_eq!(generation_seed(482_091).unwrap(), 482_091);
+ assert!(generation_seed(-2).is_err());
+ }
}
diff --git a/src/components/ProjectWorkspace.test.ts b/src/components/ProjectWorkspace.test.ts
index b0d297f..0779a8e 100644
--- a/src/components/ProjectWorkspace.test.ts
+++ b/src/components/ProjectWorkspace.test.ts
@@ -1,10 +1,12 @@
// @vitest-environment jsdom
import { act, cleanup, createEvent, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
+import { listen } from "@tauri-apps/api/event";
import { createElement, useEffect, useState } from "react";
import { afterEach, describe, expect, it, vi } from "vitest";
import completeFixture from "../../fixtures/project-v1-complete.json";
import { compileMiniMaxH3Prompt, createProjectConfig, parseProjectConfig, sceneShots, STORY_TRACK_ID, UNTITLED_SCENE, type ProjectAsset, type ProjectConfig, type ProjectRecord, type TimelineClip } from "../lib/project";
+import { saveGeneratedScene } from "../lib/generatedVideo";
import { formatDurationTimecode } from "./ProjectWorkspace";
import { ProjectWorkspace } from "./ProjectWorkspace";
import { GeneratorView } from "./workspace/GeneratorView";
@@ -14,6 +16,7 @@ import { TimelineView } from "./workspace/TimelineView";
vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));
vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn(async () => () => undefined) }));
+vi.mock("../lib/generatedVideo", () => ({ saveGeneratedScene: vi.fn() }));
afterEach(cleanup);
@@ -174,6 +177,56 @@ describe("project workspace timecode", () => {
expect(alert.textContent).toContain("The original project file is locked.");
});
+ it("persists a completed generation without waiting for the Save button", async () => {
+ const handlers = new Map<string, (event: { payload: unknown }) => void>();
+ const scope = globalThis as unknown as Record<string, unknown>;
+ scope.__TAURI_INTERNALS__ = {};
+ vi.mocked(listen).mockImplementation((async (name: string, handler: (event: { payload: unknown }) => void) => {
+ handlers.set(name, handler);
+ return () => handlers.delete(name);
+ }) as unknown as typeof listen);
+ vi.mocked(saveGeneratedScene).mockResolvedValue({
+ relativePath: "media/generated/job-initial-brief.mp4",
+ bytes: 4_200_000,
+ note: null,
+ });
+ const config = createProjectConfig({ name: "Ceramic lamp", prompt: "A quiet product film", aspectRatio: "16:9", resolution: "1080p", targetDurationSeconds: 30 });
+ const jobId = config.generationJobs[0].id;
+ const onSave = vi.fn(async (_record: ProjectRecord) => undefined);
+ const mediaLoad = HTMLMediaElement.prototype.load;
+ HTMLMediaElement.prototype.load = vi.fn();
+
+ try {
+ render(createElement(ProjectWorkspace, {
+ project: { folderPath: "C:\\Ceramic Lamp", config },
+ initialView: "timeline",
+ onBack: () => undefined,
+ onSave,
+ }));
+ await waitFor(() => expect(handlers.has("vidfab-job")).toBe(true));
+ await act(async () => {
+ handlers.get("vidfab-job")?.({ payload: { jobId, state: "framesReady", detail: "Frames ready." } });
+ await Promise.resolve();
+ });
+ await waitFor(() => expect(onSave).toHaveBeenCalledTimes(1));
+
+ const saved = onSave.mock.calls[0][0];
+ expect(saved.config.generationJobs[0]).toMatchObject({
+ status: "completed",
+ outputRelativePath: "media/generated/job-initial-brief.mp4",
+ });
+ expect(parseProjectConfig(saved.config)).toBeTruthy();
+ await waitFor(() => expect((screen.getByRole("button", { name: "Save" }) as HTMLButtonElement).disabled).toBe(true));
+ } finally {
+ cleanup();
+ HTMLMediaElement.prototype.load = mediaLoad;
+ delete scope.__TAURI_INTERNALS__;
+ vi.mocked(listen).mockReset();
+ vi.mocked(listen).mockImplementation(async () => () => undefined);
+ vi.mocked(saveGeneratedScene).mockReset();
+ }
+ });
+
it("opens the existing unstarted draft instead of duplicating it", async () => {
const config = createProjectConfig({ name: "Ceramic lamp", prompt: "A quiet product film", aspectRatio: "16:9", resolution: "1080p", targetDurationSeconds: 30 });
render(createElement(ProjectWorkspace, {
@@ -846,6 +899,8 @@ describe("project workspace timecode", () => {
];
const config = parseProjectConfig({ ...fresh, references, generationJobs: [{ ...fresh.generationJobs[0], referenceIds: ["ref-lamp", "ref-blank", "ref-score"] }] });
render(createElement(GeneratorView, { config, folderPath: "C:\\Ceramic Lamp", onChange: () => undefined, onOpenTimeline: () => undefined, selectedJobId: config.generationJobs[0].id }));
+ expect(document.querySelector(".debug-prompt .compiled-prompt__text")).toBeNull();
+ fireEvent.click(screen.getByRole("button", { name: "Debug Prompt" }));
const prompt = document.querySelector(".debug-prompt .compiled-prompt__text")!.textContent!;
expect(prompt).toContain("<Subject 1>");
expect(prompt).not.toContain("Lead character");
@@ -899,14 +954,16 @@ describe("project workspace timecode", () => {
expect(screen.queryByText("Lamp photograph")).toBeNull();
});
- it("locks the retained settings while a scene is running", () => {
+ it("keeps scene settings editable while a scene is running", () => {
const fresh = createProjectConfig({ name: "Ceramic lamp", prompt: "A quiet product film", aspectRatio: "16:9", resolution: "1080p", targetDurationSeconds: 30 });
const references = [{ id: "ref-lamp", kind: "text", name: "Lamp silhouette", description: "Matte cream ceramic.", content: "Matte cream ceramic.", intendedUse: ["product"], createdAt: fresh.createdAt }];
const config = parseProjectConfig({ ...fresh, references, generationJobs: [{ ...fresh.generationJobs[0], status: "generating", stage: "generating", progress: 0.4, referenceIds: ["ref-lamp"] }] });
render(createElement(GeneratorView, { config, folderPath: "C:\Ceramic Lamp", onChange: () => undefined, onOpenTimeline: () => undefined, selectedJobId: config.generationJobs[0].id }));
- expect((screen.getByRole("combobox", { name: "The look of this scene" }) as HTMLSelectElement).disabled).toBe(true);
- expect((screen.getByRole("textbox", { name: "The sound of this scene" }) as HTMLTextAreaElement).disabled).toBe(true);
- expect((screen.getByRole("textbox", { name: "The music of this scene" }) as HTMLTextAreaElement).disabled).toBe(true);
+ expect((screen.getByRole("combobox", { name: "The look of this scene" }) as HTMLSelectElement).disabled).toBe(false);
+ expect((screen.getByRole("textbox", { name: "The sound of this scene" }) as HTMLTextAreaElement).disabled).toBe(false);
+ expect((screen.getByRole("textbox", { name: "The music of this scene" }) as HTMLTextAreaElement).disabled).toBe(false);
+ expect((screen.getByRole("spinbutton", { name: "Generation step count" }) as HTMLInputElement).disabled).toBe(false);
+ expect((screen.getByRole("spinbutton", { name: "Generation seed" }) as HTMLInputElement).disabled).toBe(false);
});
it("does not show reference guidance in scene settings", () => {
@@ -1054,6 +1111,13 @@ describe("project workspace timecode", () => {
const openScene = (sceneTitle = "First scene") =>
fireEvent.click(screen.getByRole("button", { name: `Settings for ${sceneTitle}` }));
+ /** Opens the exact prompt preview without accidentally closing it when a
+ * test returns to the scene panel more than once. */
+ const openDebugPrompt = () => {
+ const button = screen.getByRole("button", { name: "Debug Prompt" });
+ if (button.getAttribute("aria-expanded") === "false") fireEvent.click(button);
+ };
+
/** Adds one setting to one shot: choose the setting, then choose its value.
* Settings are added one at a time now, rather than laid out as a wall of
* every term the vocabulary holds. */
@@ -1204,6 +1268,7 @@ describe("project workspace timecode", () => {
}
openScene();
+ openDebugPrompt();
const compiled = document.querySelector(".compiled-prompt__text")!.textContent!;
expect(compiled).toContain("[Shot 1] Live-action, cinematic, A quiet product film.");
expect(compiled).toContain("[Shot 2] (cut at 3s) she stops at the doorway.");
@@ -1255,6 +1320,7 @@ describe("project workspace timecode", () => {
// The compiled prompt shows it immediately, with the term marked as the
// user's choice rather than as their own prose.
openScene();
+ openDebugPrompt();
const prompt = document.querySelector(".compiled-prompt__text")!;
expect(prompt.textContent).toContain("Camera movement: push in, slow speed.");
expect([...document.querySelectorAll(".prompt-part--tag")].map((part) => part.textContent)).toContain("push in, slow speed");
@@ -1299,6 +1365,7 @@ describe("project workspace timecode", () => {
// 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();
+ openDebugPrompt();
expect(document.querySelector(".compiled-prompt__text")!.textContent).toContain("macro lens, A quiet product film");
// Its length remains on the header slider; the old length/shot-count line
// under the scene name is gone.
@@ -1315,18 +1382,19 @@ describe("project workspace timecode", () => {
expect(parseProjectConfig(onChange.mock.calls.at(-1)![0])).toBeTruthy();
});
- it("locks a running scene, because the engine already has the prompt", () => {
+ it("keeps a running scene and its shots editable for the next generation", () => {
const fresh = lampProject();
const config = parseProjectConfig({ ...fresh, generationJobs: [{ ...fresh.generationJobs[0], status: "generating", stage: "generating", progress: 0.4 }] });
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);
+ expect((screen.getByRole("slider", { name: "First scene length in seconds" }) as HTMLInputElement).disabled).toBe(false);
+ expect((screen.getByRole("button", { name: "Add a shot to First scene" }) as HTMLButtonElement).disabled).toBe(false);
openShot(1);
- 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();
+ expect((screen.getByRole("textbox", { name: "Describe shot 1" }) as HTMLTextAreaElement).disabled).toBe(false);
+ expect((screen.getByRole("combobox", { name: "Add a setting to shot 1" }) as HTMLSelectElement).disabled).toBe(false);
+ expect(screen.queryByText(/It can be changed once it finishes/)).toBeNull();
});
- it("drops a reference into a line, cites it as a subject, and swaps it for another", () => {
+ it("drops a reference into a line, cites it as a subject, and changes its smart chip", () => {
const fresh = lampProject();
const createdAt = fresh.createdAt;
const references = [
@@ -1367,6 +1435,7 @@ describe("project workspace timecode", () => {
.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();
+ openDebugPrompt();
const compiled = () => document.querySelector(".compiled-prompt__text")!.textContent!;
expect(compiled()).toContain("<Subject 1> walks towards the camera on <Subject 2>");
expect(compiled()).not.toContain("@[ref:");
@@ -1377,6 +1446,8 @@ describe("project workspace timecode", () => {
// Clicking the first reference in the line offers every other one.
openShot(1);
const token = screen.getByRole("combobox", { name: "Reference 1 · Red-haired woman — choose another reference" });
+ expect(token.closest(".shot-action-editor")).not.toBeNull();
+ expect(screen.queryByText("Every reference in the line can be swapped for another:")).toBeNull();
expect([...token.querySelectorAll("option")].map((option) => option.textContent)).toEqual([
"Reference 1 · Red-haired woman", "Reference 2 · City street", "Take it out of the line",
]);
@@ -1508,6 +1579,7 @@ describe("project workspace timecode", () => {
expect(config.generationJobs[0].shots!.map((item) => item.startSeconds)).toEqual([0, 4.5, 9]);
scene();
+ openDebugPrompt();
const compiled = document.querySelector(".compiled-prompt__text")!.textContent!;
// The panel IS the string that is sent — the parts concatenate to it.
expect([...document.querySelectorAll(".compiled-prompt__text .prompt-part")].map((part) => part.textContent).join("")).toBe(compiled);
@@ -1556,7 +1628,7 @@ describe("project workspace timecode", () => {
// And the swap: the same sentence, pointed at the other reference.
shot(1);
- const token = document.querySelector(".shot-readback__token") as HTMLSelectElement;
+ const token = document.querySelector(".reference-smart-chip") as HTMLSelectElement;
expect([...token.options].map((option) => option.textContent))
.toEqual(["Reference 1 · Red-haired woman", "Reference 2 · City street", "Take it out of the line"]);
fireEvent.change(token, { target: { value: "ref-street" } });
diff --git a/src/components/workspace/GeneratorView.test.tsx b/src/components/workspace/GeneratorView.test.tsx
index 7a60f50..09b64a4 100644
--- a/src/components/workspace/GeneratorView.test.tsx
+++ b/src/components/workspace/GeneratorView.test.tsx
@@ -3,11 +3,17 @@
import "@testing-library/jest-dom/vitest";
import { act, cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import { useState } from "react";
-import { afterEach, describe, expect, it } from "vitest";
+import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { createDraftGenerationJob, createProjectConfig, parseProjectConfig, sceneShots, type ProjectConfig } from "../../lib/project";
-import type { VidfabStatus } from "../../lib/runtime";
+import { cancelVidfabGeneration, type VidfabStatus } from "../../lib/runtime";
import { GeneratorView } from "./GeneratorView";
+vi.mock("../../lib/runtime", async (importOriginal) => ({
+ ...await importOriginal<typeof import("../../lib/runtime")>(),
+ cancelVidfabGeneration: vi.fn().mockResolvedValue(true),
+}));
+
+beforeEach(() => vi.clearAllMocks());
afterEach(cleanup);
const readyRuntime: VidfabStatus = {
@@ -95,6 +101,43 @@ async function finishFirst(state: ReturnType<typeof setup>) {
}
describe("Generator scene controls", () => {
+ it("shows scene generation controls and sends their values in the render snapshot", async () => {
+ const state = setup();
+ const generation = screen.getByRole("region", { name: "Generation" });
+ expect(within(generation).getByRole("spinbutton", { name: "Generation step count" })).toHaveValue(20);
+ expect(within(generation).getByRole("spinbutton", { name: "Generation seed" })).toHaveValue(-1);
+
+ fireEvent.change(within(generation).getByRole("spinbutton", { name: "Generation step count" }), { target: { value: "28" } });
+ fireEvent.change(within(generation).getByRole("spinbutton", { name: "Generation seed" }), { target: { value: "9173" } });
+ expect(state.latest().generationJobs[0]).toEqual(expect.objectContaining({ steps: 28, seed: 9173 }));
+
+ 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!)).toEqual(expect.objectContaining({ steps: 28, seed: 9173 }));
+ });
+
+ it("edits shot speech and sends it with the selected language in dialogue tags", async () => {
+ const state = setup();
+ fireEvent.click(screen.getByRole("button", { name: "Shot 1 of First scene" }));
+
+ const speech = screen.getByRole("textbox", { name: "Speech for shot 1" });
+ const language = screen.getByRole("combobox", { name: "Speech language for shot 1" });
+ expect(speech).toHaveValue("");
+ expect(language).toHaveValue("English");
+
+ fireEvent.change(language, { target: { value: "Korean" } });
+ fireEvent.change(speech, { target: { value: "문을 열어 주세요." } });
+ expect(sceneShots(state.latest().generationJobs[0])[0]).toEqual(expect.objectContaining({
+ speech: "문을 열어 주세요.",
+ speechLanguage: "Korean",
+ }));
+
+ 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)));
+ const snapshot = JSON.parse(state.latest().generationJobs[0].generationSnapshot!);
+ expect(snapshot.prompt).toContain("<d>[Korean] 문을 열어 주세요.</d>");
+ });
+
it("reorders shots inside a scene while keeping its cut slots", () => {
const state = setup();
const shotTransfer = transfer();
@@ -160,6 +203,41 @@ describe("Generator scene controls", () => {
expect(scene.querySelector(".scene-rule__status--changed")).not.toBeNull();
});
+ it("keeps scene and shot settings editable during generation and marks the finished scene changed", async () => {
+ const state = setup();
+ const scene = screen.getByRole("region", { name: "First scene" });
+ fireEvent.click(within(scene).getByRole("button", { name: "Generate" }));
+ await waitFor(() => expect(state.latest().generationJobs[0].status).toBe("queued"));
+ const sent = state.latest().generationJobs[0].generationSnapshot;
+ state.replace({
+ ...state.latest(),
+ generationJobs: state.latest().generationJobs.map((job, index) => index === 0
+ ? { ...job, status: "generating", stage: "generating", progress: 0.4 }
+ : job),
+ });
+
+ const sound = screen.getByRole("textbox", { name: "The sound of this scene" });
+ expect(sound).toBeEnabled();
+ fireEvent.change(sound, { target: { value: "Rain added while this run is rendering." } });
+
+ fireEvent.click(screen.getByRole("button", { name: "Shot 1 of First scene" }));
+ const addSetting = screen.getByRole("combobox", { name: "Add a setting to shot 1" });
+ expect(addSetting).toBeEnabled();
+ fireEvent.change(addSetting, { target: { value: "shotSize" } });
+ fireEvent.change(screen.getByRole("combobox", { name: "Value for Shot size on shot 1" }), { target: { value: "close-up" } });
+ expect(state.latest().generationJobs[0].generationSnapshot).toBe(sent);
+
+ state.replace({
+ ...state.latest(),
+ generationJobs: state.latest().generationJobs.map((job, index) => index === 0
+ ? { ...job, status: "completed", stage: "completed", progress: 1 }
+ : job),
+ });
+ const finished = screen.getByRole("region", { name: "First scene" });
+ expect(within(finished).getByText("CHANGED")).toBeInTheDocument();
+ expect(finished.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);
@@ -213,4 +291,40 @@ describe("Generator scene controls", () => {
expect(state.latest().generationJobs.every((job) => Boolean(job.generationSnapshot))).toBe(true);
expect(parseProjectConfig(state.latest())).toBeTruthy();
});
+
+ it("turns active generation actions into per-scene and batch cancellation", async () => {
+ const initial = project();
+ initial.generationJobs = initial.generationJobs.map((job, index) => ({
+ ...job,
+ status: index === 0 ? "generating" : "queued",
+ stage: index === 0 ? "generating" : "queued",
+ progress: index === 0 ? 0.42 : 0,
+ }));
+ setup(initial);
+
+ const first = screen.getByRole("region", { name: "First scene" });
+ const second = screen.getByRole("region", { name: "Second scene" });
+ expect(within(first).getByRole("button", { name: "Cancel" })).toBeEnabled();
+ expect(within(second).getByRole("button", { name: "Cancel" })).toBeEnabled();
+ expect(screen.getByRole("button", { name: "Cancel All" })).toBeEnabled();
+ expect(within(first).getAllByText("Rendering 42%")).toHaveLength(2);
+ const progressBars = first.querySelectorAll(".shot-thumb__progress > i");
+ expect(progressBars).toHaveLength(2);
+ expect([...progressBars].every((bar) => (bar as HTMLElement).style.width === "42%")).toBe(true);
+ expect(within(first).queryByText("RENDERING")).not.toBeInTheDocument();
+
+ fireEvent.click(within(first).getByRole("button", { name: "Cancel" }));
+ await waitFor(() => expect(cancelVidfabGeneration).toHaveBeenCalledWith("scene-first"));
+ const cancelling = within(first).getAllByRole("img", { name: /Cancelling\.\.\.$/ });
+ expect(cancelling).toHaveLength(2);
+ expect(cancelling.every((thumbnail) => thumbnail.querySelector(".spin"))).toBe(true);
+ expect(within(first).queryByText("Rendering 42%")).not.toBeInTheDocument();
+
+ vi.mocked(cancelVidfabGeneration).mockClear();
+ fireEvent.click(screen.getByRole("button", { name: "Cancel All" }));
+ await waitFor(() => {
+ expect(cancelVidfabGeneration).toHaveBeenCalledTimes(1);
+ expect(cancelVidfabGeneration).toHaveBeenCalledWith("scene-second");
+ });
+ });
});
diff --git a/src/components/workspace/GeneratorView.tsx b/src/components/workspace/GeneratorView.tsx
index 07aa865..b31bce9 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 { Plus, Sparkles, Square, WandSparkles } from "lucide-react";
import { useEffect, useMemo, useRef, useState } from "react";
-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 { actionReferenceIds, compileGenerationJobPrompt, compileGenerationJobSegments, createDraftGenerationJob, danglingReferenceTokens, sceneDurationSeconds, sceneGenerationSeed, sceneGenerationSnapshot, sceneGenerationSteps, 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";
@@ -34,6 +34,14 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
const jobs = config.generationJobs;
const configRef = useRef(config);
configRef.current = config;
+ // A scene is displayed as queued while its plan is resolving, just before
+ // the backend receives it. Remember cancellation here as well as sending it
+ // to vidfab, so a click in that small window prevents the later enqueue.
+ const cancellationRequests = useRef(new Set<string>());
+ // The ref above protects asynchronous work; this set exists so the cards
+ // repaint immediately when Cancel is pressed, before vidfab reports the
+ // terminal cancelled state.
+ const [cancellingJobIds, setCancellingJobIds] = useState<ReadonlySet<string>>(() => new Set());
/* A scene is always what is named; the shot inside it is what a card opens.
Opening the Generator, or arriving from a clip in the timeline, opens the
@@ -41,6 +49,7 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
const [selection, setSelection] = useState<GeneratorSelection>(() => ({ jobId: selectedJobId ?? jobs.find((job) => job.status === "generating")?.id ?? jobs[0]?.id ?? "", shotId: null }));
const [, setPlanNotes] = useState<Record<string, string>>({});
const [removalTarget, setRemovalTarget] = useState<RemovalTarget | null>(null);
+ const [showDebugPrompt, setShowDebugPrompt] = useState(false);
useEffect(() => { if (selectedJobId) setSelection({ jobId: selectedJobId, shotId: null }); }, [selectedJobId]);
@@ -53,10 +62,7 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
const active = jobs.filter((job) => job.status === "generating" || job.status === "ready");
const queued = jobs.filter((job) => job.status === "queued");
- // Queued and generating scenes have already been handed to the engine with
- // their references attached; re-binding now would change nothing about that
- // run while claiming otherwise.
- const refsLocked = selected?.status === "generating" || selected?.status === "queued";
+ const cancellable = jobs.filter((job) => job.status === "queued" || job.status === "generating");
const boundRefs = useMemo(() => config.references.filter((ref) => selected?.referenceIds.includes(ref.id)), [config.references, selected]);
const runtimeReady = runtime?.state === "ready";
@@ -145,8 +151,6 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
const source = current.generationJobs.find((job) => job.id === sourceJobId);
const target = current.generationJobs.find((job) => job.id === targetJobId);
if (!source || !target) return;
- if ([source.status, target.status].some((status) => status === "queued" || status === "generating")) return;
-
const sourceShots = sceneShots(source);
const moving = sourceShots.find((shot) => shot.id === shotId);
if (!moving) return;
@@ -203,8 +207,8 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
prompt: compileGenerationJobPrompt(job, bound),
// The scene's own length, not a fixed six seconds.
frames: Math.round(sceneDurationSeconds(job) * config.settings.frameRate),
- steps: 50,
- seed: 482091,
+ steps: sceneGenerationSteps(job),
+ seed: sceneGenerationSeed(job),
aspectRatio: config.settings.aspectRatio,
referencePaths: usableImageReferences(bound)
.map((reference) => projectItemPath(folderPath, reference) ?? "")
@@ -222,6 +226,10 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
show what became of it. */
const prepareOrRetry = async (job: GenerationJob) => {
+ cancellationRequests.current.delete(job.id);
+ setCancellingJobIds((current) => current.has(job.id)
+ ? new Set([...current].filter((id) => id !== job.id))
+ : current);
const now = new Date().toISOString();
const request = requestFor(job);
updateJob(job.id, {
@@ -267,6 +275,10 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
const startDraft = async (job: GenerationJob) => {
if (!runtimeReady) return;
+ cancellationRequests.current.delete(job.id);
+ setCancellingJobIds((current) => current.has(job.id)
+ ? new Set([...current].filter((id) => id !== job.id))
+ : current);
const request = requestFor(job);
updateJob(job.id, {
status: "queued",
@@ -283,13 +295,48 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
here or nobody ever sees it. */
const plan = await resolveVidfabPlan(request, configRef.current);
setPlanNotes((current) => ({ ...current, [job.id]: `Planned as ${plan.alignedFrames} frames at ${plan.canvasWidth}×${plan.canvasHeight}. ${plan.boundary}` }));
+ if (cancellationRequests.current.has(job.id)) return;
await enqueueVidfabGeneration(request, configRef.current);
} catch (reason) {
+ if (cancellationRequests.current.has(job.id)) return;
updateJob(job.id, { status: "failed", stage: "failed", error: reason instanceof Error ? reason.message : String(reason) });
}
};
+ const cancelScenes = async (scenes: GenerationJob[]) => {
+ const next = scenes.filter((job) =>
+ (job.status === "queued" || job.status === "generating")
+ && !cancellationRequests.current.has(job.id));
+ if (next.length === 0) return;
+ next.forEach((job) => cancellationRequests.current.add(job.id));
+ setCancellingJobIds((current) => new Set([...current, ...next.map((job) => job.id)]));
+ const accepted = await Promise.all(next.map(async (job) => {
+ try {
+ return await cancelVidfabGeneration(job.id);
+ } catch {
+ return false;
+ }
+ }));
+ // False means the scene was still in frontend planning and never reached
+ // vidfab. No backend event will arrive for it, so finish that cancellation
+ // locally; accepted cancellations are finalized by the normal event path.
+ const beforeEnqueue = new Set(next.filter((_, index) => !accepted[index]).map((job) => job.id));
+ if (beforeEnqueue.size > 0) {
+ const current = configRef.current;
+ onChange({
+ ...current,
+ generationJobs: current.generationJobs.map((job) => beforeEnqueue.has(job.id)
+ ? { ...job, status: "cancelled", stage: "failed", error: "Generation cancelled before it started.", updatedAt: new Date().toISOString() }
+ : job),
+ });
+ }
+ };
+
const generateScene = (job: GenerationJob) => {
+ if (job.status === "queued" || job.status === "generating") {
+ void cancelScenes([job]);
+ return;
+ }
if (job.status === "draft") void startDraft(job);
else void prepareOrRetry(job);
};
@@ -298,6 +345,12 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
const generateAll = async () => {
if (!runtimeReady || draftScenesReady.length === 0) return;
+ draftScenesReady.forEach((job) => cancellationRequests.current.delete(job.id));
+ const startingIds = new Set(draftScenesReady.map((job) => job.id));
+ setCancellingJobIds((current) => {
+ const next = new Set([...current].filter((id) => !startingIds.has(id)));
+ return next.size === current.size ? current : next;
+ });
const current = configRef.current;
const requests = draftScenesReady.map((job) => ({ job, request: requestFor(job) }));
const ids = new Map(requests.map(({ job, request }) => [job.id, snapshotFor(job, request)]));
@@ -310,11 +363,14 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
});
for (const { job, request } of requests) {
+ if (cancellationRequests.current.has(job.id)) continue;
try {
const plan = await resolveVidfabPlan(request, current);
setPlanNotes((notes) => ({ ...notes, [job.id]: `Planned as ${plan.alignedFrames} frames at ${plan.canvasWidth}×${plan.canvasHeight}. ${plan.boundary}` }));
+ if (cancellationRequests.current.has(job.id)) continue;
await enqueueVidfabGeneration(request, current);
} catch (reason) {
+ if (cancellationRequests.current.has(job.id)) continue;
updateJob(job.id, { status: "failed", stage: "failed", error: reason instanceof Error ? reason.message : String(reason) });
}
}
@@ -322,8 +378,6 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
const generationBlocker = (job: GenerationJob): string | null => {
if (!runtimeReady) return runtime?.detail ?? "The video generator is not ready.";
- if (job.status === "queued") return "This scene is already waiting in the queue.";
- if (job.status === "generating") return "This scene is generating now.";
if (job.status === "ready") return "This scene is being saved now.";
return sendBlocker(job, config.references);
};
@@ -354,16 +408,20 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
<Plus size={16} aria-hidden="true" /> Add Scene
</button>
<button
- className="primary-button"
- disabled={!runtimeReady || draftScenesReady.length === 0}
- title={!runtimeReady
- ? runtime?.detail ?? "The video generator is not ready."
- : draftScenesReady.length === 0
- ? "There are no ready draft scenes to generate."
- : `Generate ${draftScenesReady.length} draft ${draftScenesReady.length === 1 ? "scene" : "scenes"}`}
- onClick={() => void generateAll()}
+ className={cancellable.length > 0 ? "danger-button generator-heading__cancel" : "primary-button"}
+ disabled={cancellable.length === 0 && (!runtimeReady || draftScenesReady.length === 0)}
+ title={cancellable.length > 0
+ ? `Cancel ${cancellable.length} ${cancellable.length === 1 ? "generation" : "generations"}`
+ : !runtimeReady
+ ? runtime?.detail ?? "The video generator is not ready."
+ : draftScenesReady.length === 0
+ ? "There are no ready draft scenes to generate."
+ : `Generate ${draftScenesReady.length} draft ${draftScenesReady.length === 1 ? "scene" : "scenes"}`}
+ onClick={() => cancellable.length > 0 ? void cancelScenes(cancellable) : void generateAll()}
>
- <WandSparkles size={16} aria-hidden="true" /> Generate All
+ {cancellable.length > 0
+ ? <><Square size={15} aria-hidden="true" /> Cancel All</>
+ : <><WandSparkles size={16} aria-hidden="true" /> Generate All</>}
</button>
</div>
</header>
@@ -380,6 +438,7 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
onGenerate={generateScene}
generationBlocker={generationBlocker}
changedJobIds={changedJobIds}
+ cancellingJobIds={cancellingJobIds}
onMoveScene={moveScene}
onMoveShot={moveShot}
/>}
@@ -417,7 +476,6 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
placeholder={`Shot ${shotIndex + 1}`}
aria-label={`Rename shot ${shotIndex + 1}`}
title="Rename this shot"
- disabled={refsLocked}
onChange={(event) => patchShot(selected, openShot.id, { name: event.target.value || null })}
/></h2>
</header>
@@ -431,12 +489,11 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
endsAt={shotIndex + 1 < selectedShots.length ? selectedShots[shotIndex + 1].startSeconds : sceneDurationSeconds(selected)}
duration={sceneDurationSeconds(selected)}
references={config.references}
- disabled={refsLocked}
+ disabled={false}
removable={selectedShots.length > 1}
onChange={(updates) => patchShot(selected, openShot.id, updates)}
onRemove={() => setRemovalTarget({ kind: "shot", job: selected, shotId: openShot.id, shotName: openShot.name ?? `Shot ${shotIndex + 1}` })}
/>
- {refsLocked && <p className="job-refs__empty">This scene is already with the engine. It can be changed once it finishes, and the next run will use the changes.</p>}
</div>
</>
: <>
@@ -467,15 +524,20 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
key={selected.id}
job={selected}
shots={selectedShots}
- disabled={refsLocked}
+ disabled={false}
onChange={(updates) => updateScene(selected, updates)}
onShots={(next) => setShots(selected, next)}
/>
+ </div>
- {import.meta.env.DEV && <details className="debug-prompt">
- <summary>Debug: final prompt</summary>
- <CompiledPrompt segments={compileGenerationJobSegments(selected, boundRefs)} />
- </details>}
+ <div className="debug-prompt">
+ {showDebugPrompt && <CompiledPrompt segments={compileGenerationJobSegments(selected, boundRefs)} />}
+ <button
+ type="button"
+ className="secondary-button debug-prompt__toggle"
+ aria-expanded={showDebugPrompt}
+ onClick={() => setShowDebugPrompt((visible) => !visible)}
+ >Debug Prompt</button>
</div>
</>}
</aside>}
@@ -505,8 +567,8 @@ export function GeneratorView({ config, folderPath, runtime = null, onChange, se
* the prompt cannot cite would be silently dropped from the middle of a line. */
function sendBlocker(job: GenerationJob, references: ProjectReference[]): string | null {
const shots = sceneShots(job);
- if (shots.every((shot) => shot.action.trim().length === 0)) {
- return "Write what happens in at least one shot before this scene can be generated.";
+ if (shots.every((shot) => shot.action.trim().length === 0 && !(shot.speech ?? "").trim())) {
+ return "Describe what happens or add speech in at least one shot before this scene can be generated.";
}
if (sceneDurationSeconds(job) <= 0) {
return "This scene is nought seconds long, so there are no frames to render. Give it a length first.";
diff --git a/src/components/workspace/SceneBoard.tsx b/src/components/workspace/SceneBoard.tsx
index 90324cb..bb2eaf2 100644
--- a/src/components/workspace/SceneBoard.tsx
+++ b/src/components/workspace/SceneBoard.tsx
@@ -1,4 +1,4 @@
-import { GripVertical, Plus, SlidersHorizontal, Trash2, WandSparkles } from "lucide-react";
+import { GripVertical, Plus, SlidersHorizontal, Square, Trash2, WandSparkles } from "lucide-react";
import {
SCENE_MAX_SECONDS,
SCENE_MIN_SECONDS,
@@ -55,6 +55,7 @@ export function SceneBoard({
onGenerate,
generationBlocker,
changedJobIds,
+ cancellingJobIds,
onMoveScene,
onMoveShot,
}: {
@@ -69,6 +70,7 @@ export function SceneBoard({
onGenerate: (job: GenerationJob) => void;
generationBlocker: (job: GenerationJob) => string | null;
changedJobIds: ReadonlySet<string>;
+ cancellingJobIds: ReadonlySet<string>;
onMoveScene: (jobId: string, beforeJobId: string | null) => void;
onMoveShot: (sourceJobId: string, shotId: string, targetJobId: string, beforeShotId: string | null) => void;
}) {
@@ -79,7 +81,7 @@ export function SceneBoard({
const order = referenceOrder(job, shots, references);
const named = new Map(references.map((reference) => [reference.id, reference.name]));
const sceneOpen = selection.jobId === job.id && selection.shotId === null;
- const locked = job.status === "queued" || job.status === "generating";
+ const cancellable = job.status === "queued" || job.status === "generating";
const blocker = generationBlocker(job);
const indicator = changedJobIds.has(job.id) ? "changed" : job.status;
@@ -131,7 +133,7 @@ export function SceneBoard({
<span className="scene-rule__text">
<b>{job.title}</b>
</span>
- {job.status !== "draft" && <span className="scene-rule__badge">{STATUS_BADGE[indicator]}</span>}
+ {job.status !== "draft" && indicator !== "generating" && <span className="scene-rule__badge">{STATUS_BADGE[indicator]}</span>}
</div>
<label className="scene-rule__length">
@@ -142,7 +144,6 @@ export function SceneBoard({
max={SCENE_MAX_SECONDS}
step={STEP_SECONDS}
value={duration}
- disabled={locked}
aria-label={`${job.title} length in seconds`}
onChange={(event) => onDuration(job, Number(event.target.value))}
/>
@@ -167,11 +168,13 @@ export function SceneBoard({
<button
type="button"
- className="primary-button scene-rule__generate"
- disabled={Boolean(blocker)}
- title={blocker ?? `Generate ${job.title}`}
+ className={`${cancellable ? "danger-button" : "primary-button"} scene-rule__generate`}
+ disabled={!cancellable && Boolean(blocker)}
+ title={cancellable ? `Cancel ${job.title}` : blocker ?? `Generate ${job.title}`}
onClick={() => onGenerate(job)}
- ><WandSparkles size={15} aria-hidden="true" /> Generate</button>
+ >{cancellable
+ ? <><Square size={14} aria-hidden="true" /> Cancel</>
+ : <><WandSparkles size={15} aria-hidden="true" /> Generate</>}</button>
</header>
<ol className="shot-grid">
@@ -199,8 +202,9 @@ export function SceneBoard({
folderPath={folderPath}
order={order}
named={named}
+ cancelling={cancellingJobIds.has(job.id) && cancellable}
open={selection.jobId === job.id && selection.shotId === shot.id}
- draggable={!locked}
+ draggable
onOpen={() => onSelect({ jobId: job.id, shotId: shot.id })}
onDragStart={(event) => {
event.dataTransfer.setData(SHOT_DRAG_TYPE, JSON.stringify({ jobId: job.id, shotId: shot.id }));
@@ -227,7 +231,6 @@ export function SceneBoard({
type="button"
className="shot-card shot-card--add"
aria-label={`Add a shot to ${job.title}`}
- disabled={locked}
onClick={() => onAddShot(job)}
>
<Plus size={18} aria-hidden="true" />
@@ -240,7 +243,7 @@ export function SceneBoard({
</div>;
}
-function ShotCard({ job, shot, index, endsAt, folderPath, order, named, open, draggable, onOpen, onDragStart }: {
+function ShotCard({ job, shot, index, endsAt, folderPath, order, named, cancelling, open, draggable, onOpen, onDragStart }: {
job: GenerationJob;
shot: SceneShot;
index: number;
@@ -248,26 +251,31 @@ function ShotCard({ job, shot, index, endsAt, folderPath, order, named, open, dr
folderPath: string;
order: string[];
named: Map<string, string>;
+ cancelling: boolean;
open: boolean;
draggable: boolean;
onOpen: () => void;
- onDragStart: (event: React.DragEvent<HTMLButtonElement>) => void;
+ onDragStart: (event: React.DragEvent<HTMLDivElement>) => void;
}) {
const parts = splitActionText(shot.action);
const written = shot.action.trim().length > 0;
const chosen = selectedShotTagOptions(shot.settings ?? {});
- return <button
- type="button"
+ return <div
className={`shot-card ${open ? "shot-card--open" : ""}`}
- aria-pressed={open}
aria-label={`${shot.name ?? `Shot ${index + 1}`} of ${job.title}`}
title={draggable ? "Drag to reorder this shot or move it to another scene" : "This shot cannot be moved while its scene is rendering"}
draggable={draggable}
onDragStart={onDragStart}
- onClick={onOpen}
>
- <ShotThumbnail folderPath={folderPath} job={job} seconds={shot.startSeconds} shotNumber={index + 1} />
+ <ShotThumbnail folderPath={folderPath} job={job} seconds={shot.startSeconds} endSeconds={endsAt} shotNumber={index + 1} cancelling={cancelling} />
+ <button
+ type="button"
+ className="shot-card__open-control"
+ aria-pressed={open}
+ aria-label={`${shot.name ?? `Shot ${index + 1}`} of ${job.title}`}
+ onClick={onOpen}
+ >
<span className="shot-card__head">
<b>{shot.name ?? `Shot ${index + 1}`}</b>
<em>{seconds(shot.startSeconds)} – {seconds(endsAt)}</em>
@@ -283,5 +291,6 @@ function ShotCard({ job, shot, index, endsAt, folderPath, order, named, open, dr
{chosen.map(({ group, option }) => <em key={`${group.id}-${option.id}`} className="shot-card__tag">{option.label}</em>)}
{chosen.length === 0 && <em className="shot-card__tag shot-card__tag--none">No settings</em>}
</span>
- </button>;
+ </button>
+ </div>;
}
diff --git a/src/components/workspace/SceneEditor.tsx b/src/components/workspace/SceneEditor.tsx
index ff91932..99d4cb9 100644
--- a/src/components/workspace/SceneEditor.tsx
+++ b/src/components/workspace/SceneEditor.tsx
@@ -9,8 +9,13 @@ import {
referenceToken,
sceneBriefText,
sceneDurationSeconds,
+ sceneGenerationSeed,
+ sceneGenerationSteps,
splitActionText,
+ DEFAULT_SPEECH_LANGUAGE,
+ MAX_GENERATION_STEPS,
SCENE_MIN_SECONDS,
+ SPEECH_LANGUAGES,
type GenerationJob,
type ProjectReference,
type SceneShot,
@@ -98,8 +103,9 @@ export function ShotInspector({ job, shots, shot, index, endsAt, duration, refer
/** Every reference in the project. Any of them can be dropped into a line;
* doing so binds it to the scene, which is what gives it a number. */
references: ProjectReference[];
- /** True once the scene is with the engine: it already has the prompt, so an
- * edit now would change nothing about that run while claiming otherwise. */
+ /** Optional read-only presentation. Generation deliberately does not set
+ * this: the current run keeps its captured snapshot while edits prepare the
+ * next one. */
disabled: boolean;
removable: boolean;
onChange: (updates: Partial<SceneShot>) => void;
@@ -176,35 +182,69 @@ export function ShotInspector({ job, shots, shot, index, endsAt, duration, refer
><Trash2 size={15} /> Remove</button>}
</div>
- <label className="shot-card__action">
- <span className="shot-card__sublabel">Describe the shot</span>
+ <div className="shot-card__action">
+ <label className="shot-card__sublabel" htmlFor={`shot-action-${shot.id}`}>Describe the shot</label>
+ <div className="shot-action-editor">
+ <textarea
+ id={`shot-action-${shot.id}`}
+ ref={fieldRef}
+ value={display}
+ disabled={disabled}
+ 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(); }}
+ onDrop={(event) => {
+ const referenceId = event.dataTransfer.getData(REFERENCE_DRAG_TYPE);
+ if (!referenceId) return;
+ event.preventDefault();
+ insertAtCaret(referenceId);
+ }}
+ />
+ <ReferenceSmartChips
+ action={shot.action}
+ tokenOrder={tokenOrder}
+ referenceById={referenceById}
+ citable={citable}
+ numbered={numbered}
+ disabled={disabled}
+ onChange={(partIndex, to) => {
+ const action = splitActionText(shot.action).map((part, currentIndex) => {
+ if (part.kind === "text") return part.value;
+ if (currentIndex === partIndex) return to ? referenceToken(to) : "";
+ return referenceToken(part.value);
+ }).join("");
+ onChange({ action });
+ }}
+ />
+ </div>
+ </div>
+
+ <div className="shot-speech">
+ <div className="shot-speech__heading">
+ <label className="shot-card__sublabel" htmlFor={`shot-speech-${shot.id}`}>Speech</label>
+ <label className="shot-speech__language">
+ <span>Language</span>
+ <select
+ value={shot.speechLanguage ?? DEFAULT_SPEECH_LANGUAGE}
+ disabled={disabled}
+ aria-label={`Speech language for shot ${shotNumber}`}
+ onChange={(event) => onChange({ speechLanguage: event.target.value as SceneShot["speechLanguage"] })}
+ >
+ {SPEECH_LANGUAGES.map((language) => <option key={language} value={language}>{language}</option>)}
+ </select>
+ </label>
+ </div>
<textarea
- ref={fieldRef}
- value={display}
+ id={`shot-speech-${shot.id}`}
+ value={shot.speech ?? ""}
disabled={disabled}
- 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(); }}
- onDrop={(event) => {
- const referenceId = event.dataTransfer.getData(REFERENCE_DRAG_TYPE);
- if (!referenceId) return;
- event.preventDefault();
- insertAtCaret(referenceId);
- }}
+ aria-label={`Speech for shot ${shotNumber}`}
+ placeholder="Enter the words spoken in this shot."
+ onChange={(event) => onChange({ speech: event.target.value || null })}
/>
- </label>
-
- <ActionReadback
- action={shot.action}
- tokenOrder={tokenOrder}
- referenceById={referenceById}
- citable={citable}
- numbered={numbered}
- disabled={disabled}
- onRepoint={(from, to) => onChange({ action: shot.action.split(referenceToken(from)).join(referenceToken(to)) })}
- onDrop={(from) => onChange({ action: shot.action.split(referenceToken(from)).join("") })}
- />
+ <p className="shot-speech__hint">Added to the final prompt as MiniMax dialogue.</p>
+ </div>
<ReferencePalette
citable={citable}
@@ -226,9 +266,9 @@ export function ShotInspector({ job, shots, shot, index, endsAt, duration, refer
/* --- The scene, opened from its own line ---------------------------------- */
-/** What remains in scene settings: the look the description opens with (base
- * guide §4.1), and the two sound fields the guide defines per prompt (§4.6,
- * §4.7). Length lives in the scene header where it stays visible. */
+/** 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, disabled, onChange, onShots }: {
job: GenerationJob;
shots: SceneShot[];
@@ -242,8 +282,8 @@ export function SceneInspector({ job, shots, disabled, onChange, onShots }: {
const chosen = shots.map((shot) => shot.settings?.[look.id]?.[0]).find(Boolean) ?? "";
return <section className="scene-inspector" aria-label="This scene">
- <div className="scene-settings">
- <h3>Scene</h3>
+ <section className="scene-settings" aria-labelledby={`${job.id}-scene-settings`}>
+ <h3 id={`${job.id}-scene-settings`}>Scene</h3>
<label className="scene-settings__field">
<span>Look</span>
<select
@@ -284,23 +324,59 @@ export function SceneInspector({ job, shots, disabled, onChange, onShots }: {
onChange={(event) => onChange({ music: event.target.value })}
/>
</label>
- </div>
+ </section>
+ <section className="scene-settings" aria-labelledby={`${job.id}-generation-settings`}>
+ <h3 id={`${job.id}-generation-settings`}>Generation</h3>
+ <div className="scene-settings__numbers">
+ <label className="scene-settings__field">
+ <span>Steps</span>
+ <input
+ type="number"
+ min={2}
+ max={MAX_GENERATION_STEPS}
+ step={1}
+ value={sceneGenerationSteps(job)}
+ disabled={disabled}
+ aria-label="Generation step count"
+ onChange={(event) => {
+ const value = event.currentTarget.valueAsNumber;
+ if (Number.isInteger(value) && value >= 2 && value <= MAX_GENERATION_STEPS) onChange({ steps: value });
+ }}
+ />
+ </label>
+ <label className="scene-settings__field">
+ <span>Seed</span>
+ <input
+ type="number"
+ min={-1}
+ max={Number.MAX_SAFE_INTEGER}
+ step={1}
+ value={sceneGenerationSeed(job)}
+ disabled={disabled}
+ aria-label="Generation seed"
+ onChange={(event) => {
+ const value = event.currentTarget.valueAsNumber;
+ if (Number.isSafeInteger(value) && value >= -1) onChange({ seed: value });
+ }}
+ />
+ <small>Use -1 for a random seed.</small>
+ </label>
+ </div>
+ </section>
</section>;
}
-/** The same line, read back with each reference as a control. This is where
- * "click Reference 1 and choose another one" lives: the select IS the token,
- * so re-pointing it changes which reference the sentence names without
- * touching a single character the user typed around it. */
-function ActionReadback({ action, tokenOrder, referenceById, citable, numbered, disabled, onRepoint, onDrop }: {
+/** Selectable smart chips live inside the description editor. Each one owns a
+ * single token occurrence, so changing it leaves identical citations later
+ * in the same sentence alone. */
+function ReferenceSmartChips({ action, tokenOrder, referenceById, citable, numbered, disabled, onChange }: {
action: string;
tokenOrder: string[];
referenceById: Map<string, ProjectReference>;
citable: ProjectReference[];
numbered: ProjectReference[];
disabled: boolean;
- onRepoint: (from: string, to: string) => void;
- onDrop: (from: string) => void;
+ onChange: (partIndex: number, to: string | null) => void;
}) {
const parts = splitActionText(action);
if (!parts.some((part) => part.kind === "reference")) return null;
@@ -309,19 +385,16 @@ function ActionReadback({ action, tokenOrder, referenceById, citable, numbered,
const name = referenceById.get(id)?.name;
return `Reference ${number > 0 ? number : "?"}${name ? ` · ${name}` : ""}`;
};
- return <p className="shot-readback">
- <span className="shot-readback__lead">Every reference in the line can be swapped for another:</span>
- {parts.map((part, index) => part.kind === "text"
- ? <span key={index} className="shot-readback__text">{part.value}</span>
- : <select
+ return <div className="shot-action-editor__chips">
+ {parts.map((part, index) => part.kind === "reference" && <select
key={index}
- className={`shot-readback__token ${citable.some((reference) => reference.id === part.value) ? "" : "shot-readback__token--broken"}`}
+ className={`reference-smart-chip ${citable.some((reference) => reference.id === part.value) ? "" : "reference-smart-chip--broken"}`}
value={part.value}
disabled={disabled}
aria-label={`${label(part.value)} — choose another reference`}
onChange={(event) => {
- if (event.target.value === "") onDrop(part.value);
- else if (event.target.value !== part.value) onRepoint(part.value, event.target.value);
+ if (event.target.value === "") onChange(index, null);
+ else if (event.target.value !== part.value) onChange(index, event.target.value);
}}
>
{/* A reference that can no longer be cited still has to be selectable,
@@ -335,7 +408,7 @@ function ActionReadback({ action, tokenOrder, referenceById, citable, numbered,
})}
<option value="">Take it out of the line</option>
</select>)}
- </p>;
+ </div>;
}
/* --- Settings ------------------------------------------------------------- */
diff --git a/src/components/workspace/ShotThumbnail.test.tsx b/src/components/workspace/ShotThumbnail.test.tsx
index b0cf65f..eebcd6d 100644
--- a/src/components/workspace/ShotThumbnail.test.tsx
+++ b/src/components/workspace/ShotThumbnail.test.tsx
@@ -1,6 +1,6 @@
// @vitest-environment jsdom
-import { cleanup, render, screen, waitFor } from "@testing-library/react";
+import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
import { afterEach, describe, expect, it, vi } from "vitest";
import { createProjectConfig, parseProjectConfig, sceneShots, type GenerationJob } from "../../lib/project";
import { ShotThumbnail } from "./ShotThumbnail";
@@ -21,9 +21,13 @@ async function withFakeFile(file: { seconds: number }, body: (seen: { seeks: num
URL.createObjectURL = () => "blob:polstudio-test";
URL.revokeObjectURL = () => undefined;
const load = HTMLMediaElement.prototype.load;
+ const play = HTMLMediaElement.prototype.play;
+ const pause = HTMLMediaElement.prototype.pause;
const getContext = HTMLCanvasElement.prototype.getContext;
const toDataURL = HTMLCanvasElement.prototype.toDataURL;
HTMLMediaElement.prototype.load = () => undefined;
+ HTMLMediaElement.prototype.play = vi.fn().mockResolvedValue(undefined);
+ HTMLMediaElement.prototype.pause = vi.fn();
HTMLCanvasElement.prototype.getContext = (() => ({ drawImage: () => undefined })) as unknown as typeof getContext;
const seeks: number[] = [];
// The drawn frame is named after the moment it was taken from, so a test can
@@ -48,7 +52,10 @@ async function withFakeFile(file: { seconds: number }, body: (seen: { seeks: num
setTimeout(() => element.dispatchEvent(new Event("seeked")), 0);
},
});
- setTimeout(() => element.dispatchEvent(new Event("loadeddata")), 0);
+ setTimeout(() => {
+ element.dispatchEvent(new Event("loadedmetadata"));
+ element.dispatchEvent(new Event("loadeddata"));
+ }, 0);
}
return element;
});
@@ -57,6 +64,8 @@ async function withFakeFile(file: { seconds: number }, body: (seen: { seeks: num
} finally {
spy.mockRestore();
HTMLMediaElement.prototype.load = load;
+ HTMLMediaElement.prototype.play = play;
+ HTMLMediaElement.prototype.pause = pause;
HTMLCanvasElement.prototype.getContext = getContext;
HTMLCanvasElement.prototype.toDataURL = toDataURL;
delete (window as unknown as Record<string, unknown>).__TAURI_INTERNALS__;
@@ -90,7 +99,8 @@ describe("a shot's picture", () => {
const job = rendered(folder);
await withFakeFile({ seconds: 9 }, async (seen) => {
render(<ShotThumbnail folderPath={folder} job={job} seconds={0} shotNumber={1} posterOffsetSeconds={0} />);
- const picture = await screen.findByRole("img", { name: "Shot 1 of First scene" }) as HTMLImageElement;
+ const control = await screen.findByRole("button", { name: "Play shot 1 of First scene" });
+ const picture = control.querySelector("img") as HTMLImageElement;
expect(seen.seeks).toEqual([]);
expect(picture.src).toContain("frame-0");
});
@@ -109,11 +119,9 @@ describe("a shot's picture", () => {
/* Named "Shot N of <scene>" once a real frame is drawn; until then the
placeholder is named for the state instead, so this waits for the
picture rather than for anything with a role of img. */
- const drawn = () => screen.getAllByRole("img", { name: /of First scene$/ }) as HTMLImageElement[];
+ const drawn = () => screen.getAllByRole("button", { name: /^Play shot .* of First scene$/ });
await waitFor(() => expect(drawn()).toHaveLength(2));
- const pictures = drawn();
- expect(pictures.map((image) => image.getAttribute("alt")))
- .toEqual(["Shot 1 of First scene", "Shot 2 of First scene"]);
+ const pictures = drawn().map((control) => control.querySelector("img") as HTMLImageElement);
// The file was read once, for both cards.
expect(seen.reads()).toBe(1);
/* And each card got ITS shot's frame: a quarter of a second past the cut,
@@ -124,6 +132,29 @@ describe("a shot's picture", () => {
});
});
+ it("plays from this shot's cut and stops at the next cut", async () => {
+ const folder = "C:\\Shot playback";
+ const job = rendered(folder);
+ await withFakeFile({ seconds: 9 }, async (seen) => {
+ render(<ShotThumbnail folderPath={folder} job={job} seconds={4.5} endSeconds={6} shotNumber={2} />);
+ fireEvent.click(await screen.findByRole("button", { name: "Play shot 2 of First scene" }));
+
+ const video = await waitFor(() => {
+ const found = document.querySelector("video");
+ expect(found).not.toBeNull();
+ return found as HTMLVideoElement;
+ });
+ await waitFor(() => expect(screen.getByRole("button", { name: "Pause shot 2 of First scene" })).not.toBeNull());
+ expect(seen.seeks).toContain(4.5);
+
+ video.currentTime = 6;
+ fireEvent.timeUpdate(video);
+ await waitFor(() => expect(screen.getByRole("button", { name: "Play shot 2 of First scene" })).not.toBeNull());
+ expect(HTMLMediaElement.prototype.pause).toHaveBeenCalled();
+ expect(seen.reads()).toBe(2);
+ });
+ });
+
it("shows no picture and reads no file until the scene has been rendered", async () => {
const folder = "C:\\Not rendered";
const fresh = createProjectConfig({ name: "Draft", prompt: "A quiet product film", aspectRatio: "16:9", resolution: "1080p", targetDurationSeconds: 30 });
diff --git a/src/components/workspace/ShotThumbnail.tsx b/src/components/workspace/ShotThumbnail.tsx
index 4eb51f3..b2186b8 100644
--- a/src/components/workspace/ShotThumbnail.tsx
+++ b/src/components/workspace/ShotThumbnail.tsx
@@ -1,7 +1,7 @@
-import { Ban, Clock3, Film, LoaderCircle, TriangleAlert } from "lucide-react";
-import { useEffect, useState, type ReactNode } from "react";
+import { Ban, Clock3, Film, LoaderCircle, Pause, Play, TriangleAlert } from "lucide-react";
+import { useEffect, useRef, useState, type ReactNode } from "react";
import { readMediaFileUrl } from "../../lib/persistence";
-import type { GenerationJob } from "../../lib/project";
+import { sceneDurationSeconds, type GenerationJob } from "../../lib/project";
/* A real frame of ONE shot, taken from the scene's own video file.
*
@@ -36,6 +36,7 @@ const SEEK_LIMIT_MS = 4_000;
const POSTER_OFFSET_SECONDS = 0.25;
/** Small JPEGs, but not free. Bounded like MediaThumbnail's own cache. */
const CACHE_LIMIT = 96;
+const PLAY_EVENT = "polstudio:play-generated-shot";
/** Drawn frames, keyed by file and time. */
const POSTERS = new Map<string, string>();
@@ -219,7 +220,10 @@ export function shotPoster(folderPath: string, relativePath: string, seconds: nu
/** What a card says when there is no frame. Every one of these is a state of
* the scene the user can see and act on, never a shrug. */
-function placeholder(job: GenerationJob, failed: boolean): { icon: ReactNode; word: string } {
+function placeholder(job: GenerationJob, failed: boolean, cancelling: boolean): { icon: ReactNode; word: string } {
+ if (cancelling && (job.status === "queued" || job.status === "generating")) {
+ return { icon: <LoaderCircle size={18} className="spin" />, word: "Cancelling..." };
+ }
switch (job.status) {
case "generating": return { icon: <LoaderCircle size={18} className="spin" />, word: `Rendering ${Math.round(job.progress * 100)}%` };
case "queued": return { icon: <Clock3 size={18} />, word: "Waiting to render" };
@@ -235,20 +239,56 @@ function placeholder(job: GenerationJob, failed: boolean): { icon: ReactNode; wo
}
}
-export function ShotThumbnail({ folderPath, job, seconds, shotNumber, posterOffsetSeconds = POSTER_OFFSET_SECONDS }: {
+export function ShotThumbnail({ folderPath, job, seconds, endSeconds = sceneDurationSeconds(job), shotNumber, posterOffsetSeconds = POSTER_OFFSET_SECONDS, cancelling = false }: {
folderPath: string;
/** The scene this shot belongs to: it owns the file and the status. */
job: GenerationJob;
/** Where the shot starts, in seconds from the head of the scene. */
seconds: number;
+ /** The next cut (or scene end). Playback never crosses this point. */
+ endSeconds?: number;
shotNumber: number;
/** Scene cards use frame zero; shot cards offset past a possible fade-in. */
posterOffsetSeconds?: number;
+ /** Cancel was requested but the engine has not reported its terminal state. */
+ cancelling?: boolean;
}) {
const relativePath = job.status === "completed" ? job.outputRelativePath : null;
const at = seconds + posterOffsetSeconds;
+ const playbackId = `${job.id}@${seconds}`;
const [result, setResult] = useState<PosterResult>(() =>
relativePath ? { poster: POSTERS.get(posterKey(fileKey(folderPath, relativePath), at)) ?? null, failed: false } : NOTHING);
+ const [playbackUrl, setPlaybackUrl] = useState<string | null>(null);
+ const [loadingPlayback, setLoadingPlayback] = useState(false);
+ const [playing, setPlaying] = useState(false);
+ const [playFailed, setPlayFailed] = useState(false);
+ const videoRef = useRef<HTMLVideoElement>(null);
+ const requestRef = useRef(0);
+ const cutTimerRef = useRef<number | null>(null);
+
+ const clearCutTimer = () => {
+ if (cutTimerRef.current !== null) window.clearTimeout(cutTimerRef.current);
+ cutTimerRef.current = null;
+ };
+
+ const finishPlayback = () => {
+ clearCutTimer();
+ videoRef.current?.pause();
+ setPlaying(false);
+ setPlaybackUrl(null);
+ };
+
+ const playToCut = async (video: HTMLVideoElement) => {
+ clearCutTimer();
+ try {
+ await video.play();
+ setPlaying(true);
+ const rate = video.playbackRate > 0 ? video.playbackRate : 1;
+ cutTimerRef.current = window.setTimeout(finishPlayback, Math.max(0, (endSeconds - video.currentTime) * 1_000 / rate));
+ } catch {
+ setPlayFailed(true);
+ }
+ };
useEffect(() => {
if (!relativePath) {
@@ -260,14 +300,100 @@ export function ShotThumbnail({ folderPath, job, seconds, shotNumber, posterOffs
return () => { live = false; };
}, [folderPath, relativePath, at]);
+ useEffect(() => {
+ const stopOtherShot = (event: Event) => {
+ if ((event as CustomEvent<string>).detail === playbackId) return;
+ requestRef.current += 1;
+ setLoadingPlayback(false);
+ finishPlayback();
+ };
+ window.addEventListener(PLAY_EVENT, stopOtherShot);
+ return () => window.removeEventListener(PLAY_EVENT, stopOtherShot);
+ }, [playbackId]);
+
+ useEffect(() => () => {
+ requestRef.current += 1;
+ clearCutTimer();
+ }, []);
+ useEffect(() => () => {
+ if (playbackUrl) URL.revokeObjectURL(playbackUrl);
+ }, [playbackUrl]);
+
+ const stopAtCut = () => {
+ const video = videoRef.current;
+ if (!video || video.currentTime + 0.02 < endSeconds) return;
+ finishPlayback();
+ };
+
+ const togglePlayback = async (event: React.MouseEvent<HTMLButtonElement>) => {
+ event.stopPropagation();
+ if (!relativePath || loadingPlayback) return;
+ const video = videoRef.current;
+ if (video) {
+ if (!video.paused) {
+ clearCutTimer();
+ video.pause();
+ setPlaying(false);
+ } else {
+ window.dispatchEvent(new CustomEvent<string>(PLAY_EVENT, { detail: playbackId }));
+ if (video.currentTime < seconds || video.currentTime >= endSeconds) video.currentTime = seconds;
+ await playToCut(video);
+ }
+ return;
+ }
+
+ const request = ++requestRef.current;
+ window.dispatchEvent(new CustomEvent<string>(PLAY_EVENT, { detail: playbackId }));
+ setLoadingPlayback(true);
+ setPlayFailed(false);
+ try {
+ const url = await readMediaFileUrl(folderPath, { relativePath }, "video/mp4");
+ if (request !== requestRef.current) {
+ if (url) URL.revokeObjectURL(url);
+ return;
+ }
+ if (!url) throw new Error("The generated file is not available in this view.");
+ setPlaybackUrl(url);
+ } catch {
+ if (request === requestRef.current) setPlayFailed(true);
+ } finally {
+ if (request === requestRef.current) setLoadingPlayback(false);
+ }
+ };
+
if (result.poster) {
- return <span className="shot-thumb shot-thumb--poster">
- <img src={result.poster} alt={`Shot ${shotNumber} of ${job.title}`} loading="lazy" />
- </span>;
+ const action = playFailed ? "Playback unavailable" : loadingPlayback ? "Opening shot" : playing ? "Pause" : "Play";
+ return <button
+ type="button"
+ className="shot-thumb shot-thumb--poster shot-thumb--playable"
+ aria-label={`${action} shot ${shotNumber} of ${job.title}`}
+ title={`${action} this shot only (${seconds.toFixed(1)}s–${endSeconds.toFixed(1)}s)`}
+ onClick={(event) => void togglePlayback(event)}
+ >
+ {playbackUrl
+ ? <video
+ ref={videoRef}
+ src={playbackUrl}
+ playsInline
+ onLoadedMetadata={(event) => {
+ event.currentTarget.currentTime = Math.min(seconds, Math.max(0, event.currentTarget.duration - 0.01));
+ void playToCut(event.currentTarget);
+ }}
+ onTimeUpdate={stopAtCut}
+ onEnded={stopAtCut}
+ />
+ : <img src={result.poster} alt="" loading="lazy" />}
+ <span className={`shot-thumb__play ${loadingPlayback ? "shot-thumb__play--loading" : ""}`} aria-hidden="true">
+ {loadingPlayback ? <LoaderCircle size={20} className="spin" /> : playing ? <Pause size={20} /> : playFailed ? <TriangleAlert size={20} /> : <Play size={20} fill="currentColor" />}
+ </span>
+ </button>;
}
- const { icon, word } = placeholder(job, result.failed);
+ const { icon, word } = placeholder(job, result.failed, cancelling);
return <span className={`shot-thumb shot-thumb--${job.status}`} role="img" aria-label={`Shot ${shotNumber} — ${word}`}>
{icon}
<em>{word}</em>
+ {job.status === "generating" && <span className="shot-thumb__progress" aria-hidden="true">
+ <i style={{ width: `${Math.max(0, Math.min(100, job.progress * 100))}%` }} />
+ </span>}
</span>;
}
diff --git a/src/lib/project.test.ts b/src/lib/project.test.ts
index 7873fb2..55a7f8e 100644
--- a/src/lib/project.test.ts
+++ b/src/lib/project.test.ts
@@ -41,6 +41,8 @@ import {
sceneShots,
splitActionText,
DEFAULT_SCENE_SECONDS,
+ DEFAULT_GENERATION_STEPS,
+ RANDOM_GENERATION_SEED,
SCENE_MAX_SECONDS,
LEGACY_PROJECT_FILE_NAMES,
PROJECT_FILE_NAME,
@@ -640,6 +642,38 @@ describe("scenes and the shots inside them", () => {
expect(sceneBriefText(sceneShots(job))).toBe(job.creativeBrief);
});
+ it("keeps shot speech inside MiniMax dialogue tags with its selected language", () => {
+ const firstLine = "行こう! Keep the punctuation, exactly.";
+ const secondLine = "I will meet you there.";
+ const job = createDraftGenerationJob("", {
+ id: "scene-dialogue", title: "Dialogue", now, durationSeconds: 6,
+ shots: [
+ { id: "dialogue-a", startSeconds: 0, action: "She turns toward the doorway", speech: firstLine, speechLanguage: "Japanese" },
+ { id: "dialogue-b", startSeconds: 3, action: "The camera follows", speech: secondLine },
+ ],
+ });
+
+ for (const compiled of [compileGenerationJobPrompt(job), compileGenerationJobPrompt(job, [imageReference()])]) {
+ expect(compiled).toContain(`The scene's speaker (S1) says, <d>[Japanese] ${firstLine}</d>`);
+ expect(compiled).toContain(`The scene's speaker (S1) says, <d>[English] ${secondLine}</d>`);
+ // The full-reference summary must not repeat spoken words without tags.
+ expect(compiled.split(firstLine)).toHaveLength(2);
+ expect(compiled.split(secondLine)).toHaveLength(2);
+ }
+
+ expect(sceneShots(job)[0]).toEqual(expect.objectContaining({ speech: firstLine, speechLanguage: "Japanese" }));
+ expect(generationJobSchema.parse(job)).toEqual(job);
+ });
+
+ it("omits an empty speech field from the compiled prompt", () => {
+ const job = createDraftGenerationJob("A silent look", {
+ id: "scene-silent", title: "Silent", now,
+ shots: [{ id: "silent-a", startSeconds: 0, action: "A silent look", speech: " ", speechLanguage: "French" }],
+ });
+ expect(compileGenerationJobPrompt(job)).not.toContain("<d>");
+ expect(compileGenerationJobPrompt(job)).not.toContain("(S1)");
+ });
+
it("turns a reference token into <Subject N>, in lockstep with reference_paths", () => {
const config = scene();
const job = config.generationJobs[0];
@@ -740,6 +774,14 @@ describe("scenes and the shots inside them", () => {
expect(formatSceneSeconds(4.5)).toBe("4.5");
});
+ it("defaults new scenes to 20 steps and a random seed marker", () => {
+ const job = createDraftGenerationJob("A slow push towards the doorway.");
+ expect(job.steps).toBe(DEFAULT_GENERATION_STEPS);
+ expect(job.seed).toBe(RANDOM_GENERATION_SEED);
+ expect(generationJobSchema.safeParse({ ...job, steps: 1 }).success).toBe(false);
+ expect(generationJobSchema.safeParse({ ...job, seed: -2 }).success).toBe(false);
+ });
+
it("keeps the scene fixture readable by both validators, in both directions", () => {
// The frontend's own file and the bytes Rust really wrote for it.
expect(parseProjectConfig(sceneFixture)).toBeTruthy();
diff --git a/src/lib/project.ts b/src/lib/project.ts
index c66f9ec..df9ba1c 100644
--- a/src/lib/project.ts
+++ b/src/lib/project.ts
@@ -7,6 +7,29 @@ export const PROJECT_FILE_NAME = "polstudio.json";
* ever written. */
export const LEGACY_PROJECT_FILE_NAMES = ["pols.json", "polstudio.project.json"] as const;
export const CURRENT_SCHEMA_VERSION = 1 as const;
+export const DEFAULT_GENERATION_STEPS = 20;
+export const MAX_GENERATION_STEPS = 2_147_483_647;
+export const RANDOM_GENERATION_SEED = -1;
+
+/** Languages MiniMax H3 documents as stable for dialogue generation. Keep the
+ * labels verbatim: they are written into the model's required `[Language]`
+ * marker rather than translated into the UI locale. */
+export const SPEECH_LANGUAGES = [
+ "Arabic",
+ "Chinese",
+ "English",
+ "French",
+ "German",
+ "Italian",
+ "Japanese",
+ "Korean",
+ "Portuguese",
+ "Russian",
+ "Spanish",
+] as const;
+export const speechLanguageSchema = z.enum(SPEECH_LANGUAGES);
+export type SpeechLanguage = z.infer<typeof speechLanguageSchema>;
+export const DEFAULT_SPEECH_LANGUAGE: SpeechLanguage = "English";
const idSchema = z.string().min(1);
const isoDateSchema = z.string().datetime();
@@ -250,6 +273,11 @@ export const sceneShotSchema = z.object({
* that has just been added has nothing written in it yet, and PolStudio
* never writes that line for anyone. */
action: z.string(),
+ /** Dialogue is separate from the visual action so the compiler can guarantee
+ * that every spoken character lands inside MiniMax H3's `<d>...</d>` syntax.
+ * Both fields are optional to preserve projects written before speech UI. */
+ speech: z.string().nullish(),
+ speechLanguage: speechLanguageSchema.nullish(),
/** The H3 vocabulary settings on this shot: group id -> option ids. Same
* shape, same ids and same normalisation as the older per-job `shotTags`. */
settings: shotTagSelectionSchema.nullish(),
@@ -341,6 +369,11 @@ export const generationJobSchema = z.object({
/** How long the whole scene runs. Absent means the length every shot was
* generated at before this was settable; read `sceneDurationSeconds(job)`. */
durationSeconds: z.number().min(SCENE_MIN_SECONDS).max(SCENE_MAX_SECONDS).nullish(),
+ /** Renderer controls. Missing values belong to projects written before these
+ * were exposed; the readers below give those scenes the current defaults
+ * without rewriting the file just because it was opened. */
+ steps: z.number().int().min(2).max(MAX_GENERATION_STEPS).nullish(),
+ seed: z.number().int().min(RANDOM_GENERATION_SEED).max(Number.MAX_SAFE_INTEGER).nullish(),
/** Base guide §4.6 and §4.7. Per-PROMPT fields, not per-shot, so they live on
* the scene. Blank or absent means the compiler emits its own content-neutral
* line; anything here is the user's own words and is marked as theirs. */
@@ -668,6 +701,14 @@ export function sceneDurationSeconds(job: GenerationJob): number {
return Math.min(SCENE_MAX_SECONDS, Math.max(SCENE_MIN_SECONDS, stored));
}
+export function sceneGenerationSteps(job: GenerationJob): number {
+ return job.steps ?? DEFAULT_GENERATION_STEPS;
+}
+
+export function sceneGenerationSeed(job: GenerationJob): number {
+ return job.seed ?? RANDOM_GENERATION_SEED;
+}
+
export interface SceneGenerationInput {
prompt: string;
frames: number;
@@ -746,6 +787,8 @@ interface CompiledShot {
/** Reference ids this shot cites, first citation first. */
citedIds: string[];
tags: ShotTagClauses;
+ speech: string | null;
+ speechLanguage: SpeechLanguage;
}
export function compileScenePromptSegments(scene: ScenePrompt, references: ProjectReference[] = []): PromptSegment[] {
@@ -776,7 +819,16 @@ export function compileScenePromptSegments(scene: ScenePrompt, references: Proje
body.push(frame(`<Subject ${number}>`));
text += `<Subject ${number}>`;
}
- return { index, startSeconds: shot.startSeconds, body, text, citedIds, tags: shotTagClauses(shot.settings ?? null) };
+ return {
+ index,
+ startSeconds: shot.startSeconds,
+ body,
+ text,
+ citedIds,
+ tags: shotTagClauses(shot.settings ?? null),
+ speech: shot.speech?.trim().length ? shot.speech : null,
+ speechLanguage: shot.speechLanguage ?? DEFAULT_SPEECH_LANGUAGE,
+ };
});
// §4.1: the description opens with ONE overall style, so the first shot that
@@ -800,11 +852,22 @@ export function compileScenePromptSegments(scene: ScenePrompt, references: Proje
tagged(clause.terms.join(", ")),
frame("."),
]);
+ /** Base guide dialogue syntax: identifying phrase and stable speaker id stay
+ * outside `<d>`, while only the language marker and the user's exact text are
+ * inside. One scene-level speech track means the same (S1) voice is retained
+ * across its shots. The pieces stay split so prompt provenance remains honest. */
+ const dialogue = (shot: CompiledShot, separate: boolean): PromptSegment[] => shot.speech === null ? [] : [
+ frame(`${separate ? " " : ""}The scene's speaker (S1) says, <d>[`),
+ tagged(shot.speechLanguage),
+ frame("] "),
+ own(shot.speech),
+ frame("</d>"),
+ ];
/* A stop is added when something follows the line — another clause, or
another shot. A lone untagged shot keeps whatever terminal punctuation the
user gave it, so every prompt this app has ever produced is unchanged. */
const stop = (shot: CompiledShot): PromptSegment[] =>
- shot.tags.clauses.length > 0 || shot.index < compiled.length - 1 ? addedStop(shot.text) : [];
+ shot.tags.clauses.length > 0 || shot.speech !== null || shot.index < compiled.length - 1 ? addedStop(shot.text) : [];
const sound = (scene.soundscape ?? "").trim();
const music = (scene.music ?? "").trim();
@@ -824,6 +887,7 @@ export function compileScenePromptSegments(scene: ScenePrompt, references: Proje
...shot.body,
...stop(shot),
...tail(shot),
+ ...dialogue(shot, shot.text.length > 0 || shot.tags.clauses.length > 0),
]),
frame("\n\noverall_soundscape: "),
soundSegment,
@@ -926,6 +990,7 @@ export function compileScenePromptSegments(scene: ScenePrompt, references: Proje
? [frame(` The shot features ${listOf(featured[shot.index].map((id) => `<Subject ${subjectNumber.get(id)}>`))}, matching the definitions above.`)]
: []),
...tail(shot),
+ ...dialogue(shot, shot.text.length > 0 || featured[shot.index].length > 0 || shot.tags.clauses.length > 0),
]),
];
@@ -976,6 +1041,8 @@ export function createDraftGenerationJob(
* `creativeBrief`, which is what every caller wanted before scenes. */
shots?: SceneShot[];
durationSeconds?: number;
+ steps?: number;
+ seed?: number;
now?: string;
} = {},
): GenerationJob {
@@ -1011,6 +1078,8 @@ export function createDraftGenerationJob(
referenceIds: options.referenceIds ?? [],
shots,
durationSeconds,
+ steps: options.steps ?? DEFAULT_GENERATION_STEPS,
+ seed: options.seed ?? RANDOM_GENERATION_SEED,
createdAt: now,
updatedAt: now,
});
diff --git a/src/styles/generator.css b/src/styles/generator.css
index 93ebc17..28f73f4 100644
--- a/src/styles/generator.css
+++ b/src/styles/generator.css
@@ -146,6 +146,13 @@
background: var(--panel);
}
+.generator-heading__cancel {
+ width: auto;
+ min-height: var(--control-lg);
+ padding: 0 var(--space-5);
+ font-size: var(--text-base);
+}
+
.scene-rule__drag {
width: var(--control-sm);
height: var(--control-sm);
@@ -287,6 +294,7 @@
}
.scene-rule__generate {
+ width: auto;
flex: 0 0 auto;
min-height: var(--control-sm);
white-space: nowrap;
@@ -491,6 +499,26 @@
background: var(--accent-soft);
}
+/* The picture and the editor affordance are separate controls: clicking the
+ picture plays this shot; clicking the copy still opens its settings. */
+.shot-card__open-control {
+ min-width: 0;
+ display: flex;
+ flex: 1;
+ flex-direction: column;
+ gap: var(--space-2);
+ padding: 0;
+ border: 0;
+ color: inherit;
+ background: none;
+ text-align: left;
+ cursor: pointer;
+}
+
+.shot-card:focus-within {
+ border-color: var(--accent-bright);
+}
+
.shot-card__head {
display: flex;
align-items: baseline;
@@ -620,10 +648,51 @@
object-fit: cover;
}
+.shot-thumb video {
+ width: 100%;
+ height: 100%;
+ object-fit: cover;
+}
+
.shot-thumb--poster {
background-image: none;
}
+.shot-thumb--playable {
+ padding: 0;
+ border: 0;
+ cursor: pointer;
+}
+
+.shot-thumb__play {
+ position: absolute;
+ inset: 50% auto auto 50%;
+ width: 38px;
+ height: 38px;
+ display: grid;
+ place-items: center;
+ transform: translate(-50%, -50%);
+ border-radius: var(--radius-pill);
+ color: var(--on-accent);
+ background: var(--scrim);
+ box-shadow: var(--shadow-sm);
+ opacity: 0;
+ transition: opacity 120ms ease, transform 120ms ease;
+}
+
+.shot-thumb--playable:hover .shot-thumb__play,
+.shot-thumb--playable:focus-visible .shot-thumb__play,
+.shot-thumb--playable .shot-thumb__play--loading,
+.shot-thumb--playable[aria-label^="Pause"] .shot-thumb__play,
+.shot-thumb--playable[aria-label^="Playback unavailable"] .shot-thumb__play {
+ opacity: 1;
+}
+
+.shot-thumb--playable:hover .shot-thumb__play,
+.shot-thumb--playable:focus-visible .shot-thumb__play {
+ transform: translate(-50%, -50%) scale(1.06);
+}
+
.shot-thumb em {
padding: 0 var(--space-2);
color: inherit;
@@ -646,6 +715,21 @@
animation: spin 1.4s linear infinite;
}
+.shot-thumb__progress {
+ position: absolute;
+ inset: auto 0 0;
+ height: 3px;
+ overflow: hidden;
+ background: var(--line);
+}
+
+.shot-thumb__progress > i {
+ height: 100%;
+ display: block;
+ background: var(--accent-bright);
+ transition: width 180ms ease;
+}
+
/* --- The controls a shot's panel is made of -------------------------------- */
.shot-card__start {
@@ -725,14 +809,31 @@
line-height: var(--leading-snug);
}
+.shot-action-editor {
+ overflow: hidden;
+ border: 1px solid var(--line-strong);
+ border-radius: var(--radius-md);
+ background: var(--panel-2);
+}
+
+.shot-action-editor:focus-within {
+ border-color: var(--accent);
+}
+
+.shot-action-editor:has(textarea:focus-visible) {
+ outline: var(--focus-ring-width) solid var(--focus-ring-color);
+ outline-offset: 2px;
+}
+
.shot-card__action textarea {
width: 100%;
min-height: 104px;
padding: var(--space-3);
- border: 1px solid var(--line-strong);
- border-radius: var(--radius-md);
+ border: 0;
+ border-radius: 0;
+ outline: 0;
color: var(--text-primary);
- background: var(--panel-2);
+ background: transparent;
font-family: var(--font-sans);
font-size: var(--text-base);
line-height: var(--leading-normal);
@@ -744,37 +845,83 @@
cursor: default;
}
-/* The same line read back, with every reference as a control you can change. */
-.shot-readback {
+.shot-speech {
+ margin-top: var(--space-4);
+}
+
+.shot-speech__heading {
+ display: flex;
+ align-items: end;
+ justify-content: space-between;
+ gap: var(--space-3);
+ margin-bottom: var(--space-2);
+}
+
+.shot-speech__heading > .shot-card__sublabel {
+ margin-bottom: 0;
+}
+
+.shot-speech__language {
display: flex;
- flex-wrap: wrap;
align-items: center;
- gap: var(--space-1);
- margin: var(--space-3) 0 0;
- padding: var(--space-2) var(--space-3);
- border: 1px dashed var(--line-strong);
+ gap: var(--space-2);
+ color: var(--text-muted);
+ font-size: var(--text-xs);
+}
+
+.shot-speech__language select {
+ min-height: var(--control-sm);
+ padding: 0 var(--space-7) 0 var(--space-3);
+ border: 1px solid var(--line-strong);
+ border-radius: var(--radius-sm);
+ color: var(--text-primary);
+ background: var(--panel-2);
+ font: inherit;
+}
+
+.shot-speech > textarea {
+ width: 100%;
+ min-height: 76px;
+ padding: var(--space-3);
+ border: 1px solid var(--line-strong);
border-radius: var(--radius-md);
- color: var(--text-secondary);
+ outline: 0;
+ color: var(--text-primary);
+ background: var(--panel-2);
+ font-family: var(--font-sans);
font-size: var(--text-sm);
line-height: var(--leading-normal);
+ resize: vertical;
}
-.shot-readback__lead {
- width: 100%;
+.shot-speech > textarea:focus-visible,
+.shot-speech__language select:focus-visible {
+ border-color: var(--accent);
+ outline: var(--focus-ring-width) solid var(--focus-ring-color);
+ outline-offset: 2px;
+}
+
+.shot-speech__hint {
+ margin: var(--space-2) 0 0;
color: var(--text-faint);
font-size: var(--text-2xs);
- text-transform: uppercase;
- letter-spacing: var(--tracking-label);
}
-.shot-readback__text {
- white-space: pre-wrap;
+/* Reference controls are part of the description box instead of a second
+ readback of the same sentence. Each select is one token occurrence. */
+.shot-action-editor__chips {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: var(--space-2);
+ padding: var(--space-2) var(--space-3) var(--space-3);
+ border-top: 1px solid var(--line);
}
-.shot-readback__token {
+.reference-smart-chip {
min-height: var(--control-sm);
max-width: 100%;
- padding: 0 var(--space-2);
+ padding: 0 var(--space-3);
border: 1px solid var(--accent);
border-radius: var(--radius-pill);
color: var(--text-primary);
@@ -785,7 +932,7 @@
cursor: pointer;
}
-.shot-readback__token--broken {
+.reference-smart-chip--broken {
border-color: var(--danger);
background: color-mix(in srgb, var(--danger) 16%, transparent);
}
@@ -914,6 +1061,37 @@
line-height: var(--leading-snug);
}
+.scene-settings__numbers {
+ display: grid;
+ grid-template-columns: 1fr 1fr;
+ gap: var(--space-3);
+ margin-top: var(--space-4);
+}
+
+.scene-settings > h3 + .scene-settings__numbers {
+ margin-top: 0;
+}
+
+.scene-settings__numbers .scene-settings__field + .scene-settings__field {
+ margin-top: 0;
+}
+
+.scene-settings__numbers + .scene-settings__field {
+ margin-top: var(--space-4);
+}
+
+.scene-settings__numbers input {
+ width: 100%;
+ height: var(--field-height);
+ padding: 0 var(--space-3);
+ border: 1px solid var(--line);
+ border-radius: var(--radius-sm);
+ color: var(--text-primary);
+ background: var(--panel-2);
+ font-family: var(--font-mono);
+ font-size: var(--text-sm);
+}
+
.scene-settings__field textarea {
width: 100%;
min-height: 64px;
@@ -1250,14 +1428,19 @@
gap: var(--space-4);
}
-.debug-prompt summary {
- color: var(--text-muted);
- cursor: pointer;
- font-size: var(--text-xs);
+.debug-prompt {
+ flex: 0 0 auto;
+ padding: var(--space-4) var(--space-5);
+ border-top: 1px solid var(--line);
+ background: var(--panel);
}
.debug-prompt .compiled-prompt {
- margin-top: var(--space-3);
+ margin: 0 0 var(--space-3);
+}
+
+.debug-prompt__toggle {
+ width: 100%;
}
.remove-dialog-backdrop {
@@ -1738,6 +1921,7 @@
.panel-head,
.panel-scroll,
+ .debug-prompt,
.generator-panel .job-actions {
padding: var(--space-4);
}