Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Add Single Shot context video selection

Bitti7f8b38ff2fdc
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 583d684..85b008f 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -14,7 +14,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.** Generate a short ending first, then anchor a continuous shot to it. Supports references in both prompts and optional continuation from any generated scene.
+- **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.
- **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/components/workspace/GeneratorView.test.tsx b/src/components/workspace/GeneratorView.test.tsx
index 489f3bf..ecfb493 100644
--- a/src/components/workspace/GeneratorView.test.tsx
+++ b/src/components/workspace/GeneratorView.test.tsx
@@ -142,7 +142,7 @@ it("queues Long Shot anchors before their intervening bridges", () => {
expect(submitted.mock.calls[0][0][2].request.latentBridge).toMatchObject({ leftSceneId: "1", rightSceneId: "3", leftMarginFrames: 17, rightMarginFrames: 17 });
});
-it("keeps Single Shot prompts in the shot panel and the ending prompt and starting video in the scene panel", () => {
+it("keeps Single Shot prompts in the shot panel and the ending prompt and previous video in the scene panel", () => {
const initial = project();
initial.references = [{ id: "hero", kind: "image", name: "Hero", description: "", intendedUse: [], relativePath: "references/hero.png", createdAt: initial.createdAt }];
initial.generationJobs[1].sceneType = "single-shot";
@@ -159,12 +159,18 @@ it("keeps Single Shot prompts in the shot panel and the ending prompt and starti
fireEvent.click(screen.getByRole("button", { name: /^Hero\b/ }));
expect(state.latest().generationJobs[0].endingPrompt).toContain("@[ref:hero]");
expect(screen.queryByRole("button", { name: "Add a shot to First scene" })).not.toBeInTheDocument();
- const source = screen.getByRole("combobox", { name: "Single Shot starting video" });
+ const source = screen.getByRole("combobox", { name: "Single Shot previous video" });
expect(optionNames(source)).toEqual(["None", "Second scene", "Ordinary"]);
chooseOption(source, "Second scene");
expect(state.latest().generationJobs[0].continuationSceneId).toBe("scene-second");
+ const context = screen.getByRole("combobox", { name: "Single Shot context video" });
+ chooseOption(context, "Second scene");
+ expect(state.latest().generationJobs[0].contextSceneId).toBe("scene-second");
+ expect(screen.queryByLabelText("Ending prompt")).not.toBeInTheDocument();
+ chooseOption(context, "None");
+ expect(screen.getByLabelText("Ending prompt")).toBeInTheDocument();
expect(screen.queryByRole("spinbutton", { name: "Continuation" })).not.toBeInTheDocument();
- expect(screen.getByText(/middle starts from fresh noise/)).toBeInTheDocument();
+ expect(screen.queryByText(/middle starts from fresh noise/)).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "Shot 1 of First scene" }));
expect(screen.queryByRole("spinbutton", { name: "Continuation" })).not.toBeInTheDocument();
expect(screen.queryByLabelText("Ending prompt")).not.toBeInTheDocument();
@@ -183,11 +189,11 @@ it("keeps Single Shot prompts in the shot panel and the ending prompt and starti
expect(state.latest().generationJobs.at(-1)?.sceneType).toBe("single-shot");
});
-it.each(["prompt", "single-shot"] as const)("queues a starting %s scene before Single Shot dependents even when board order is reversed", (type) => {
+it.each(["prompt", "single-shot", "context"] as const)("queues a starting %s scene before Single Shot dependents even when board order is reversed", (type) => {
const initial = project();
initial.generationJobs = [
- { ...createDraftGenerationJob("Next", { id: "next", sceneType: "single-shot" }), endingPrompt: "Finish next", continuationSceneId: "start" },
- createDraftGenerationJob("Start", { id: "start", sceneType: type }),
+ { ...createDraftGenerationJob("Next", { id: "next", sceneType: "single-shot" }), endingPrompt: "Finish next", continuationSceneId: "start", contextSceneId: type === "context" ? "start" : null },
+ createDraftGenerationJob("Start", { id: "start", sceneType: type === "context" ? "prompt" : type }),
];
const submitted = vi.fn();
render(<GeneratorView config={initial} folderPath="C:/project" runtime={readyRuntime} onChange={vi.fn()} onGenerate={submitted} onOpenTimeline={() => {}} />);
@@ -196,7 +202,10 @@ it.each(["prompt", "single-shot"] as const)("queues a starting %s scene before S
expect(submissions.map((item: { job: { id: string } }) => item.job.id)).toEqual(["start", "next"]);
if (type === "single-shot") expect(submissions[0].request.singleShot.endingPrompt).toBe(submissions[0].request.prompt);
else expect(submissions[0].request.singleShot).toBeUndefined();
- expect(submissions[1].request.singleShot.endingPrompt).toContain("Finish next");
+ if (type === "context") {
+ expect(submissions[1].request.contextSceneId).toBe("start");
+ expect(submissions[1].request.singleShot.endingPrompt).toBe("");
+ } else expect(submissions[1].request.singleShot.endingPrompt).toContain("Finish next");
expect(submissions[1].request.previousSceneId).toBe("start");
});
diff --git a/src/components/workspace/GeneratorView.tsx b/src/components/workspace/GeneratorView.tsx
index e3b64ab..ad6b6a6 100644
--- a/src/components/workspace/GeneratorView.tsx
+++ b/src/components/workspace/GeneratorView.tsx
@@ -432,7 +432,8 @@ export function GeneratorView({ config, sceneIds, toolbarStart, folderPath, runt
if (visiting.has(job.id)) return false;
if (["queued", "generating", "ready"].includes(job.status)) { visited.add(job.id); return true; }
const previous = config.generationJobs.find((candidate) => candidate.id === continuationSceneId(job, config.generationJobs));
- const dependencies = [...(previous ? [previous] : []), ...longShotDependencies(job, sceneSiblings(job, config))];
+ const context = job.sceneType === "single-shot" && config.generationJobs.find((candidate) => candidate.id === job.contextSceneId);
+ const dependencies = [...(previous ? [previous] : []), ...(context ? [context] : []), ...longShotDependencies(job, sceneSiblings(job, config))];
visiting.add(job.id);
if (dependencies.some((source) => !visitForBatch(source))) { visiting.delete(job.id); return false; }
visiting.delete(job.id);
@@ -457,8 +458,10 @@ export function GeneratorView({ config, sceneIds, toolbarStart, folderPath, runt
if (!runtimeReady) return runtimeError ?? generatorRuntime?.detail ?? "The video generator is not ready.";
if (job.status === "ready") return "Saving this scene.";
const source = config.generationJobs.find((candidate) => candidate.id === continuationSceneId(job, config.generationJobs));
+ const context = job.sceneType === "single-shot" && config.generationJobs.find((candidate) => candidate.id === job.contextSceneId);
return continuationBlocker(job, config.generationJobs)
?? longShotBlocker(job, config, true, true)
+ ?? (context && !sceneGenerationPending(context) && (!context.latentRelativePath || context.status !== "completed") ? "Generate or queue the Context video first, or use Generate all." : null)
?? (source && !sceneGenerationPending(source) && (!source.latentRelativePath || source.status !== "completed") ? "Generate or queue the selected source scene first, or use Generate all." : null)
?? templateSceneBlocker(sceneTypeFor(job), templateFor(job)) ?? sendBlocker(job, config.references, config);
};
@@ -467,7 +470,7 @@ export function GeneratorView({ config, sceneIds, toolbarStart, folderPath, runt
.filter((job) => job.status === "completed"
&& Boolean(job.generationSnapshot)
&& (job.generationSnapshot !== snapshotFor(job)
- || config.generationJobs.some((source) => (source.id === continuationSceneId(job, config.generationJobs) || longShotDependencies(job, sceneSiblings(job, config)).includes(source)) && ["queued", "generating", "ready"].includes(source.status))))
+ || config.generationJobs.some((source) => (source.id === continuationSceneId(job, config.generationJobs) || job.sceneType === "single-shot" && source.id === job.contextSceneId || longShotDependencies(job, sceneSiblings(job, config)).includes(source)) && ["queued", "generating", "ready"].includes(source.status))))
.map((job) => job.id));
const selectedIndicator = selected && changedJobIds.has(selected.id) && !selected.generationHistory?.selectedId ? "changed" : selected?.status;
const selectedCancellable = selected?.status === "queued" || selected?.status === "generating";
diff --git a/src/components/workspace/SceneEditor.tsx b/src/components/workspace/SceneEditor.tsx
index 1f65271..117a526 100644
--- a/src/components/workspace/SceneEditor.tsx
+++ b/src/components/workspace/SceneEditor.tsx
@@ -298,7 +298,7 @@ function SingleShotEndingPrompt({ job, references, folderPath, disabled, onChang
const SCENE_TYPE_DESCRIPTIONS: Record<SceneType, string> = {
prompt: "Generate video from shot descriptions and optional references, without fixed start or last frames.",
- "single-shot": "Generate an ending first, then a continuous shot guided by that ending and an optional starting scene.",
+ "single-shot": "Continue a sequence using its first video as context, or generate a continuous shot guided by an ending prompt.",
"first-last-frame": "Generate video guided by optional start and last images, with shot descriptions controlling the action.",
backdrop: "Generate subjects and action against a solid green, blue, black or white background for keying.",
"long-shot": "Legacy scene type. Use Bridge to connect videos in new scenes.",
@@ -370,16 +370,23 @@ export function SceneInspector({ job, shots, references, folderPath = "", scenes
...(value === "animate" ? { endFrameReferenceId: undefined } : {}) })} />
</PropRow>
{sceneType === "single-shot" && <>
- <PropRow label="Starting video" htmlFor={`${id}-single-source`} tooltip="Continue from the ending latents of another scene's full video. Generate all handles the required order.">
- <ComboBox id={`${id}-single-source`} aria-label="Single Shot starting video" disabled={disabled} value={job.continuationSceneId ?? ""}
+ <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.">
+ <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)
+ ? [{ value: job.contextSceneId, label: "Unavailable scene", disabled: true }] : []),
+ ...scenes.filter((scene) => scene.id !== job.id).map((scene) => ({ value: scene.id, label: scene.title }))]}
+ onChange={(value) => onChange({ contextSceneId: value || null })} />
+ </PropRow>
+ <PropRow label="Previous video" htmlFor={`${id}-single-source`} tooltip="Continue from the ending latents of another scene's full video. Generate all handles the required order.">
+ <ComboBox id={`${id}-single-source`} aria-label="Single Shot previous video" disabled={disabled} value={job.continuationSceneId ?? ""}
options={[{ value: "", label: "None" },
...(job.continuationSceneId && !scenes.some((scene) => scene.id === job.continuationSceneId && scene.id !== job.id)
? [{ value: job.continuationSceneId, label: "Unavailable scene", disabled: true }] : []),
...scenes.filter((scene) => scene.id !== job.id).map((scene) => ({ value: scene.id, label: scene.title }))]}
onChange={(value) => onChange({ continuationSceneId: value || null })} />
</PropRow>
- {job.continuationSceneId && <p className="prop-caption">The previous video's ending anchors the start. The middle starts from fresh noise and progresses toward the ending prompt.</p>}
- <SingleShotEndingPrompt job={job} references={references} folderPath={folderPath} disabled={disabled} onChange={onChange} />
+ {!job.contextSceneId && <SingleShotEndingPrompt job={job} references={references} folderPath={folderPath} disabled={disabled} onChange={onChange} />}
</>}
{longShot && <>
<p className="prop-caption">Long Shot is retained for this saved scene. Use Bridge to connect videos in new scenes.</p>
diff --git a/src/lib/agentGeneration.ts b/src/lib/agentGeneration.ts
index d7b1842..2008986 100644
--- a/src/lib/agentGeneration.ts
+++ b/src/lib/agentGeneration.ts
@@ -127,8 +127,10 @@ export async function generateAgentScene(queue: WorkQueue, session: ProjectSessi
throw new Error(`Scene '${job.title}' already has generation in progress. Do not submit it again.`);
}
const source = config.generationJobs.find((candidate) => candidate.id === continuationSceneId(job, config.generationJobs));
+ const context = job.sceneType === "single-shot" && config.generationJobs.find((candidate) => candidate.id === job.contextSceneId);
const blocker = continuationBlocker(job, config.generationJobs)
?? longShotBlocker(job, config, true, true)
+ ?? (context && !sceneGenerationPending(context) && (!context.latentRelativePath || context.status !== "completed") ? "Generate or queue the Context video first." : null)
?? (source && !sceneGenerationPending(source) && (!source.latentRelativePath || source.status !== "completed") ? "Generate or queue the selected source scene first." : null)
?? templateSceneBlocker(sceneTypeFor(job), template) ?? sendBlocker(job, config.references, config);
if (blocker) throw new Error(blocker);
diff --git a/src/lib/project.singleShot.test.ts b/src/lib/project.singleShot.test.ts
index 828284b..a2a2c7c 100644
--- a/src/lib/project.singleShot.test.ts
+++ b/src/lib/project.singleShot.test.ts
@@ -6,6 +6,30 @@ import { duplicateScene, sceneInput } from "./sceneHistory";
const project = () => createProjectConfig({ name: "Single", prompt: "A dancer walks", resolution: "416p", aspectRatio: "16:9", targetDurationSeconds: 10 });
const shot = (id: string): GenerationJob => createDraftGenerationJob("A dancer walks", { id, sceneType: "single-shot", durationSeconds: 6 });
+it("keeps the original context archive while continuation advances and persists context in takes", () => {
+ const config = project();
+ const original = { ...shot("original"), sceneType: "prompt" as const, latentRelativePath: "latents/original.safetensors" };
+ const previous = { ...shot("previous"), continuationSceneId: original.id, contextSceneId: original.id, latentRelativePath: "latents/previous.safetensors" };
+ const next = { ...shot("next"), continuationSceneId: previous.id, contextSceneId: original.id, endingPrompt: "@[ref:missing] leaves." };
+ config.generationJobs = [next, previous, original];
+ expect(continuationBlocker(next, config.generationJobs)).toBeNull();
+ expect(sendBlocker(next, [])).toBeNull();
+ 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(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");
+ const duplicate = duplicateScene(config, next.id)!;
+ expect(duplicate.config.generationJobs.find((job) => job.id === duplicate.id)?.contextSceneId).toBe("original");
+ expect(continuationBlocker({ ...next, contextSceneId: previous.id }, config.generationJobs)).toMatch(/first video/);
+ expect(continuationBlocker({ ...next, contextSceneId: next.id }, config.generationJobs)).toMatch(/itself/);
+ expect(continuationBlocker({ ...next, contextSceneId: "missing" }, config.generationJobs)).toMatch(/no longer exists/);
+ expect(continuationBlocker({ ...next, continuationSceneId: null }, config.generationJobs)).toMatch(/Previous video/);
+ expect(sceneGenerationRequest({ ...next, sceneType: "prompt" }, config, "C:/Project", 9).keystoneRelativePath).toBeUndefined();
+});
+
it("uses fresh middle noise with locked start/end anchors and ignores legacy Continuation values", () => {
const config = project(), source = { ...shot("source"), latentRelativePath: "latents/source.safetensors" };
const job = { ...shot("next"), continuationSceneId: source.id }; config.generationJobs = [source, job];
diff --git a/src/lib/project.ts b/src/lib/project.ts
index 3bc4d46..41287da 100644
--- a/src/lib/project.ts
+++ b/src/lib/project.ts
@@ -590,6 +590,7 @@ const generationJobBaseSchema = z.object({
endFrameReferenceId: idSchema.nullish(),
usePreviousSceneLastFrame: z.boolean().nullish(),
continuationSceneId: idSchema.nullish(),
+ contextSceneId: idSchema.nullish(),
continuationOverlapFrames: z.number().int().min(DEFAULT_CONTINUATION_OVERLAP).max(MAX_CONTINUATION_OVERLAP)
.refine((frames) => (frames - 5) % 17 === 0, "Overlap must be 22, 39, 56, … frames.").nullish(),
continuationFrom: z.enum(["start", "end"]).nullish(),
@@ -1039,7 +1040,7 @@ export function audioReferenceBlocker(job: GenerationJob, bound: ProjectReferenc
* the same anchor selected for both ends is sent only once. */
export function sceneGenerationReferences(job: GenerationJob, references: ProjectReference[]): ProjectReference[] {
if (job.sceneType === "prompt" || job.sceneType === "backdrop" || job.sceneType === "long-shot" || job.sceneType === "single-shot") {
- const cited = [...sceneShots(job).flatMap(shotReferenceIds), ...(job.sceneType === "single-shot" ? actionReferenceIds(job.endingPrompt ?? "") : [])];
+ const cited = [...sceneShots(job).flatMap(shotReferenceIds), ...(job.sceneType === "single-shot" && !job.contextSceneId ? actionReferenceIds(job.endingPrompt ?? "") : [])];
return references.filter((reference) => cited.includes(reference.id));
}
if (job.sceneType === "pose") {
@@ -1089,6 +1090,12 @@ export function continuationSceneId(job: GenerationJob, jobs: readonly Generatio
export const sceneGenerationPending = (job: GenerationJob) => ["queued", "generating", "ready"].includes(job.status);
export function continuationBlocker(job: GenerationJob, jobs: readonly GenerationJob[]): string | null {
+ const context = job.sceneType === "single-shot" ? job.contextSceneId : undefined;
+ if (context) {
+ if (!job.continuationSceneId) return "Select a Previous video to use Context video.";
+ if (context === job.id) return "A scene cannot use itself as its Context video.";
+ if (!jobs.some((source) => source.id === context)) return "The selected Context video no longer exists.";
+ }
if (job.sceneType === "single-shot" && !job.continuationSceneId) return null;
if (job.sceneType !== "continue" && job.sceneType !== "single-shot" && !job.usePreviousSceneLastFrame) return null;
if (job.sceneType && !["continue", "first-last-frame", "single-shot"].includes(job.sceneType)) return null;
@@ -1101,7 +1108,8 @@ export function continuationBlocker(job: GenerationJob, jobs: readonly Generatio
seen.add(id);
const source = jobs.find((candidate) => candidate.id === id);
if (!source) return "The selected source scene no longer exists.";
- if (source.sceneType !== "continue" && !continuationSceneId(source, jobs)) return null;
+ if (source.sceneType !== "continue" && !continuationSceneId(source, jobs))
+ return context && context !== source.id ? "Choose the first video in this continuation sequence as Context video." : null;
current = source;
}
}
@@ -1247,6 +1255,8 @@ export function sceneGenerationSeed(job: GenerationJob): number {
}
export interface SceneGenerationInput {
+ contextSceneId?: string;
+ keystoneRelativePath?: string;
singleShot?: { endingPrompt: string };
generationEffects?: GenerationEffects;
prompt: string;
@@ -1291,7 +1301,8 @@ export function sceneGenerationSnapshot(job: GenerationJob, input: SceneGenerati
return JSON.stringify({
...(job.sceneType ? { sceneType: job.sceneType } : {}),
prompt: input.prompt,
- ...(input.singleShot ? { singleShot: input.singleShot, endingPrompt: job.endingPrompt ?? "" } : {}),
+ ...(input.contextSceneId ? { contextSceneId: input.contextSceneId, keystoneRelativePath: input.keystoneRelativePath, capstoneLockAfter: 4 } : {}),
+ ...(input.singleShot ? { singleShot: input.singleShot, ...(!input.contextSceneId ? { endingPrompt: job.endingPrompt ?? "" } : {}) } : {}),
...(input.videoTransition ? { videoTransition: input.videoTransition } : {}),
...(input.latentBridge ? { latentBridge: input.latentBridge } : {}),
frames: input.frames,
diff --git a/src/lib/runtime.ts b/src/lib/runtime.ts
index 2f3f962..cde6387 100644
--- a/src/lib/runtime.ts
+++ b/src/lib/runtime.ts
@@ -101,6 +101,8 @@ export interface AgentTurnResponse {
}
export interface SlopfabGenerationRequest {
+ contextSceneId?: string;
+ keystoneRelativePath?: string;
singleShot?: { endingPrompt: string };
music?: import("./music").MusicSettings;
jobId: string;
diff --git a/src/lib/sceneGeneration.ts b/src/lib/sceneGeneration.ts
index 612bfd0..60f5aea 100644
--- a/src/lib/sceneGeneration.ts
+++ b/src/lib/sceneGeneration.ts
@@ -26,7 +26,9 @@ export function sceneGenerationRequest(job: GenerationJob, config: ProjectConfig
const longShot = longShotInputs(job, config);
return {
jobId: job.id,
- ...(job.sceneType === "single-shot" ? { singleShot: { endingPrompt: job.endingPrompt?.trim()
+ ...(job.sceneType === "single-shot" && job.contextSceneId ? { contextSceneId: job.contextSceneId,
+ keystoneRelativePath: config.generationJobs.find((scene) => scene.id === job.contextSceneId)?.latentRelativePath ?? undefined } : {}),
+ ...(job.sceneType === "single-shot" ? { singleShot: { endingPrompt: job.contextSceneId ? "" : job.endingPrompt?.trim()
? compileScenePromptSegments({ shots: [{ id: `${job.id}-ending`, startSeconds: 0, action: job.endingPrompt }], soundscape: job.soundscape, music: job.music }, bound, settings.defaultLook).map((segment) => segment.value).join("")
: compileGenerationJobPrompt(inputs.job, bound, settings.defaultLook) } } : {}),
...(longShot ? { latentBridge: longShot.bridge } : {}),
@@ -77,7 +79,7 @@ export function sendBlocker(job: GenerationJob, references: ProjectReference[],
const shots = sceneShots(job);
if (job.sceneType === "single-shot") {
if (sceneDurationSeconds(job) < 2) return "Single Shot needs at least 2 seconds.";
- if (danglingReferenceTokens([{ id: "ending", startSeconds: 0, action: job.endingPrompt ?? "" }], references).length)
+ if (!job.contextSceneId && danglingReferenceTokens([{ id: "ending", startSeconds: 0, action: job.endingPrompt ?? "" }], references).length)
return "A reference in the ending prompt can't be used. Replace it or remove it.";
}
const animate = job.sceneType === "animate";
diff --git a/src/lib/workQueue.test.ts b/src/lib/workQueue.test.ts
index 3d5fcdc..cd24f40 100644
--- a/src/lib/workQueue.test.ts
+++ b/src/lib/workQueue.test.ts
@@ -287,10 +287,11 @@ it("resolves queued Long Shot dependencies after encoding and extends the joined
expect(JSON.parse(saved.generationJobs[1].generationSnapshot!).latentBridge.leftMarginFrames).toBe(17);
});
-it("chains Single Shots from a regular generated scene while capturing prompts and joined scene ranges", async () => {
+it.each([false, true])("chains Single Shots with persistent context %s while capturing prompts and joined scene ranges", async (context) => {
const { queue, first } = setup();
first.update((config) => ({ ...config, generationJobs: ["a", "b", "c"].map((id, index) => ({ ...config.generationJobs[0], id,
- sceneType: index === 0 ? "prompt" as const : "single-shot" as const, endingPrompt: `Ending ${id}`, continuationSceneId: index ? ["a", "b"][index - 1] : null })) }));
+ sceneType: index === 0 ? "prompt" as const : "single-shot" as const, endingPrompt: `Ending ${id}`, continuationSceneId: index ? ["a", "b"][index - 1] : null,
+ contextSceneId: context && index ? "a" : null })) }));
vi.mocked(resolveSlopfabPlan).mockImplementation(async (request) => {
const live = first.getSnapshot().config;
const source = live.generationJobs.find((job) => job.latentRelativePath === request.continuationRelativePath);
@@ -306,7 +307,7 @@ it("chains Single Shots from a regular generated scene while capturing prompts a
first.update((current) => ({ ...current, generationJobs: current.generationJobs.map((job) => ({ ...job, endingPrompt: "Edited later" })) }));
for (let index = 0; index < ids.length; index++) {
await waitFor(() => expect(enqueueSlopfabGeneration).toHaveBeenCalledTimes(index + 1));
- if (index > 0) {
+ if (index > 0 && !context) {
emit("slopfab-progress", { jobId: ids[index], stage: "singleShotEnding", step: 1, totalSteps: 14, plannedSteps: 14, elapsedSeconds: 1, timingProfile: "test" });
expect(queue.getSnapshot().find((item) => item.id === ids[index])?.detail).toBe("Generating ending (1 of 2)");
emit("slopfab-progress", { jobId: ids[index], stage: "singleShotFull", step: 8, totalSteps: 14, plannedSteps: 14, elapsedSeconds: 2, timingProfile: "test" });
@@ -318,7 +319,13 @@ it("chains Single Shots from a regular generated scene while capturing prompts a
expect(requests[0].singleShot).toBeUndefined();
expect(requests[1].continuationRelativePath).toBe(`latents/${ids[0]}.safetensors`);
expect(requests[2].continuationRelativePath).toBe(`latents/${ids[1]}.safetensors`);
- expect(requests[2].singleShot?.endingPrompt).toContain("Ending c");
+ if (context) {
+ expect(requests[1].keystoneRelativePath).toBe(`latents/${ids[0]}.safetensors`);
+ expect(requests[2].keystoneRelativePath).toBe(`latents/${ids[0]}.safetensors`);
+ expect(requests[2].singleShot?.endingPrompt).toBe("");
+ const snapshot = JSON.parse(first.getSnapshot().config.generationJobs[2].generationSnapshot!);
+ expect(snapshot.keystoneRelativePath).toBe(`latents/${ids[0]}.safetensors`);
+ } else expect(requests[2].singleShot?.endingPrompt).toContain("Ending c");
expect(requests[2].singleShot?.endingPrompt).not.toContain("Edited later");
const saved = first.getSnapshot().config;
expect(saved.assets.find((asset) => asset.id === "asset-c")?.sceneSegments?.map((part) => part.sceneId)).toEqual(["a", "b", "c"]);
diff --git a/src/lib/workQueue.ts b/src/lib/workQueue.ts
index 59f6bae..5edfcec 100644
--- a/src/lib/workQueue.ts
+++ b/src/lib/workQueue.ts
@@ -271,7 +271,7 @@ export class WorkQueue {
const work = this.work.get(id)!;
const job = work.config.generationJobs.find((job) => job.id === work.sceneId)!;
if (work.upscaleSource) continue;
- const sources = new Set([work.request.previousSceneId, work.request.latentBridge?.leftSceneId,
+ const sources = new Set([work.request.previousSceneId, work.request.contextSceneId, work.request.latentBridge?.leftSceneId,
work.request.latentBridge?.rightSceneId, longShotPosition(job, sceneSiblings(job, work.config))?.previousBridge?.id]);
const group = this.items.find((item) => item.id === id)!.generationGroupId!;
const groups = new Set(this.items.filter((item) => item.projectKey === projectKey && !item.kind && isWorkActive(item)
@@ -579,7 +579,7 @@ export class WorkQueue {
const sourceInput = JSON.parse(previous.generationSnapshot ?? "null");
const divisor = sourceInput?.latentUpscale ? 2 : 1;
if (sourceInput && (Math.ceil(sourceInput.canvasWidth / divisor / 32) * 32 !== work.request.canvasWidth || Math.ceil(sourceInput.canvasHeight / divisor / 32) * 32 !== work.request.canvasHeight))
- throw new Error("Use the resolution of the starting video's original latents.");
+ throw new Error("Use the resolution of the previous video's original latents.");
}
if (captured.sceneType === "long-shot") {
const current = live.generationJobs.find((job) => job.id === work.sceneId);
@@ -598,6 +598,16 @@ export class WorkQueue {
work.snapshot = sceneGenerationSnapshot(captured, work.request);
this.updateScene(work, { generationSnapshot: work.snapshot });
}
+ if (work.request.contextSceneId) {
+ const live = work.session.getSnapshot().config;
+ const context = live.generationJobs.find((job) => job.id === work.request.contextSceneId);
+ if (!context?.latentRelativePath || context.status !== "completed")
+ throw new Error("Generate the Context video successfully to save its latents first, or use Generate all.");
+ work.request.keystoneRelativePath = context.latentRelativePath;
+ const captured = work.config.generationJobs.find((job) => job.id === work.sceneId)!;
+ work.snapshot = sceneGenerationSnapshot(captured, work.request);
+ this.updateScene(work, { generationSnapshot: work.snapshot });
+ }
if (!work.image && !work.music) await purgeTimelineThumbnails(next.folderPath, work.sceneId).catch(() => undefined);
if (work.cancelled) continue;
await this.prepareReferences(work, next.folderPath);