Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Support retained latent bridges

Bitti740fdca26509
diff --git a/docs/slopfab-compatibility.md b/docs/slopfab-compatibility.md
index 9db06a3..18fdbce 100644
--- a/docs/slopfab-compatibility.md
+++ b/docs/slopfab-compatibility.md
@@ -1,5 +1,31 @@
# Slopfab compatibility
+## API 1.26: Long Shot latent bridges
+
+Consecutive **Long Shot** scenes alternate fresh anchors and bridges. Generate
+all queues 1, 3, 2, 5, 4, 7, 6. A bridge requires completed neighbors with saved
+latents; an unfinished final bridge needs another Long Shot scene after it.
+The two margin controls replace the previous anchor's ending and the following
+anchor's beginning in multiples of 17 frames (default 17, zero allowed).
+Each anchor must also provide 22 preserved context frames. Use the same canvas,
+VAE models and latent upscale setting throughout the run. Cite original subject
+references in every scene that needs them.
+
+Slopus calls `slopfab_request_set_latent_bridge_files`. The requested gap rounds
+up to `17*k+12` frames; output is the full left archive, gap and right archive.
+MotionCache is disabled for bridge requests. The next bridge uses the previous
+joined archive as its left input, preserving earlier changes to shared anchors.
+Scene ranges keep editing coordinates and duration local to each scene while
+preview, timeline playback and export use the latest compatible joined decode,
+including audio. Regenerating an anchor invalidates joined playback derived
+from its old latents. Original anchor archives are never overwritten.
+
+Windows and Linux bundles include API 1.26 builds with FFmpeg disabled. LAN
+protocol 9 transfers both archives and preserves margin/context settings;
+update the desktop and worker together. Older local runtimes report an API
+requirement when a bridge is requested. Planning tests exercise both bundles
+with synthetic latent archives, without running model inference.
+
## API 1.25: generation sample lifetime
Finished generation cleanup calls `slopfab_generation_release_samples` before
diff --git a/lib/slopfab/libslopfab.so b/lib/slopfab/libslopfab.so
index f42f5d4..252c8ac 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:50c842f079273a08cf4e31a7a09f8ea9eb81d5cbc5686a981d4d8b36597c8829
-size 20323840
+oid sha256:6b0b04b1f5275477e984cc8bad939423bbacc296beb8134f9c0612404356a431
+size 20354384
diff --git a/lib/slopfab/slopfab.dll b/lib/slopfab/slopfab.dll
index 6ffdae4..fa4be4a 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:4156f602b714b5e252cec593b26bf2916c77e8c5dde0704daefe6108b0cbff99
-size 17624576
+oid sha256:3837d329a919532988526ab8fa5fab93eb609ad91b4c05bcc4059375b5de37c3
+size 17639936
diff --git a/src-tauri/core/src/slopfab/config.rs b/src-tauri/core/src/slopfab/config.rs
index d3b1d89..81b26b1 100644
--- a/src-tauri/core/src/slopfab/config.rs
+++ b/src-tauri/core/src/slopfab/config.rs
@@ -133,7 +133,7 @@ impl Configuration {
"Animate requires exactly one repainted frame of the driving scene.".into(),
);
}
- if request.continuation_path.is_some() || !request.refmods.is_empty() || !request.reference_audio_ids.is_empty() {
+ if request.continuation_path.is_some() || request.latent_bridge.is_some() || !request.refmods.is_empty() || !request.reference_audio_ids.is_empty() {
return Err("Animate does not support scene continuation, sound references or refmods.".into());
}
} else if request.prompt.trim().is_empty() {
diff --git a/src-tauri/core/src/slopfab/continuation.rs b/src-tauri/core/src/slopfab/continuation.rs
index e6d139e..cdf2eaf 100644
--- a/src-tauri/core/src/slopfab/continuation.rs
+++ b/src-tauri/core/src/slopfab/continuation.rs
@@ -247,6 +247,41 @@ mod tests {
file
}
+ #[test]
+ fn long_shot_plans_full_joined_outputs_and_keeps_source_archives_immutable() {
+ use super::super::{types::LatentBridgeRequest, planning::validate_generation_controls};
+ let left = archive(124).into_temp_path();
+ let right = archive(90).into_temp_path();
+ let originals = [std::fs::read(&left).unwrap(), std::fs::read(&right).unwrap()];
+ let mut request = GenerationRequest {
+ prompt: "The subject continues walking".into(), frames: 30, steps: 4, seed: 1,
+ canvas_width: 64, canvas_height: 32,
+ bridge_left_path: Some(left.to_path_buf()), bridge_right_path: Some(right.to_path_buf()),
+ latent_bridge: Some(LatentBridgeRequest { left_scene_id: "left".into(), right_scene_id: "right".into(),
+ left_frames: Some(124), right_frames: Some(90), left_margin_frames: 17, right_margin_frames: 34,
+ context_frames: 22, ..Default::default() }), ..Default::default()
+ };
+ let settings = BTreeMap::from([("slopfab".into(), crate::settings::ProviderSetting {
+ enabled: true, model: None, options: BTreeMap::from([("motionCache".into(), crate::settings::ProviderOption::Boolean(true))]),
+ })]);
+ let plan = resolve_plan(&request, &settings, &ReferenceVideos::default()).unwrap();
+ assert_eq!(plan.aligned_frames, 260); // 124 + 46 + 90, including replaced margins.
+ assert!((plan.duration_seconds - 260.0 / 24.0).abs() < 0.0001);
+ for margin in [-17, 1, 357] {
+ request.latent_bridge.as_mut().unwrap().left_margin_frames = margin;
+ assert!(validate_generation_controls(&request).is_err());
+ }
+ request.latent_bridge.as_mut().unwrap().left_margin_frames = 0;
+ assert!(resolve_plan(&request, &settings, &ReferenceVideos::default()).is_ok());
+ request.bridge_right_path = None;
+ assert!(validate_generation_controls(&request).is_err());
+ assert_eq!(std::fs::read(&left).unwrap(), originals[0]);
+ assert_eq!(std::fs::read(&right).unwrap(), originals[1]);
+ let wire = serde_json::to_value(request).unwrap();
+ assert!(wire.get("bridgeLeftPath").is_none());
+ assert_eq!(wire["latentBridge"]["rightMarginFrames"], 34);
+ }
+
#[test]
fn opening_continuation_crops_the_selected_scene_and_both_audio_channels() {
let source = archive(124);
diff --git a/src-tauri/core/src/slopfab/ffi/mod.rs b/src-tauri/core/src/slopfab/ffi/mod.rs
index 4610fd4..8508627 100644
--- a/src-tauri/core/src/slopfab/ffi/mod.rs
+++ b/src-tauri/core/src/slopfab/ffi/mod.rs
@@ -125,6 +125,10 @@ impl Api {
self.check(r)?;
self.inner.set_save_latents(r.pointer.as_ptr(), path)
}
+ pub fn set_latent_bridge_files(&self, r: &RequestHandle, left: &Path, right: &Path, left_margin: i32, right_margin: i32, context: i32) -> Result<(), String> {
+ self.check(r)?;
+ self.inner.set_latent_bridge_files(r.pointer.as_ptr(), left, right, left_margin, right_margin, context)
+ }
pub fn set_continuation_file(
&self,
r: &RequestHandle,
diff --git a/src-tauri/core/src/slopfab/ffi/raw/mod.rs b/src-tauri/core/src/slopfab/ffi/raw/mod.rs
index d4d9ec1..1d96a28 100644
--- a/src-tauri/core/src/slopfab/ffi/raw/mod.rs
+++ b/src-tauri/core/src/slopfab/ffi/raw/mod.rs
@@ -86,6 +86,7 @@ pub struct Api {
set_image_edit_invert_mask: Option<unsafe extern "C" fn(*mut Request, i32) -> i32>,
set_save_latents: Option<unsafe extern "C" fn(*mut Request, *const c_char) -> i32>,
set_continuation_file: Option<unsafe extern "C" fn(*mut Request, *const c_char, i32) -> i32>,
+ set_latent_bridge_files: Option<unsafe extern "C" fn(*mut Request, *const c_char, *const c_char, i32, i32, i32) -> i32>,
set_continuation_lock_overlap: Option<unsafe extern "C" fn(*mut Request, i32) -> i32>,
set_video_transition: Option<unsafe extern "C" fn(*mut Request, i32) -> i32>,
set_steps: unsafe extern "C" fn(*mut Request, i32) -> i32,
@@ -242,6 +243,7 @@ impl Api {
)
.ok()
.map(|symbol| *symbol),
+ set_latent_bridge_files: library.get::<unsafe extern "C" fn(*mut Request, *const c_char, *const c_char, i32, i32, i32) -> i32>(b"slopfab_request_set_latent_bridge_files\0").ok().map(|symbol| *symbol),
set_continuation_file: library
.get::<unsafe extern "C" fn(*mut Request, *const c_char, i32) -> i32>(
b"slopfab_request_set_continuation_file\0",
@@ -453,6 +455,12 @@ impl Api {
)?;
self.error(unsafe { set(r, mode) })
}
+ pub fn set_latent_bridge_files(&self, r: *mut Request, left: &Path, right: &Path, left_margin: i32, right_margin: i32, context: i32) -> Result<(), String> {
+ let set = self.set_latent_bridge_files.ok_or("Long Shot requires SlopFab API 1.26 or later. Update the runtime.")?;
+ let left = path_cstring(left)?;
+ let right = path_cstring(right)?;
+ self.error(unsafe { set(r, left.as_ptr(), right.as_ptr(), left_margin, right_margin, context) })
+ }
pub fn set_continuation_file(
&self,
r: *mut Request,
diff --git a/src-tauri/core/src/slopfab/h3.rs b/src-tauri/core/src/slopfab/h3.rs
index 86d5728..11bd5b7 100644
--- a/src-tauri/core/src/slopfab/h3.rs
+++ b/src-tauri/core/src/slopfab/h3.rs
@@ -98,7 +98,13 @@ pub(super) fn configure_request(
let lock_overlap = request.continuation_path.is_some() && request.continuation_lock_overlap;
let independent_audio = request.audio_steps.is_some_and(|steps| steps != video_steps);
// Overlap locking and different audio/video step counts require full evaluations.
- api.set_motion_cache(handle, configuration.motion_cache && !dmad && request.image_edit.is_none() && !lock_overlap && !independent_audio)?;
+ api.set_motion_cache(handle, configuration.motion_cache && !dmad && request.image_edit.is_none() && !lock_overlap && !independent_audio && request.latent_bridge.is_none())?;
+ if let Some(bridge) = &request.latent_bridge {
+ api.set_latent_bridge_files(handle,
+ request.bridge_left_path.as_deref().ok_or("Missing left Long Shot archive.")?,
+ request.bridge_right_path.as_deref().ok_or("Missing right Long Shot archive.")?,
+ bridge.left_margin_frames, bridge.right_margin_frames, bridge.context_frames)?;
+ }
api.set_verbose(handle, false)?;
if let Some(mode) = request.video_transition.as_deref() {
api.set_video_transition(handle, if mode == "bridge" { 2 } else { 1 })?;
diff --git a/src-tauri/core/src/slopfab/planning.rs b/src-tauri/core/src/slopfab/planning.rs
index 958691e..cee4bfc 100644
--- a/src-tauri/core/src/slopfab/planning.rs
+++ b/src-tauri/core/src/slopfab/planning.rs
@@ -58,6 +58,17 @@ pub fn resolve_plan(
pub(super) fn validate_generation_controls(request: &GenerationRequest) -> Result<(), String> {
super::continuation::validate(request)?;
+ if let Some(bridge) = &request.latent_bridge {
+ if request.bridge_left_path.is_none() || request.bridge_right_path.is_none()
+ || request.still_image || request.image_edit.is_some() || request.video_transition.is_some()
+ || request.continuation_path.is_some() || request.continuation_relative_path.is_some()
+ || request.frames <= 0 || bridge.context_frames < 5 || bridge.context_frames % 17 != 5
+ || [bridge.left_margin_frames, bridge.right_margin_frames].iter().any(|margin| !(0..=340).contains(margin) || margin % 17 != 0)
+ || [(bridge.left_frames, bridge.left_margin_frames), (bridge.right_frames, bridge.right_margin_frames)].iter()
+ .any(|(frames, margin)| frames.is_none_or(|frames| i64::from(frames) < i64::from(*margin) + i64::from(bridge.context_frames) || frames % 17 != 5)) {
+ return Err("Long Shot requires two generated latent archives, compatible video settings, margins in multiples of 17, and enough context in both anchors.".into());
+ }
+ }
if request.latent_upscale && (request.still_image || request.image_edit.is_some()
|| request.canvas_width < 64 || request.canvas_height < 64
|| request.canvas_width % 32 != 0 || request.canvas_height % 32 != 0) {
@@ -127,6 +138,13 @@ pub(super) fn scene_frame_window(
if total <= 0 {
return Err("Slopfab returned no video frames.".into());
}
+ if let Some(bridge) = &request.latent_bridge {
+ let gap = ((i64::from(request.frames) - 12).max(0) + 16) / 17 * 17 + 12;
+ if i64::from(total) != i64::from(bridge.left_frames.unwrap_or(0)) + gap + i64::from(bridge.right_frames.unwrap_or(0)) {
+ return Err("Long Shot output must contain both anchors and the entire bridge.".into());
+ }
+ return Ok((0, total));
+ }
if request.continuation_path.is_none() {
return Ok((0, total));
}
diff --git a/src-tauri/core/src/slopfab/types.rs b/src-tauri/core/src/slopfab/types.rs
index 98aacef..0d94733 100644
--- a/src-tauri/core/src/slopfab/types.rs
+++ b/src-tauri/core/src/slopfab/types.rs
@@ -35,6 +35,20 @@ pub fn gpu_devices() -> Vec<GpuDevice> {
ffi::gpu_devices()
}
+#[derive(Debug, Clone, Default, Deserialize, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct LatentBridgeRequest {
+ pub left_scene_id: String,
+ pub right_scene_id: String,
+ pub left_relative_path: Option<String>,
+ pub right_relative_path: Option<String>,
+ pub left_frames: Option<i32>,
+ pub right_frames: Option<i32>,
+ pub left_margin_frames: i32,
+ pub right_margin_frames: i32,
+ pub context_frames: i32,
+}
+
// Serialize exists for LAN workers. Skipped fields stay on this side: the
// worker resolves its own continuation, edit source and latent paths.
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
@@ -81,6 +95,12 @@ pub struct GenerationRequest {
pub continuation_lock_overlap: bool,
#[serde(default)]
pub continuation_source_frames: Option<i32>,
+ #[serde(default)]
+ pub latent_bridge: Option<LatentBridgeRequest>,
+ #[serde(skip)]
+ pub bridge_left_path: Option<PathBuf>,
+ #[serde(skip)]
+ pub bridge_right_path: Option<PathBuf>,
// Only the project commands resolve paths; IPC cannot supply save targets.
#[serde(skip)]
pub continuation_path: Option<PathBuf>,
diff --git a/src-tauri/core/src/worker/protocol.rs b/src-tauri/core/src/worker/protocol.rs
index 6aaf5aa..ddd084b 100644
--- a/src-tauri/core/src/worker/protocol.rs
+++ b/src-tauri/core/src/worker/protocol.rs
@@ -10,11 +10,12 @@ use std::collections::BTreeMap;
pub const SERVICE_TYPE: &str = "_slopus-worker._tcp.local.";
/// Bumped on any incompatible change to the routes or bodies below.
// 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 = 8;
+pub const PROTOCOL_VERSION: u32 = 9;
/// Streaming SeedVR2 restoration; model paths are resolved on the worker.
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -92,6 +93,8 @@ pub struct RemoteJob {
pub settings: BTreeMap<String, ProviderSetting>,
pub files: Vec<FileRef>,
pub continuation: Option<usize>,
+ pub bridge_left: Option<usize>,
+ pub bridge_right: Option<usize>,
pub image_edit_source: Option<usize>,
}
diff --git a/src-tauri/core/src/worker/server.rs b/src-tauri/core/src/worker/server.rs
index f0b30db..669d8a8 100644
--- a/src-tauri/core/src/worker/server.rs
+++ b/src-tauri/core/src/worker/server.rs
@@ -640,6 +640,11 @@ impl Worker {
}
let file = |index: Option<usize>| index.map(|index| paths.get(index).cloned().ok_or("A worker job names a file it did not send.")).transpose();
request.continuation_path = file(job.continuation)?;
+ request.bridge_left_path = file(job.bridge_left)?;
+ request.bridge_right_path = file(job.bridge_right)?;
+ if request.latent_bridge.is_some() && (request.bridge_left_path.is_none() || request.bridge_right_path.is_none()) {
+ return Err("Long Shot requires both neighboring latent archives.".into());
+ }
request.image_edit_path = file(job.image_edit_source)?;
if request.image_edit.is_some() && request.image_edit_path.is_none() {
return Err("Image edits require their source image.".into());
diff --git a/src-tauri/src/media/artifacts.rs b/src-tauri/src/media/artifacts.rs
index e72d474..4645246 100644
--- a/src-tauri/src/media/artifacts.rs
+++ b/src-tauri/src/media/artifacts.rs
@@ -57,6 +57,18 @@ pub(crate) fn prepare_continuation_path(
folder_path: Option<&str>,
) -> Result<(), String> {
request.continuation_path = None;
+ request.bridge_left_path = None;
+ request.bridge_right_path = None;
+ if let Some(bridge) = &request.latent_bridge {
+ let root = ProjectRoot::open(folder_path.ok_or("A project folder is required for Long Shot.")?)?;
+ let resolve = |relative: &Option<String>| -> Result<PathBuf, String> {
+ let path = root.existing(relative.as_deref().ok_or("Generate both Long Shot neighbors first.")?)?;
+ if !path.is_file() { return Err("Long Shot latents must be files inside this project.".into()); }
+ Ok(path)
+ };
+ request.bridge_left_path = Some(resolve(&bridge.left_relative_path)?);
+ request.bridge_right_path = Some(resolve(&bridge.right_relative_path)?);
+ }
if let Some(relative) = &request.continuation_relative_path {
let root = ProjectRoot::open(
folder_path.ok_or("A project folder is required to continue a scene.")?,
diff --git a/src-tauri/src/project/commands/clips.rs b/src-tauri/src/project/commands/clips.rs
index 04055bb..2bdbc7f 100644
--- a/src-tauri/src/project/commands/clips.rs
+++ b/src-tauri/src/project/commands/clips.rs
@@ -47,8 +47,7 @@ pub(super) fn apply(
true,
)?
.max(frame_ms.max(1));
- let scene_ms = existing.and_then(|index| project.assets[index].scene_segments.as_ref()
- .and_then(|segments| segments.last()).map(|part| (f64::from(part.frame_count) * 1000.0 / 24.0).round() as u64)).unwrap_or(scene_ms);
+ let scene_ms = existing.and_then(|index| project.assets[index].clip_duration_ms()).unwrap_or(scene_ms);
let asset_id = if let Some(index) = existing {
project.assets[index].id.clone()
} else {
diff --git a/src-tauri/src/project/model.rs b/src-tauri/src/project/model.rs
index 4335f61..ef5c56f 100644
--- a/src-tauri/src/project/model.rs
+++ b/src-tauri/src/project/model.rs
@@ -134,7 +134,7 @@ pub(crate) struct AgentConversation {
impl ProjectAsset {
pub(crate) fn clip_duration_ms(&self) -> Option<u64> {
- self.scene_segments.as_ref().and_then(|segments| segments.last())
+ self.scene_segments.as_ref().and_then(|segments| segments.iter().find(|part| self.id == format!("asset-{}", part.scene_id)).or_else(|| segments.last()))
.map(|segment| (f64::from(segment.frame_count) * 1000.0 / 24.0).round() as u64)
.or(self.duration_ms)
}
diff --git a/src-tauri/src/project/scenes.rs b/src-tauri/src/project/scenes.rs
index 7b36d52..66ac5a8 100644
--- a/src-tauri/src/project/scenes.rs
+++ b/src-tauri/src/project/scenes.rs
@@ -46,6 +46,10 @@ pub(crate) struct GenerationJob {
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) backdrop_color: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) bridge_left_margin: Option<i32>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub(crate) bridge_right_margin: Option<i32>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) pose_video_reference_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub(crate) start_video_reference_id: Option<String>,
@@ -158,6 +162,8 @@ impl GenerationJob {
id: id.to_string(),
scene_type: None,
backdrop_color: None,
+ bridge_left_margin: None,
+ bridge_right_margin: None,
pose_video_reference_id: None,
start_video_reference_id: None,
end_video_reference_id: None,
diff --git a/src-tauri/src/project/validation/scenes.rs b/src-tauri/src/project/validation/scenes.rs
index 733a822..5137211 100644
--- a/src-tauri/src/project/validation/scenes.rs
+++ b/src-tauri/src/project/validation/scenes.rs
@@ -22,11 +22,14 @@ pub(super) fn validate(config: &mut ProjectConfig) -> Result<(), String> {
if job.scene_type.as_deref().is_some_and(|value| {
!matches!(
value,
- "first-last-frame" | "continue" | "animate" | "pose" | "character-replace" | "extend" | "bridge" | "backdrop"
+ "first-last-frame" | "continue" | "animate" | "pose" | "character-replace" | "extend" | "bridge" | "backdrop" | "long-shot"
)
}) {
return Err(format!("Scene '{}' has an unsupported scene type.", job.id));
}
+ if [job.bridge_left_margin, job.bridge_right_margin].iter().flatten().any(|margin| !(0..=340).contains(margin) || margin % 17 != 0) {
+ return Err(format!("Scene '{}' has invalid Long Shot margins. Use multiples of 17 from 0 to 340 frames.", job.id));
+ }
if job.backdrop_color.as_deref().is_some_and(|value| !matches!(value, "green" | "blue" | "black" | "white")) {
return Err(format!("Scene '{}' has an unsupported backdrop color.", job.id));
}
diff --git a/src-tauri/src/tests/artifacts.rs b/src-tauri/src/tests/artifacts.rs
index 044343a..4a93a21 100644
--- a/src-tauri/src/tests/artifacts.rs
+++ b/src-tauri/src/tests/artifacts.rs
@@ -1,5 +1,28 @@
use super::*;
+#[test]
+fn long_shot_resolves_both_archives_inside_the_project_only() {
+ let folder = project_folder();
+ let root = folder.path().to_string_lossy();
+ let destination = generated_latent_destination(&root, "anchor").unwrap();
+ fs::write(&destination, b"latents").unwrap();
+ let mut request = slopfab::GenerationRequest {
+ latent_bridge: Some(slopfab::LatentBridgeRequest {
+ left_relative_path: Some("latents/anchor.safetensors".into()), right_relative_path: Some("latents/anchor.safetensors".into()),
+ ..Default::default()
+ }), ..Default::default()
+ };
+ assert!(prepare_continuation_path(&mut request, None).is_err());
+ prepare_continuation_path(&mut request, Some(&root)).unwrap();
+ assert_eq!(request.bridge_left_path.as_ref(), Some(&destination));
+ assert_eq!(request.bridge_right_path.as_ref(), Some(&destination));
+ for invalid in ["../outside.safetensors", "C:/outside.safetensors", "latents/missing.safetensors", "latents"] {
+ request.latent_bridge.as_mut().unwrap().right_relative_path = Some(invalid.into());
+ assert!(prepare_continuation_path(&mut request, Some(&root)).is_err());
+ assert!(request.bridge_right_path.is_none());
+ }
+}
+
#[test]
fn a_rendered_scene_lands_in_the_project_under_its_own_id() {
let folder = project_folder();
diff --git a/src-tauri/src/tests/scenes.rs b/src-tauri/src/tests/scenes.rs
index 91eab4a..2cbee9a 100644
--- a/src-tauri/src/tests/scenes.rs
+++ b/src-tauri/src/tests/scenes.rs
@@ -1,5 +1,30 @@
use super::*;
+#[test]
+fn long_shot_settings_and_middle_scene_duration_survive_save() {
+ let mut config = fixture();
+ config.generation_jobs[0].scene_type = Some("long-shot".into());
+ config.generation_jobs[0].bridge_left_margin = Some(34);
+ config.generation_jobs[0].bridge_right_margin = Some(0);
+ let mut asset = config.assets[0].clone();
+ asset.id = "asset-middle".into();
+ asset.scene_segments = Some(vec![
+ SceneMediaSegment { scene_id: "left".into(), latent_relative_path: "latents/left.safetensors".into(), start_frame: 0, frame_count: 124 },
+ SceneMediaSegment { scene_id: "middle".into(), latent_relative_path: "latents/middle.safetensors".into(), start_frame: 124, frame_count: 46 },
+ SceneMediaSegment { scene_id: "right".into(), latent_relative_path: "latents/right.safetensors".into(), start_frame: 170, frame_count: 124 },
+ ]);
+ assert_eq!(asset.clip_duration_ms(), Some(1917));
+ let folder = tempfile::tempdir().unwrap();
+ write_project(folder.path(), &config).unwrap();
+ let restored = read_project(folder.path()).unwrap().config;
+ assert_eq!(restored.generation_jobs[0].bridge_left_margin, Some(34));
+ assert_eq!(restored.generation_jobs[0].bridge_right_margin, Some(0));
+ for margin in [-17, 1, 357] {
+ config.generation_jobs[0].bridge_left_margin = Some(margin);
+ assert!(validate_and_normalize_config(config.clone()).is_err());
+ }
+}
+
#[test]
fn joined_scene_ranges_survive_save_and_validate_bounds() {
let mut value = serde_json::to_value(fixture()).unwrap();
diff --git a/src-tauri/src/worker/client.rs b/src-tauri/src/worker/client.rs
index 1f18699..008bf91 100644
--- a/src-tauri/src/worker/client.rs
+++ b/src-tauri/src/worker/client.rs
@@ -279,7 +279,7 @@ impl Workers {
if stop.load(Ordering::Acquire) { return Err("Export cancelled.".into()); }
if !uploads.is_empty() {
let job = RemoteJob { request: GenerationRequest { job_id: id.into(), ..Default::default() },
- settings: BTreeMap::new(), files: uploads, continuation: None, image_edit_source: None };
+ settings: BTreeMap::new(), files: uploads, continuation: None, image_edit_source: None, bridge_left: None, bridge_right: None };
let cancel = Arc::new(AtomicBool::new(false));
let finished = AtomicBool::new(false);
std::thread::scope(|scope| {
@@ -963,7 +963,11 @@ pub(crate) fn build_job(request: &GenerationRequest, settings: &BTreeMap<String,
.map(|path| add(PathKind::Input, &path.to_string_lossy(), &mut files)).transpose()?;
request.save_latents_path = None;
request.image_edit_pixels = None;
- Ok((RemoteJob { request, settings, files, continuation, image_edit_source }, sources))
+ let bridge_left = request.bridge_left_path.take()
+ .map(|path| add(PathKind::Input, &path.to_string_lossy(), &mut files)).transpose()?;
+ let bridge_right = request.bridge_right_path.take()
+ .map(|path| add(PathKind::Input, &path.to_string_lossy(), &mut files)).transpose()?;
+ Ok((RemoteJob { request, settings, files, continuation, image_edit_source, bridge_left, bridge_right }, sources))
}
#[cfg(test)]
@@ -1063,6 +1067,28 @@ mod tests {
assert!(normalize_address("").is_err());
}
+ #[test]
+ fn long_shot_transfers_both_anchors_without_serializing_host_paths() {
+ let folder = tempfile::tempdir().unwrap();
+ let left = folder.path().join("left.safetensors");
+ let right = folder.path().join("right.safetensors");
+ fs::write(&left, b"left archive").unwrap();
+ fs::write(&right, b"right archive").unwrap();
+ let request = GenerationRequest { bridge_left_path: Some(left), bridge_right_path: Some(right),
+ latent_bridge: Some(slopfab::LatentBridgeRequest { left_margin_frames: 17, right_margin_frames: 34, context_frames: 22, ..Default::default() }),
+ ..Default::default() };
+ let (job, uploads) = build_job(&request, &BTreeMap::new(), &[]).unwrap();
+ assert_eq!(job.files.len(), 2);
+ assert_eq!(uploads.len(), 2);
+ assert_eq!(job.bridge_left, Some(0));
+ assert_eq!(job.bridge_right, Some(1));
+ assert!(job.request.bridge_left_path.is_none());
+ assert!(job.request.bridge_right_path.is_none());
+ let wire = serde_json::to_value(&job).unwrap();
+ assert_eq!(wire["request"]["latentBridge"]["rightMarginFrames"], 34);
+ assert!(wire["request"].get("bridgeLeftPath").is_none());
+ }
+
#[test]
fn latent_upscale_jobs_transfer_custom_weights_or_download_on_the_worker() {
let folder = tempfile::tempdir().unwrap();