AI media harness for planning, generating, and editing locally
TypeScript
Show live H3 generation previews
Bitti4ff903e552a7
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex d2bc9a0..583d684 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -4,7 +4,7 @@ Changes since 0.3.2.## What's new-- **TAEH3 preview weights.** Added the MiniMax H3 tiny VAE under Other weights and a saved generation-preview preference in Settings.+- **Generation previews.** Download TAEH3 from Other weights to play silent MiniMax H3 previews in scene cards during generation, locally or on a worker. A Settings switch controls previews; final videos use the generator's selected VAE.- **Pika H3 Flex.** Added FL2VA and Ref2VA LoRA downloads with Pika's fixed six-step re-noising recipe and video/audio sigma shifts of 12/3.diff --git a/lib/slopfab/libslopfab.so b/lib/slopfab/libslopfab.soindex c9a2f26..ad411e2 100644--- a/lib/slopfab/libslopfab.so+++ b/lib/slopfab/libslopfab.so@@ -1,3 +1,3 @@version https://git-lfs.github.com/spec/v1-oid sha256:1d4637d8fe4372ebc859d3ea9f8bc33e8c7012e4be720fe51b4772fb6ef839b5-size 23090992+oid sha256:e6c39feae591e2085b4c1fcd99582a744d98a98098a1931661e8d00322913549+size 23516352diff --git a/lib/slopfab/slopfab.dll b/lib/slopfab/slopfab.dllindex 36d858e..87153d5 100644--- a/lib/slopfab/slopfab.dll+++ b/lib/slopfab/slopfab.dll@@ -1,3 +1,3 @@version https://git-lfs.github.com/spec/v1-oid sha256:baadda394f2c6bcd39da606f7cacbf7b6d32465effbd2a4d7cba99e525dbb01c-size 19668480+oid sha256:293af1096a07f54cd9c25e0ff3a2e3d23729422b129c5d0d42cdde72d8d74762+size 20005888diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lockindex df262e3..3ea736e 100644--- a/src-tauri/Cargo.lock+++ b/src-tauri/Cargo.lock@@ -3446,6 +3446,7 @@ dependencies = [name = "slopus-core"version = "0.3.2"dependencies = [+ "base64 0.22.1","getrandom 0.3.4","image","jpeg-encoder",diff --git a/src-tauri/core/Cargo.toml b/src-tauri/core/Cargo.tomlindex 5f6801e..fe0897f 100644--- a/src-tauri/core/Cargo.toml+++ b/src-tauri/core/Cargo.toml@@ -18,6 +18,7 @@ reqwest = { version = "0.12", default-features = false, features = ["blocking",# Verifies the downloaded legacy LoRA timestep grid.sha2 = "0.10"jpeg-encoder = "0.6"+base64 = "0.22"# Keep image decoding compatible with the package's Rust 1.87 minimum.image = { version = "=0.25.8", default-features = false, features = ["jpeg", "png"] }tiny_http = "0.12"diff --git a/src-tauri/core/src/slopfab/config.rs b/src-tauri/core/src/slopfab/config.rsindex 7d94f43..b052b2c 100644--- a/src-tauri/core/src/slopfab/config.rs+++ b/src-tauri/core/src/slopfab/config.rs@@ -34,6 +34,7 @@ pub(super) struct Configuration {pub(super) animate: bool,pub(super) prompt_embedding: Option<PathBuf>,pub(super) latent_upscaler: Option<PathBuf>,+ pub(super) preview_vae: Option<PathBuf>,pub(super) models: [(i32, &'static str, Option<PathBuf>); 5],pub(super) loras: Result<Vec<LoraAdapter>, String>,pub(super) step_override: Result<Option<i32>, String>,@@ -82,6 +83,7 @@ impl Configuration {),prompt_embedding: option("promptEmbedding"),latent_upscaler: option("latentUpscaler"),+ preview_vae: option("previewVae"),attention: match string_option("attention") {Some("exact") => "exact",Some("flash2") => "flash2",diff --git a/src-tauri/core/src/slopfab/events.rs b/src-tauri/core/src/slopfab/events.rsindex 7b72f80..18fdc6b 100644--- a/src-tauri/core/src/slopfab/events.rs+++ b/src-tauri/core/src/slopfab/events.rs@@ -7,6 +7,23 @@ pub type EventSink = Arc<dyn Fn(NativeEvent) + Send + Sync>;pub enum NativeEvent {Job(JobEvent),Progress(ProgressEvent),+ Preview(super::types::PreviewEvent),+}++pub(super) fn preview_sink(events: EventSink, job_id: String) -> ffi::PreviewSink {+ Box::new(move |preview| {+ use base64::Engine;+ let mut frames = Vec::with_capacity(preview.frames as usize);+ for rgb in preview.rgb.chunks_exact(preview.width as usize * preview.height as usize * 3) {+ let mut jpeg = Vec::new();+ if jpeg_encoder::Encoder::new(&mut jpeg, 75).encode(rgb, preview.width as u16, preview.height as u16, jpeg_encoder::ColorType::Rgb).is_err() { return; }+ frames.push(base64::engine::general_purpose::STANDARD.encode(jpeg));+ }+ events(NativeEvent::Preview(super::types::PreviewEvent {+ job_id: job_id.clone(), step: preview.step, width: preview.width, height: preview.height,+ fps: preview.fps, frames,+ }));+ })}pub(super) struct CallbackContext {diff --git a/src-tauri/core/src/slopfab/ffi/handles.rs b/src-tauri/core/src/slopfab/ffi/handles.rsindex 203fe38..9d426f0 100644--- a/src-tauri/core/src/slopfab/ffi/handles.rs+++ b/src-tauri/core/src/slopfab/ffi/handles.rs@@ -2,6 +2,51 @@ use super::{raw, Api, RequestHandle};use std::{ffi::c_void, ptr::NonNull};pub type ProgressSink = Box<dyn Fn(&super::Progress) + Send + Sync>;+pub struct Preview<'a> {+ pub rgb: &'a [u8], pub frames: i32, pub width: i32, pub height: i32,+ pub step: i32, pub fps: f64,+}+pub type PreviewSink = Box<dyn Fn(Preview<'_>) + Send + Sync>;+struct PreviewCallback(PreviewSink);+unsafe extern "C" fn preview_callback(preview: *const raw::Preview, userdata: *mut c_void) {+ let _ = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {+ if preview.is_null() || userdata.is_null() { return; }+ let p = unsafe { &*preview };+ if p.rgb.is_null() || !(1..=128).contains(&p.frames) || !(1..=256).contains(&p.width)+ || !(1..=256).contains(&p.height) || !p.fps.is_finite() || p.fps <= 0.0+ || p.byte_count != p.frames as usize * p.width as usize * p.height as usize * 3 { return; }+ let callback = unsafe { &*userdata.cast::<PreviewCallback>() };+ (callback.0)(Preview { rgb: unsafe { std::slice::from_raw_parts(p.rgb, p.byte_count) },+ frames: p.frames, width: p.width, height: p.height, step: p.step, fps: p.fps });+ }));+}++#[cfg(test)]+mod preview_tests {+ use super::*;+ use std::sync::{Arc, atomic::{AtomicUsize, Ordering}};+ #[test]+ fn validates_preview_buffers_and_contains_callback_panics() {+ let calls = Arc::new(AtomicUsize::new(0));+ let count = calls.clone();+ let mut callback = Box::new(PreviewCallback(Box::new(move |p| {+ assert_eq!(p.rgb.len(), 12);+ count.fetch_add(1, Ordering::SeqCst);+ })));+ let data = [128u8; 12];+ let mut p = raw::Preview { rgb: data.as_ptr(), byte_count: data.len(), frames: 1, width: 2, height: 2, step: 0, fps: 6.0 };+ let userdata = (&mut *callback as *mut PreviewCallback).cast();+ unsafe { preview_callback(&p, userdata); }+ p.byte_count = 11;+ unsafe { preview_callback(&p, userdata); }+ p.byte_count = 12; p.width = i32::MAX;+ unsafe { preview_callback(&p, userdata); preview_callback(std::ptr::null(), userdata); }+ assert_eq!(calls.load(Ordering::SeqCst), 1);+ callback.0 = Box::new(|_| panic!("callback panic must not unwind through C"));+ p.width = 2;+ unsafe { preview_callback(&p, userdata); }+ }+}struct Callback(ProgressSink);unsafe extern "C" fn progress_callback(progress: *const raw::Progress, userdata: *mut c_void) {@@ -19,6 +64,7 @@ pub struct GenerationHandle {api: Api,pointer: NonNull<raw::Generation>,_callback: Option<Box<Callback>>,+ _preview: Option<Box<PreviewCallback>>,terminal: bool,succeeded: bool,}@@ -28,12 +74,21 @@ impl GenerationHandle {let mut callback = Box::new(Callback(sink));let userdata = (&mut *callback as *mut Callback).cast();let pointer = api.inner.upscale_decode(source, checkpoint, scale, video, audio, backend, Some(progress_callback), userdata)?;- Ok(Self { api: api.clone(), pointer: NonNull::new(pointer).ok_or("SlopFab returned an empty upscale handle.")?, _callback: Some(callback), terminal: false, succeeded: false })+ Ok(Self { api: api.clone(), pointer: NonNull::new(pointer).ok_or("SlopFab returned an empty upscale handle.")?, _callback: Some(callback), _preview: None, terminal: false, succeeded: false })}pub(super) fn start(request: RequestHandle,sink: Option<ProgressSink>,+ preview: Option<(std::path::PathBuf, PreviewSink)>,) -> Result<Self, String> {+ let preview = preview.map(|(path, sink)| {+ let mut callback = Box::new(PreviewCallback(sink));+ let userdata = (&mut *callback as *mut PreviewCallback).cast();+ if let Err(reason) = request.api.inner.set_preview(request.pointer.as_ptr(), &path, preview_callback, userdata) {+ eprintln!("Generation previews unavailable: {reason}");+ }+ callback+ });let mut callback = sink.map(|sink| Box::new(Callback(sink)));let userdata = callback.as_mut().map_or(std::ptr::null_mut(), |value| {(&mut **value as *mut Callback).cast()@@ -51,6 +106,7 @@ impl GenerationHandle {api: request.api.clone(),pointer,_callback: callback,+ _preview: preview,// slopfab_generation_start snapshots the request. Let the caller's// copy (including image/reference samples) drop now instead of// retaining it through inference and the webview's encoding pass.diff --git a/src-tauri/core/src/slopfab/ffi/mod.rs b/src-tauri/core/src/slopfab/ffi/mod.rsindex da7006e..3ff661e 100644--- a/src-tauri/core/src/slopfab/ffi/mod.rs+++ b/src-tauri/core/src/slopfab/ffi/mod.rs@@ -5,6 +5,7 @@ mod tests;#[cfg(test)]mod lcs_tests;pub use handles::{FinishedGeneration, GenerationHandle, ProgressSink, Output};+pub use handles::PreviewSink;pub use raw::{cuda_device_names, gpu_devices, has_cuda_device, Plan, Progress};pub use raw::VideoDecodeTimings;use std::{@@ -320,7 +321,10 @@ impl RequestHandle {})}pub fn start(self, callback: Option<ProgressSink>) -> Result<GenerationHandle, String> {- GenerationHandle::start(self, callback)+ GenerationHandle::start(self, callback, None)+ }+ pub fn start_with_preview(self, callback: Option<ProgressSink>, preview: Option<(PathBuf, PreviewSink)>) -> Result<GenerationHandle, String> {+ GenerationHandle::start(self, callback, preview)}}impl Drop for RequestHandle {diff --git a/src-tauri/core/src/slopfab/ffi/raw/mod.rs b/src-tauri/core/src/slopfab/ffi/raw/mod.rsindex 9213509..fb43bed 100644--- a/src-tauri/core/src/slopfab/ffi/raw/mod.rs+++ b/src-tauri/core/src/slopfab/ffi/raw/mod.rs@@ -13,6 +13,18 @@ pub use device::{cuda_device_names, gpu_devices, has_cuda_device};pub use reference_video::ReferenceVideoHandle;pub enum Generation {}#[repr(C)]+pub struct Preview {+ pub rgb: *const u8,+ pub byte_count: usize,+ pub frames: i32,+ pub width: i32,+ pub height: i32,+ pub step: i32,+ pub fps: f64,+}+pub type PreviewFn = unsafe extern "C" fn(*const Preview, *mut c_void);+type SetPreview = unsafe extern "C" fn(*mut Request, *const c_char, Option<PreviewFn>, *mut c_void) -> i32;+#[repr(C)]#[derive(Debug, Clone, Copy, Default, serde::Serialize)]#[serde(rename_all = "camelCase")]pub struct VideoDecodeTimings {@@ -81,6 +93,7 @@ type UpscaleDecode = unsafe extern "C" fn(*const c_char, *const c_char, f32, *cotype SetImageGuidance = unsafe extern "C" fn(*mut Request, f32, *const c_char, *const i32, i32) -> i32;pub struct Api {+ set_preview: Option<SetPreview>,upscale_decode: Option<UpscaleDecode>,save_generation_latents: Option<unsafe extern "C" fn(*const Generation, *const c_char) -> i32>,set_music_settings: Option<unsafe extern "C" fn(*mut Request, *const c_char) -> i32>,@@ -148,6 +161,10 @@ pub struct Api {}impl Api {+ pub fn set_preview(&self, request: *mut Request, path: &Path, callback: PreviewFn, userdata: *mut c_void) -> Result<(), String> {+ let Some(set) = self.set_preview else { return Ok(()); };+ self.error(unsafe { set(request, path_cstring(path)?.as_ptr(), Some(callback), userdata) })+ }pub fn load(path: &Path) -> Result<Self, String> {// SAFETY: symbols are copied function pointers with signatures from capi.h.// The Library is retained in Api, so no pointer outlives the loaded module.@@ -162,6 +179,7 @@ impl Api {};}Ok(Self {+ set_preview: library.get::<SetPreview>(b"slopfab_request_set_preview\0").ok().map(|f| *f),set_video_transition: library.get::<unsafe extern "C" fn(*mut Request, i32) -> i32>(b"slopfab_request_set_video_transition\0",diff --git a/src-tauri/core/src/slopfab/ffi/tests.rs b/src-tauri/core/src/slopfab/ffi/tests.rsindex ada81ae..44a1bbe 100644--- a/src-tauri/core/src/slopfab/ffi/tests.rs+++ b/src-tauri/core/src/slopfab/ffi/tests.rs@@ -1,5 +1,20 @@use super::*;+#[test]+fn bundled_runtime_accepts_optional_preview_callback() {+ let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../lib/slopfab").join(crate::slopfab::DLL_FILE_NAME);+ let api = Api::load(&path).unwrap();+ // Optional symbol loading must not hide a stale bundled binary.+ unsafe {+ let library = libloading::Library::new(&path).unwrap();+ assert!(library.get::<unsafe extern "C" fn()>(b"slopfab_request_set_preview\0").is_ok());+ }+ let request = RequestHandle::new(&api).unwrap();+ unsafe extern "C" fn callback(_: *const raw::Preview, _: *mut std::ffi::c_void) {}+ api.inner.set_preview(request.pointer.as_ptr(), Path::new("missing-taeh3.safetensors"), callback, std::ptr::null_mut()).unwrap();+ assert!(api.resolve(&request).is_ok(), "optional preview weights must not block planning");+}+#[test]fn bundled_runtime_exposes_saved_latent_upscale_and_decode() {let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../lib/slopfab").join(crate::slopfab::DLL_FILE_NAME);diff --git a/src-tauri/core/src/slopfab/generation.rs b/src-tauri/core/src/slopfab/generation.rsindex 90e0bff..5128cd7 100644--- a/src-tauri/core/src/slopfab/generation.rs+++ b/src-tauri/core/src/slopfab/generation.rs@@ -236,7 +236,10 @@ fn run_single_generation(timing_profile: timing_profile.clone(),planned_steps: plan.num_model_evaluations,};- let mut generation = request.start(Some(progress_sink(context)))?;+ let preview = item.configuration.preview_vae.as_ref()+ .filter(|path| path.is_file() && item.configuration.model_type == "minimax-h3" && !item.request.still_image && item.request.music.is_none())+ .map(|path| (path.clone(), super::events::preview_sink(item.events.clone(), item.request.job_id.clone())));+ let mut generation = request.start_with_preview(Some(progress_sink(context)), preview)?;diagnostics::debug("slopfab","generation.api_started",diff --git a/src-tauri/core/src/slopfab/icons.rs b/src-tauri/core/src/slopfab/icons.rsindex 851cce6..282df0b 100644--- a/src-tauri/core/src/slopfab/icons.rs+++ b/src-tauri/core/src/slopfab/icons.rs@@ -122,6 +122,7 @@ pub fn generate_reference_icon_batch(animate: false,prompt_embedding: None,latent_upscaler: None,+ preview_vae: None,models: [(0, "transformer", Some(batch.transformer.clone())),(1, "textEncoder", Some(batch.text_encoder.clone())),diff --git a/src-tauri/core/src/slopfab/types.rs b/src-tauri/core/src/slopfab/types.rsindex 5d932c5..17d5ce1 100644--- a/src-tauri/core/src/slopfab/types.rs+++ b/src-tauri/core/src/slopfab/types.rs@@ -209,6 +209,17 @@ pub struct ResolvedPlan {pub boundary: &'static str,}+#[derive(Debug, Clone, Serialize)]+#[serde(rename_all = "camelCase")]+pub struct PreviewEvent {+ pub job_id: String,+ pub step: i32,+ pub width: i32,+ pub height: i32,+ pub fps: f64,+ pub frames: Vec<String>,+}+#[derive(Debug, Clone, Serialize)]#[serde(rename_all = "camelCase")]pub struct ProgressEvent {diff --git a/src-tauri/core/src/worker/protocol.rs b/src-tauri/core/src/worker/protocol.rsindex 6933b3d..d13c3fa 100644--- a/src-tauri/core/src/worker/protocol.rs+++ b/src-tauri/core/src/worker/protocol.rs@@ -173,7 +173,7 @@ pub enum PathKind {Input,}-const MODEL_OPTIONS: [&str; 6] = ["transformer", "textEncoder", "videoVae", "audioVae", "promptEmbedding", "latentUpscaler"];+const MODEL_OPTIONS: [&str; 7] = ["transformer", "textEncoder", "videoVae", "audioVae", "promptEmbedding", "latentUpscaler", "previewVae"];/// Visits every file path a generation names, in a fixed order. The client/// swaps local paths for tokens with it, and the worker swaps tokens back@@ -326,6 +326,19 @@ mod tests {}}+ #[test]+ fn preview_vae_crosses_the_worker_boundary_as_a_model_file() {+ let mut request = GenerationRequest::default();+ let mut settings = settings(&[("previewVae", "C:/weights/taeh3.safetensors")]);+ visit_paths(&mut request, &mut settings, |kind, path| {+ assert_eq!(kind, PathKind::Model);+ assert_eq!(path, "C:/weights/taeh3.safetensors");+ *path = file_token(0);+ Ok(())+ }).unwrap();+ assert_eq!(settings["slopfab"].options["previewVae"], ProviderOption::String(file_token(0)));+ }+#[test]fn saved_latent_upscale_transfers_archive_and_decoder_weights_only() {let mut request: GenerationRequest = serde_json::from_value(serde_json::json!({"jobId":"upscale", "prompt":"", "frames":124, "steps":8, "seed":42, "canvasWidth":736, "canvasHeight":416,diff --git a/src-tauri/core/src/worker/server.rs b/src-tauri/core/src/worker/server.rsindex ee80540..b2fdb22 100644--- a/src-tauri/core/src/worker/server.rs+++ b/src-tauri/core/src/worker/server.rs@@ -135,6 +135,12 @@ impl JobLog {return;}if let Ok(mut events) = self.events.lock() {+ if kind == "preview" || kind == "job" && matches!(payload["state"].as_str(), Some("failed" | "cancelled" | "framesReady")) {+ // Keep sequence cursors stable but retain only the latest preview payload.+ for event in events.iter_mut().filter(|event| event.kind == "preview") {+ event.payload = serde_json::Value::Null;+ }+ }let seq = events.len() as u64 + 1;events.push(WireEvent { seq, kind: kind.into(), payload });}@@ -683,6 +689,7 @@ impl Worker {Arc::new(move |event| match event {slopfab::NativeEvent::Job(value) => sink.push("job", serde_json::to_value(value).unwrap_or_default()),slopfab::NativeEvent::Progress(value) => sink.push("progress", serde_json::to_value(value).unwrap_or_default()),+ slopfab::NativeEvent::Preview(value) => sink.push("preview", serde_json::to_value(value).unwrap_or_default()),}),request,&settings,@@ -738,6 +745,21 @@ fn percent_decode(part: &str) -> Result<String, String> {mod tests {use super::*;+ #[test]+ fn preview_log_retains_only_latest_pixels_without_reusing_cursors() {+ let log = JobLog { events: Mutex::default(), changed: Condvar::new(), latents: None,+ created: Instant::now(), released: AtomicBool::new(false) };+ log.push("preview", serde_json::json!({"frames": ["first"]}));+ log.push("progress", serde_json::json!({"step": 1}));+ log.push("preview", serde_json::json!({"frames": ["second"]}));+ let events = log.after(0, Duration::ZERO);+ assert!(events[0].payload.is_null());+ assert_eq!(events[2].seq, 3);+ assert_eq!(events[2].payload["frames"][0], "second");+ log.push("job", serde_json::json!({"state": "framesReady"}));+ assert!(log.after(2, Duration::ZERO)[0].payload.is_null());+ }+struct TrackedFrames(Arc<AtomicBool>);impl rendered::FrameSource for TrackedFrames {diff --git a/src-tauri/src/commands/extend_image.rs b/src-tauri/src/commands/extend_image.rsindex e8e4483..d65ac5d 100644--- a/src-tauri/src/commands/extend_image.rs+++ b/src-tauri/src/commands/extend_image.rs@@ -422,6 +422,7 @@ mod tests {.unwrap();loop {match receive.recv_timeout(Duration::from_secs(600)).unwrap() {+ NativeEvent::Preview(_) => {}NativeEvent::Progress(event) => {eprintln!("{}", serde_json::to_value(event).unwrap())}diff --git a/src-tauri/src/commands/generation.rs b/src-tauri/src/commands/generation.rsindex 0da080f..d9045b4 100644--- a/src-tauri/src/commands/generation.rs+++ b/src-tauri/src/commands/generation.rs@@ -264,6 +264,9 @@ pub(crate) async fn enqueue_slopfab_generation(slopfab::NativeEvent::Progress(value) => {let _ = app.emit("slopfab-progress", value);}+ slopfab::NativeEvent::Preview(value) => {+ let _ = app.emit("slopfab-preview", value);+ }}),request,&config.provider_settings,diff --git a/src-tauri/src/worker/client.rs b/src-tauri/src/worker/client.rsindex 48dd6b8..af8ef6d 100644--- a/src-tauri/src/worker/client.rs+++ b/src-tauri/src/worker/client.rs@@ -721,6 +721,10 @@ impl Workers {};for event in events {after = event.seq;+ if event.kind == "preview" {+ if !event.payload.is_null() { self.emit("slopfab-preview", event.payload); }+ continue;+ }if event.kind == "progress" {self.emit("slopfab-progress", event.payload);continue;@@ -942,6 +946,11 @@ pub(crate) fn build_job(request: &GenerationRequest, settings: &BTreeMap<String,let mut settings: BTreeMap<String, ProviderSetting> = settings.iter().filter(|(name, _)| name.as_str() == "slopfab").map(|(name, value)| (name.clone(), value.clone())).collect();super::variants::select(&mut settings, gpus)?;+ if let Some(slopfab) = settings.get_mut("slopfab") {+ if matches!(slopfab.options.get("previewVae"), Some(slopus_core::settings::ProviderOption::String(path)) if !Path::new(path).is_file()) {+ slopfab.options.remove("previewVae");+ }+ }let mut files = Vec::new();let mut indices: HashMap<String, usize> = HashMap::new();let mut sources = HashMap::new();diff --git a/src/components/GenerationPreviewSetting.tsx b/src/components/GenerationPreviewSetting.tsxindex e1a971b..572484b 100644--- a/src/components/GenerationPreviewSetting.tsx+++ b/src/components/GenerationPreviewSetting.tsx@@ -5,7 +5,7 @@ import { SettingsCard, SettingsGroup, ToggleSwitch } from "./ui";export function GenerationPreviewSetting() {const enabled = useSyncExternalStore(subscribeGenerationPreviews, loadGenerationPreviewsEnabled);return <SettingsGroup heading="Generation previews">- <SettingsCard header="Show generation previews" description="Play MiniMax H3 previews in scene cards during generation. Requires TAEH3 from Other weights and a runtime with preview support.">+ <SettingsCard header="Show generation previews" description="Play MiniMax H3 previews in scene cards during generation. Download TAEH3 from Other weights first. Decoder changes apply to new generations."><ToggleSwitch checked={enabled} aria-label="Enable generation previews" onChange={saveGenerationPreviewsEnabled} /></SettingsCard></SettingsGroup>;diff --git a/src/components/OtherWeightsSettings.tsx b/src/components/OtherWeightsSettings.tsxindex e4019b8..ea7a0e4 100644--- a/src/components/OtherWeightsSettings.tsx+++ b/src/components/OtherWeightsSettings.tsx@@ -82,7 +82,7 @@ function OtherWeightEditor({ template, desktop, busy, onDone }: {<button className="secondary-button" type="button" disabled={!desktop} aria-label={`Browse for ${file.name}`} onClick={() => void browse(file)}>Browse…</button></span></label>)}{template.id === "latent-upscale" && <p>Upscale saved scene Takes from the Generate menu. Workers receive local files or download the standard weights.</p>}- {template.id === "taeh3" && <p>A lightweight MiniMax H3 VAE for generation previews. Final videos use the Video VAE selected in the generator.</p>}+ {template.id === "taeh3" && <p>A lightweight MiniMax H3 VAE for playable previews during generation. Enable Generation previews in Settings. Final videos use the Video VAE selected in the generator.</p>}{template.id === "seedvr2" && <p>SeedVR2 runs locally or on the selected worker. Workers receive local files and download any weights without a local path.</p>}{error && <InfoBar severity="error" message={error} />}</fieldset>diff --git a/src/components/ProjectWorkspace.tsx b/src/components/ProjectWorkspace.tsxindex 7ff2656..ebb606d 100644--- a/src/components/ProjectWorkspace.tsx+++ b/src/components/ProjectWorkspace.tsx@@ -313,7 +313,7 @@ export function ProjectWorkspace({ project, initialView, runtime = null, onBack,</div>}{view === "editor" && <ImageEditor onBackNavigationChange={setBackNavigation} openImage={imageNavigation} onImageOpened={() => setImageNavigation(undefined)} config={config} folderPath={project.folderPath} onChange={changeConfig} onGenerate={(template, count) => queue.enqueueImage(session, template, count)} onGenerateCharacterSheet={(template, sourceId, options) => queue.enqueueCharacterSheet(session, template, sourceId, options)} onGenerateExtend={(template, sourceId, options) => queue.enqueueExtendImage(session, template, sourceId, options)} onCancel={(id) => queue.cancel(id)} workItems={projectItems.filter((item) => item.kind === "image")} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); setVideoNavigation(jobId ? { id: jobId } : undefined); setView("generator"); }} onOpenReferences={() => setView("references")} />}{view === "timeline" && <TimelineView config={config} openSceneId={selectedGenerationJobId} folderPath={project.folderPath} generationCompletionTimes={generationCompletionTimes} onChange={changeConfig} onMeasured={recordMeasurement} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); setVideoNavigation(jobId ? { id: jobId } : undefined); setView("generator"); }} />}- {view === "generator" && <VideoLibraryView onBackNavigationChange={setBackNavigation} initialOpenVideoId={openVideoId} onOpenVideoChange={setOpenVideoId} openScene={videoNavigation} onSceneOpened={() => setVideoNavigation(undefined)} onGenerate={(submissions) => queue.enqueue(session, submissions)} onCancelGeneration={(ids) => queue.cancelScenes(session, ids)} cancellingJobIds={cancellingJobIds} config={config} folderPath={project.folderPath} generationCompletionTimes={generationCompletionTimes} runtime={runtime?.slopfab ?? null} onRuntimeChange={onGeneratorRuntimeChange} onChange={changeConfig} selectedJobId={selectedGenerationJobId} onSelectedJobChange={setSelectedGenerationJobId} onOpenTimeline={() => setView("timeline")} />}+ {view === "generator" && <VideoLibraryView onBackNavigationChange={setBackNavigation} initialOpenVideoId={openVideoId} onOpenVideoChange={setOpenVideoId} openScene={videoNavigation} onSceneOpened={() => setVideoNavigation(undefined)} onGenerate={(submissions) => queue.enqueue(session, submissions)} onCancelGeneration={(ids) => queue.cancelScenes(session, ids)} cancellingJobIds={cancellingJobIds} config={config} folderPath={project.folderPath} generationPreviews={Object.fromEntries(projectItems.filter((item) => item.preview).map((item) => [item.sceneId, item.preview!]))} generationCompletionTimes={generationCompletionTimes} runtime={runtime?.slopfab ?? null} onRuntimeChange={onGeneratorRuntimeChange} onChange={changeConfig} selectedJobId={selectedGenerationJobId} onSelectedJobChange={setSelectedGenerationJobId} onOpenTimeline={() => setView("timeline")} />}{view === "references" && <ReferencesView openReference={referenceNavigation} onReferenceOpened={() => setReferenceNavigation(undefined)} config={config} folderPath={project.folderPath} onChange={changeConfig} onRegenerateIcon={(id) => queue.regenerateReferenceIcon(session, id)} onExportRefmod={(id, outputPath) => queue.exportReferenceRefmod(session, id, outputPath)} onGenerateBuiltinIcons={() => queue.generateBuiltinReferenceIcons(session)} onRegenerateBuiltinIcon={(id) => queue.regenerateBuiltinReferenceIcon(session, id)} pendingBuiltinIconIds={queue.pendingBuiltinIconIds()} pendingIconIds={new Set(config.references.filter((reference) => queue.isReferenceIconPending(session, reference.id)).map((reference) => reference.id))} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); setVideoNavigation(jobId ? { id: jobId } : undefined); setView("generator"); }} />}{view === "export" && <div className="project-export"><SelectorBar aria-label="Export type" className="project-export__types" value={mediaMode} onChange={chooseExportMode} items={[{ value: "video", label: "Video" }, { value: "image", label: "Image" }, { value: "music", label: "Music" }]} />diff --git a/src/components/workspace/GenerationPreviewPlayer.test.tsx b/src/components/workspace/GenerationPreviewPlayer.test.tsxnew file mode 100644index 0000000..9d56b66--- /dev/null+++ b/src/components/workspace/GenerationPreviewPlayer.test.tsx@@ -0,0 +1,37 @@+// @vitest-environment jsdom+import "@testing-library/jest-dom/vitest";+import { cleanup, render, screen, waitFor } from "@testing-library/react";+import { afterEach, expect, it, vi } from "vitest";+import { encodeGenerationPreview, type GenerationPreview } from "../../lib/generationPreview";+import { GenerationPreviewPlayer } from "./GenerationPreviewPlayer";+vi.mock("../../lib/generationPreview", () => ({ encodeGenerationPreview: vi.fn() }));+afterEach(() => { cleanup(); vi.restoreAllMocks(); vi.unstubAllGlobals(); });+const preview: GenerationPreview = { jobId: "job", width: 2, height: 2, fps: 4, step: 0, frames: ["/9j/AA=="] };++it("replaces playable previews, ignores stale encoding and releases URLs on unmount", async () => {+ const create = vi.fn().mockReturnValueOnce("blob:first").mockReturnValueOnce("blob:second");+ const revoke = vi.fn();+ vi.stubGlobal("URL", { createObjectURL: create, revokeObjectURL: revoke });+ vi.mocked(encodeGenerationPreview).mockResolvedValueOnce(new Blob());+ const view = render(<GenerationPreviewPlayer preview={preview} />);+ await waitFor(() => expect(screen.getByLabelText("Play generation preview")).toHaveAttribute("src", "blob:first"));+ let stale!: (blob: Blob) => void;+ vi.mocked(encodeGenerationPreview).mockImplementationOnce(() => new Promise((resolve) => { stale = resolve; }));+ view.rerender(<GenerationPreviewPlayer preview={{ ...preview, step: 1 }} />);+ vi.mocked(encodeGenerationPreview).mockResolvedValueOnce(new Blob());+ view.rerender(<GenerationPreviewPlayer preview={{ ...preview, step: 2 }} />);+ await waitFor(() => expect(screen.getByLabelText("Play generation preview")).toHaveAttribute("src", "blob:second"));+ stale(new Blob());+ await Promise.resolve();+ expect(create).toHaveBeenCalledTimes(2);+ expect(revoke).toHaveBeenCalledWith("blob:first");+ view.unmount();+ expect(revoke).toHaveBeenCalledWith("blob:second");+});++it("keeps a still preview when this webview cannot encode previews", async () => {+ vi.mocked(encodeGenerationPreview).mockRejectedValue(new Error("unsupported"));+ render(<GenerationPreviewPlayer preview={preview} />);+ expect(await screen.findByText("Preview playback unavailable")).toBeInTheDocument();+ expect(screen.getByRole("img")).toHaveAttribute("src", "data:image/jpeg;base64,/9j/AA==");+});diff --git a/src/components/workspace/GenerationPreviewPlayer.tsx b/src/components/workspace/GenerationPreviewPlayer.tsxnew file mode 100644index 0000000..79a39fe--- /dev/null+++ b/src/components/workspace/GenerationPreviewPlayer.tsx@@ -0,0 +1,34 @@+import { useEffect, useRef, useState } from "react";+import { encodeGenerationPreview, type GenerationPreview } from "../../lib/generationPreview";++export function GenerationPreviewPlayer({ preview }: { preview: GenerationPreview }) {+ const [source, setSource] = useState<{ url: string; step: number }>();+ const [failed, setFailed] = useState(false);+ const video = useRef<HTMLVideoElement>(null);+ const url = useRef<string>();+ const position = useRef({ time: 0, paused: true });+ useEffect(() => {+ const controller = new AbortController();+ void encodeGenerationPreview(preview, controller.signal).then((blob) => {+ if (controller.signal.aborted) return;+ const next = URL.createObjectURL(blob);+ position.current = { time: video.current?.currentTime ?? 0, paused: video.current?.paused ?? true };+ if (url.current) URL.revokeObjectURL(url.current);+ url.current = next;+ setSource({ url: next, step: preview.step });+ setFailed(false);+ }).catch(() => { if (!controller.signal.aborted) setFailed(true); });+ return () => controller.abort();+ }, [preview]);+ useEffect(() => () => { if (url.current) URL.revokeObjectURL(url.current); }, []);+ return <div className="generation-preview" aria-label="Generation preview">+ {source ? <video ref={video} src={source.url} controls muted loop playsInline preload="auto" aria-label="Play generation preview"+ onLoadedMetadata={() => {+ const element = video.current;+ if (!element) return;+ element.currentTime = Math.min(position.current.time, Math.max(0, element.duration - .01));+ if (!position.current.paused) void element.play().catch(() => {});+ }} /> : <img src={`data:image/jpeg;base64,${preview.frames[0]}`} alt="Generation preview" />}+ <span>{failed && !source ? "Preview playback unavailable" : `Generation preview · Step ${(source?.step ?? preview.step) + 1}`}</span>+ </div>;+}diff --git a/src/components/workspace/GeneratorView.tsx b/src/components/workspace/GeneratorView.tsxindex 4ac12e4..e3b64ab 100644--- a/src/components/workspace/GeneratorView.tsx+++ b/src/components/workspace/GeneratorView.tsx@@ -1,3 +1,4 @@+import type { GenerationPreview } from "../../lib/generationPreview";import { generatorOptions } from "../generatorOptions";import { sceneUpscaleSubmission, selectedUpscaleTake } from "../../lib/sceneUpscale";import { Flyout } from "../ui";@@ -38,6 +39,7 @@ interface GeneratorViewProps {config: ProjectConfig;folderPath: string;runtime?: SlopfabStatus | null;+ generationPreviews?: Readonly<Record<string, GenerationPreview>>;generationCompletionTimes?: Readonly<Record<string, number>>;/** `key` groups rapid edits of one thing into one undo step (the workspace's session.edit). */onChange: (next: ProjectConfig, key?: string) => void;@@ -68,7 +70,7 @@ const readDensity = (): BoardDensity => {* The panel is whatever is open — one shot, or the scene itself. Nothing is* edited on the board, and nothing is duplicated in the panel: there is exactly* one place to change any given thing. */-export function GeneratorView({ config, sceneIds, toolbarStart, folderPath, runtime = null, generationCompletionTimes = {}, onChange, selectedJobId, onSelectedJobChange, onRuntimeChange, onGenerate, onCancelGeneration, cancellingJobIds = new Set() }: GeneratorViewProps) {+export function GeneratorView({ config, sceneIds, toolbarStart, folderPath, runtime = null, generationPreviews = {}, generationCompletionTimes = {}, onChange, selectedJobId, onSelectedJobChange, onRuntimeChange, onGenerate, onCancelGeneration, cancellingJobIds = new Set() }: GeneratorViewProps) {const jobs = sceneIds ? sceneIds.flatMap((id) => { const job = config.generationJobs.find((job) => job.id === id); return job ? [job] : []; }) : config.generationJobs;const [selection, setSelection] = useState<GeneratorSelection>(() => ({ jobId: selectedJobId ?? jobs.find((job) => job.status === "generating")?.id ?? jobs[0]?.id ?? "", shotId: null }));const [templateSettings, setTemplateSettings] = useState(loadGeneratorTemplateSettings);@@ -563,6 +565,7 @@ export function GeneratorView({ config, sceneIds, toolbarStart, folderPath, runtassets={config.assets}jobs={jobs}folderPath={folderPath}+ generationPreviews={generationPreviews}generationCompletionTimes={generationCompletionTimes}references={config.references}selection={{ jobId: selected?.id ?? "", shotId: openShot?.id ?? null }}diff --git a/src/components/workspace/SceneBoard.tsx b/src/components/workspace/SceneBoard.tsxindex f93ead9..e247f49 100644--- a/src/components/workspace/SceneBoard.tsx+++ b/src/components/workspace/SceneBoard.tsx@@ -1,3 +1,5 @@+import type { GenerationPreview } from "../../lib/generationPreview";+import { GenerationPreviewPlayer } from "./GenerationPreviewPlayer";import { SceneHistoryBar } from "./SceneHistoryBar";import { scenePreviewJob, scenePreviewAsset } from "../../lib/sceneHistory";import { Copy16, Add16, ArrowDown16, ArrowUp16, ChevronDown12, ChevronRight12, Delete16, Grip16, MoveTo16, OpenExternal16, Rename16, Stop14, Stop16, Wand16 } from "../ui/icons";@@ -70,6 +72,7 @@ export function SceneBoard({assets = [],folderPath,generationCompletionTimes,+ generationPreviews = {},references,selection,density = "tiles",@@ -89,6 +92,7 @@ export function SceneBoard({jobs: GenerationJob[];assets?: ProjectAsset[];folderPath: string;+ generationPreviews?: Readonly<Record<string, GenerationPreview>>;generationCompletionTimes?: Readonly<Record<string, number>>;references: ProjectReference[];selection: GeneratorSelection;@@ -403,6 +407,7 @@ export function SceneBoard({>{cancellable ? <Stop14 /> : <Wand16 />}</HeaderButton></header>+ {!isCollapsed && generationPreviews[job.id] && <GenerationPreviewPlayer key={generationPreviews[job.id].jobId} preview={generationPreviews[job.id]} />}{!isCollapsed && <div className="scene-section__content"><olclassName={`shot-grid${shotDrop?.beforeShotId === null ? " shot-grid--drop-end" : ""}`}aria-label={`Shots in ${job.title}`}diff --git a/src/lib/generationPreview.test.ts b/src/lib/generationPreview.test.tsnew file mode 100644index 0000000..12fbceb--- /dev/null+++ b/src/lib/generationPreview.test.ts@@ -0,0 +1,27 @@+// @vitest-environment jsdom+import { afterEach, expect, it } from "vitest";+import { validGenerationPreview } from "./generationPreview";+import { engineProviderSetting, EMPTY_ENGINE_SETTINGS } from "./settings";+import { saveGenerationPreviewsEnabled } from "./generationPreviewSettings";+import { saveOtherWeightPath, TAEH3_URL } from "./upscalers";+afterEach(() => localStorage.clear());++it("only configures available H3 preview weights when enabled and removes stale settings", () => {+ const base = { enabled: true, model: null, options: { previewVae: "stale" } };+ const options = (modelType = "minimax-h3") => engineProviderSetting(EMPTY_ENGINE_SETTINGS, base, "sage2", [], "prompt", [], false, {}, { modelType }).options;+ expect(options()).not.toHaveProperty("previewVae");+ saveOtherWeightPath(TAEH3_URL, "C:/weights/taeh3.safetensors");+ expect(options()).toHaveProperty("previewVae", "C:/weights/taeh3.safetensors");+ expect(options("moss")).not.toHaveProperty("previewVae");+ saveGenerationPreviewsEnabled(false);+ expect(options()).not.toHaveProperty("previewVae");+});++it("rejects malformed and excessive worker preview payloads", () => {+ const valid = { jobId: "job", step: 0, width: 168, height: 96, fps: 7, frames: ["jpeg"] };+ expect(validGenerationPreview(valid)).toBe(true);+ for (const patch of [{ frames: [] }, { frames: Array(129).fill("jpeg") }, { frames: ["x".repeat(262145)] },+ { fps: Infinity }, { fps: 0 }, { width: 257 }, { height: -2 }, { step: -1 }]) {+ expect(validGenerationPreview({ ...valid, ...patch })).toBe(false);+ }+});diff --git a/src/lib/generationPreview.ts b/src/lib/generationPreview.tsnew file mode 100644index 0000000..094c83f--- /dev/null+++ b/src/lib/generationPreview.ts@@ -0,0 +1,54 @@+export interface GenerationPreview {+ jobId: string;+ step: number;+ width: number;+ height: number;+ fps: number;+ /** Base64 JPEG frames; transient and never written into the project. */+ frames: string[];+}++export function validGenerationPreview(value: GenerationPreview): boolean {+ return Boolean(value && typeof value.jobId === "string" && Number.isInteger(value.step) && value.step >= 0+ && [value.width, value.height].every((size) => Number.isInteger(size) && size > 0 && size <= 256 && size % 2 === 0)+ && Number.isFinite(value.fps) && value.fps > 0 && value.fps <= 60+ && Array.isArray(value.frames) && value.frames.length > 0 && value.frames.length <= 128+ && value.frames.every((frame) => typeof frame === "string" && frame.length > 0 && frame.length <= 262144)+ && value.frames.reduce((bytes, frame) => bytes + frame.length, 0) <= 8 * 1024 * 1024);+}++/** Small silent MP4 for the scene card. WebCodecs owns encoding; no files or FFmpeg. */+export async function encodeGenerationPreview(preview: GenerationPreview, signal: AbortSignal): Promise<Blob> {+ if (!validGenerationPreview(preview)) throw new Error("Invalid generation preview.");+ signal.throwIfAborted();+ const { width, height, fps } = preview;+ const config: VideoEncoderConfig = { codec: "avc1.42001f", width, height, framerate: fps, bitrate: 600_000, avc: { format: "avc" } };+ if (!(await VideoEncoder.isConfigSupported(config)).supported) throw new Error("Preview encoding is unavailable.");+ const { ArrayBufferTarget, Muxer } = await import("mp4-muxer");+ signal.throwIfAborted();+ const target = new ArrayBufferTarget();+ const muxer = new Muxer({ target, video: { codec: "avc", width, height }, fastStart: "in-memory" });+ const failure: { error?: DOMException } = {};+ const encoder = new VideoEncoder({ output: (chunk, metadata) => muxer.addVideoChunk(chunk, metadata), error: (error) => { failure.error = error; } });+ try {+ encoder.configure(config);+ for (let i = 0; i < preview.frames.length; ++i) {+ signal.throwIfAborted();+ if (failure.error) throw failure.error;+ const jpeg = Uint8Array.from(atob(preview.frames[i]), (char) => char.charCodeAt(0));+ const bitmap = await createImageBitmap(new Blob([jpeg], { type: "image/jpeg" }));+ try {+ signal.throwIfAborted();+ const frame = new VideoFrame(bitmap, { timestamp: Math.round(i * 1e6 / fps), duration: Math.round((i + 1) * 1e6 / fps) - Math.round(i * 1e6 / fps) });+ try { encoder.encode(frame, { keyFrame: i === 0 }); }+ finally { frame.close(); }+ } finally { bitmap.close(); }+ if (encoder.encodeQueueSize >= 8) await encoder.flush();+ }+ await encoder.flush();+ signal.throwIfAborted();+ if (failure.error) throw failure.error;+ muxer.finalize();+ return new Blob([target.buffer], { type: "video/mp4" });+ } finally { if (encoder.state !== "closed") encoder.close(); }+}diff --git a/src/lib/settings.ts b/src/lib/settings.tsindex 4755a9b..0cbadc8 100644--- a/src/lib/settings.ts+++ b/src/lib/settings.ts@@ -16,7 +16,8 @@ import { isSigmaShift, type SigmaShifts } from "./sampling";import { normalizeH3Library, resolveH3Components, type H3Components } from "./h3Components";import { generatorModel } from "./generatorModels";export { generatorModel, GENERATOR_MODELS } from "./generatorModels";-import { latentUpscalerPath } from "./upscalers";+import { latentUpscalerPath, otherWeightPaths, TAEH3_URL } from "./upscalers";+import { loadGenerationPreviewsEnabled } from "./generationPreviewSettings";import { DEFAULT_GENERATION_STEPS, MAX_GENERATION_STEPS, type ProjectConfig, type ProviderSetting } from "./project";// Type-only: erased at build time, so this does not close a cycle with runtime.ts.import type { ProviderId } from "./runtime";@@ -758,6 +759,9 @@ export function engineProviderSetting(settings: EngineSettings, base?: ProviderSdelete options.motionCache;delete options.workerWeightSources;delete options.latentUpscaler;+ delete options.previewVae;+ const previewVae = otherWeightPaths()[TAEH3_URL];+ if (loadGenerationPreviewsEnabled() && (shifts.modelType ?? "minimax-h3") === "minimax-h3" && previewVae) options.previewVae = previewVae;const latentUpscaler = latentUpscalerPath();if (latentUpscaler && !generatorModel(shifts.modelType).musicGeneration) options.latentUpscaler = latentUpscaler;if (remote && sources) {diff --git a/src/lib/workQueue.test.ts b/src/lib/workQueue.test.tsindex 85aa17d..3d5fcdc 100644--- a/src/lib/workQueue.test.ts+++ b/src/lib/workQueue.test.ts@@ -14,6 +14,7 @@ import { generateAgentImage, generateAgentScene, generateAgentMusic } from "./agimport { applyImageDraftCommand } from "./imageDraftCommands";import { LATENT_UPSCALER_URL, saveLocalOtherWeightPaths } from "./upscalers";import { WorkQueue, type GenerationSubmission } from "./workQueue";+import { saveGenerationPreviewsEnabled } from "./generationPreviewSettings";import { saveSceneLastFrame } from "./sceneLastFrame";import { prepareReferenceVideos, releaseReferenceVideos } from "./referenceVideo";import { downloadTemplateWeights, getWeightDownloadState } from "./weightDownloads";@@ -68,6 +69,34 @@ const finish = async (queue: WorkQueue, id: string) => {await waitFor(() => expect(queue.getSnapshot().find((item) => item.id === id)?.status).toBe("completed"));};+it("isolates live previews by native job and clears them on disable, cancel and completion", async () => {+ const { queue, first, second } = setup();+ const [id] = queue.enqueue(first, [submission(first)]);+ const [other] = queue.enqueue(second, [submission(second)]);+ await waitFor(() => expect(queue.getSnapshot().find((item) => item.id === id)?.status).toBe("generating"));+ const preview = { jobId: id, width: 2, height: 2, fps: 4, step: 0, frames: ["/9j/AA=="] };+ emit("slopfab-preview", { ...preview, jobId: "unknown" });+ expect(queue.getSnapshot().every((item) => !item.preview)).toBe(true);+ emit("slopfab-preview", preview);+ expect(queue.getSnapshot().find((item) => item.id === id)?.preview).toEqual(preview);+ expect(queue.getSnapshot().find((item) => item.id === other)?.preview).toBeUndefined();+ expect(JSON.stringify(first.getSnapshot().config)).not.toContain("/9j/AA==");+ saveGenerationPreviewsEnabled(false);+ emit("slopfab-preview", preview);+ expect(queue.getSnapshot().find((item) => item.id === id)?.preview).toBeUndefined();+ saveGenerationPreviewsEnabled(true);+ emit("slopfab-preview", preview);+ await finish(queue, id);+ emit("slopfab-preview", preview);+ expect(queue.getSnapshot().find((item) => item.id === id)?.preview).toBeUndefined();+ await waitFor(() => expect(queue.getSnapshot().find((item) => item.id === other)?.status).toBe("generating"));+ emit("slopfab-preview", { ...preview, jobId: other });+ await queue.cancel(other);+ emit("slopfab-preview", { ...preview, jobId: other });+ expect(queue.getSnapshot().find((item) => item.id === other)?.preview).toBeUndefined();+ emit("slopfab-job", { jobId: other, state: "cancelled", detail: "Cancelled" });+});+it("upscales selected Takes repeatedly without diffusion, preserving source lineage and joined scene ranges", async () => {const { queue, first } = setup();const job = first.getSnapshot().config.generationJobs[0];diff --git a/src/lib/workQueue.ts b/src/lib/workQueue.tsindex d2e8084..59f6bae 100644--- a/src/lib/workQueue.ts+++ b/src/lib/workQueue.ts@@ -18,6 +18,8 @@ import { projectItemPath, referenceDefinition, referenceImages, referenceRefmodIimport { generationSigmaShiftsWithLoras, engineProviderSetting, generatorModel, templateSupportsEditing, templateSupportsOutpainting, templateSupportsImages, templateSupportsVideo, defaultGeneratorTemplate, loadGeneratorTemplateSettings, type GeneratorTemplate } from "./settings";import { describeDiagnosticError, writeDiagnostic } from "./diagnostics";import { GenerationTimingEstimator, type CompletedGenerationTiming, type GenerationTimingProgress } from "./generationTiming";+import { validGenerationPreview, type GenerationPreview } from "./generationPreview";+import { loadGenerationPreviewsEnabled, subscribeGenerationPreviews } from "./generationPreviewSettings";import { releaseRendered, saveGeneratedScene } from "./generatedVideo";import { isTauri, saveProject } from "./persistence";import { continuationBlocker, generationAssetId, generationLatentPath, GENERATION_FRAME_RATE, sceneSiblings, sceneOutputFrames, sceneGenerationSnapshot, type SceneInput, type GenerationJob, type ProjectRecord, type ProjectConfig } from "./project";@@ -65,6 +67,7 @@ export interface WorkItem {completionAt: number | null;cancelling: boolean;needsSave: boolean;+ preview?: GenerationPreview;settings: { frames: number; steps: number; audioSteps?: number; videoSigmaShift?: number; audioSigmaShift?: number; latentUpscale?: boolean; seed: number; canvasWidth: number; canvasHeight: number };}interface PendingWork {@@ -147,6 +150,7 @@ export class WorkQueue {subscribe = (listener: () => void) => { this.listeners.add(listener); return () => { this.listeners.delete(listener); }; };private publish() { this.listeners.forEach((listener) => listener()); }private patch(id: string, patch: Partial<WorkItem>) {+ if (patch.cancelling || (patch.status && ["completed", "failed", "cancelled"].includes(patch.status))) patch = { ...patch, preview: undefined };this.items = this.items.map((item) => item.id === id ? { ...item, ...patch } : item);this.publish();}@@ -204,12 +208,19 @@ export class WorkQueue {if (this.connections === 1 && isTauri()) {let disposed = false;const stops: (() => void)[] = [];+ stops.push(subscribeGenerationPreviews(() => {+ if (!loadGenerationPreviewsEnabled()) {+ this.items = this.items.map((item) => item.preview ? { ...item, preview: undefined } : item);+ this.publish();+ }+ }));const subscribe = async <T,>(name: string, handler: (payload: T) => void) => {const stop = await listen<T>(name, ({ payload }) => { if (!disposed) handler(payload); });if (disposed) stop(); else stops.push(stop);};this.ready = Promise.all([subscribe<GenerationTimingProgress>("slopfab-progress", (event) => this.progress(event)),+ subscribe<GenerationPreview>("slopfab-preview", (event) => this.preview(event)),subscribe<JobEvent>("slopfab-job", (event) => this.event(event)),]).then(() => undefined);void this.ready.catch((reason) => writeDiagnostic("error", "work-queue", "subscription.failed", describeDiagnosticError(reason), {}));@@ -695,6 +706,14 @@ export class WorkQueue {void work.session.save().catch(() => undefined);work.finish();}+ private preview(event: GenerationPreview) {+ if (!loadGenerationPreviewsEnabled() || !validGenerationPreview(event)) return;+ const work = this.nativeWork(event.jobId);+ const item = this.items.find((candidate) => candidate.id === work?.id);+ if (!work || !item || work.cancelled || item.cancelling || item.kind || work.upscaleSource+ || !["preparing", "generating"].includes(item.status)) return;+ this.patch(work.id, { preview: event });+ }private progress(event: GenerationTimingProgress) {if (this.icons.progressEvent(event)) return;const work = this.nativeWork(event.jobId);diff --git a/src/styles/generator.css b/src/styles/generator.cssindex 91578fe..f1b8903 100644--- a/src/styles/generator.css+++ b/src/styles/generator.css@@ -1032,6 +1032,9 @@/* Takes sit beside tiles, or in a wrapping row below the shot list. */.scene-section__content { display: grid; grid-template-columns: minmax(0, 1fr) 88px; align-items: start; gap: var(--space-2); }+.generation-preview { display: grid; gap: var(--space-1); width: min(100%, 360px); margin-bottom: var(--space-2); }+.generation-preview video, .generation-preview img { display: block; width: 100%; max-height: 260px; object-fit: contain; background: #000; border-radius: var(--radius-lg); }+.generation-preview > span { font-size: 12px; color: var(--text-secondary); }.scene-section__content > .shot-grid { min-width: 0; grid-template-columns: repeat(auto-fill, minmax(0, min(var(--shot-tile-width), 100%))); }.scene-board--list .scene-section__content { grid-template-columns: minmax(0, 1fr); gap: 0; }.scene-board--list .scene-section__content > .shot-grid { grid-template-columns: minmax(0, 1fr); }