Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Add generation-time LCS effects

Bittidcb4282cd7f3
diff --git a/fixtures/generation-effects.json b/fixtures/generation-effects.json
new file mode 100644
index 0000000..bafc5ab
--- /dev/null
+++ b/fixtures/generation-effects.json
@@ -0,0 +1,9 @@
+{
+ "color": { "color": "#804020", "strength": 0.5, "mode": "interpolated" },
+ "tone": { "contrast": 1.25, "brightness": -0.1, "saturation": 0.9, "temperature": 0.2 },
+ "sharpness": { "strength": 0.1, "enabled": false },
+ "anchor": { "mode": "self", "strength": 0.3 },
+ "startStep": 2,
+ "endStep": 12,
+ "region": { "x": 25, "y": 0, "width": 50, "height": 100, "invert": false }
+}
diff --git a/src-tauri/core/src/generation_effects.rs b/src-tauri/core/src/generation_effects.rs
new file mode 100644
index 0000000..1ff1700
--- /dev/null
+++ b/src-tauri/core/src/generation_effects.rs
@@ -0,0 +1,128 @@
+//! Portable authoring settings; calibration files belong to the generation host.
+use serde::{Deserialize, Serialize};
+use serde_json::{json, Value};
+
+#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase", deny_unknown_fields)]
+pub struct GenerationEffects {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub color: Option<Color>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub tone: Option<Tone>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub sharpness: Option<Strength>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub anchor: Option<Anchor>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub start_step: Option<i32>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub end_step: Option<i32>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub region: Option<Region>,
+}
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
+pub struct Color {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub enabled: Option<bool>, pub color: String, pub strength: f32, pub mode: String,
+}
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
+pub struct Tone {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub enabled: Option<bool>, pub contrast: f32, pub brightness: f32, pub saturation: f32, pub temperature: f32,
+}
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
+pub struct Strength { #[serde(default, skip_serializing_if = "Option::is_none")] pub enabled: Option<bool>, pub strength: f32 }
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
+pub struct Anchor { #[serde(default, skip_serializing_if = "Option::is_none")] pub enabled: Option<bool>, pub mode: String, pub strength: f32 }
+#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
+#[serde(deny_unknown_fields)]
+pub struct Region { pub x: f32, pub y: f32, pub width: f32, pub height: f32, pub invert: bool }
+
+fn range(value: f32, min: f32, max: f32) -> bool { value.is_finite() && (min..=max).contains(&value) }
+impl GenerationEffects {
+ pub fn validate(&self) -> Result<(), String> {
+ let invalid = self.color.as_ref().is_some_and(|c| !range(c.strength, 0.0, 2.0)
+ || c.color.len() != 7 || !c.color.starts_with('#') || !c.color.as_bytes()[1..].iter().all(u8::is_ascii_hexdigit)
+ || !matches!(c.mode.as_str(), "interpolated" | "type_i" | "type_ii"))
+ || self.tone.as_ref().is_some_and(|t| !range(t.contrast, 0.0, 4.0) || !range(t.brightness, -1.0, 1.0) || !range(t.saturation, 0.0, 4.0) || !range(t.temperature, -1.0, 1.0))
+ || self.sharpness.as_ref().is_some_and(|s| !range(s.strength, -5.0, 5.0))
+ || self.anchor.as_ref().is_some_and(|a| !range(a.strength, 0.0, 1.0) || !matches!(a.mode.as_str(), "self" | "smooth"))
+ || self.start_step.unwrap_or(0) < 0 || self.end_step.unwrap_or(i32::MAX) < self.start_step.unwrap_or(0)
+ || self.region.as_ref().is_some_and(|r| !range(r.x, 0.0, 100.0) || !range(r.y, 0.0, 100.0) || !range(r.width, 0.1, 100.0) || !range(r.height, 0.1, 100.0) || r.x + r.width > 100.0 || r.y + r.height > 100.0);
+ if invalid { Err("Invalid generation effects settings.".into()) } else { Ok(()) }
+ }
+
+ /// Translate to the native LCS schema; bypassed/neutral cards do no work.
+ pub fn native_settings(&self) -> Result<Option<Value>, String> {
+ self.validate()?;
+ let mut settings = json!({});
+ if let Some(c) = self.color.as_ref().filter(|c| c.enabled != Some(false) && c.strength != 0.0) {
+ let rgb: Vec<f32> = [1, 3, 5].into_iter().map(|i| u8::from_str_radix(&c.color[i..i + 2], 16).unwrap() as f32 / 255.0).collect();
+ settings["color"] = json!(rgb); settings["strength"] = json!(c.strength); settings["mode"] = json!(c.mode);
+ }
+ if let Some(t) = self.tone.as_ref().filter(|t| t.enabled != Some(false) && (t.contrast != 1.0 || t.brightness != 0.0 || t.saturation != 1.0 || t.temperature != 0.0)) {
+ settings["contrast"] = json!(t.contrast); settings["brightness"] = json!(t.brightness);
+ settings["saturation"] = json!(t.saturation); settings["temperature"] = json!(t.temperature);
+ }
+ if let Some(s) = self.sharpness.as_ref().filter(|s| s.enabled != Some(false) && s.strength != 0.0) { settings["sharpness"] = json!(s.strength); }
+ if let Some(a) = self.anchor.as_ref().filter(|a| a.enabled != Some(false) && a.strength != 0.0) { settings["anchor"] = json!(a.mode); settings["anchor_strength"] = json!(a.strength); }
+ if settings.as_object().unwrap().is_empty() { return Ok(None); }
+ settings["start_step"] = json!(self.start_step.unwrap_or(0));
+ settings["end_step"] = json!(self.end_step.unwrap_or(i32::MAX));
+ Ok(Some(settings))
+ }
+
+ pub fn mask(&self, width: i32, height: i32) -> Result<Option<Vec<f32>>, String> {
+ self.validate()?;
+ let Some(r) = &self.region else { return Ok(None); };
+ if width <= 0 || height <= 0 || i64::from(width) * i64::from(height) > 4_194_304 { return Err("Invalid LCS mask dimensions.".into()); }
+ // Fractional coverage keeps small regions useful at latent resolution.
+ let overlap = |index: i32, count: i32, start: f32, size: f32| {
+ let left = start / 100.0 * count as f32;
+ let right = (start + size) / 100.0 * count as f32;
+ (right.min((index + 1) as f32) - left.max(index as f32)).clamp(0.0, 1.0)
+ };
+ Ok(Some((0..height).flat_map(|y| (0..width).map(move |x| {
+ let coverage = overlap(x, width, r.x, r.width) * overlap(y, height, r.y, r.height);
+ if r.invert { 1.0 - coverage } else { coverage }
+ })).collect()))
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ #[test]
+ fn shared_fixture_roundtrips_and_maps_to_native_controls() {
+ let fixture: Value = serde_json::from_str(include_str!("../../../fixtures/generation-effects.json")).unwrap();
+ let effects: GenerationEffects = serde_json::from_value(fixture.clone()).unwrap();
+ effects.validate().unwrap();
+ let native = effects.native_settings().unwrap().unwrap();
+ assert_eq!(native["start_step"], 2);
+ assert_eq!(native["anchor"], "self");
+ assert_eq!(native["contrast"], 1.25);
+ assert!(native.get("sharpness").is_none());
+ assert!((native["color"][0].as_f64().unwrap() - 128.0 / 255.0).abs() < 0.00001);
+ let roundtrip: GenerationEffects = serde_json::from_value(serde_json::to_value(&effects).unwrap()).unwrap();
+ assert_eq!(effects, roundtrip);
+ assert_eq!(effects.mask(4, 2).unwrap().unwrap(), vec![0., 1., 1., 0., 0., 1., 1., 0.]);
+ let mut inverted = effects.clone(); inverted.region.as_mut().unwrap().invert = true;
+ assert_eq!(inverted.mask(4, 1).unwrap().unwrap(), vec![1., 0., 0., 1.]);
+ assert_eq!(effects.mask(2, 1).unwrap().unwrap(), vec![0.5, 0.5]);
+ }
+ #[test]
+ fn rejects_invalid_values_even_when_bypassed_and_skips_neutral_settings() {
+ for value in [json!({"color":{"color":"#xyzxyz","strength":0.5,"mode":"type_i"}}),
+ json!({"sharpness":{"strength":6,"enabled":false}}), json!({"startStep":4,"endStep":3}),
+ json!({"region":{"x":60,"y":0,"width":50,"height":100,"invert":false}})] {
+ assert!(serde_json::from_value::<GenerationEffects>(value).unwrap().validate().is_err());
+ }
+ let neutral: GenerationEffects = serde_json::from_value(json!({"tone":{"contrast":1,"brightness":0,"saturation":1,"temperature":0},"sharpness":{"strength":1,"enabled":false}})).unwrap();
+ assert!(neutral.native_settings().unwrap().is_none());
+ assert!(serde_json::from_value::<GenerationEffects>(json!({"sharpness":{"strength":true}})).is_err());
+ }
+}
diff --git a/src-tauri/core/src/lib.rs b/src-tauri/core/src/lib.rs
index caebaed..c56deb9 100644
--- a/src-tauri/core/src/lib.rs
+++ b/src-tauri/core/src/lib.rs
@@ -4,6 +4,7 @@
pub mod conditioning;
pub mod diagnostics;
pub mod models;
+pub mod generation_effects;
pub mod names;
pub mod reference_icons;
pub mod rendered;
diff --git a/src-tauri/core/src/models.rs b/src-tauri/core/src/models.rs
index 4278412..9310497 100644
--- a/src-tauri/core/src/models.rs
+++ b/src-tauri/core/src/models.rs
@@ -11,6 +11,7 @@ pub struct GeneratorFeatures {
pub image_references: bool,
pub loras: bool,
pub motion_cache: bool,
+ pub generation_effects: bool,
}
pub fn generator_features(model_type: &str) -> &'static GeneratorFeatures {
diff --git a/src-tauri/core/src/slopfab/config.rs b/src-tauri/core/src/slopfab/config.rs
index 5543e7e..93c4ba2 100644
--- a/src-tauri/core/src/slopfab/config.rs
+++ b/src-tauri/core/src/slopfab/config.rs
@@ -122,6 +122,9 @@ impl Configuration {
pub(super) fn validate_inputs(&self, request: &GenerationRequest) -> Result<(), String> {
let features = crate::models::generator_features(&self.model_type);
+ if let Some(effects) = &request.generation_effects {
+ if effects.native_settings()?.is_some() && !features.generation_effects { return Err(format!("{} does not support generation effects.", features.label)); }
+ }
if request.still_image && !features.image_generation || !request.still_image && !features.video_generation {
return Err(format!("{} does not support {} generation.", features.label, if request.still_image { "image" } else { "video" }));
}
diff --git a/src-tauri/core/src/slopfab/ffi/lcs_tests.rs b/src-tauri/core/src/slopfab/ffi/lcs_tests.rs
new file mode 100644
index 0000000..15820cd
--- /dev/null
+++ b/src-tauri/core/src/slopfab/ffi/lcs_tests.rs
@@ -0,0 +1,75 @@
+use super::*;
+use serde_json::json;
+
+fn bundled_api() -> Api {
+ Api::load(&Path::new(env!("CARGO_MANIFEST_DIR")).join("../../lib/slopfab").join(crate::slopfab::DLL_FILE_NAME)).unwrap()
+}
+
+fn calibration(path: &Path) {
+ let mut header = json!({"__metadata__":{"slopfab_lcs":"1","vae_sha256":"a".repeat(64)}});
+ let mut data = Vec::<u8>::new();
+ let mut basis = vec![0_f32; 288];
+ basis[0] = 1.; basis[4] = 1.; basis[8] = 1.;
+ for (name, shape, values) in [
+ ("basis", vec![96, 3], basis), ("mean", vec![96], vec![0.; 96]),
+ ("anchor_lcs", vec![8, 3], vec![1.,0.,0., 0.,0.,1., 0.,1.,0., 1.,0.,1., 0.,1.,1., 1.,1.,0., 0.,0.,0., 1.,1.,1.]),
+ ("latent_mean", vec![24], vec![0.; 24]), ("latent_std", vec![24], vec![1.; 24]),
+ ("explained_variance", vec![1], vec![1.]),
+ ] {
+ let start = data.len();
+ data.extend(values.into_iter().flat_map(f32::to_le_bytes));
+ header[name] = json!({"dtype":"F32","shape":shape,"data_offsets":[start,data.len()]});
+ }
+ let mut header = header.to_string().into_bytes();
+ while header.len() % 8 != 0 { header.push(b' '); }
+ let mut bytes = (header.len() as u64).to_le_bytes().to_vec();
+ bytes.extend(header); bytes.extend(data);
+ std::fs::write(path, bytes).unwrap();
+}
+
+#[test]
+fn bundled_lcs_snapshots_settings_and_validates_masks() {
+ let api = bundled_api(); api.require_lcs().unwrap();
+ let request = RequestHandle::new(&api).unwrap();
+ let folder = tempfile::tempdir().unwrap();
+ let archive = folder.path().join("calibration.safetensors");
+ calibration(&archive);
+ let effects: crate::generation_effects::GenerationEffects = serde_json::from_str(include_str!("../../../../../fixtures/generation-effects.json")).unwrap();
+ api.set_lcs(&request, &archive, &effects.native_settings().unwrap().unwrap().to_string()).unwrap();
+ // Malformed native settings must fail without replacing the previous snapshot.
+ for settings in [r#"{"strength":true}"#, "{broken", r#"{"typo":1}"#] {
+ assert!(api.set_lcs(&request, &archive, settings).is_err());
+ }
+ std::fs::remove_file(archive).unwrap();
+ let plan = api.resolve(&request).unwrap();
+ let mask = effects.mask(plan.latent_width / 2, plan.latent_height / 2).unwrap().unwrap();
+ api.set_lcs_mask(&request, &mask).unwrap();
+ api.resolve(&request).unwrap();
+ assert!(api.set_lcs_mask(&request, &[f32::NAN]).is_err());
+ assert!(api.set_lcs_mask(&request, &[2.]).is_err());
+ api.resolve(&request).unwrap();
+ api.set_lcs_mask(&request, &[0.5]).unwrap();
+ assert!(api.resolve(&request).is_err());
+ api.set_lcs_mask(&request, &[]).unwrap();
+ api.resolve(&request).unwrap();
+ let other = bundled_api();
+ assert!(other.set_lcs_mask(&request, &[]).unwrap_err().contains("different runtime"));
+}
+
+#[test]
+fn calibration_cancellation_and_callback_panics_preserve_existing_archive() {
+ let api = bundled_api();
+ let request = RequestHandle::new(&api).unwrap();
+ api.set_model(&request, 3, Path::new("missing-vae")).unwrap();
+ let folder = tempfile::tempdir().unwrap();
+ let archive = folder.path().join("existing.safetensors");
+ std::fs::write(&archive, b"keep").unwrap();
+ let mut called = false;
+ assert!(api.calibrate_lcs(&request, &archive, &mut |done, total| {
+ called = true; assert_eq!((done, total), (0, 80)); false
+ }).is_err());
+ assert!(called);
+ assert_eq!(std::fs::read(&archive).unwrap(), b"keep");
+ assert!(api.calibrate_lcs(&request, &archive, &mut |_, _| panic!("callback failure")).is_err());
+ assert_eq!(std::fs::read(&archive).unwrap(), b"keep");
+}
diff --git a/src-tauri/core/src/slopfab/ffi/mod.rs b/src-tauri/core/src/slopfab/ffi/mod.rs
index 32d9bd8..7d02cc3 100644
--- a/src-tauri/core/src/slopfab/ffi/mod.rs
+++ b/src-tauri/core/src/slopfab/ffi/mod.rs
@@ -2,6 +2,8 @@ mod handles;
mod raw;
#[cfg(test)]
mod tests;
+#[cfg(test)]
+mod lcs_tests;
pub use handles::{FinishedGeneration, GenerationHandle, ProgressSink, Output};
pub use raw::{cuda_device_names, gpu_devices, has_cuda_device, Plan, Progress};
pub use raw::VideoDecodeTimings;
@@ -25,6 +27,16 @@ impl Api {
path: path.to_owned(),
})
}
+ pub fn require_lcs(&self) -> Result<(), String> { self.inner.require_lcs() }
+ pub fn set_lcs(&self, r: &RequestHandle, path: &Path, settings: &str) -> Result<(), String> {
+ self.check(r)?; self.inner.set_lcs(r.pointer.as_ptr(), path, settings)
+ }
+ pub fn set_lcs_mask(&self, r: &RequestHandle, mask: &[f32]) -> Result<(), String> {
+ self.check(r)?; self.inner.set_lcs_mask(r.pointer.as_ptr(), mask)
+ }
+ pub fn calibrate_lcs(&self, r: &RequestHandle, path: &Path, progress: &mut dyn FnMut(i32, i32) -> bool) -> Result<(), String> {
+ self.check(r)?; self.inner.calibrate_lcs(r.pointer.as_ptr(), path, progress)
+ }
pub fn version(&self) -> Result<String, String> {
self.inner.version()
}
diff --git a/src-tauri/core/src/slopfab/ffi/raw/lcs.rs b/src-tauri/core/src/slopfab/ffi/raw/lcs.rs
new file mode 100644
index 0000000..309dafb
--- /dev/null
+++ b/src-tauri/core/src/slopfab/ffi/raw/lcs.rs
@@ -0,0 +1,46 @@
+use super::*;
+type Calibrate = unsafe extern "C" fn(*const Request, *const c_char, i32, i32, Option<unsafe extern "C" fn(i32, i32, *mut c_void) -> i32>, *mut c_void) -> i32;
+type SetLcs = unsafe extern "C" fn(*mut Request, *const c_char, *const c_char) -> i32;
+type SetMask = unsafe extern "C" fn(*mut Request, *const f32, usize) -> i32;
+const UPDATE: &str = "Generation effects require SlopFab API 1.31 or newer. Update the runtime on the machine running generation.";
+
+impl Api {
+ pub fn require_lcs(&self) -> Result<(), String> {
+ unsafe {
+ self._library.get::<Calibrate>(b"slopfab_lcs_calibrate\0").map_err(|_| UPDATE)?;
+ self._library.get::<SetLcs>(b"slopfab_request_set_lcs\0").map_err(|_| UPDATE)?;
+ self._library.get::<SetMask>(b"slopfab_request_set_lcs_mask\0").map_err(|_| UPDATE)?;
+ }
+ Ok(())
+ }
+ pub fn set_lcs(&self, r: *mut Request, path: &Path, settings: &str) -> Result<(), String> {
+ let path = path_cstring(path)?;
+ let settings = CString::new(settings).map_err(|_| "Invalid LCS settings.")?;
+ unsafe {
+ let set = self._library.get::<SetLcs>(b"slopfab_request_set_lcs\0").map_err(|_| UPDATE)?;
+ self.error(set(r, path.as_ptr(), settings.as_ptr()))
+ }
+ }
+ pub fn set_lcs_mask(&self, r: *mut Request, mask: &[f32]) -> Result<(), String> {
+ unsafe {
+ let set = self._library.get::<SetMask>(b"slopfab_request_set_lcs_mask\0").map_err(|_| UPDATE)?;
+ self.error(set(r, if mask.is_empty() { ptr::null() } else { mask.as_ptr() }, mask.len()))
+ }
+ }
+ pub fn calibrate_lcs(&self, r: *mut Request, path: &Path, progress: &mut dyn FnMut(i32, i32) -> bool) -> Result<(), String> {
+ let path = path_cstring(path)?;
+ // Native calibration is synchronous and never retains this borrowed callback.
+ struct Callback<'a>(&'a mut dyn FnMut(i32, i32) -> bool);
+ unsafe extern "C" fn report(completed: i32, total: i32, data: *mut c_void) -> i32 {
+ std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
+ let callback = &mut *data.cast::<Callback<'_>>();
+ if (callback.0)(completed, total) { 0 } else { 1 }
+ })).unwrap_or(2)
+ }
+ let mut callback = Callback(progress);
+ unsafe {
+ let calibrate = self._library.get::<Calibrate>(b"slopfab_lcs_calibrate\0").map_err(|_| UPDATE)?;
+ self.error(calibrate(r, path.as_ptr(), 64, 256, Some(report), (&mut callback as *mut Callback<'_>).cast()))
+ }
+ }
+}
diff --git a/src-tauri/core/src/slopfab/ffi/raw/mod.rs b/src-tauri/core/src/slopfab/ffi/raw/mod.rs
index 151ef21..f114067 100644
--- a/src-tauri/core/src/slopfab/ffi/raw/mod.rs
+++ b/src-tauri/core/src/slopfab/ffi/raw/mod.rs
@@ -7,6 +7,7 @@ use std::{
pub enum Request {}
mod device;
+mod lcs;
mod reference_video;
pub use device::{cuda_device_names, gpu_devices, has_cuda_device};
pub use reference_video::ReferenceVideoHandle;
diff --git a/src-tauri/core/src/slopfab/generation.rs b/src-tauri/core/src/slopfab/generation.rs
index bad863d..62221c7 100644
--- a/src-tauri/core/src/slopfab/generation.rs
+++ b/src-tauri/core/src/slopfab/generation.rs
@@ -53,7 +53,7 @@ fn run_edit_sequence(
request, configuration: item.configuration.clone(), references: item.references.clone(), cancel: item.cancel.clone(),
events: std::sync::Arc::new(move |event| {
let event = match event {
- super::events::NativeEvent::Progress(mut progress) => {
+ super::events::NativeEvent::Progress(mut progress) if progress.stage != "calibrating" => {
let per_edit = progress.planned_steps.max(1);
progress.step = index as i32 * per_edit + progress.step.clamp(0, per_edit);
progress.total_steps = per_edit * count as i32;
@@ -118,7 +118,14 @@ fn run_single_generation(
RequestPurpose::Generate,
&item.references,
)?;
+ let effects_active = super::lcs::prepare(&api, &request, item, platform)?;
let plan = api.resolve(&request)?;
+ if effects_active {
+ if let Some(mask) = item.request.generation_effects.as_ref().unwrap().mask(plan.latent_width / 2, plan.latent_height / 2)? {
+ api.set_lcs_mask(&request, &mask)?;
+ }
+ }
+ if item.cancel.load(Ordering::Acquire) { return Err("Generation cancelled.".into()); }
diagnostics::debug(
"slopfab",
"generation.request_resolved",
diff --git a/src-tauri/core/src/slopfab/lcs.rs b/src-tauri/core/src/slopfab/lcs.rs
new file mode 100644
index 0000000..a819c6a
--- /dev/null
+++ b/src-tauri/core/src/slopfab/lcs.rs
@@ -0,0 +1,65 @@
+use super::{events::NativeEvent, ffi::{Api, RequestHandle}, platform::ComputePlatform, runtime::QueueItem, types::ProgressEvent};
+use sha2::{Digest, Sha256};
+use std::{fs::File, io::Read, path::{Path, PathBuf}, sync::atomic::{AtomicBool, Ordering}, time::Instant};
+
+fn calibration_path(directory: &Path, vae: &Path, cancel: &AtomicBool) -> Result<PathBuf, String> {
+ let mut source = File::open(vae).map_err(|e| format!("Cannot read the VAE for generation effects: {e}"))?;
+ let mut hash = Sha256::new();
+ let mut buffer = vec![0; 1024 * 1024];
+ loop {
+ if cancel.load(Ordering::Acquire) { return Err("Generation effects preparation cancelled.".into()); }
+ let count = source.read(&mut buffer).map_err(|e| e.to_string())?;
+ if count == 0 { break; }
+ hash.update(&buffer[..count]);
+ }
+ Ok(directory.join(format!("h3-v1-64-256-{:x}.safetensors", hash.finalize())))
+}
+
+pub(super) fn prepare(api: &Api, request: &RequestHandle, item: &QueueItem, platform: ComputePlatform) -> Result<bool, String> {
+ let Some(settings) = item.request.generation_effects.as_ref().map(|e| e.native_settings()).transpose()?.flatten() else { return Ok(false); };
+ api.require_lcs()?;
+ let started = Instant::now();
+ let report = |completed, total| {
+ (item.events)(NativeEvent::Progress(ProgressEvent {
+ job_id: item.request.job_id.clone(), stage: "calibrating", step: completed, total_steps: total, planned_steps: 0,
+ elapsed_seconds: started.elapsed().as_secs_f64(), frames: item.request.frames,
+ canvas_width: item.request.canvas_width, canvas_height: item.request.canvas_height,
+ reference_count: item.request.reference_count(), timing_profile: String::new(),
+ }));
+ !item.cancel.load(Ordering::Acquire)
+ };
+ if !report(0, 0) { return Err("Generation effects preparation cancelled.".into()); }
+ let vae = item.configuration.models.iter().find(|(id, _, _)| *id == 3).and_then(|(_, _, path)| path.as_deref()).ok_or("Generation effects require a video VAE.")?;
+ let log_path = PathBuf::from(crate::diagnostics::log_info()?.path);
+ let directory = log_path.parent().ok_or("Cannot locate the generation effects cache.")?.join("lcs");
+ std::fs::create_dir_all(&directory).map_err(|e| format!("Cannot create the generation effects cache: {e}"))?;
+ let path = calibration_path(&directory, vae, &item.cancel)?;
+ let settings = settings.to_string();
+ // set_lcs snapshots the archive, so a valid cache needs no GPU calibration.
+ if path.is_file() && api.set_lcs(request, &path, &settings).is_ok() { return Ok(true); }
+ let calibration = RequestHandle::new(api)?;
+ api.set_model(&calibration, 3, vae)?;
+ api.set_inference_backend(&calibration, platform.backend())?;
+ api.calibrate_lcs(&calibration, &path, &mut { report })?;
+ if item.cancel.load(Ordering::Acquire) { return Err("Generation effects preparation cancelled.".into()); }
+ api.set_lcs(request, &path, &settings)?;
+ Ok(true)
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ #[test]
+ fn calibration_cache_tracks_vae_contents_and_cancellation() {
+ let directory = tempfile::tempdir().unwrap();
+ let vae = directory.path().join("vae");
+ let cancel = AtomicBool::new(false);
+ std::fs::write(&vae, b"first").unwrap();
+ let first = calibration_path(directory.path(), &vae, &cancel).unwrap();
+ assert_eq!(first, calibration_path(directory.path(), &vae, &cancel).unwrap());
+ std::fs::write(&vae, b"other").unwrap();
+ assert_ne!(first, calibration_path(directory.path(), &vae, &cancel).unwrap());
+ cancel.store(true, Ordering::Release);
+ assert!(calibration_path(directory.path(), &vae, &cancel).unwrap_err().contains("cancelled"));
+ }
+}
diff --git a/src-tauri/core/src/slopfab/mod.rs b/src-tauri/core/src/slopfab/mod.rs
index 810aca4..add9168 100644
--- a/src-tauri/core/src/slopfab/mod.rs
+++ b/src-tauri/core/src/slopfab/mod.rs
@@ -15,6 +15,7 @@ mod continuation;
mod events;
mod ffi;
mod generation;
+mod lcs;
mod h3;
mod icons;
mod planning;
diff --git a/src-tauri/core/src/slopfab/planning.rs b/src-tauri/core/src/slopfab/planning.rs
index 43a8325..e654856 100644
--- a/src-tauri/core/src/slopfab/planning.rs
+++ b/src-tauri/core/src/slopfab/planning.rs
@@ -57,6 +57,7 @@ pub fn resolve_plan(
}
pub(super) fn validate_generation_controls(request: &GenerationRequest) -> Result<(), String> {
+ if let Some(effects) = &request.generation_effects { effects.validate()?; }
super::continuation::validate(request)?;
if let Some(bridge) = &request.latent_bridge {
if request.bridge_left_path.is_none() || request.bridge_right_path.is_none()
diff --git a/src-tauri/core/src/slopfab/tests.rs b/src-tauri/core/src/slopfab/tests.rs
index 3adce8e..f39ccdd 100644
--- a/src-tauri/core/src/slopfab/tests.rs
+++ b/src-tauri/core/src/slopfab/tests.rs
@@ -11,6 +11,11 @@ fn moss_capabilities_reject_video_edits_and_references() {
configuration.model_type = "moss".into();
let mut request = GenerationRequest { still_image: true, frames: 1, steps: 50, prompt: "A red apple".into(), canvas_width: 512, canvas_height: 512, ..Default::default() };
configuration.validate_inputs(&request).unwrap();
+ request.generation_effects = Some(serde_json::from_value(serde_json::json!({"sharpness":{"strength":1}})).unwrap());
+ assert!(configuration.validate_inputs(&request).unwrap_err().contains("generation effects"));
+ request.generation_effects.as_mut().unwrap().sharpness.as_mut().unwrap().enabled = Some(false);
+ configuration.validate_inputs(&request).unwrap();
+ request.generation_effects = None;
request.still_image = false;
assert!(configuration.validate_inputs(&request).unwrap_err().contains("video generation"));
request.still_image = true;
diff --git a/src-tauri/core/src/slopfab/types.rs b/src-tauri/core/src/slopfab/types.rs
index a6b94e0..7bf9aaa 100644
--- a/src-tauri/core/src/slopfab/types.rs
+++ b/src-tauri/core/src/slopfab/types.rs
@@ -54,6 +54,8 @@ pub struct LatentBridgeRequest {
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct GenerationRequest {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub generation_effects: Option<crate::generation_effects::GenerationEffects>,
pub job_id: String,
#[serde(default)]
pub video_transition: Option<String>,
diff --git a/src-tauri/core/src/worker/protocol.rs b/src-tauri/core/src/worker/protocol.rs
index 5626136..ac3b0ca 100644
--- a/src-tauri/core/src/worker/protocol.rs
+++ b/src-tauri/core/src/worker/protocol.rs
@@ -9,13 +9,14 @@ use std::collections::BTreeMap;
pub const SERVICE_TYPE: &str = "_slopus-worker._tcp.local.";
/// Bumped on any incompatible change to the routes or bodies below.
+// v10 carries generation effects; older workers would silently discard them.
// v8 carries latent upscaling and its model weights.
// v9 carries retained latent bridges and both anchor archives.
// v7 carries separate audio steps; older workers would silently ignore them.
// v6 added custom upscale weights.
// v5 added overlap locking.
// v4 added SeedVR2 export streams. v3 added inverted image masks.
-pub const PROTOCOL_VERSION: u32 = 9;
+pub const PROTOCOL_VERSION: u32 = 10;
/// Streaming SeedVR2 restoration; model paths are resolved on the worker.
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -311,6 +312,16 @@ mod tests {
}
}
+ #[test]
+ fn generation_effects_roundtrip_without_machine_specific_paths() {
+ let effects = serde_json::from_str(include_str!("../../../../fixtures/generation-effects.json")).unwrap();
+ let mut request = GenerationRequest { generation_effects: Some(effects), ..Default::default() };
+ let mut settings = settings(&[]);
+ visit_paths(&mut request, &mut settings, |_, _| panic!("Effects must not transfer calibration files")).unwrap();
+ let restored: GenerationRequest = serde_json::from_slice(&serde_json::to_vec(&request).unwrap()).unwrap();
+ assert_eq!(restored.generation_effects, request.generation_effects);
+ }
+
#[test]
fn moss_tokenizer_is_transferred_as_a_file_instead_of_a_folder() {
let mut settings = settings(&[("modelType", "moss"), ("tokenizer", "C:/weights/tokenizer.json")]);
diff --git a/src-tauri/src/project/commands/images.rs b/src-tauri/src/project/commands/images.rs
index 32d0d8b..66d084e 100644
--- a/src-tauri/src/project/commands/images.rs
+++ b/src-tauri/src/project/commands/images.rs
@@ -23,6 +23,7 @@ pub struct ImageStylePatch {
pub(super) fn new_scene(prompt: &str) -> ImageScene {
ImageScene {
+ generation_effects: None,
root_type: None,
source_image: None,
output_size: None,
@@ -151,6 +152,7 @@ pub(super) fn apply(
reference_ids,
} => {
scene = ImageScene {
+ generation_effects: scene.generation_effects,
root_type: scene.root_type,
source_image: scene.source_image,
output_size: scene.output_size,
diff --git a/src-tauri/src/project/image.rs b/src-tauri/src/project/image.rs
index 7317b99..7ba4f72 100644
--- a/src-tauri/src/project/image.rs
+++ b/src-tauri/src/project/image.rs
@@ -65,6 +65,8 @@ impl ImageTemplateSnapshot {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", deny_unknown_fields)]
pub struct ImageScene {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub generation_effects: Option<slopus_core::generation_effects::GenerationEffects>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub root_type: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
@@ -141,6 +143,7 @@ impl ImageScene {
}
pub fn validate(&self) -> Result<(), String> {
+ if let Some(effects) = &self.generation_effects { effects.validate()?; }
if self.output_size.as_ref().is_some_and(|size| [size.width, size.height].iter().any(|value|
!(32..=8192).contains(value) || value % 32 != 0)) {
return Err("Image output dimensions must be multiples of 32 between 32 and 8192 pixels.".into());
diff --git a/src-tauri/src/project/scenes.rs b/src-tauri/src/project/scenes.rs
index 155ebe2..134db71 100644
--- a/src-tauri/src/project/scenes.rs
+++ b/src-tauri/src/project/scenes.rs
@@ -125,6 +125,8 @@ pub(crate) struct GenerationJob {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) audio_steps: Option<i32>,
#[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) generation_effects: Option<slopus_core::generation_effects::GenerationEffects>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) video_sigma_shift: Option<f64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) audio_sigma_shift: Option<f64>,
@@ -193,6 +195,7 @@ impl GenerationJob {
duration_seconds: Some(defaults.duration_seconds),
steps: None,
audio_steps: None,
+ generation_effects: None,
video_sigma_shift: None,
audio_sigma_shift: None,
latent_upscale: None,
diff --git a/src-tauri/src/project/validation/scenes.rs b/src-tauri/src/project/validation/scenes.rs
index 998cecf..8bf650f 100644
--- a/src-tauri/src/project/validation/scenes.rs
+++ b/src-tauri/src/project/validation/scenes.rs
@@ -114,6 +114,7 @@ pub(super) fn validate(config: &mut ProjectConfig) -> Result<(), String> {
if job.audio_steps.is_some_and(|steps| !(2..=1_000_000).contains(&steps)) {
return Err(format!("Scene '{}' must use 2 to 1000000 audio steps.", job.id));
}
+ if let Some(effects) = &job.generation_effects { effects.validate()?; }
for shift in [job.video_sigma_shift, job.audio_sigma_shift].into_iter().flatten() {
if !shift.is_finite() || shift < f32::from_bits(1) as f64 || shift > f32::MAX as f64 {
return Err(format!("Scene '{}' sigma shifts must be finite, positive float32 values.", job.id));
diff --git a/src-tauri/src/tests/images.rs b/src-tauri/src/tests/images.rs
index f9a9e0f..645d448 100644
--- a/src-tauri/src/tests/images.rs
+++ b/src-tauri/src/tests/images.rs
@@ -77,6 +77,7 @@ fn image_root_survives_save_and_agent_hierarchy_replacement() {
let mut config = image_fixture();
let scene = config.image_scene.as_mut().unwrap();
scene.style.mode = "none".into();
+ scene.generation_effects = Some(serde_json::from_str(include_str!("../../../fixtures/generation-effects.json")).unwrap());
scene.root_type = Some("image".into());
scene.source_image = Some(crate::project::image::ImageSource { relative_path: "media/imported/source.png".into(), name: "Source".into(), width: 65, height: 41 });
scene.output_size = Some(crate::project::image::ImageOutputSize { width: 128, height: 64 });
@@ -85,7 +86,7 @@ fn image_root_survives_save_and_agent_hierarchy_replacement() {
let reopened = read_project(Path::new(&created.folder_path)).unwrap();
assert_eq!(reopened.config.image_scene, config.image_scene);
let mut command = serde_json::to_value(config.image_scene.as_ref().unwrap()).unwrap();
- for field in ["rootType", "sourceImage", "outputAssetId", "outputSize"] { command.as_object_mut().unwrap().remove(field); }
+ for field in ["rootType", "sourceImage", "outputAssetId", "outputSize", "generationEffects"] { command.as_object_mut().unwrap().remove(field); }
command["op"] = serde_json::json!("image.set");
let parsed: ProjectCommand = serde_json::from_value(command).unwrap();
let changed = execute_commands_at(&config, &[parsed], &config.updated_at).unwrap();
diff --git a/src-tauri/src/tests/scenes.rs b/src-tauri/src/tests/scenes.rs
index 3fbb8ef..71f68c8 100644
--- a/src-tauri/src/tests/scenes.rs
+++ b/src-tauri/src/tests/scenes.rs
@@ -558,3 +558,15 @@ fn scene_sigma_shifts_round_trip_and_validate() {
assert!(validate_and_normalize_config(invalid_config).is_err());
}
}
+
+#[test]
+fn scene_generation_effects_survive_project_storage_and_reject_invalid_controls() {
+ let mut config = scene_fixture();
+ let effects: slopus_core::generation_effects::GenerationEffects = serde_json::from_str(include_str!("../../../fixtures/generation-effects.json")).unwrap();
+ config.generation_jobs[0].generation_effects = Some(effects.clone());
+ let folder = tempfile::tempdir().unwrap();
+ write_project(folder.path(), &config).unwrap();
+ assert_eq!(read_project(folder.path()).unwrap().config.generation_jobs[0].generation_effects, Some(effects));
+ config.generation_jobs[0].generation_effects.as_mut().unwrap().end_step = Some(-1);
+ assert!(validate_and_normalize_config(config).is_err());
+}
diff --git a/src-tauri/src/worker/client.rs b/src-tauri/src/worker/client.rs
index 8f4e917..48dd6b8 100644
--- a/src-tauri/src/worker/client.rs
+++ b/src-tauri/src/worker/client.rs
@@ -1144,6 +1144,7 @@ mod tests {
audio_steps: Some(17),
video_sigma_shift: Some(8.5),
audio_sigma_shift: Some(2.5),
+ generation_effects: Some(serde_json::from_str(include_str!("../../../fixtures/generation-effects.json")).unwrap()),
..Default::default()
};
let (job, sources) = build_job(&request, &settings, &[]).unwrap();
@@ -1162,6 +1163,7 @@ mod tests {
assert_eq!(wire["request"]["audioSteps"], 17);
assert_eq!(wire["request"]["videoSigmaShift"], 8.5);
assert_eq!(wire["request"]["audioSigmaShift"], 2.5);
+ assert_eq!(wire["request"]["generationEffects"]["color"]["strength"], 0.5);
assert_eq!(sources.len(), 2);
assert!(build_job(&GenerationRequest { reference_paths: vec![folder.path().join("missing.png").to_string_lossy().into_owned()], ..Default::default() }, &BTreeMap::new(), &[]).is_err());
}
diff --git a/src/components/workspace/GenerationEffects.test.tsx b/src/components/workspace/GenerationEffects.test.tsx
new file mode 100644
index 0000000..e9b5a4b
--- /dev/null
+++ b/src/components/workspace/GenerationEffects.test.tsx
@@ -0,0 +1,55 @@
+// @vitest-environment jsdom
+import "@testing-library/jest-dom/vitest";
+import { useState } from "react";
+import { cleanup, fireEvent, render, screen } from "@testing-library/react";
+import { afterEach, expect, it, vi } from "vitest";
+import { GenerationEffects } from "./GenerationEffects";
+import { activeGenerationEffects, type GenerationEffects as Settings } from "../../lib/generationEffects";
+
+afterEach(() => { cleanup(); localStorage.clear(); });
+function Harness() {
+ const [settings, set] = useState<Settings>();
+ return <><GenerationEffects value={settings} supported onChange={set} /><output data-testid="settings">{JSON.stringify(settings)}</output></>;
+}
+const saved = () => JSON.parse(screen.getByTestId("settings").textContent || "null");
+it("adds, edits, bypasses, resets and removes generation effects", () => {
+ render(<Harness />);
+ fireEvent.click(screen.getByRole("button", { name: "Add effect" }));
+ fireEvent.click(screen.getByRole("button", { name: "Color steering" }));
+ fireEvent.change(screen.getByRole("slider", { name: "Color strength" }), { target: { value: "1.2" } });
+ expect(saved().color.strength).toBe(1.2);
+ fireEvent.click(screen.getByRole("checkbox", { name: "Enable Color steering" }));
+ expect(saved().color.strength).toBe(1.2);
+ expect(activeGenerationEffects(saved())).toBeUndefined();
+ expect(screen.getByRole("slider", { name: "Color strength" })).toBeDisabled();
+ fireEvent.click(screen.getByRole("button", { name: "Reset Color steering" }));
+ expect(saved().color.strength).toBe(0.35);
+ fireEvent.click(screen.getByRole("checkbox", { name: "Limit to a region" }));
+ fireEvent.change(screen.getByLabelText("Effect region width"), { target: { value: "50" } });
+ fireEvent.change(screen.getByLabelText("Effect region x"), { target: { value: "25" } });
+ expect(saved().region).toMatchObject({ x: 25, width: 50 });
+ fireEvent.click(screen.getByRole("button", { name: "Remove Color steering" }));
+ expect(saved()).toBeNull();
+});
+it("blocks unsupported models but allows bypassing or removing existing effects", () => {
+ const change = vi.fn();
+ render(<GenerationEffects supported={false} value={{ sharpness: { strength: 0.5 } }} onChange={change} />);
+ expect(screen.getByRole("button", { name: "Add effect" })).toBeDisabled();
+ expect(screen.getByRole("slider", { name: "Sharpness" })).toBeDisabled();
+ fireEvent.click(screen.getByRole("checkbox", { name: "Enable Sharpness" }));
+ expect(change).toHaveBeenLastCalledWith({ sharpness: { strength: 0.5, enabled: false } });
+ fireEvent.click(screen.getByRole("button", { name: "Remove Sharpness" }));
+ expect(change).toHaveBeenLastCalledWith(undefined);
+});
+
+it("edits the selected video scene from its right panel", async () => {
+ const { SceneInspector } = await import("./SceneEditor");
+ const { createProjectConfig, sceneShots } = await import("../../lib/project");
+ const config = createProjectConfig({ name: "Effects", prompt: "Apple", aspectRatio: "16:9", resolution: "416p", targetDurationSeconds: 5 });
+ const job = config.generationJobs[0];
+ const change = vi.fn();
+ render(<SceneInspector job={job} shots={sceneShots(job)} references={[]} defaultSteps={20} disabled={false} importAvailable={false} importError={null} onAddStartFrame={vi.fn()} onAddEndFrame={vi.fn()} onChange={change} onShots={vi.fn()} />);
+ fireEvent.click(screen.getByRole("button", { name: "Add effect" }));
+ fireEvent.click(screen.getByRole("button", { name: "Color stabilization" }));
+ expect(change).toHaveBeenLastCalledWith({ generationEffects: { anchor: { mode: "self", strength: 0.25 } } });
+});
diff --git a/src/components/workspace/GenerationEffects.tsx b/src/components/workspace/GenerationEffects.tsx
new file mode 100644
index 0000000..7b5cd70
--- /dev/null
+++ b/src/components/workspace/GenerationEffects.tsx
@@ -0,0 +1,84 @@
+import { useEffect, useRef, useState, type KeyboardEvent } from "react";
+import { Checkbox, ComboBox, Flyout, PropRow, PropSection, Slider, tooltipProps } from "../ui";
+import { Add16, ChevronDown12, Delete14, Reset16 } from "../ui/icons";
+import { GENERATION_EFFECTS, GENERATION_EFFECT_DEFAULTS, generationEffectsSchema, type GenerationEffectId, type GenerationEffects as Settings } from "../../lib/generationEffects";
+
+export function GenerationEffects({ value, onChange, supported, disabled = false }: {
+ value?: Settings | null; onChange: (value: Settings | undefined) => void; supported: boolean; disabled?: boolean;
+}) {
+ const effects = value ?? {};
+ const [open, setOpen] = useState(false);
+ const [collapsed, setCollapsed] = useState<Set<string>>(new Set());
+ const trigger = useRef<HTMLButtonElement>(null);
+ const picker = useRef<HTMLDivElement>(null);
+ const moveFocus = (event: KeyboardEvent<HTMLDivElement>) => {
+ if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;
+ event.preventDefault();
+ const buttons = Array.from(picker.current?.querySelectorAll<HTMLButtonElement>("button") ?? []);
+ const index = buttons.indexOf(document.activeElement as HTMLButtonElement);
+ const next = event.key === "Home" ? 0 : event.key === "End" ? buttons.length - 1 : (index + (event.key === "ArrowUp" ? -1 : 1) + buttons.length) % buttons.length;
+ buttons[next]?.focus();
+ };
+ const locked = disabled || !supported;
+ useEffect(() => { if (locked) setOpen(false); }, [locked]);
+ const present = GENERATION_EFFECTS.filter(({ id }) => effects[id]);
+ const available = GENERATION_EFFECTS.filter(({ id }) => !effects[id]);
+ const update = (next: Settings) => {
+ if (disabled || !generationEffectsSchema.safeParse(next).success) return;
+ onChange(GENERATION_EFFECTS.some(({ id }) => next[id]) ? next : undefined);
+ };
+ const set = <K extends GenerationEffectId>(id: K, patch: Partial<NonNullable<Settings[K]>>) => update({ ...effects, [id]: { ...effects[id], ...patch } });
+ const param = (id: GenerationEffectId, field: string, label: string, min: number, max: number, initial: number) => {
+ const settings = effects[id] as unknown as Record<string, number>;
+ const inactive = locked || effects[id]?.enabled === false;
+ const change = (next: number) => { if (!inactive) set(id, { [field]: next }); };
+ return <PropRow key={field} label={label} value={settings[field]} defaultValue={initial} onReset={inactive ? undefined : () => change(initial)} scrub={inactive ? undefined : { value: settings[field], onChange: change, step: 0.01, min, max }}>
+ <Slider aria-label={label} min={min} max={max} step={0.01} value={settings[field]} disabled={inactive} onChange={change} />
+ <span className="clip-effect__value">{settings[field].toFixed(2)}</span>
+ </PropRow>;
+ };
+ return <PropSection title="Effects" persistKey="generation.effects" summary={present.length ? `${present.length}` : "None"}>
+ <div className="clip-effects generation-effects">
+ <p className="clip-effect__note">{supported ? "Applied during generation. The first use prepares a reusable calibration for your VAE." : "This model does not support generation effects. Bypass or remove existing effects to generate."}</p>
+ {present.map(({ id, name }) => {
+ const on = effects[id]?.enabled !== false;
+ const inactive = locked || !on;
+ return <section key={id} className={`clip-effect${collapsed.has(id) ? "" : " clip-effect--open"}${on ? "" : " clip-effect--bypassed"}`} aria-label={name}>
+ <div className="clip-effect__header">
+ <Checkbox className="clip-effect__bypass" aria-label={`Enable ${name}`} checked={on} disabled={disabled || (!supported && !on)} onChange={(enabled) => set(id, { enabled })} />
+ <button type="button" className="clip-effect__toggle" aria-expanded={!collapsed.has(id)} onClick={() => setCollapsed((old) => { const next = new Set(old); if (next.has(id)) next.delete(id); else next.add(id); return next; })}><ChevronDown12 aria-hidden="true" className="clip-effect__chevron" /><h3 className="clip-effect__name">{name}</h3></button>
+ <button type="button" className="clip-effect__action" aria-label={`Reset ${name}`} disabled={locked} onClick={() => update({ ...effects, [id]: { ...GENERATION_EFFECT_DEFAULTS[id], ...(on ? {} : { enabled: false }) } })}><Reset16 aria-hidden="true" /></button>
+ <button type="button" className="clip-effect__action" aria-label={`Remove ${name}`} disabled={disabled} onClick={() => { const next = { ...effects }; delete next[id]; update(next); }}><Delete14 aria-hidden="true" /></button>
+ </div>
+ {!collapsed.has(id) && <fieldset className="clip-effect__body" disabled={inactive}>
+ {id === "color" && effects.color && <>
+ <PropRow label="Target color"><input type="color" aria-label="Target color" value={effects.color.color} disabled={inactive} onChange={(event) => set("color", { color: event.target.value })} /></PropRow>
+ {param(id, "strength", "Color strength", 0, 2, 0.35)}
+ <PropRow label="Method"><ComboBox aria-label="Color method" disabled={inactive} value={effects.color.mode} options={[{ value: "interpolated", label: "Interpolated" }, { value: "type_i", label: "Type I" }, { value: "type_ii", label: "Type II" }]} onChange={(mode) => set("color", { mode: mode as NonNullable<Settings["color"]>["mode"] })} /></PropRow>
+ </>}
+ {id === "tone" && <>{param(id, "contrast", "Contrast", 0, 4, 1)}{param(id, "brightness", "Brightness", -1, 1, 0)}{param(id, "saturation", "Saturation", 0, 4, 1)}{param(id, "temperature", "Temperature", -1, 1, 0)}</>}
+ {id === "sharpness" && param(id, "strength", "Sharpness", -5, 5, 0.1)}
+ {id === "anchor" && effects.anchor && <>
+ <PropRow label="Anchor"><ComboBox aria-label="Color anchor" disabled={inactive} value={effects.anchor.mode} options={[{ value: "self", label: "Self" }, { value: "smooth", label: "Smooth" }]} onChange={(mode) => set("anchor", { mode: mode as "self" | "smooth" })} /></PropRow>
+ {param(id, "strength", "Anchor strength", 0, 1, 0.25)}
+ </>}
+ </fieldset>}
+ </section>;
+ })}
+ <button ref={trigger} type="button" className="secondary-button clip-effects__add" disabled={locked || !available.length} aria-haspopup="dialog" aria-expanded={open} onClick={() => setOpen(!open)}><Add16 aria-hidden="true" />Add effect</button>
+ <Flyout open={open} anchor={trigger} onClose={() => setOpen(false)} aria-label="Available generation effects" role="group" placement="top" width={240}>
+ <div ref={picker} className="clip-effects__picker" onKeyDown={moveFocus}>{available.map(({ id, name, description }) => <button type="button" key={id} className="clip-effects__item" {...tooltipProps(description)} onClick={() => { if (!locked) update({ ...effects, [id]: { ...GENERATION_EFFECT_DEFAULTS[id] } }); setOpen(false); trigger.current?.focus(); }}>{name}</button>)}</div>
+ </Flyout>
+ {present.length > 0 && <>
+ <PropRow label="First step"><input className="text-field" aria-label="First effect step" type="number" min={0} max={effects.endStep ?? 2147483647} disabled={locked} value={effects.startStep ?? 0} onChange={(e) => update({ ...effects, startStep: Number(e.target.value) })} /></PropRow>
+ <PropRow label="Last step"><input className="text-field" aria-label="Last effect step" type="number" min={effects.startStep ?? 0} max={2147483647} placeholder="Last" disabled={locked} value={effects.endStep ?? ""} onChange={(e) => update({ ...effects, endStep: e.target.value === "" ? undefined : Number(e.target.value) })} /></PropRow>
+ <p className="clip-effect__note">Steps start at 0. Leave the last step empty to apply through completion.</p>
+ <Checkbox label="Limit to a region" checked={!!effects.region} disabled={locked} onChange={(enabled) => update({ ...effects, region: enabled ? { x: 0, y: 0, width: 100, height: 100, invert: false } : undefined })} />
+ {effects.region && <>
+ {(["x", "y", "width", "height"] as const).map((field) => <PropRow key={field} label={`${field[0].toUpperCase()}${field.slice(1)} (%)`}><input className="text-field" aria-label={`Effect region ${field}`} type="number" min={field === "x" || field === "y" ? 0 : 0.1} max={100} step={0.1} disabled={locked} value={effects.region![field]} onChange={(e) => update({ ...effects, region: { ...effects.region!, [field]: Number(e.target.value) } })} /></PropRow>)}
+ <Checkbox label="Apply outside region" checked={effects.region.invert} disabled={locked} onChange={(invert) => update({ ...effects, region: { ...effects.region!, invert } })} />
+ </>}
+ </>}
+ </div>
+ </PropSection>;
+}
diff --git a/src/components/workspace/ImageEditor.test.tsx b/src/components/workspace/ImageEditor.test.tsx
index cd0e610..bfa481d 100644
--- a/src/components/workspace/ImageEditor.test.tsx
+++ b/src/components/workspace/ImageEditor.test.tsx
@@ -1026,3 +1026,20 @@ it("shows the image bar's scrollbar while it scrolls, then hides it again", () =
expect(bar).not.toHaveClass("image-results--scrolling");
} finally { vi.useRealTimers(); }
});
+
+it("saves generation effects from the image root inspector and blocks them on MOSS", () => {
+ const initial = parseProjectConfig(fixture);
+ initial.imageScene = createImageScene("A red apple");
+ const latest = setup(initial);
+ fireEvent.click(screen.getByRole("button", { name: "Add effect" }));
+ fireEvent.click(screen.getByRole("button", { name: "Tone" }));
+ fireEvent.change(screen.getByRole("slider", { name: "Contrast" }), { target: { value: "1.5" } });
+ expect(latest().imageScene?.generationEffects?.tone?.contrast).toBe(1.5);
+ const saved = parseProjectConfig(JSON.parse(JSON.stringify(latest())));
+ cleanup();
+ saveGeneratorTemplateSettings({ templates: [mossImageTemplate()], defaultTemplateId: "moss-image", catalogVersion: 10 });
+ setup(saved);
+ expect(screen.getByRole("button", { name: "Add effect" })).toBeDisabled();
+ expect(screen.getByRole("button", { name: "Generate" })).toBeDisabled();
+ expect(screen.getByRole("checkbox", { name: "Enable Tone" })).toBeEnabled();
+});
diff --git a/src/components/workspace/ImageEditor.tsx b/src/components/workspace/ImageEditor.tsx
index e78dfb9..df6aa1e 100644
--- a/src/components/workspace/ImageEditor.tsx
+++ b/src/components/workspace/ImageEditor.tsx
@@ -1,3 +1,5 @@
+import { activeGenerationEffects } from "../../lib/generationEffects";
+import { GenerationEffects } from "./GenerationEffects";
import { useEffect, useId, useMemo, useRef, useState, useSyncExternalStore, type CSSProperties, type DragEvent, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent } from "react";
import { Add14, Add16, Boxes16, Boxes16Filled, ChevronDown14, ChevronRight14, Copy16, Cube16, Cube16Filled, Cursor16, Cursor16Filled, Delete14, Delete16, Edit16, Film16, FolderAdd16, FolderOpen16, Group16, Group16Filled, Image16, Image32, Paste16, References16, Rename16, Sparkle16, Stop14, Text16, Text16Filled } from "../ui/icons";
import { invoke } from "@tauri-apps/api/core";
@@ -101,6 +103,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene
const imageTemplates = templates.templates.filter(templateSupportsImages);
const template = imageTemplates.find((candidate) => candidate.id === templateId) ?? imageTemplates.find(templateUsable) ?? imageTemplates[0];
const model = generatorModel(template?.modelType);
+ const effectsBlocked = activeGenerationEffects(scene.generationEffects) && !model.generationEffects ? "This model does not support generation effects. Bypass or remove the effects, or choose another generator." : null;
const editingBlocked = !model.imageEditing ? `${model.label} does not support image editing. Choose an editing generator.` : null;
const referencesBlocked = !model.imageReferences ? `${model.label} does not support reference images. Choose a reference generator.` : null;
const isMiniMaxH3 = !template || template.modelType === MINIMAX_H3_MODEL_TYPE;
@@ -537,7 +540,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene
// A chip for a video or audio reference names it; one deleted says so.
const missingReference = (id: string) => config.references.find((reference) => reference.id === id)?.name ?? "Deleted reference";
const templateInspector = Boolean((extendMode && output && extendOptions) || (output && templateSourceId === output.id) || (runningTemplate && templateSource));
- const generateButton = <button type="button" className="primary-button image-generate-button" data-tooltip={(imageRoot ? editingBlocked : null) ?? editPlan?.error ?? undefined} disabled={active ? work.cancelling || work.status === "encoding" : Boolean(templateSnapshot && output?.imageDraft) || !isTauri() || !template || !templateUsable(template) || (imageRoot ? Boolean(editingBlocked || editPlan?.error) : !imageScenePrompt(scene))} onClick={() => attempt(() => active ? onCancel(work.id) : onGenerate(template!))}>{active ? <Stop14 aria-hidden="true" /> : <Sparkle16 aria-hidden="true" />}{active ? work.cancelling ? "Cancelling…" : "Cancel" : "Generate"}</button>;
+ const generateButton = <button type="button" className="primary-button image-generate-button" data-tooltip={effectsBlocked ?? (imageRoot ? editingBlocked : null) ?? editPlan?.error ?? undefined} disabled={active ? work.cancelling || work.status === "encoding" : Boolean(effectsBlocked) || Boolean(templateSnapshot && output?.imageDraft) || !isTauri() || !template || !templateUsable(template) || (imageRoot ? Boolean(editingBlocked || editPlan?.error) : !imageScenePrompt(scene))} onClick={() => attempt(() => active ? onCancel(work.id) : onGenerate(template!))}>{active ? <Stop14 aria-hidden="true" /> : <Sparkle16 aria-hidden="true" />}{active ? work.cancelling ? "Cancelling…" : "Cancel" : "Generate"}</button>;
return <div ref={editorRoot} className="image-editor" style={{ ...treePane.style, ...inspectorPane.style }}>
<div className="image-canvas-tools" role="toolbar" aria-label="Image tools">
@@ -747,6 +750,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene
{!imageRoot && <PropRow label="Aspect ratio" htmlFor={rootField("ratio")}><ComboBox id={rootField("ratio")} aria-label="Aspect ratio" value={settings.aspectRatio} options={["16:9", "9:16", "1:1", "4:5"].map((ratio) => ({ value: ratio, label: ratio }))} onChange={(value) => { const aspectRatio = value as ProjectConfig["settings"]["aspectRatio"]; onChange((current) => ({ ...current, imageSettings: { ...imageSettings(current), aspectRatio } })); }} /></PropRow>}
{imageRoot ? editSize && <PropRow label="Resolution" htmlFor={rootField("resolution")}><ComboBox id={rootField("resolution")} aria-label="Resolution" value={sizeValue(editSize)} options={editSizes.map((size) => ({ value: sizeValue(size), label: `${size.width} × ${size.height}` }))} onChange={(value) => { const size = editSizes.find((size) => sizeValue(size) === value); if (size) commit({ ...scene, outputSize: size }); }} /></PropRow> : <PropRow label="Resolution" htmlFor={rootField("resolution")}><ComboBox id={rootField("resolution")} aria-label="Resolution" value={settings.resolution} options={[...new Set([...PROJECT_RESOLUTIONS, settings.resolution])].map((resolution) => { const size = outputDimensions(resolution, settings.aspectRatio); return { value: resolution, label: `${size.width} × ${size.height}` }; })} onChange={(value) => { const resolution = value as ProjectConfig["settings"]["resolution"]; onChange((current) => ({ ...current, imageSettings: { ...imageSettings(current), resolution } })); }} /></PropRow>}
</PropSection>
+ <GenerationEffects key={selected.id} value={scene.generationEffects} supported={model.generationEffects} disabled={active} onChange={(generationEffects) => commit({ ...scene, generationEffects })} />
{!imageRoot && <PropSection title="Style" persistKey="image.style">
<PropRow label="Mode" htmlFor={rootField("mode")}><ComboBox id={rootField("mode")} aria-label="Mode" value={scene.style.mode} options={[{ value: "none", label: "None" }, { value: "photo", label: "Photo" }, { value: "art", label: "Art" }]} onChange={(value) => commit({ ...scene, style: { ...scene.style, mode: value as "none" | "photo" | "art" } })} /></PropRow>
{scene.style.mode !== "none" && <>
diff --git a/src/components/workspace/SceneEditor.tsx b/src/components/workspace/SceneEditor.tsx
index 956b576..541b690 100644
--- a/src/components/workspace/SceneEditor.tsx
+++ b/src/components/workspace/SceneEditor.tsx
@@ -1,3 +1,5 @@
+import { GenerationEffects } from "./GenerationEffects";
+import { generatorModel } from "../../lib/generatorModels";
import { DEFAULT_VIDEO_SIGMA_SHIFT, DEFAULT_AUDIO_SIGMA_SHIFT, MIN_SIGMA_SHIFT, MAX_SIGMA_SHIFT } from "../../lib/sampling";
import { sigmaShiftOverridesForTemplate, type GeneratorTemplate } from "../../lib/settings";
import { Audio16, Dismiss12, Image16, ImageAdd16, Text16, Video16 } from "../ui/icons";
@@ -556,6 +558,7 @@ export function SceneInspector({ job, shots, references, folderPath = "", scenes
</>}
</PropSection>
</div>
+ <GenerationEffects key={job.id} value={job.generationEffects} supported={generatorModel(template?.modelType).generationEffects} disabled={disabled} onChange={(generationEffects) => onChange({ generationEffects })} />
</section>;
}
diff --git a/src/lib/generationEffects.test.ts b/src/lib/generationEffects.test.ts
new file mode 100644
index 0000000..d083682
--- /dev/null
+++ b/src/lib/generationEffects.test.ts
@@ -0,0 +1,34 @@
+import { expect, it } from "vitest";
+import fixture from "../../fixtures/generation-effects.json";
+import { activeGenerationEffects, generationEffectsSchema } from "./generationEffects";
+import { createProjectConfig, parseProjectConfig, sceneGenerationSnapshot } from "./project";
+import { sceneGenerationRequest } from "./sceneGeneration";
+import { createImageScene, imageSceneSchema } from "./imageScene";
+
+it("preserves effects across project and image serialization and fingerprints active video effects", () => {
+ const effects = generationEffectsSchema.parse(fixture);
+ const config = createProjectConfig({ name: "Effects", prompt: "A red apple", aspectRatio: "16:9", resolution: "416p", targetDurationSeconds: 5 });
+ config.generationJobs[0].generationEffects = effects;
+ config.imageScene = { ...createImageScene("Apple"), generationEffects: effects };
+ const restored = parseProjectConfig(JSON.parse(JSON.stringify(config)));
+ expect(restored.generationJobs[0].generationEffects).toEqual(effects);
+ expect(imageSceneSchema.parse(restored.imageScene).generationEffects).toEqual(effects);
+ const job = restored.generationJobs[0];
+ const request = sceneGenerationRequest(job, restored, "D:/project", 20);
+ expect(request.generationEffects).toEqual(activeGenerationEffects(effects));
+ expect(request.generationEffects?.sharpness).toBeUndefined();
+ const snapshot = sceneGenerationSnapshot(job, request);
+ expect(JSON.parse(snapshot).generationEffects).toEqual(request.generationEffects);
+ expect(sceneGenerationSnapshot(job, { ...request, generationEffects: { tone: { contrast: 1, brightness: 0, saturation: 1, temperature: 0 } } }))
+ .toBe(sceneGenerationSnapshot(job, { ...request, generationEffects: undefined }));
+ expect(snapshot).not.toBe(sceneGenerationSnapshot(job, { ...request, generationEffects: undefined }));
+});
+
+it.each([
+ { color: { color: "red", strength: 1, mode: "type_i" } },
+ { sharpness: { strength: Infinity } }, { sharpness: { strength: 6 } },
+ { anchor: { strength: 1, mode: "reference" } }, { startStep: 10, endStep: 9 },
+ { region: { x: 60, y: 0, width: 50, height: 100, invert: false } },
+])("rejects invalid native controls %j", (value) => {
+ expect(generationEffectsSchema.safeParse(value).success).toBe(false);
+});
diff --git a/src/lib/generationEffects.ts b/src/lib/generationEffects.ts
new file mode 100644
index 0000000..8b4b7a6
--- /dev/null
+++ b/src/lib/generationEffects.ts
@@ -0,0 +1,42 @@
+import { z } from "zod";
+
+const enabled = z.boolean().optional();
+const scalar = (min: number, max: number) => z.number().finite().min(min).max(max);
+export const generationEffectsSchema = z.object({
+ color: z.object({ enabled, color: z.string().regex(/^#[0-9a-fA-F]{6}$/), strength: scalar(0, 2), mode: z.enum(["interpolated", "type_i", "type_ii"]) }).strict().optional(),
+ tone: z.object({ enabled, contrast: scalar(0, 4), brightness: scalar(-1, 1), saturation: scalar(0, 4), temperature: scalar(-1, 1) }).strict().optional(),
+ sharpness: z.object({ enabled, strength: scalar(-5, 5) }).strict().optional(),
+ anchor: z.object({ enabled, mode: z.enum(["self", "smooth"]), strength: scalar(0, 1) }).strict().optional(),
+ startStep: z.number().int().min(0).max(2147483647).optional(),
+ endStep: z.number().int().min(0).max(2147483647).optional(),
+ region: z.object({ x: scalar(0, 100), y: scalar(0, 100), width: scalar(0.1, 100), height: scalar(0.1, 100), invert: z.boolean() }).strict()
+ .refine((r) => r.x + r.width <= 100 && r.y + r.height <= 100, "Effect region must stay inside the picture.").optional(),
+}).strict().refine((effects) => (effects.endStep ?? 2147483647) >= (effects.startStep ?? 0), "The last effect step must follow the first.");
+export type GenerationEffects = z.infer<typeof generationEffectsSchema>;
+export const GENERATION_EFFECTS = [
+ { id: "color", name: "Color steering", description: "Guide colors toward a target during generation." },
+ { id: "tone", name: "Tone", description: "Adjust contrast, brightness, saturation and temperature during generation." },
+ { id: "sharpness", name: "Sharpness", description: "Sharpen or soften during generation." },
+ { id: "anchor", name: "Color stabilization", description: "Reduce color drift or smooth color boundaries during generation." },
+] as const;
+export type GenerationEffectId = typeof GENERATION_EFFECTS[number]["id"];
+export const GENERATION_EFFECT_DEFAULTS: Required<Pick<GenerationEffects, GenerationEffectId>> = {
+ color: { color: "#ff8000", strength: 0.35, mode: "interpolated" },
+ tone: { contrast: 1, brightness: 0, saturation: 1, temperature: 0 },
+ sharpness: { strength: 0.1 },
+ anchor: { mode: "self", strength: 0.25 },
+};
+
+/** Only active, non-neutral controls are submitted or included in render fingerprints. */
+export function activeGenerationEffects(value?: GenerationEffects | null): GenerationEffects | undefined {
+ if (!value) return;
+ const effects: GenerationEffects = {};
+ if (value.color && value.color.enabled !== false && value.color.strength !== 0) effects.color = { color: value.color.color, strength: value.color.strength, mode: value.color.mode };
+ if (value.tone && value.tone.enabled !== false && (value.tone.contrast !== 1 || value.tone.brightness !== 0 || value.tone.saturation !== 1 || value.tone.temperature !== 0)) {
+ const { enabled: _enabled, ...tone } = value.tone; effects.tone = tone;
+ }
+ if (value.sharpness && value.sharpness.enabled !== false && value.sharpness.strength !== 0) effects.sharpness = { strength: value.sharpness.strength };
+ if (value.anchor && value.anchor.enabled !== false && value.anchor.strength !== 0) effects.anchor = { mode: value.anchor.mode, strength: value.anchor.strength };
+ if (!Object.keys(effects).length) return;
+ return { ...effects, ...(value.startStep !== undefined ? { startStep: value.startStep } : {}), ...(value.endStep !== undefined ? { endStep: value.endStep } : {}), ...(value.region ? { region: { ...value.region } } : {}) };
+}
diff --git a/src/lib/generatorModels.json b/src/lib/generatorModels.json
index dbe5483..3fb3416 100644
--- a/src/lib/generatorModels.json
+++ b/src/lib/generatorModels.json
@@ -7,7 +7,8 @@
"imageEditing": true,
"imageReferences": true,
"loras": true,
- "motionCache": true
+ "motionCache": true,
+ "generationEffects": true
},
"moss": {
"label": "MOSS Image",
@@ -17,6 +18,7 @@
"imageEditing": false,
"imageReferences": false,
"loras": false,
- "motionCache": false
+ "motionCache": false,
+ "generationEffects": false
}
}
diff --git a/src/lib/imageScene.ts b/src/lib/imageScene.ts
index 3290107..d4febe4 100644
--- a/src/lib/imageScene.ts
+++ b/src/lib/imageScene.ts
@@ -1,3 +1,4 @@
+import { generationEffectsSchema } from "./generationEffects";
import { z } from "zod";
const boxSchema = z.object({ x: z.number().min(0).max(999), y: z.number().min(0).max(999), width: z.number().positive().max(1000), height: z.number().positive().max(1000) })
@@ -15,6 +16,7 @@ export const imageSourceSchema = z.object({
});
export type ImageSource = z.infer<typeof imageSourceSchema>;
export const imageSceneSchema = z.object({
+ generationEffects: generationEffectsSchema.optional(),
rootType: z.enum(["prompt", "image"]).optional(),
sourceImage: imageSourceSchema.nullish(),
outputSize: z.object({ width: z.number().int().min(32).max(8192).multipleOf(32), height: z.number().int().min(32).max(8192).multipleOf(32) }).optional(),
@@ -56,6 +58,7 @@ export function createImageScene(prompt = ""): ImageScene {
}
export function createImageEditScene(sourceImage: ImageSource | null, previous?: ImageScene): ImageScene {
return { ...createImageScene(), rootType: "image", sourceImage,
+ ...(previous?.generationEffects ? { generationEffects: structuredClone(previous.generationEffects) } : {}),
steps: previous?.steps ?? 20, seed: previous?.seed ?? -1, referenceIds: previous?.referenceIds ?? [] };
}
export function imageDescendants(scene: ImageScene, id: string): Set<string> {
diff --git a/src/lib/project.ts b/src/lib/project.ts
index ea742d1..9c8257a 100644
--- a/src/lib/project.ts
+++ b/src/lib/project.ts
@@ -1,3 +1,4 @@
+import { generationEffectsSchema, activeGenerationEffects, type GenerationEffects } from "./generationEffects";
import { MIN_SIGMA_SHIFT, MAX_SIGMA_SHIFT } from "./sampling";
import { z } from "zod";
import { backdropDirection, backdropShotDirection, backdropSummary, type BackdropColor } from "./backdrop";
@@ -604,6 +605,7 @@ export const generationJobSchema = z.object({
steps: z.number().int().min(2).max(MAX_GENERATION_STEPS).nullish(),
latentUpscale: z.boolean().nullish(),
audioSteps: z.number().int().min(2).max(MAX_AUDIO_GENERATION_STEPS).nullish(),
+ generationEffects: generationEffectsSchema.nullish(),
videoSigmaShift: z.number().min(MIN_SIGMA_SHIFT).max(MAX_SIGMA_SHIFT).nullish(),
audioSigmaShift: z.number().min(MIN_SIGMA_SHIFT).max(MAX_SIGMA_SHIFT).nullish(),
seed: z.number().int().min(RANDOM_GENERATION_SEED).max(Number.MAX_SAFE_INTEGER).nullish(),
@@ -1176,6 +1178,7 @@ export function sceneGenerationSeed(job: GenerationJob): number {
}
export interface SceneGenerationInput {
+ generationEffects?: GenerationEffects;
prompt: string;
latentBridge?: {
leftSceneId: string; rightSceneId: string;
@@ -1222,6 +1225,7 @@ export function sceneGenerationSnapshot(job: GenerationJob, input: SceneGenerati
frames: input.frames,
steps: input.steps,
...(input.audioSteps !== undefined ? { audioSteps: input.audioSteps } : {}),
+ ...(activeGenerationEffects(input.generationEffects) ? { generationEffects: activeGenerationEffects(input.generationEffects) } : {}),
...(input.videoSigmaShift !== undefined ? { videoSigmaShift: input.videoSigmaShift } : {}),
...(input.audioSigmaShift !== undefined ? { audioSigmaShift: input.audioSigmaShift } : {}),
...(input.latentUpscale ? { latentUpscale: true } : {}),
diff --git a/src/lib/runtime.ts b/src/lib/runtime.ts
index cba77cd..474214c 100644
--- a/src/lib/runtime.ts
+++ b/src/lib/runtime.ts
@@ -105,6 +105,7 @@ export interface SlopfabGenerationRequest {
imageEdit?: { sourceRelativePath: string; edits: import("./imageEditing").ImageEditStep[] };
steps: number;
audioSteps?: number;
+ generationEffects?: import("./generationEffects").GenerationEffects;
videoSigmaShift?: number;
audioSigmaShift?: number;
latentUpscale?: boolean;
diff --git a/src/lib/sceneGeneration.ts b/src/lib/sceneGeneration.ts
index b3c84ba..1fb474a 100644
--- a/src/lib/sceneGeneration.ts
+++ b/src/lib/sceneGeneration.ts
@@ -1,3 +1,4 @@
+import { activeGenerationEffects } from "./generationEffects";
import { generationDimensions } from "./export";
import { longShotContinuationInputs, longShotInputs } from "./longShot";
import {
@@ -37,6 +38,7 @@ export function sceneGenerationRequest(job: GenerationJob, config: ProjectConfig
frames: Math.round(sceneDurationSeconds(job) * GENERATION_FRAME_RATE),
steps: sceneGenerationSteps(job, defaultGenerationSteps),
...generationSigmaShifts(job, template),
+ generationEffects: activeGenerationEffects(job.generationEffects),
...(job.audioSteps != null ? { audioSteps: job.audioSteps } : {}),
...(job.latentUpscale ? { latentUpscale: true } : {}),
seed: sceneGenerationSeed(job),
diff --git a/src/lib/workQueue.test.ts b/src/lib/workQueue.test.ts
index f5f2c35..0fa68a8 100644
--- a/src/lib/workQueue.test.ts
+++ b/src/lib/workQueue.test.ts
@@ -372,6 +372,21 @@ describe("image generation work", () => {
expect(() => queue.enqueueImage(session, moss)).toThrow(/does not support image editing/);
expect(() => queue.enqueueExtendImage(session, moss, "source", { bounds: { x: 0, y: 0, width: 512, height: 512 }, prompt: "", steps: 50, seed: 1 })).toThrow(/supports image editing/);
});
+ it("captures image effects, shows calibration progress and refuses active effects on MOSS", async () => {
+ const { queue } = setup();
+ const session = queue.project(imageProject());
+ session.update((config) => ({ ...config, imageScene: { ...config.imageScene!, generationEffects: { sharpness: { strength: 0.5 } } } }));
+ expect(() => queue.enqueueImage(session, mossImageTemplate())).toThrow(/generation effects/);
+ queue.enqueueImage(session, template);
+ session.update((config) => ({ ...config, imageScene: { ...config.imageScene!, generationEffects: { sharpness: { strength: 1.5 } } } }));
+ await waitFor(() => expect(enqueueSlopfabGeneration).toHaveBeenCalledOnce());
+ const request = vi.mocked(enqueueSlopfabGeneration).mock.calls[0][0];
+ expect(request.generationEffects).toEqual({ sharpness: { strength: 0.5 } });
+ emit("slopfab-progress", { jobId: request.jobId, stage: "calibrating", step: 3, totalSteps: 80, plannedSteps: 0, elapsedSeconds: 2 });
+ expect(queue.getSnapshot()[0]).toMatchObject({ detail: "Preparing generation effects (3/80)", completionAt: null });
+ await queue.cancel(request.jobId);
+ expect(cancelSlopfabGeneration).toHaveBeenCalled();
+ });
it("generates an image at its own resolution and preserves the video generation canvas after reopening", async () => {
const { queue, first } = setup();
const original = first.getSnapshot().config;
diff --git a/src/lib/workQueue.ts b/src/lib/workQueue.ts
index 7bfa56f..5aa2b23 100644
--- a/src/lib/workQueue.ts
+++ b/src/lib/workQueue.ts
@@ -1,3 +1,4 @@
+import { activeGenerationEffects } from "./generationEffects";
import { imageSettings } from "./imageSettings";
import { listen } from "@tauri-apps/api/event";
import { invoke } from "@tauri-apps/api/core";
@@ -273,6 +274,7 @@ export class WorkQueue {
const current = session.getSnapshot().config;
const scene = current.imageScene ?? createImageScene(current.brief.prompt);
if (!generatorModel(template.modelType).imageEditing && scene.rootType === "image") throw new Error(`${generatorModel(template.modelType).label} does not support image editing. Choose an editing generator.`);
+ if (activeGenerationEffects(scene.generationEffects) && !generatorModel(template.modelType).generationEffects) throw new Error("This model does not support generation effects. Bypass or remove the effects, or choose another generator.");
const edit = scene.rootType === "image" ? compileImageEdits(current) : null;
if (!imageScenePrompt(scene)) throw new Error("Describe the image or add an object before generating.");
const projectKey = projectQueueKey(session.record);
@@ -291,7 +293,7 @@ export class WorkQueue {
const imageParentId = imageDraftId ? undefined : imageFamilyRoot(current.assets, scene.outputAssetId);
let finish!: () => void;
const done = new Promise<void>((resolve) => { finish = resolve; });
- const request: SlopfabGenerationRequest = { jobId: id, stillImage: true, frames: 1, prompt: edit ? edit.edits[0].prompt : prompt,
+ const request: SlopfabGenerationRequest = { generationEffects: activeGenerationEffects(scene.generationEffects), jobId: id, stillImage: true, frames: 1, prompt: edit ? edit.edits[0].prompt : prompt,
...(edit ? { imageEdit: { sourceRelativePath: edit.source.relativePath, edits: edit.edits.map(({ references, ...step }) => ({
...step, referencePaths: referencePaths(references), refmods: referenceRefmodInputs(session.record.folderPath, references),
})) } } : {}),
@@ -596,6 +598,10 @@ export class WorkQueue {
if (!item.cancelling) this.patch(work.id, { detail: workerTransferDetail(event) });
return;
}
+ if (event.stage === "calibrating") {
+ this.patch(work.id, { status: "generating", completionAt: null, detail: item.cancelling ? "Cancelling generation" : event.totalSteps > 0 ? `Preparing generation effects (${event.step}/${event.totalSteps})` : "Checking generation effects calibration" });
+ return;
+ }
if (work.characterSheet) {
const sheet = work.characterSheet;
const fraction = event.totalSteps > 0 ? Math.max(0, Math.min(1, event.step / event.totalSteps)) : 0;
@@ -674,6 +680,7 @@ export class WorkQueue {
const saved = await invoke<{ relativePath: string; width: number; height: number }>("combine_character_sheet", { folderPath, sheetId: work.id, indices: [...sheet.order].sort((a, b) => a - b) });
const scene = createImageEditScene({ ...saved, name: sheet.name }, work.config.imageScene ?? undefined);
scene.referenceIds = [];
+ scene.generationEffects = work.request.generationEffects;
const generation = { ...work.imageGeneration!, scene };
work.session.update(derivedImageUpdate(work.id, sheet.sourceId, { id: work.id, kind: "image", name: sheet.name,
...saved, mimeType: "image/png", imageGeneration: generation, createdAt: new Date().toISOString() }));
@@ -737,7 +744,7 @@ export class WorkQueue {
try {
const saved = await invoke<{ relativePath: string; width: number; height: number }>(work.extend ? "save_extended_image" : "save_generated_image", { folderPath: work.session.record.folderPath, jobId: work.id, ...(!work.extend && work.request.imageEdit ? { format: "png" } : {}) });
if (work.extend) {
- const scene = createImageEditScene({ ...saved, name: work.extend.name }, { ...work.config.imageScene!, steps: work.request.steps, seed: work.request.seed });
+ const scene = createImageEditScene({ ...saved, name: work.extend.name }, { ...work.config.imageScene!, steps: work.request.steps, seed: work.request.seed, generationEffects: work.request.generationEffects });
work.imageGeneration = { ...work.imageGeneration!, scene };
work.session.update(derivedImageUpdate(work.id, work.extend.sourceId, { id: work.id, kind: "image", name: work.extend.name,
...saved, mimeType: "image/png", imageGeneration: work.imageGeneration, createdAt: new Date().toISOString() }));
diff --git a/src/styles/timeline.css b/src/styles/timeline.css
index b32e7d3..f781c68 100644
--- a/src/styles/timeline.css
+++ b/src/styles/timeline.css
@@ -1752,3 +1752,5 @@ button.transport-time:hover { background: var(--fill-subtle-hover); }
.grading-wheel[aria-disabled="true"] { opacity: .4; cursor: default; }
.grading-wheel__center { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; border-radius: 50%; background: var(--text-secondary); transform: translate(-50%, -50%); }
.grading-wheel__handle { position: absolute; width: 10px; height: 10px; border: 2px solid var(--focus-outer); border-radius: 50%; box-shadow: 0 0 0 1px var(--focus-inner); transform: translate(-50%, -50%); pointer-events: none; }
+
+.generation-effects > .clip-effect__note { padding-left: 0; }