Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Adapt capstone delay to short video schedules

Bitti99a8246ad2a0
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index c1eb71e..943d989 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -16,7 +16,7 @@ Changes since 0.3.2.
- **Video library.** Organize Videos → Scenes → Shots in folders, play scenes sequentially on cards or in a popout, and apply shared prompts and timed music/video references. Split a complete song into scenes; timeline clips remain individual scenes.
- **Music export.** Preview and export WAV, MP3, lossless FLAC, AAC/M4A or Opus/WebM/Ogg, with bitrate controls and background export. MP3/FLAC use bundled Mediabunny encoders.
-- **Single Shot.** Select the sequence's first video as Context video and continue from Previous video using its original latent anchors, with capstone locking after four steps. Without context, generate a short ending first and anchor the full shot to it.
+- **Single Shot.** Select the sequence's first video as Context video and continue from Previous video using its original latent anchors, with capstone locking after up to four video updates. Short LoRA schedules automatically use an earlier lock without changing their sampling recipe. Without context, generate a short ending first and anchor the full shot to it.
- **Music.** YuE2 and MiniMax Music3 generation with folders, drag-and-drop organization, grid/list views, background playback, references and timeline audio. Playback appears in the Music tab and pauses when Timeline, Video or Export playback starts. YuE2 selects BF16 above 8 GiB VRAM, otherwise INT8.
- **Motions.** Create JavaScript animations with the agent, edit elements and parameters, and export them on the timeline or as reference videos.
- **Scene history.** Keep up to four takes and an editable Draft, restore take settings, choose the primary timeline video, and duplicate scenes.
diff --git a/src-tauri/core/src/slopfab/continuation.rs b/src-tauri/core/src/slopfab/continuation.rs
index f6596b8..4f03333 100644
--- a/src-tauri/core/src/slopfab/continuation.rs
+++ b/src-tauri/core/src/slopfab/continuation.rs
@@ -312,7 +312,7 @@ pub(super) mod tests {
}
#[test]
- fn single_shot_keystone_resolves_one_pass_and_requires_more_than_four_video_updates() {
+ fn single_shot_keystone_adapts_lock_delay_to_short_video_schedules() {
use super::super::types::SingleShotRequest;
let source = archive(124).into_temp_path();
let context = archive(56).into_temp_path();
@@ -330,13 +330,55 @@ pub(super) mod tests {
assert_eq!(plan.model_evaluations, 8);
assert_eq!(std::fs::read(&source).unwrap(), source_bytes);
assert_eq!(std::fs::read(&context).unwrap(), context_bytes);
+ for steps in [2, 3, 4, 5, 6, 9] {
+ request.steps = steps;
+ let plan = resolve_plan(&request, &settings, &ReferenceVideos::default()).unwrap();
+ assert_eq!(plan.aligned_frames, 175);
+ assert_eq!(plan.model_evaluations, steps - 1);
+ assert!(plan.description.contains(&format!("capstone locks after {} video updates", (steps - 2).min(4))));
+ }
+ // Audio can add joint evaluations without adding any video updates.
request.steps = 4;
- assert!(resolve_plan(&request, &settings, &ReferenceVideos::default()).is_err());
+ request.audio_steps = Some(17);
+ let plan = resolve_plan(&request, &settings, &ReferenceVideos::default()).unwrap();
+ assert!(plan.model_evaluations > 4);
+ assert!(plan.description.contains("capstone locks after 2 video updates"));
+ request.audio_steps = None;
request.steps = 9;
request.continuation_path = None;
assert!(resolve_plan(&request, &settings, &ReferenceVideos::default()).unwrap_err().contains("Previous video"));
}
+ #[test]
+ fn single_shot_keystone_keeps_fixed_recipes_in_planning_and_execution() {
+ use super::super::{ffi::{Api, RequestHandle}, h3::configure_request, config::Configuration,
+ platform::ComputePlatform, planning::RequestPurpose, types::SingleShotRequest};
+ use crate::settings::{ProviderOption, ProviderSetting};
+ let source = archive(124).into_temp_path();
+ let context = archive(56).into_temp_path();
+ let request = GenerationRequest { prompt: "Walk forward".into(), frames: 48, steps: 30, seed: 1,
+ canvas_width: 64, canvas_height: 32, audio_steps: Some(17),
+ single_shot: Some(SingleShotRequest { ending_prompt: String::new(), ending_path: None }),
+ continuation_path: Some(source.to_path_buf()), continuation_overlap_frames: Some(22),
+ continuation_from: Some("end".into()), continuation_lock_overlap: true,
+ keystone_path: Some(context.to_path_buf()), ..Default::default() };
+ for (preset, delay, updates) in [("dmad-4step", 3, 4), ("pika-6step", 4, 6)] {
+ let settings = BTreeMap::from([("slopfab".into(), ProviderSetting { enabled: true, model: None,
+ options: BTreeMap::from([("samplingPreset".into(), ProviderOption::String(preset.into()))]) })]);
+ let configuration = Configuration::from_settings(&settings);
+ let api = Api::load(&configuration.dll_path).unwrap();
+ for platform in [ComputePlatform::Cuda13, ComputePlatform::Vulkan] {
+ for purpose in [RequestPurpose::Plan, RequestPurpose::Generate] {
+ let handle = RequestHandle::new(&api).unwrap();
+ configure_request(&api, &handle, &request, &configuration, platform, purpose, &ReferenceVideos::default()).unwrap();
+ let description = api.describe(&handle).unwrap();
+ assert!(description.contains(&format!("capstone locks after {delay} video updates")));
+ assert!(description.contains(&format!("modality updates video {updates}")));
+ }
+ }
+ }
+ }
+
#[test]
fn single_shot_anchor_plan_matches_preview_with_and_without_a_starting_source() {
use super::super::{ffi::{Api, RequestHandle}, h3::configure_request, config::Configuration,
diff --git a/src-tauri/core/src/slopfab/ffi/mod.rs b/src-tauri/core/src/slopfab/ffi/mod.rs
index a82b541..53bd63c 100644
--- a/src-tauri/core/src/slopfab/ffi/mod.rs
+++ b/src-tauri/core/src/slopfab/ffi/mod.rs
@@ -165,9 +165,9 @@ impl Api {
self.inner.set_latent_bridge_files(r.pointer.as_ptr(), left, right, left_margin, right_margin, context)
}
pub fn require_end_anchor(&self) -> Result<(), String> { self.inner.require_end_anchor() }
- pub fn set_keystone_file(&self, r: &RequestHandle, path: &Path) -> Result<(), String> {
+ pub fn set_keystone_file(&self, r: &RequestHandle, path: &Path, lock_after: i32) -> Result<(), String> {
self.check(r)?;
- self.inner.set_keystone_file(r.pointer.as_ptr(), path)
+ self.inner.set_keystone_file(r.pointer.as_ptr(), path, lock_after)
}
pub fn require_continuation_source_init(&self) -> Result<(), String> { self.inner.require_continuation_source_init() }
pub fn set_continuation_source_init(&self, r: &RequestHandle, noise: f32) -> Result<(), String> {
diff --git a/src-tauri/core/src/slopfab/ffi/raw/mod.rs b/src-tauri/core/src/slopfab/ffi/raw/mod.rs
index e978d3f..aa9177c 100644
--- a/src-tauri/core/src/slopfab/ffi/raw/mod.rs
+++ b/src-tauri/core/src/slopfab/ffi/raw/mod.rs
@@ -568,10 +568,10 @@ impl Api {
pub fn require_end_anchor(&self) -> Result<(), String> {
self.set_end_anchor_file.map(|_| ()).ok_or("Single Shot requires SlopFab API 1.40 or newer. Update the app and workers.".into())
}
- pub fn set_keystone_file(&self, r: *mut Request, path: &Path) -> Result<(), String> {
+ pub fn set_keystone_file(&self, r: *mut Request, path: &Path, lock_after: i32) -> Result<(), String> {
let set = self.set_keystone_file.ok_or("Context video requires SlopFab API 1.45 or newer. Update the app and workers.")?;
let path = CString::new(path.to_string_lossy().as_bytes()).map_err(|_| "Context video path contains a null byte.")?;
- self.error(unsafe { set(r, path.as_ptr(), 1, 4) })
+ self.error(unsafe { set(r, path.as_ptr(), 1, lock_after) })
}
pub fn require_continuation_source_init(&self) -> Result<(), String> {
self.set_continuation_source_init.map(|_| ()).ok_or("Single Shot continuation requires SlopFab API 1.41 or newer. Update the app and workers.".into())
diff --git a/src-tauri/core/src/slopfab/h3.rs b/src-tauri/core/src/slopfab/h3.rs
index 949c43e..173048c 100644
--- a/src-tauri/core/src/slopfab/h3.rs
+++ b/src-tauri/core/src/slopfab/h3.rs
@@ -163,9 +163,6 @@ pub(super) fn configure_request(
)?;
api.set_continuation_lock_overlap(handle, lock_overlap)?;
}
- if let Some(path) = &request.keystone_path {
- api.set_keystone_file(handle, path)?;
- }
if let Some(path) = request.single_shot.as_ref().and_then(|single| single.ending_path.as_ref()) {
api.set_end_anchor_file(handle, path)?;
}
@@ -222,6 +219,20 @@ pub(super) fn configure_request(
refmod.copies as i32,
)?;
}
+ if let Some(path) = &request.keystone_path {
+ // Check after all model/adapter metadata and audio settings are attached.
+ // The C API exposes joint evaluations, not the video update count, so
+ // it cannot safely be inferred from steps (especially with fixed grids).
+ // Prefer four; shorten only for this specific schedule validation error.
+ for delay in (0..=4).rev() {
+ api.set_keystone_file(handle, path, delay)?;
+ match api.resolve(handle) {
+ Ok(_) => break,
+ Err(error) if delay > 0 && error.contains("capstone lock delay must be smaller than the number of video updates") => continue,
+ Err(error) => return Err(error),
+ }
+ }
+ }
Ok(())
}
diff --git a/src-tauri/core/src/slopfab/tests.rs b/src-tauri/core/src/slopfab/tests.rs
index 16b5556..3a2e7b1 100644
--- a/src-tauri/core/src/slopfab/tests.rs
+++ b/src-tauri/core/src/slopfab/tests.rs
@@ -449,6 +449,31 @@ fn metadata_checkpoint(path: &std::path::Path, metadata: serde_json::Value) {
std::fs::write(path, bytes).unwrap();
}
+#[test]
+fn keystone_lock_uses_checkpoint_video_updates_instead_of_requested_or_joint_steps() {
+ let root = tempfile::tempdir().unwrap();
+ let transformer = root.path().join("short-grid.safetensors");
+ metadata_checkpoint(&transformer, serde_json::json!({
+ "slopfab.sampling": r#"{"version":1,"base_sigmas":[1,0.5,0]}"#
+ }));
+ let mut configuration = Configuration::from_settings(&BTreeMap::new());
+ configuration.models[0].2 = Some(transformer);
+ let api = ffi::Api::load(&configuration.dll_path).unwrap();
+ let source = continuation::tests::archive(124).into_temp_path();
+ let context = continuation::tests::archive(56).into_temp_path();
+ let request = GenerationRequest { prompt: "A quiet harbour.".into(), frames: 48, steps: 20,
+ audio_steps: Some(17), canvas_width: 64, canvas_height: 32,
+ single_shot: Some(types::SingleShotRequest { ending_prompt: String::new(), ending_path: None }),
+ continuation_path: Some(source.to_path_buf()), continuation_overlap_frames: Some(22),
+ continuation_lock_overlap: true, keystone_path: Some(context.to_path_buf()), ..Default::default() };
+ for purpose in [RequestPurpose::Plan, RequestPurpose::Generate] {
+ let handle = RequestHandle::new(&api).unwrap();
+ configure_request(&api, &handle, &request, &configuration, ComputePlatform::Cuda13, purpose, &ReferenceVideos::default()).unwrap();
+ assert!(api.resolve(&handle).unwrap().num_model_evaluations > 4);
+ assert!(api.describe(&handle).unwrap().contains("capstone locks after 1 video updates"));
+ }
+}
+
#[test]
fn model_metadata_is_shared_by_preview_and_execution_requests() {
let root = tempfile::tempdir().unwrap();
diff --git a/src-tauri/core/src/worker/protocol.rs b/src-tauri/core/src/worker/protocol.rs
index ffd5ded..0c08181 100644
--- a/src-tauri/core/src/worker/protocol.rs
+++ b/src-tauri/core/src/worker/protocol.rs
@@ -27,7 +27,8 @@ pub const SERVICE_TYPE: &str = "_slopus-worker._tcp.local.";
// v20 carries source-initialized continuation; older workers would ignore it.
// v21 keeps Single Shot's middle fresh; v20 workers default to a repeated source prior.
// v23 carries Single Shot's persistent context archive; older workers ignore Keystone.
-pub const PROTOCOL_VERSION: u32 = 23;
+// v24 adapts capstone locking to the resolved video schedule, including short LoRA grids.
+pub const PROTOCOL_VERSION: u32 = 24;
/// Streaming SeedVR2 restoration; model paths are resolved on the worker.
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -382,7 +383,7 @@ mod tests {
let single = restored.single_shot.unwrap();
assert_eq!(single.ending_prompt, "The subject waves goodbye");
assert!(single.ending_path.is_none());
- assert_eq!(PROTOCOL_VERSION, 23);
+ assert_eq!(PROTOCOL_VERSION, 24);
}
#[test]
diff --git a/src/components/workspace/SceneEditor.tsx b/src/components/workspace/SceneEditor.tsx
index db40005..01ab3d0 100644
--- a/src/components/workspace/SceneEditor.tsx
+++ b/src/components/workspace/SceneEditor.tsx
@@ -372,7 +372,7 @@ export function SceneInspector({ job, shots, references, folderPath = "", scenes
...(value === "animate" ? { endFrameReferenceId: undefined } : {}) })} />
</PropRow>
{sceneType === "single-shot" && <>
- <PropRow label="Context video" htmlFor={`${id}-single-context`} tooltip="Select the first video in the sequence. Its latents keep the original appearance across continuations, with the rear anchor locking after four steps.">
+ <PropRow label="Context video" htmlFor={`${id}-single-context`} tooltip="Select the first video in the sequence. Its latents keep the original appearance across continuations. The rear anchor locks after up to four video updates, automatically shortened for faster LoRA schedules.">
<ComboBox id={`${id}-single-context`} aria-label="Single Shot context video" disabled={disabled} value={job.contextSceneId ?? ""}
options={[{ value: "", label: "None" },
...(job.contextSceneId && !scenes.some((scene) => scene.id === job.contextSceneId && scene.id !== job.id)
diff --git a/src/lib/loras.test.ts b/src/lib/loras.test.ts
index 68bf3f8..4273d07 100644
--- a/src/lib/loras.test.ts
+++ b/src/lib/loras.test.ts
@@ -38,11 +38,11 @@ it("rejects incompatible global recipes and Pika variants without changing the s
expect(templateNeedsDownload(createGeneratorTemplate())).toBe(true);
});
-it("blocks a four-update global recipe for Single Shot context and permits Pika's six updates", () => {
+it("allows short global recipes for Single Shot context with automatic native lock timing", () => {
saveLoras([{ ...DMAD_LORA, path: "D:/dmad", globallyEnabled: true }]);
const job = { ...createDraftGenerationJob("Continue", { sceneType: "single-shot" }), contextSceneId: "original" };
const template = createGeneratorTemplate();
- expect(sceneLoraBlocker(job, template)).toContain("more than four");
+ expect(sceneLoraBlocker(job, template)).toBeNull();
saveLoras(loadLoras().map((lora) => ({ ...lora, globallyEnabled: lora.id === PIKA_REF2VA_LORA.id })));
expect(sceneLoraBlocker(job, template)).toBeNull();
});
diff --git a/src/lib/project.singleShot.test.ts b/src/lib/project.singleShot.test.ts
index a2a2c7c..899156b 100644
--- a/src/lib/project.singleShot.test.ts
+++ b/src/lib/project.singleShot.test.ts
@@ -17,7 +17,7 @@ it("keeps the original context archive while continuation advances and persists
const request = sceneGenerationRequest(next, config, "C:/Project", 9);
expect(request).toMatchObject({ contextSceneId: "original", keystoneRelativePath: original.latentRelativePath,
previousSceneId: "previous", continuationRelativePath: previous.latentRelativePath, singleShot: { endingPrompt: "" } });
- expect(JSON.parse(sceneGenerationSnapshot(next, request))).toMatchObject({ contextSceneId: "original", capstoneLockAfter: 4 });
+ expect(JSON.parse(sceneGenerationSnapshot(next, request))).toMatchObject({ contextSceneId: "original", capstoneLockAfter: "auto" });
expect(sceneGenerationSnapshot({ ...next, endingPrompt: "Something else" }, request)).toBe(sceneGenerationSnapshot(next, request));
expect(parseProjectConfig(JSON.parse(JSON.stringify(config))).generationJobs[0].contextSceneId).toBe("original");
expect(sceneInput(next).contextSceneId).toBe("original");
diff --git a/src/lib/project.ts b/src/lib/project.ts
index 55fade8..61faa91 100644
--- a/src/lib/project.ts
+++ b/src/lib/project.ts
@@ -1306,7 +1306,7 @@ export function sceneGenerationSnapshot(job: GenerationJob, input: SceneGenerati
...(job.sceneType ? { sceneType: job.sceneType } : {}),
prompt: input.prompt,
...(input.loraSnapshot?.length ? { loras: input.loraSnapshot } : {}),
- ...(input.contextSceneId ? { contextSceneId: input.contextSceneId, keystoneRelativePath: input.keystoneRelativePath, capstoneLockAfter: 4 } : {}),
+ ...(input.contextSceneId ? { contextSceneId: input.contextSceneId, keystoneRelativePath: input.keystoneRelativePath, capstoneLockAfter: "auto" } : {}),
...(input.singleShot ? { singleShot: input.singleShot, ...(!input.contextSceneId ? { endingPrompt: job.endingPrompt ?? "" } : {}) } : {}),
...(input.videoTransition ? { videoTransition: input.videoTransition } : {}),
...(input.latentBridge ? { latentBridge: input.latentBridge } : {}),
diff --git a/src/lib/sceneGeneration.ts b/src/lib/sceneGeneration.ts
index 8307afa..d0768fe 100644
--- a/src/lib/sceneGeneration.ts
+++ b/src/lib/sceneGeneration.ts
@@ -1,5 +1,5 @@
import { activeGenerationEffects } from "./generationEffects";
-import { effectiveLoras, loraSnapshot, loraStepOverride, selectionConflict } from "./loras";
+import { effectiveLoras, loraSnapshot, selectionConflict } from "./loras";
import { generationDimensions } from "./export";
import { longShotContinuationInputs, longShotInputs } from "./longShot";
import {
@@ -133,14 +133,6 @@ export function templateSceneBlocker(type: SceneType, template: GeneratorTemplat
export function sceneLoraBlocker(job: GenerationJob, template: GeneratorTemplate): string | null {
const selection = effectiveLoras(template.loras, job.loraOverrides ?? [], template.modelType);
- const conflict = selectionConflict(selection);
- if (conflict) return conflict;
- if (job.sceneType === "single-shot" && job.contextSceneId) {
- const active = loraSnapshot(selection);
- const steps = loraStepOverride(active) ?? sceneGenerationSteps(job, template.defaultSteps);
- const updates = active.some((lora) => lora.samplingPreset) ? steps : steps - 1;
- if (updates <= 4) return "Context video needs more than four video sampling updates. Choose a longer sampling recipe or increase the step count.";
- }
- return null;
+ return selectionConflict(selection);
}