Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Test and refine image project workflows

Bitti68d5ba533007
diff --git a/README.md b/README.md
index 8776799..e306c88 100644
--- a/README.md
+++ b/README.md
@@ -21,6 +21,10 @@
Slopus brings an AI assistant, a scene generator, reusable visual references, and a timeline editor together. Describe what you want to make, generate clips locally with SlopFab, and shape the result into a video you can export and share.
+New projects can be **Image projects** or **Video projects**. Existing projects open as Video projects. Both live in folders with a `slopus.json` document.
+
+Image projects use **Agent**, **Editor**, and **References** tabs. In the Editor, build a hierarchy of objects, text and groups on the left, arrange their placement boxes in the center, and edit descriptions, style, colors and generation settings in the right inspector. Choose a MiniMax H3 generator template above the canvas and press **Generate**. Generation uses the native SlopFab runtime without Python. Full-resolution JPEGs are saved in `media/generated/`, remain available in the image history, and can be exported from the canvas toolbar. Placement boxes guide the model through the prompt; they are not exact masks.
+
> **GPU recommendation:** A GPU with **24 GB of VRAM or more** is currently recommended for local video generation. We plan to reduce VRAM usage in future updates.
![Slopus application screenshot](marketing/screenshot1.png)
diff --git a/src-tauri/assets/agent-image.md b/src-tauri/assets/agent-image.md
index 376ec96..900d0dc 100644
--- a/src-tauri/assets/agent-image.md
+++ b/src-tauri/assets/agent-image.md
@@ -6,6 +6,6 @@ Author the image tree with this command, then a commit line:
All fields are required; copy unchanged authored fields from imageScene in the current project. Do not send outputAssetId: generated results belong to the app. Each node has exactly these fields:
{"id":"stable-id","parentId":null,"kind":"root","name":"Image","description":"high-level image prompt","text":"","box":null,"colors":[]}
-Use exactly one root with parentId null. Other nodes have kind group, object, text or background, and parentId naming an existing node. IDs must be unique and the tree connected and acyclic. Objects, groups and text may carry box {"x":100,"y":100,"width":400,"height":600} in 0–1000 image coordinates; extents must be positive and stay within the image. Box null means automatic placement. A group's description provides context to its children. Text nodes use text for the exact lettering and description for appearance. Colors are hex #RRGGBB strings (up to 16). Names are short tree labels; put visual instructions in description. At most 500 nodes. Style mode is photo or art, steps 1–1000, seed -1 for random or a nonnegative safe integer. Placement is prose guidance to H3, not a guaranteed pixel mask.
+Use exactly one root with parentId null. Other nodes have kind group, object, text or background, and parentId naming an existing node. IDs must be unique and the tree connected and acyclic. Objects, groups and text may carry box {"x":100,"y":100,"width":400,"height":600} in 0–1000 image coordinates; extents must be positive and stay within the image. Box null means automatic placement. A group's description provides context to its children. Text nodes use text for the exact lettering and description for appearance. Colors are hex #RRGGBB strings (up to 16). Names are short tree labels; put visual instructions in description. At most 500 nodes. Style mode is photo or art, steps 2–1000, seed -1 for random or a nonnegative safe integer. Placement is prose guidance to H3, not a guaranteed pixel mask.
Use project.set for project name, resolution and aspectRatio. Use ref.add/ref.set for reusable descriptions, then include their IDs in image.set referenceIds. Bind only existing image/text references. Do not create scene.*, shot.* or clip.* commands for image projects. Preserve the current image composition unless asked to change it. Never invent files or claim to have generated an image: the user runs Generate in the Editor.
diff --git a/src-tauri/src/agent/prompt.rs b/src-tauri/src/agent/prompt.rs
index 033a1b5..f179efc 100644
--- a/src-tauri/src/agent/prompt.rs
+++ b/src-tauri/src/agent/prompt.rs
@@ -27,7 +27,10 @@ pub(super) fn context_prompt(config: &ProjectConfig, prompt: &str) -> Result<Str
/// project gets the default policy; unknown persisted models remain inert data.
pub(super) fn project_system_prompt(config: &ProjectConfig) -> String {
if config.generation_type == crate::project::GenerationType::Image {
- return format!("{AGENT_SYSTEM_PROMPT}\n\n{}", include_str!("../../assets/agent-image.md"));
+ return format!(
+ "{AGENT_SYSTEM_PROMPT}\n\n{}",
+ include_str!("../../assets/agent-image.md")
+ );
}
let mut ids = std::collections::BTreeSet::new();
let models: Vec<_> = config
diff --git a/src-tauri/src/commands/artifacts.rs b/src-tauri/src/commands/artifacts.rs
index d287c9f..542f613 100644
--- a/src-tauri/src/commands/artifacts.rs
+++ b/src-tauri/src/commands/artifacts.rs
@@ -134,38 +134,89 @@ pub(crate) fn save_reference_icon(folder_path: String, job_id: String) -> Result
/// Preserve the full-resolution still; reference icons intentionally downscale.
#[tauri::command]
-pub(crate) fn save_generated_image(folder_path: String, job_id: String) -> Result<serde_json::Value, String> {
- let summary = rendered::summary(&job_id).ok_or("The generated image is no longer in memory.")?;
- if summary.frame_count != 1 { return Err("Expected a single still image.".into()); }
- let width = u16::try_from(summary.width).map_err(|_| "Image width exceeds JPEG limits.")?;
- let height = u16::try_from(summary.height).map_err(|_| "Image height exceeds JPEG limits.")?;
+pub(crate) fn save_generated_image(
+ folder_path: String,
+ job_id: String,
+) -> Result<GeneratedImageFile, String> {
+ let summary =
+ rendered::summary(&job_id).ok_or("The generated image is no longer in memory.")?;
+ if summary.frame_count != 1 {
+ return Err("Expected a single still image.".into());
+ }
let rgba = rendered::frame(&job_id, 0)?.ok_or("The generated image has no pixels.")?;
+ write_generated_image_frame(&folder_path, &job_id, summary.width, summary.height, &rgba)
+}
+
+#[derive(Debug, serde::Serialize)]
+#[serde(rename_all = "camelCase")]
+pub(crate) struct GeneratedImageFile {
+ pub relative_path: String,
+ pub width: u16,
+ pub height: u16,
+}
+
+pub(crate) fn write_generated_image_frame(
+ folder_path: &str,
+ job_id: &str,
+ width: u32,
+ height: u32,
+ rgba: &[u8],
+) -> Result<GeneratedImageFile, String> {
+ let root = ProjectRoot::open(folder_path)?;
+ let stem = generated_file_stem(job_id)?;
+ let width = u16::try_from(width).map_err(|_| "Image width exceeds JPEG limits.")?;
+ let height = u16::try_from(height).map_err(|_| "Image height exceeds JPEG limits.")?;
+ if width == 0 || height == 0 || rgba.len() != width as usize * height as usize * 4 {
+ return Err("Image dimensions do not match the RGBA pixels.".into());
+ }
let mut bytes = Vec::new();
- jpeg_encoder::Encoder::new(&mut bytes, 95).encode(&rgba, width, height, jpeg_encoder::ColorType::Rgba)
+ jpeg_encoder::Encoder::new(&mut bytes, 95)
+ .encode(rgba, width, height, jpeg_encoder::ColorType::Rgba)
.map_err(|error| format!("Could not encode image: {error}"))?;
- let root = ProjectRoot::open(&folder_path)?;
- let stem = generated_file_stem(&job_id)?;
let directory = root.directory("media/generated")?;
let relative_path = format!("media/generated/{stem}.jpg");
crate::storage::atomic::write_atomically(&directory.join(format!("{stem}.jpg")), &bytes)?;
- Ok(serde_json::json!({ "relativePath": relative_path, "width": width, "height": height }))
+ Ok(GeneratedImageFile {
+ relative_path,
+ width,
+ height,
+ })
}
#[tauri::command]
-pub(crate) async fn export_generated_image(app: AppHandle, folder_path: String, relative_path: String) -> Result<bool, String> {
+pub(crate) async fn export_generated_image(
+ app: AppHandle,
+ folder_path: String,
+ relative_path: String,
+) -> Result<bool, String> {
tauri::async_runtime::spawn_blocking(move || {
use tauri_plugin_dialog::DialogExt;
let root = ProjectRoot::open(&folder_path)?;
let source = root.existing(&relative_path)?;
- if !relative_path.starts_with("media/generated/") || source.extension().and_then(|s| s.to_str()) != Some("jpg") {
+ if !relative_path.starts_with("media/generated/")
+ || source.extension().and_then(|s| s.to_str()) != Some("jpg")
+ {
return Err("Choose a generated JPEG image to export.".into());
}
- let Some(destination) = app.dialog().file().set_title("Export image").add_filter("JPEG image", &["jpg", "jpeg"]).set_file_name("image.jpg").blocking_save_file() else { return Ok(false); };
- let destination = destination.into_path().map_err(|_| "Choose a local image destination.")?;
+ let Some(destination) = app
+ .dialog()
+ .file()
+ .set_title("Export image")
+ .add_filter("JPEG image", &["jpg", "jpeg"])
+ .set_file_name("image.jpg")
+ .blocking_save_file()
+ else {
+ return Ok(false);
+ };
+ let destination = destination
+ .into_path()
+ .map_err(|_| "Choose a local image destination.")?;
let bytes = fs::read(source).map_err(|error| format!("Could not read image: {error}"))?;
crate::storage::atomic::write_atomically(&destination, &bytes)?;
Ok(true)
- }).await.map_err(|error| error.to_string())?
+ })
+ .await
+ .map_err(|error| error.to_string())?
}
#[tauri::command]
diff --git a/src-tauri/src/project/commands/batch.rs b/src-tauri/src/project/commands/batch.rs
index 8b8ee3c..3c84611 100644
--- a/src-tauri/src/project/commands/batch.rs
+++ b/src-tauri/src/project/commands/batch.rs
@@ -80,14 +80,39 @@ fn apply_command(
effects: &mut Effects,
) -> Result<(), String> {
match command {
- ProjectCommand::ImageSet { nodes, background, style, steps, seed, reference_ids } => {
- if project.generation_type != crate::project::GenerationType::Image { return Err("image.set requires an image project.".into()); }
+ ProjectCommand::ImageSet {
+ nodes,
+ background,
+ style,
+ steps,
+ seed,
+ reference_ids,
+ } => {
+ if project.generation_type != crate::project::GenerationType::Image {
+ return Err("image.set requires an image project.".into());
+ }
let scene = crate::project::image::ImageScene {
- nodes: nodes.clone(), background: background.clone(), style: style.clone(), steps: *steps, seed: *seed,
- reference_ids: reference_ids.clone(), output_asset_id: project.image_scene.as_ref().and_then(|scene| scene.output_asset_id.clone()),
+ nodes: nodes.clone(),
+ background: background.clone(),
+ style: style.clone(),
+ steps: *steps,
+ seed: *seed,
+ reference_ids: reference_ids.clone(),
+ output_asset_id: project
+ .image_scene
+ .as_ref()
+ .and_then(|scene| scene.output_asset_id.clone()),
};
scene.validate()?;
- for id in reference_ids { if !project.references.iter().any(|reference| &reference.id == id) { return Err(format!("Image reference '{id}' does not exist.")); } }
+ for id in reference_ids {
+ if !project
+ .references
+ .iter()
+ .any(|reference| &reference.id == id)
+ {
+ return Err(format!("Image reference '{id}' does not exist."));
+ }
+ }
project.image_scene = Some(scene);
project.updated_at = timestamp.into();
Ok(())
diff --git a/src-tauri/src/project/commands/references.rs b/src-tauri/src/project/commands/references.rs
index 77c7330..21f0444 100644
--- a/src-tauri/src/project/commands/references.rs
+++ b/src-tauri/src/project/commands/references.rs
@@ -71,6 +71,13 @@ pub(super) fn apply(
}
}
ProjectCommand::ReferenceRemove { id } => {
+ if project
+ .image_scene
+ .as_ref()
+ .is_some_and(|scene| scene.reference_ids.contains(id))
+ {
+ return Err(format!("reference '{id}' is still used by the image; update image.set before removing it"));
+ }
let at = project
.references
.iter()
diff --git a/src-tauri/src/project/image.rs b/src-tauri/src/project/image.rs
index 285ba06..4664a4f 100644
--- a/src-tauri/src/project/image.rs
+++ b/src-tauri/src/project/image.rs
@@ -26,45 +26,94 @@ pub struct ImageNode {
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
-pub struct ImageBox { pub x: f64, pub y: f64, pub width: f64, pub height: f64 }
+pub struct ImageBox {
+ pub x: f64,
+ pub y: f64,
+ pub width: f64,
+ pub height: f64,
+}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(deny_unknown_fields)]
-pub struct ImageStyle { pub mode: String, pub aesthetics: String, pub lighting: String, pub medium: String, pub detail: String }
+pub struct ImageStyle {
+ pub mode: String,
+ pub aesthetics: String,
+ pub lighting: String,
+ pub medium: String,
+ pub detail: String,
+}
impl ImageScene {
pub fn validate(&self) -> Result<(), String> {
- if self.nodes.is_empty() || self.nodes.len() > 500 || !(1..=1000).contains(&self.steps)
+ if self.nodes.is_empty()
+ || self.nodes.len() > 500
+ || !(2..=1000).contains(&self.steps)
|| !(-1..=9_007_199_254_740_991).contains(&self.seed)
|| !matches!(self.style.mode.as_str(), "photo" | "art")
- || self.reference_ids.len() > 100 || self.reference_ids.iter().any(String::is_empty)
- || self.output_asset_id.as_ref().is_some_and(String::is_empty) {
+ || self.reference_ids.len() > 100
+ || self.reference_ids.iter().any(String::is_empty)
+ || self.output_asset_id.as_ref().is_some_and(String::is_empty)
+ {
return Err("Invalid image generation settings.".into());
}
- let nodes: HashMap<_, _> = self.nodes.iter().map(|node| (node.id.as_str(), node)).collect();
- let roots: Vec<_> = self.nodes.iter().filter(|node| node.kind == "root").collect();
+ let nodes: HashMap<_, _> = self
+ .nodes
+ .iter()
+ .map(|node| (node.id.as_str(), node))
+ .collect();
+ let roots: Vec<_> = self
+ .nodes
+ .iter()
+ .filter(|node| node.kind == "root")
+ .collect();
if nodes.len() != self.nodes.len() || roots.len() != 1 || roots[0].parent_id.is_some() {
return Err("Image nodes must form one connected tree with unique IDs.".into());
}
for node in &self.nodes {
- if node.id.is_empty() || node.name.is_empty() || node.name.chars().count() > 120
- || !matches!(node.kind.as_str(), "root" | "group" | "object" | "text" | "background")
- || node.colors.len() > 16 || node.colors.iter().any(|color| color.len() != 7 || !color.starts_with('#') || !color[1..].bytes().all(|c| c.is_ascii_hexdigit())) {
+ if node.id.is_empty()
+ || node.name.is_empty()
+ || node.name.chars().count() > 120
+ || !matches!(
+ node.kind.as_str(),
+ "root" | "group" | "object" | "text" | "background"
+ )
+ || node.colors.len() > 16
+ || node.colors.iter().any(|color| {
+ color.len() != 7
+ || !color.starts_with('#')
+ || !color[1..].bytes().all(|c| c.is_ascii_hexdigit())
+ })
+ {
return Err("Invalid image node.".into());
}
if let Some(b) = &node.r#box {
if ![b.x, b.y, b.width, b.height].iter().all(|v| v.is_finite())
- || b.x < 0.0 || b.y < 0.0 || b.x > 999.0 || b.y > 999.0
- || b.width <= 0.0 || b.height <= 0.0 || b.x + b.width > 1000.0 || b.y + b.height > 1000.0 {
+ || b.x < 0.0
+ || b.y < 0.0
+ || b.x > 999.0
+ || b.y > 999.0
+ || b.width <= 0.0
+ || b.height <= 0.0
+ || b.x + b.width > 1000.0
+ || b.y + b.height > 1000.0
+ {
return Err("Image placement must stay inside the image.".into());
}
}
let mut seen = HashSet::from([node.id.as_str()]);
let mut parent = node.parent_id.as_deref();
while let Some(id) = parent {
- if !seen.insert(id) { return Err("Image hierarchy contains a cycle.".into()); }
- parent = nodes.get(id).ok_or("Image parent does not exist.")?.parent_id.as_deref();
+ if !seen.insert(id) {
+ return Err("Image hierarchy contains a cycle.".into());
+ }
+ parent = nodes
+ .get(id)
+ .ok_or("Image parent does not exist.")?
+ .parent_id
+ .as_deref();
+ }
+ if !seen.contains(roots[0].id.as_str()) {
+ return Err("Image node is disconnected from the root.".into());
}
- if !seen.contains(roots[0].id.as_str()) { return Err("Image node is disconnected from the root.".into()); }
}
Ok(())
}
diff --git a/src-tauri/src/project/validation/mod.rs b/src-tauri/src/project/validation/mod.rs
index cd51c6e..22e325b 100644
--- a/src-tauri/src/project/validation/mod.rs
+++ b/src-tauri/src/project/validation/mod.rs
@@ -22,7 +22,14 @@ pub(crate) fn validate_checked(
mut config: ProjectConfig,
) -> Result<ProjectConfig, issue::ValidationIssue> {
if let Some(scene) = &config.image_scene {
- scene.validate().map_err(|message| issue::ValidationIssue::new("project.invalid", Some(config.id.clone()), "imageScene", message))?;
+ scene.validate().map_err(|message| {
+ issue::ValidationIssue::new(
+ "project.invalid",
+ Some(config.id.clone()),
+ "imageScene",
+ message,
+ )
+ })?;
}
settings::validate(&mut config).map_err(|message| {
issue::ValidationIssue::new(
diff --git a/src-tauri/src/slopfab/ffi/raw/mod.rs b/src-tauri/src/slopfab/ffi/raw/mod.rs
index b9a1562..f508799 100644
--- a/src-tauri/src/slopfab/ffi/raw/mod.rs
+++ b/src-tauri/src/slopfab/ffi/raw/mod.rs
@@ -371,7 +371,7 @@ impl Api {
self.error(unsafe { (self.set_frames)(r, v) })
}
pub fn set_still_image(&self, r: *mut Request) -> Result<(), String> {
- let set = self.set_still_image.ok_or("This slopfab.dll does not support still-image generation. Update the runtime to generate reference icons.")?;
+ let set = self.set_still_image.ok_or("This slopfab.dll does not support still-image generation. Update the runtime to generate images and reference icons.")?;
self.error(unsafe { set(r, 1) })
}
pub fn set_save_latents(&self, r: *mut Request, path: &Path) -> Result<(), String> {
diff --git a/src-tauri/src/slopfab/tests.rs b/src-tauri/src/slopfab/tests.rs
index 6e00680..aeb62dd 100644
--- a/src-tauri/src/slopfab/tests.rs
+++ b/src-tauri/src/slopfab/tests.rs
@@ -948,6 +948,17 @@ fn installed_dll_resolves_icons_as_one_still_frame_when_present() {
assert_eq!(plan.aligned_frames, 1);
assert_eq!(plan.latent_frames, 1);
assert_eq!((plan.canvas_width, plan.canvas_height), (768, 768));
+ for (width, height) in [(1376, 768), (768, 1376), (768, 960)] {
+ let request = GenerationRequest {
+ canvas_width: width,
+ canvas_height: height,
+ ..request.clone()
+ };
+ let plan = resolve_plan(&request, &BTreeMap::new(), &references).unwrap();
+ assert_eq!(plan.aligned_frames, 1);
+ assert_eq!(plan.latent_frames, 1);
+ assert_eq!((plan.canvas_width, plan.canvas_height), (width, height));
+ }
}
#[test]
diff --git a/src-tauri/src/tests/images.rs b/src-tauri/src/tests/images.rs
new file mode 100644
index 0000000..964b285
--- /dev/null
+++ b/src-tauri/src/tests/images.rs
@@ -0,0 +1,89 @@
+use super::*;
+
+fn image_fixture() -> ProjectConfig {
+ serde_json::from_str(include_str!("../../../fixtures/project-v1-image.json")).unwrap()
+}
+
+#[test]
+fn generated_jpeg_preserves_resolution_and_stays_inside_the_project() {
+ let folder = project_folder();
+ let root = folder.path().to_string_lossy();
+ let rgba = vec![128; 640 * 416 * 4];
+ let saved = write_generated_image_frame(&root, "image-test", 640, 416, &rgba).unwrap();
+ assert_eq!((saved.width, saved.height), (640, 416));
+ assert_eq!(saved.relative_path, "media/generated/image-test.jpg");
+ let bytes = fs::read(folder.path().join(saved.relative_path)).unwrap();
+ assert!(bytes.starts_with(&[0xff, 0xd8]));
+ // Baseline JPEG SOF: precision, then big-endian height and width.
+ let sof = bytes
+ .windows(2)
+ .position(|pair| pair == [0xff, 0xc0])
+ .unwrap();
+ assert_eq!(&bytes[sof + 5..sof + 9], &[1, 160, 2, 128]);
+ assert!(write_generated_image_frame(&root, "../escape", 640, 416, &rgba).is_err());
+ assert!(write_generated_image_frame(&root, "bad-pixels", 640, 416, &[0; 4]).is_err());
+}
+
+#[test]
+fn image_tree_survives_folder_creation_save_and_reopen() {
+ let root = tempfile::tempdir().unwrap();
+ let config = image_fixture();
+ let created = create_project_in(root.path(), &config).unwrap();
+ let folder = Path::new(&created.folder_path);
+ let mut opened = read_project(folder).unwrap();
+ opened.config.image_scene.as_mut().unwrap().nodes[2].text = "TO THE MOON".into();
+ write_project(folder, &opened.config).unwrap();
+ let reopened = read_project(folder).unwrap();
+ assert_eq!(reopened.config.generation_type, GenerationType::Image);
+ assert_eq!(reopened.config.image_scene, opened.config.image_scene);
+ assert!(reopened.config.generation_jobs.is_empty());
+ let wire = serde_json::to_value(config.clone()).unwrap();
+ assert_eq!(wire["imageScene"]["nodes"][1]["parentId"], "image-root");
+ let roundtrip: ProjectConfig = serde_json::from_value(wire).unwrap();
+ assert_eq!(roundtrip.image_scene, config.image_scene);
+}
+
+#[test]
+fn invalid_image_hierarchies_and_bounds_are_rejected() {
+ for invalid in ["cycle", "missing", "duplicate", "disconnected", "bounds"] {
+ let mut config = image_fixture();
+ let scene = config.image_scene.as_mut().unwrap();
+ match invalid {
+ "cycle" => scene.nodes[1].parent_id = Some(scene.nodes[2].id.clone()),
+ "missing" => scene.nodes[1].parent_id = Some("missing".into()),
+ "duplicate" => scene.nodes[1].id = scene.nodes[0].id.clone(),
+ "disconnected" => scene.nodes[1].parent_id = None,
+ _ => scene.nodes[1].r#box.as_mut().unwrap().width = 1000.0,
+ }
+ assert!(validate_and_normalize_config(config).is_err(), "{invalid}");
+ }
+}
+
+#[test]
+fn agent_image_edits_preserve_outputs_and_reject_video_projects_or_invalid_trees() {
+ use crate::project::commands::{execute_commands_at, ProjectCommand};
+ let mut config = image_fixture();
+ config.image_scene.as_mut().unwrap().output_asset_id = Some("generated-picture".into());
+ let mut command = serde_json::to_value(config.image_scene.as_ref().unwrap()).unwrap();
+ command.as_object_mut().unwrap().remove("outputAssetId");
+ command["op"] = serde_json::json!("image.set");
+ command["background"] = serde_json::json!("A moonlit ocean");
+ let parsed: ProjectCommand = serde_json::from_value(command.clone()).unwrap();
+ let next = execute_commands_at(&config, &[parsed.clone()], &config.updated_at).unwrap();
+ assert_eq!(
+ next.image_scene.as_ref().unwrap().background,
+ "A moonlit ocean"
+ );
+ assert_eq!(
+ next.image_scene
+ .as_ref()
+ .unwrap()
+ .output_asset_id
+ .as_deref(),
+ Some("generated-picture")
+ );
+ assert!(execute_commands_at(&created_fixture(), &[parsed], &config.updated_at).is_err());
+ command["nodes"][1]["parentId"] = serde_json::json!("missing");
+ let parsed: ProjectCommand = serde_json::from_value(command).unwrap();
+ assert!(execute_commands_at(&config, &[parsed], &config.updated_at).is_err());
+}
diff --git a/src-tauri/src/tests/mod.rs b/src-tauri/src/tests/mod.rs
index a21bf70..ba75761 100644
--- a/src-tauri/src/tests/mod.rs
+++ b/src-tauri/src/tests/mod.rs
@@ -122,6 +122,7 @@ fn project_folder() -> tempfile::TempDir {
}
mod artifacts;
+mod images;
mod media_access;
mod persistence;
mod references;
diff --git a/src/components/ImageProject.integration.test.tsx b/src/components/ImageProject.integration.test.tsx
new file mode 100644
index 0000000..a51993d
--- /dev/null
+++ b/src/components/ImageProject.integration.test.tsx
@@ -0,0 +1,57 @@
+// @vitest-environment jsdom
+import "@testing-library/jest-dom/vitest";
+import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";
+import { afterEach, expect, it, vi } from "vitest";
+import { ProjectWorkspace } from "./ProjectWorkspace";
+import { PromptComposer } from "./PromptComposer";
+import { createProjectConfig, parseProjectConfig, type ProjectRecord } from "../lib/project";
+import { executeAgentCommands } from "../lib/runtime";
+import fixture from "../../fixtures/project-v1-image.json";
+
+vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));
+vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn(async () => () => undefined) }));
+afterEach(() => { cleanup(); localStorage.clear(); });
+const record = (): ProjectRecord => ({ folderPath: "D:/Images", config: parseProjectConfig(fixture) });
+
+it("offers image and video projects when creating a folder project", async () => {
+ const submit = vi.fn(async () => undefined);
+ render(<PromptComposer busy={false} onCreate={submit} onClose={vi.fn()} />);
+ fireEvent.change(screen.getByLabelText("Project type"), { target: { value: "image" } });
+ expect(screen.getByLabelText("Project name")).toHaveValue("Untitled image");
+ expect(screen.getByText("Image settings")).toBeInTheDocument();
+ fireEvent.click(screen.getByRole("button", { name: /Create project/ }));
+ await waitFor(() => expect(submit).toHaveBeenCalledWith(expect.objectContaining({ generationType: "image" })));
+});
+
+it("opens the three-tab image workspace and saves hierarchy/inspector edits through the project session", async () => {
+ const save = vi.fn(async () => undefined);
+ render(<ProjectWorkspace project={record()} onBack={vi.fn()} onSave={save} />);
+ const navigation = within(screen.getByRole("navigation", { name: "Project views" }));
+ expect(navigation.getAllByRole("button").map((button) => button.textContent)).toEqual([" Agent", " Editor", " References"]);
+ fireEvent.click(screen.getByRole("button", { name: "Text" }));
+ fireEvent.change(screen.getByLabelText("Text to render"), { target: { value: "Hello world" } });
+ fireEvent.change(screen.getByLabelText("Description"), { target: { value: "Large blue letters" } });
+ fireEvent.click(screen.getByRole("button", { name: "Save" }));
+ await waitFor(() => expect(save).toHaveBeenCalled());
+ expect(save.mock.calls[0]).toBeDefined();
+ const saved = (save.mock.calls as unknown as [ProjectRecord][])[0][0];
+ expect(saved.config.imageScene?.nodes.at(-1)).toMatchObject({ kind: "text", text: "Hello world", description: "Large blue letters", parentId: "image-root" });
+ expect(parseProjectConfig(saved.config).imageScene).toEqual(saved.config.imageScene);
+ fireEvent.click(navigation.getByRole("button", { name: "References" }));
+ fireEvent.click(navigation.getByRole("button", { name: "Editor" }));
+ expect(screen.getByRole("tree", { name: "Image nodes" })).toBeInTheDocument();
+});
+
+it("keeps the video tabs and applies image agent commands without changing generated output", async () => {
+ const image = record().config;
+ const { outputAssetId: _output, ...authored } = image.imageScene!;
+ const next = await executeAgentCommands(image, [{ op: "image.set", ...authored, background: "A moonlit ocean" }]);
+ expect(next.imageScene?.background).toBe("A moonlit ocean");
+ const video = createProjectConfig({ name: "Film", prompt: "", aspectRatio: "16:9", resolution: "768p", targetDurationSeconds: 60 });
+ await expect(executeAgentCommands(video, [{ op: "image.set", ...authored }])).rejects.toThrow("image project");
+ render(<ProjectWorkspace project={{ folderPath: "D:/Film", config: video }} onBack={vi.fn()} onSave={vi.fn()} />);
+ const navigation = within(screen.getByRole("navigation", { name: "Project views" }));
+ expect(navigation.getByRole("button", { name: "Timeline" })).toBeInTheDocument();
+ expect(navigation.getByRole("button", { name: "Generator" })).toBeInTheDocument();
+ expect(navigation.queryByRole("button", { name: "Editor" })).not.toBeInTheDocument();
+});
diff --git a/src/components/workspace/AgentDock.tsx b/src/components/workspace/AgentDock.tsx
index 1276b86..879edc4 100644
--- a/src/components/workspace/AgentDock.tsx
+++ b/src/components/workspace/AgentDock.tsx
@@ -87,7 +87,7 @@ export function AgentDock({ context, record, providers, expanded, onPromptStart,
? [selected.detail, providerNextStep(selected)].filter(Boolean).join(" ")
: null;
const placeholder = ready
- ? `Ask Slop to write a new scene from a prompt, refine ${context}, or make an edit…`
+ ? record.config.generationType === "image" ? "Ask Slop to compose an image, describe objects, or refine the layout…" : `Ask Slop to write a new scene from a prompt, refine ${context}, or make an edit…`
: blockedDetail ?? "No agent provider is available";
const providerStatusLabel = requestId && selected
? `${selected.label} status: Processing`
diff --git a/src/components/workspace/ImageEditor.tsx b/src/components/workspace/ImageEditor.tsx
index c3f181c..d5da319 100644
--- a/src/components/workspace/ImageEditor.tsx
+++ b/src/components/workspace/ImageEditor.tsx
@@ -21,7 +21,7 @@ export function ImageEditor({ config, folderPath, onChange, onGenerate, onCancel
const selected = scene.nodes.find((node) => node.id === selection) ?? root;
const [collapsed, setCollapsed] = useState(new Set<string>());
const [templates, setTemplates] = useState(loadGeneratorTemplateSettings);
- const [templateId, setTemplateId] = useState(() => defaultGeneratorTemplate().id);
+ const [templateId, setTemplateId] = useState(() => localStorage.getItem("slopus.image-generator-template.v1") ?? defaultGeneratorTemplate().id);
const imageTemplates = templates.templates.filter((template) => template.mode !== "animate");
const template = imageTemplates.find((candidate) => candidate.id === templateId) ?? imageTemplates.find((candidate) => !templateNeedsDownload(candidate)) ?? imageTemplates[0];
const [error, setError] = useState<string | null>(null);
@@ -99,7 +99,7 @@ export function ImageEditor({ config, folderPath, onChange, onGenerate, onCancel
return <div key={node.id} role="treeitem" aria-selected={selected.id === node.id} aria-expanded={children.length ? open : undefined}>
<div className={`image-tree__row ${selected.id === node.id ? "selected" : ""}`} style={{ paddingLeft: `calc(var(--space-2) + ${depth} * var(--space-4))` }}>
{children.length ? <button className="icon-button" aria-label={`${open ? "Collapse" : "Expand"} ${node.name}`} onClick={() => setCollapsed((current) => { const next = new Set(current); if (open) next.add(node.id); else next.delete(node.id); return next; })}>{open ? <ChevronDown size={14} /> : <ChevronRight size={14} />}</button> : <span className="image-tree__spacer" />}
- <button className="image-tree__select" onClick={() => setSelection(node.id)}><span>{node.kind === "text" ? "T" : node.kind === "root" ? <Image size={16} /> : <Box size={16} />}</span><span>{node.name}</span></button>
+ <button className="image-tree__select" onClick={() => setSelection(node.id)}><span aria-hidden="true">{node.kind === "text" ? "T" : node.kind === "root" ? <Image size={16} /> : <Box size={16} />}</span><span>{node.name}</span></button>
</div>
{open && children.length > 0 && <div role="group">{children.map((child) => tree(child, depth + 1))}</div>}
</div>;
@@ -113,7 +113,7 @@ export function ImageEditor({ config, folderPath, onChange, onGenerate, onCancel
</aside>
<section className="image-center" aria-label="Image panel">
<header className="image-toolbar"><button className="primary-button" disabled={active ? work.cancelling || work.status === "encoding" : !isTauri() || !template || templateNeedsDownload(template) || !imageScenePrompt(scene)} onClick={() => attempt(() => active ? onCancel(work.id) : onGenerate(template!))}><Sparkles size={16} />{active ? work.cancelling ? "Cancelling…" : "Cancel" : "Generate"}</button>
- <label>Generator template<select aria-label="Image generator template" value={template?.id ?? ""} disabled={Boolean(active)} onChange={(event) => { setTemplateId(event.target.value); const next = imageTemplates.find((candidate) => candidate.id === event.target.value); if (next) commit({ ...scene, steps: next.defaultSteps }); }}>
+ <label>Generator template<select aria-label="Image generator template" value={template?.id ?? ""} disabled={Boolean(active)} onChange={(event) => { setTemplateId(event.target.value); localStorage.setItem("slopus.image-generator-template.v1", event.target.value); const next = imageTemplates.find((candidate) => candidate.id === event.target.value); if (next) commit({ ...scene, steps: next.defaultSteps }); }}>
{!imageTemplates.length && <option value="">No MiniMax H3 templates</option>}{imageTemplates.map((item) => <option key={item.id} value={item.id} disabled={templateNeedsDownload(item)}>{item.name}{templateNeedsDownload(item) ? " (download in Settings)" : ""}</option>)}
</select></label><span className="image-model">MiniMax H3</span>
</header>
@@ -127,10 +127,11 @@ export function ImageEditor({ config, folderPath, onChange, onGenerate, onCancel
<svg className={`image-overlay ${drawKind ? "drawing" : ""}`} viewBox="0 0 1000 1000" preserveAspectRatio="none" aria-label="Image placement canvas" onPointerDown={pointerDown} onPointerMove={pointerMove} onPointerUp={pointerUp} onPointerCancel={() => { pointer.current = null; setDraftBox(null); }}>
{boxes && scene.nodes.filter((node) => node.box).map((node) => {
const box = pointer.current?.id === node.id && draftBox ? draftBox : node.box!;
- return <g key={node.id} className={selected.id === node.id ? "selected" : ""}><rect data-node={node.id} x={box.x} y={box.y} width={box.width} height={box.height} vectorEffect="non-scaling-stroke" /><text x={box.x + 8} y={box.y + 30}>{node.name}</text>{selected.id === node.id && <rect className="image-box-handle" data-node={node.id} data-resize="true" x={box.x + box.width - 16} y={box.y + box.height - 16} width="16" height="16" />}</g>;
+ return <g key={node.id} className={selected.id === node.id ? "selected" : ""}><rect data-node={node.id} x={box.x} y={box.y} width={box.width} height={box.height} vectorEffect="non-scaling-stroke" />{selected.id === node.id && <rect className="image-box-handle" data-node={node.id} data-resize="true" x={box.x + box.width - 16} y={box.y + box.height - 16} width="16" height="16" />}</g>;
})}
{draftBox && !pointer.current?.id && <rect className="image-box-draft" {...{ x: draftBox.x, y: draftBox.y, width: draftBox.width, height: draftBox.height }} />}
</svg>
+ {boxes && scene.nodes.filter((node) => node.box).map((node) => { const box = pointer.current?.id === node.id && draftBox ? draftBox : node.box!; return <span key={node.id} className="image-box-label" style={{ left: `${box.x / 10}%`, top: `${box.y / 10}%` }}>{node.name}</span>; })}
</div></div>
<div className="image-status" role="status">{active && <progress value={work.progress} max="1" />}<span>{active ? work.detail : !isTauri() ? "Image generation is available in the desktop app." : `${width} × ${height} · Placement boxes guide the prompt.`}</span></div>
{(error || work?.error) && <p className="image-error" role="alert">{error ?? work?.error}</p>}
@@ -143,7 +144,7 @@ export function ImageEditor({ config, folderPath, onChange, onGenerate, onCancel
{selected.kind !== "root" && <label>Parent<select value={selected.parentId ?? root.id} onChange={(event) => patchNode({ parentId: event.target.value })}>{scene.nodes.filter((node) => !descendants.has(node.id)).map((node) => <option key={node.id} value={node.id}>{node.name}</option>)}</select></label>}
{selected.kind === "root" && <>
<label>Background (environment)<textarea rows={3} value={scene.background} onChange={(event) => commit({ ...scene, background: event.target.value })} /></label>
- <h3>Image generation</h3><label>Steps<input type="number" min="1" max="1000" value={scene.steps} onChange={(event) => { const value = Number(event.target.value); if (Number.isInteger(value) && value >= 1 && value <= 1000) commit({ ...scene, steps: value }); }} /></label>
+ <h3>Image generation</h3><label>Steps<input type="number" min="2" max="1000" value={scene.steps} onChange={(event) => { const value = Number(event.target.value); if (Number.isInteger(value) && value >= 2 && value <= 1000) commit({ ...scene, steps: value }); }} /></label>
<label>Seed (−1 = random)<input type="number" min="-1" max={Number.MAX_SAFE_INTEGER} value={scene.seed} onChange={(event) => { const value = Number(event.target.value); if (Number.isSafeInteger(value) && value >= -1) commit({ ...scene, seed: value }); }} /></label>
<label>Aspect ratio<select value={config.settings.aspectRatio} onChange={(event) => { const aspectRatio = event.target.value as ProjectConfig["settings"]["aspectRatio"]; onChange((current) => ({ ...current, settings: { ...current.settings, aspectRatio }, brief: { ...current.brief, aspectRatio } })); }}>{["16:9", "9:16", "1:1", "4:5"].map((ratio) => <option key={ratio}>{ratio}</option>)}</select></label>
<label>Resolution<select value={config.settings.resolution} onChange={(event) => { const resolution = event.target.value as ProjectConfig["settings"]["resolution"]; onChange((current) => ({ ...current, settings: { ...current.settings, resolution }, brief: { ...current.brief, resolution } })); }}>{[...new Set([...PROJECT_RESOLUTIONS, config.settings.resolution])].map((resolution) => { const size = outputDimensions(resolution, config.settings.aspectRatio); return <option key={resolution} value={resolution}>{size.width} × {size.height}</option>; })}</select></label>
diff --git a/src/lib/imageScene.test.ts b/src/lib/imageScene.test.ts
new file mode 100644
index 0000000..f790725
--- /dev/null
+++ b/src/lib/imageScene.test.ts
@@ -0,0 +1,48 @@
+import { describe, expect, it } from "vitest";
+import imageFixture from "../../fixtures/project-v1-image.json";
+import oldFixture from "../../fixtures/project-v1-created.json";
+import { addImageNode, createImageScene, duplicateImageNode, imageScenePrompt, imageSceneSchema, removeImageNode, resizeImageNode } from "./imageScene";
+import { createProjectConfig, parseProjectConfig } from "./project";
+
+describe("image documents", () => {
+ it("opens old projects as video and round-trips image authoring without creating video jobs", () => {
+ expect(parseProjectConfig(oldFixture).generationType).toBe("video");
+ const project = createProjectConfig({ name: "Poster", prompt: "A still life", generationType: "image", aspectRatio: "1:1", resolution: "768p", targetDurationSeconds: 60 });
+ expect(project.generationJobs).toEqual([]);
+ expect(project.imageScene?.nodes[0].description).toBe("A still life");
+ expect(parseProjectConfig(JSON.parse(JSON.stringify(project)))).toEqual(project);
+ expect(parseProjectConfig(imageFixture).imageScene).toEqual(imageFixture.imageScene);
+ });
+ it("rejects duplicate IDs, cycles, disconnected nodes and invalid placement", () => {
+ const scene = imageSceneSchema.parse(imageFixture.imageScene);
+ const bad = (change: (copy: typeof scene) => void) => { const copy = structuredClone(scene); change(copy); expect(imageSceneSchema.safeParse(copy).success).toBe(false); };
+ bad((copy) => { copy.nodes[1].id = copy.nodes[0].id; });
+ bad((copy) => { copy.nodes[1].parentId = copy.nodes[2].id; });
+ bad((copy) => { copy.nodes[1].parentId = null; });
+ bad((copy) => { copy.nodes[1].box!.width = 1000; });
+ bad((copy) => { copy.nodes[1].parentId = "missing"; });
+ });
+ it("duplicates and removes entire subtrees without breaking relationships", () => {
+ const scene = imageSceneSchema.parse(imageFixture.imageScene);
+ const duplicate = duplicateImageNode(scene, "group-rocket");
+ expect(duplicate.nodes).toHaveLength(5);
+ expect(duplicate.nodes[4].parentId).toBe(duplicate.nodes[3].id);
+ const removed = removeImageNode(duplicate, "group-rocket");
+ expect(removed.nodes).toHaveLength(3);
+ expect(imageSceneSchema.safeParse(removed).success).toBe(true);
+ expect(removeImageNode(scene, "image-root")).toBe(scene);
+ });
+ it("transforms child boxes with their group and compiles nested descriptions and exact text", () => {
+ const scene = imageSceneSchema.parse(imageFixture.imageScene);
+ const resized = resizeImageNode(scene, "group-rocket", { x: 100, y: 100, width: 200, height: 400 });
+ expect(resized.nodes[2].box).toEqual({ x: 125, y: 125, width: 150, height: 50 });
+ const prompt = imageScenePrompt(resized);
+ expect(prompt).toContain('Render the exact text "LIFT OFF"');
+ expect(prompt).toContain("white rocket surrounded by glowing vapor");
+ expect(prompt).toContain("left 12.5%");
+ expect(prompt).toContain("Screen print");
+ expect(prompt).toContain("#FF0000");
+ expect(imageScenePrompt(createImageScene())).toBe("");
+ expect(addImageNode(createImageScene(), "image-root", "object").nodes).toHaveLength(2);
+ });
+});
diff --git a/src/lib/imageScene.ts b/src/lib/imageScene.ts
index 37888c3..9e8b681 100644
--- a/src/lib/imageScene.ts
+++ b/src/lib/imageScene.ts
@@ -12,7 +12,7 @@ export const imageSceneSchema = z.object({
nodes: z.array(imageNodeSchema).min(1).max(500),
background: z.string(),
style: z.object({ mode: z.enum(["photo", "art"]), aesthetics: z.string(), lighting: z.string(), medium: z.string(), detail: z.string() }),
- steps: z.number().int().min(1).max(1000), seed: z.number().int().min(-1).max(Number.MAX_SAFE_INTEGER),
+ steps: z.number().int().min(2).max(1000), seed: z.number().int().min(-1).max(Number.MAX_SAFE_INTEGER),
referenceIds: z.array(z.string().min(1)).max(100),
outputAssetId: z.string().min(1).nullable(),
}).superRefine((scene, context) => {
diff --git a/src/lib/runtime.ts b/src/lib/runtime.ts
index d79505c..b447b0d 100644
--- a/src/lib/runtime.ts
+++ b/src/lib/runtime.ts
@@ -345,6 +345,7 @@ function executeDemoCommands(config: ProjectConfig, commands: ProjectCommand[]):
break;
}
case "ref.remove": {
+ if (next.imageScene?.referenceIds.includes(command.id)) throw new Error(`Reference '${command.id}' is still used by the image; update image.set before removing it.`);
const token = `@[ref:${command.id}]`;
if (next.generationJobs.some((job) => job.startFrameReferenceId === command.id || job.endFrameReferenceId === command.id || job.shots?.some((shot) => shot.action.includes(token)))) {
throw new Error(`Reference '${command.id}' is still used by a scene.`);
diff --git a/src/lib/workQueue.test.ts b/src/lib/workQueue.test.ts
index 2422855..50cb78b 100644
--- a/src/lib/workQueue.test.ts
+++ b/src/lib/workQueue.test.ts
@@ -7,7 +7,7 @@ import { releaseRendered, saveGeneratedScene } from "./generatedVideo";
import { createProjectConfig, parseProjectConfig, type ProjectRecord } from "./project";
import { ProjectSession } from "./projectSession";
import { cancelSlopfabGeneration, enqueueSlopfabGeneration, resolveSlopfabPlan } from "./runtime";
-import { saveEngineSettings, EMPTY_ENGINE_SETTINGS } from "./settings";
+import { saveEngineSettings, EMPTY_ENGINE_SETTINGS, type GeneratorTemplate } from "./settings";
import { WorkQueue, type GenerationSubmission } from "./workQueue";
import { saveSceneLastFrame } from "./sceneLastFrame";
import { prepareReferenceVideos, releaseReferenceVideos } from "./referenceVideo";
@@ -52,6 +52,58 @@ const finish = async (queue: WorkQueue, id: string) => {
await waitFor(() => expect(queue.getSnapshot().find((item) => item.id === id)?.status).toBe("completed"));
};
+describe("image generation work", () => {
+ const template: GeneratorTemplate = { id: "image-test", name: "MiniMax H3", defaultSteps: 20, attention: "sage2", paths: { ...EMPTY_ENGINE_SETTINGS, transformer: "C:/h3.safetensors" } };
+ const imageProject = (): ProjectRecord => ({ folderPath: "C:/Image", config: createProjectConfig({ name: "Poster", prompt: "An ocean poster", generationType: "image", aspectRatio: "1:1", resolution: "768p", targetDurationSeconds: 60 }) });
+ it("generates one native still, preserves ongoing edits, saves full-size JPEG, and releases frames", async () => {
+ const { queue } = setup(); const session = queue.project(imageProject());
+ vi.mocked(invoke).mockResolvedValue({ relativePath: "media/generated/still.jpg", width: 768, height: 768 });
+ queue.enqueueImage(session, template);
+ await waitFor(() => expect(enqueueSlopfabGeneration).toHaveBeenCalledOnce());
+ const [request, config] = vi.mocked(enqueueSlopfabGeneration).mock.calls[0];
+ expect(request).toMatchObject({ stillImage: true, frames: 1, canvasWidth: 768, canvasHeight: 768 });
+ expect(config.providerSettings.slopfab.options.transformer).toBe("C:/h3.safetensors");
+ session.update((current) => ({ ...current, imageScene: { ...current.imageScene!, background: "Edited during generation" } }));
+ await finish(queue, queue.getSnapshot().find((item) => item.kind === "image")!.id);
+ expect(invoke).toHaveBeenCalledWith("save_generated_image", { folderPath: "C:/Image", jobId: request.jobId });
+ const saved = session.getSnapshot().config;
+ expect(saved.imageScene?.background).toBe("Edited during generation");
+ expect(saved.imageScene?.outputAssetId).toBe(request.jobId);
+ expect(saved.assets[0]).toMatchObject({ kind: "image", mimeType: "image/jpeg", relativePath: "media/generated/still.jpg", width: 768, height: 768 });
+ expect(saved.generationJobs).toHaveLength(0);
+ expect(saveGeneratedScene).not.toHaveBeenCalled();
+ expect(releaseRendered).toHaveBeenCalledWith(request.jobId);
+ expect(parseProjectConfig(JSON.parse(JSON.stringify(saved))).imageScene).toEqual(saved.imageScene);
+ });
+ it("serializes image and video work and allows cancellation before native submission", async () => {
+ const { queue, first } = setup(); const session = queue.project(imageProject());
+ queue.enqueue(first, [submission(first)]);
+ await waitFor(() => expect(enqueueSlopfabGeneration).toHaveBeenCalledOnce());
+ queue.enqueueImage(session, template);
+ const image = queue.getSnapshot().find((item) => item.kind === "image")!;
+ expect(image.status).toBe("queued");
+ await queue.cancel(image.id);
+ expect(queue.getSnapshot().find((item) => item.id === image.id)?.status).toBe("cancelled");
+ await finish(queue, queue.getSnapshot()[0].id);
+ expect(enqueueSlopfabGeneration).toHaveBeenCalledOnce();
+ expect(session.getSnapshot().config.assets).toHaveLength(0);
+ });
+ it("retains the saved image for retry when writing the project fails", async () => {
+ const { queue, saved } = setup(); const session = queue.project(imageProject());
+ vi.mocked(invoke).mockResolvedValue({ relativePath: "media/generated/still.jpg", width: 768, height: 768 });
+ queue.enqueueImage(session, template);
+ await waitFor(() => expect(enqueueSlopfabGeneration).toHaveBeenCalledOnce());
+ saved.mockRejectedValueOnce(new Error("Disk unavailable"));
+ const id = queue.getSnapshot().find((item) => item.kind === "image")!.id;
+ emit("slopfab-job", { jobId: id, state: "framesReady", detail: "Ready" });
+ await waitFor(() => expect(queue.getSnapshot().find((item) => item.id === id)?.needsSave).toBe(true));
+ expect(session.getSnapshot().config.imageScene?.outputAssetId).toBe(id);
+ expect(releaseRendered).toHaveBeenCalledWith(id);
+ await queue.retrySave(id);
+ expect(queue.getSnapshot().find((item) => item.id === id)).toMatchObject({ status: "completed", needsSave: false });
+ });
+});
+
describe("application work queue", () => {
it("prepares video inputs for both planning and generation and releases them after completion", async () => {
const { queue, first } = setup();
diff --git a/src/lib/workQueue.ts b/src/lib/workQueue.ts
index d3fbfc0..5aae431 100644
--- a/src/lib/workQueue.ts
+++ b/src/lib/workQueue.ts
@@ -2,8 +2,9 @@ import { listen } from "@tauri-apps/api/event";
import { invoke } from "@tauri-apps/api/core";
import { createImageScene, imageScenePrompt } from "./imageScene";
import { outputDimensions } from "./export";
-import { projectItemPath, referenceImages, referenceRefmodInputs } from "./project";
+import { projectItemPath, referenceDefinition, referenceImages, referenceRefmodInputs } from "./project";
import { engineProviderSetting, type GeneratorTemplate } from "./settings";
+import { SHOT_TAG_GROUPS } from "./shot-tags";
import { describeDiagnosticError, writeDiagnostic } from "./diagnostics";
import { GenerationTimingEstimator, type CompletedGenerationTiming, type GenerationTimingProgress } from "./generationTiming";
import { releaseRendered, saveGeneratedScene } from "./generatedVideo";
@@ -212,10 +213,17 @@ export class WorkQueue {
return reference;
});
const { width, height } = outputDimensions(current.settings.resolution, current.settings.aspectRatio);
+ let picture = 0;
+ const referencePrompts = references.map((reference) => {
+ const labels = referenceImages(reference).map(() => `<Picture ${++picture}>`);
+ return `${referenceDefinition(reference)}${labels.length ? ` Use ${labels.join(", ")} as visual references for this subject.` : ""}`;
+ });
+ if (picture > 9) throw new Error("MiniMax H3 supports at most nine reference images per generation.");
+ const look = SHOT_TAG_GROUPS.find((group) => group.id === "visualStyle")?.options.find((option) => option.id === current.settings.defaultLook)?.label;
const id = `image-${crypto.randomUUID()}`;
let finish!: () => void;
const done = new Promise<void>((resolve) => { finish = resolve; });
- const request: SlopfabGenerationRequest = { jobId: id, stillImage: true, frames: 1, prompt: [prompt, ...references.map((reference) => `${reference.name}: ${reference.description}`)].join("\n"),
+ const request: SlopfabGenerationRequest = { jobId: id, stillImage: true, frames: 1, prompt: [prompt, ...(look ? [`Visual style: ${look}.`] : []), ...referencePrompts].join("\n"),
canvasWidth: width, canvasHeight: height, steps: generationStepsWithLoras(scene.steps, config), seed: scene.seed,
referencePaths: references.flatMap((reference) => referenceImages(reference).map((image) => projectItemPath(session.record.folderPath, image)!)),
refmods: referenceRefmodInputs(session.record.folderPath, references),
diff --git a/src/styles/image-editor.css b/src/styles/image-editor.css
index 16d8930..ba6f4a1 100644
--- a/src/styles/image-editor.css
+++ b/src/styles/image-editor.css
@@ -1,5 +1,6 @@
.project-content--editor { padding: 0; overflow: hidden; }
.image-editor { display: grid; grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) minmax(220px, 300px); height: 100%; min-height: 0; }
+.image-editor input:not([type="checkbox"]):not([type="range"]):not([type="color"]), .image-editor select, .image-editor textarea { min-height: var(--field-height); padding: var(--space-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--field-bg); color: var(--text-primary); }
.image-editor header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-3); border-bottom: 1px solid var(--line-solid); }
.image-tree, .image-inspector { min-height: 0; overflow: auto; background: var(--panel); }
.image-tree { display: flex; flex-direction: column; border-right: 1px solid var(--line-solid); }
@@ -31,7 +32,7 @@
.image-overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.image-overlay rect { fill: color-mix(in srgb, var(--accent) 8%, transparent); stroke: var(--accent); stroke-width: 1.5; cursor: move; }
.image-overlay .selected > rect { stroke-width: 3; }
-.image-overlay text { fill: var(--accent); font: 24px var(--font-sans); paint-order: stroke; stroke: var(--panel); stroke-width: 3px; pointer-events: none; }
+.image-box-label { position: absolute; margin: var(--space-1); padding: 0 var(--space-1); border-radius: var(--radius-sm); color: var(--text-primary); background: var(--panel); font-size: var(--text-xs); pointer-events: none; }
.image-overlay .image-box-handle { fill: var(--accent); cursor: nwse-resize; }
.image-overlay.drawing, .image-overlay.drawing rect { cursor: crosshair; }
.image-status { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-2) var(--space-3); font-size: var(--text-xs); border-top: 1px solid var(--line-solid); }
@@ -53,4 +54,4 @@
.image-palette { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.image-palette > div { display: flex; align-items: center; }
.image-palette input[type="color"] { width: var(--control-sm); height: var(--control-sm); padding: var(--space-1); }
-@media (max-width: 1100px) { .image-editor { grid-template-columns: 180px minmax(0, 1fr) 240px; } .image-model { display: none; } }
+@media (max-width: 1100px) { .image-editor { grid-template-columns: 180px minmax(0, 1fr) 240px; } .image-tree__add { grid-template-columns: 1fr; } .image-model { display: none; } }