AI media harness for planning, generating, and editing locally
TypeScript
Drop removed prompt references from scene inputs
Bittibb72666bf085
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex 2a6d5d6..1e4731a 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -25,6 +25,7 @@ This alpha update adds DMAD LoRA support, resumable model downloads, and improve## Fixes and improvements+- Removing a reference from a scene's last prompt citation now removes it from generation inputs and “Used by.” References selected as frame or motion inputs remain active.- Reference chips now highlight when included in a prompt's text selection.- The Video scene list scrollbar no longer overlaps the Generate and Cancel buttons.- Timeline media thumbnails stay inside their preview area, keeping filenames clear in grid and list layouts.diff --git a/src/components/ProjectWorkspace.test.ts b/src/components/ProjectWorkspace.test.tsindex 7df354b..d1808fd 100644--- a/src/components/ProjectWorkspace.test.ts+++ b/src/components/ProjectWorkspace.test.ts@@ -427,6 +427,7 @@ describe("project workspace timecode", () => {{ id: "ref-score", kind: "text", name: "Score idea", description: "Sparse piano.", content: "Sparse piano.", intendedUse: ["audio"], createdAt },];const config = parseProjectConfig({ ...fresh, references, generationJobs: [{ ...fresh.generationJobs[0], referenceIds: ["ref-lamp", "ref-blank", "ref-score"] }] });+ config.generationJobs[0].shots![0].action = "@[ref:ref-lamp] @[ref:ref-blank] @[ref:ref-score]";render(createElement(GeneratorView, { config, folderPath: "C:\\Ceramic Lamp", onChange: () => undefined, onOpenTimeline: () => undefined, selectedJobId: config.generationJobs[0].id }));expect(document.querySelector(".debug-prompt-dialog .compiled-prompt__text")).toBeNull();fireEvent.click(screen.getByRole("button", { name: "Debug prompt" }));@@ -983,7 +984,8 @@ describe("project workspace timecode", () => {show(next);expect(next.generationJobs[0].shots[0].action).toBe("@[ref:ref-street] walks towards the camera on @[ref:ref-street]");openScene();- expect(compiled()).toContain("<Subject 2> walks towards the camera on <Subject 2>");+ expect(compiled()).toContain("<Subject 1> walks towards the camera on <Subject 1>");+ expect(compiled()).not.toContain("Dark red hair");// A reference that can no longer be cited stays on its chip, marked.openShot(1);@@ -1161,7 +1163,7 @@ describe("project workspace timecode", () => {show();scene();expect(document.querySelector(".compiled-prompt__text")!.textContent)- .toContain("[Shot 1] <Subject 2> walks towards the camera on <Subject 2>.");+ .toContain("[Shot 1] <Subject 1> walks towards the camera on <Subject 1>.");});it("labels a cancelled scene as cancelled instead of queued, on the card and on its line", () => {diff --git a/src/components/ReferenceNavigation.integration.test.tsx b/src/components/ReferenceNavigation.integration.test.tsxindex 7758799..b996215 100644--- a/src/components/ReferenceNavigation.integration.test.tsx+++ b/src/components/ReferenceNavigation.integration.test.tsx@@ -11,7 +11,7 @@ it("shows only titles in Used by and opens the selected generation", () => {const config = createProjectConfig({ name: "Reference navigation", prompt: "A scene", aspectRatio: "16:9", resolution: "416p", targetDurationSeconds: 10 });config.references = [{ id: "hero", kind: "text", name: "Hero", description: "", intendedUse: ["character"], createdAt: config.createdAt }];const first = { ...config.generationJobs[0], id: "first", title: "First scene", referenceIds: [] };- const target = { ...first, id: "target", title: "The forest encounter", referenceIds: ["hero"], status: "failed" as const, stage: "failed" as const };+ const target = { ...first, id: "target", title: "The forest encounter", referenceIds: ["hero"], shots: [{ id: "shot", startSeconds: 0, action: "@[ref:hero] in the forest" }], status: "failed" as const, stage: "failed" as const };config.generationJobs = [first, target];const { container } = render(<ProjectWorkspace project={{ config, folderPath: "C:/Reference navigation" }} initialView="references" onBack={vi.fn()} onSave={async () => undefined} />);const usage = container.querySelector(".reference-used-by")! as HTMLElement;diff --git a/src/components/workspace/GeneratorView.test.tsx b/src/components/workspace/GeneratorView.test.tsxindex 6badf67..ea2fa4a 100644--- a/src/components/workspace/GeneratorView.test.tsx+++ b/src/components/workspace/GeneratorView.test.tsx@@ -8,8 +8,9 @@ import { createDraftGenerationJob, createProjectConfig, parseProjectConfig, scenimport { cancelSlopfabGeneration, getEngineStatus, type SlopfabStatus } from "../../lib/runtime";import { askNative } from "../../lib/nativeShell";import { GeneratorView, templateSceneBlocker } from "./GeneratorView";+import { ReferencesView } from "./ReferencesView";import { choose, chooseOption, comboValue, optionNames } from "./comboTestUtils";-import { insertPromptReference, placePromptCaret, typePrompt } from "./promptTestUtils";+import { changePromptChip, insertPromptReference, placePromptCaret, typePrompt } from "./promptTestUtils";import { minimaxOriginalTemplate, viggleAnimateTemplate, saveDebugOptionsEnabled } from "../../lib/settings";vi.mock("../../lib/nativeShell", async (importOriginal) => ({@@ -37,6 +38,47 @@ it("hides unfinished templates from the generator picker", () => {expect(screen.queryByRole("option", { name: "First/Last Frame" })).toBeNull();});+it("unbinds a reference after its last prompt chip is removed and excludes it from generation and Used by", () => {+ const initial = project();+ initial.references = ["hero", "opening"].map((id) => ({ id, kind: "image", name: id, description: "", intendedUse: [],+ relativePath: `references/${id}.png`, createdAt: initial.createdAt }));+ initial.generationJobs[0].referenceIds = ["hero"];+ initial.generationJobs[0].startFrameReferenceId = "opening";+ initial.generationJobs[0].shots!.forEach((shot) => { shot.action = "@[ref:hero] walks."; });+ const state = setup(initial);+ fireEvent.click(screen.getByRole("button", { name: "Shot 1 of First scene" }));+ changePromptChip(screen.getByLabelText("Describe shot 1"), 0, null);+ expect(state.latest().generationJobs[0].referenceIds).toEqual(["hero"]);+ fireEvent.click(screen.getByRole("button", { name: "Shot 2 of First scene" }));+ typePrompt(screen.getByLabelText("Describe shot 2"), "A walk through the forest.");+ expect(state.latest().generationJobs[0].referenceIds).toEqual([]);+ fireEvent.click(within(screen.getByRole("region", { name: "First scene" })).getByRole("button", { name: "Generate" }));+ const saved = parseProjectConfig(JSON.parse(JSON.stringify(state.latest())));+ const snapshot = JSON.parse(saved.generationJobs[0].generationSnapshot!);+ expect(snapshot.referencePaths).toHaveLength(1);+ expect(snapshot.referencePaths[0]).toContain("opening.png");+ expect(snapshot.prompt).not.toContain("<Subject");+ cleanup();+ const { container } = render(<ReferencesView config={saved} folderPath="C:/project" onChange={vi.fn()} />);+ expect(container.querySelector(".reference-used-by")).toHaveTextContent("No scenes yet.");+ fireEvent.click(screen.getByRole("option", { name: /opening/ }));+ expect(within(container.querySelector(".reference-used-by")! as HTMLElement).getByRole("button", { name: "First scene" })).toBeInTheDocument();+});++it("replaces a chip's binding and removes bindings when its shot is deleted", async () => {+ const initial = project();+ initial.references = ["Hero", "Forest"].map((name) => ({ id: name.toLowerCase(), kind: "image", name, description: "", intendedUse: [],+ relativePath: `references/${name}.png`, createdAt: initial.createdAt }));+ initial.generationJobs[0].referenceIds = ["hero"];+ initial.generationJobs[0].shots![1].action = "@[ref:hero] walks.";+ const state = setup(initial);+ fireEvent.click(screen.getByRole("button", { name: "Shot 2 of First scene" }));+ changePromptChip(screen.getByLabelText("Describe shot 2"), 0, "Forest");+ expect(state.latest().generationJobs[0].referenceIds).toEqual(["forest"]);+ fireEvent.click(screen.getByRole("button", { name: "Delete shot 2" }));+ await waitFor(() => expect(state.latest().generationJobs[0].referenceIds).toEqual([]));+});+it("has no selected generator when all templates still need downloads", () => {localStorage.setItem("slopus.generator-templates.v1", JSON.stringify({ templates: [minimaxOriginalTemplate()], defaultTemplateId: "minimax-h3-original", catalogVersion: 1 }));setup();diff --git a/src/components/workspace/GeneratorView.tsx b/src/components/workspace/GeneratorView.tsxindex bbbec82..89ba485 100644--- a/src/components/workspace/GeneratorView.tsx+++ b/src/components/workspace/GeneratorView.tsx@@ -167,16 +167,12 @@ export function GeneratorView({ config, folderPath, runtime = null, generationCoonChange({ ...current, generationJobs: current.generationJobs.map((job) => job.id === id ? { ...job, ...updates } : job) }, `scene:${id}`);};- /* An edit from the panel. Writing a reference into a line BINDS it to the- scene, because binding is what gives it a <Subject N> and puts its picture- in `reference_paths` — a citation the engine was never sent the reference- for would point at nothing. Nothing is ever auto-unbound: taking a name out- of one line is not a decision to stop steering the scene with it, and the- reference library is where those references themselves are managed. */+ // Keep saved bindings in sync with all shots, including chip replacement,+ // shot removal and moves between scenes. Animate has separate input pickers.const mergeSceneUpdates = (job: GenerationJob, updates: Partial<GenerationJob>): GenerationJob => {const next: Partial<GenerationJob> = { ...updates, updatedAt: new Date().toISOString() };- if (updates.shots) {- const referenceIds = [...job.referenceIds];+ if (updates.shots && (updates.sceneType ?? job.sceneType) !== "animate") {+ const referenceIds: string[] = [];for (const shot of updates.shots) {for (const id of actionReferenceIds(shot.action)) {if (!referenceIds.includes(id) && config.references.some((reference) => reference.id === id)) referenceIds.push(id);diff --git a/src/components/workspace/ReferencesView.test.tsx b/src/components/workspace/ReferencesView.test.tsxindex 39f63ed..f46c228 100644--- a/src/components/workspace/ReferencesView.test.tsx+++ b/src/components/workspace/ReferencesView.test.tsx@@ -447,6 +447,18 @@ describe("Reference type presets", () => {});describe("Reference library views and selection", () => {+ it("does not count stale scene bindings as usage", () => {+ const initial = project();+ initial.generationJobs[0].referenceIds = ["ref-hero"];+ setup(initial);+ expect(screen.getByText("No scenes yet.")).toBeInTheDocument();+ fireEvent.contextMenu(screen.getByRole("option", { name: /^Hero/ }));+ expect(screen.getByRole("menuitem", { name: "Not used by any scene" })).toBeDisabled();+ fireEvent.keyDown(screen.getByRole("menu"), { key: "Escape" });+ fireEvent.click(screen.getByRole("button", { name: "Details" }));+ expect(within(screen.getByRole("grid", { name: "References" })).queryByText("1 scene")).not.toBeInTheDocument();+ });+const three = () => {const initial = project();const base = initial.references[0];@@ -456,6 +468,7 @@ describe("Reference library views and selection", () => {{ ...base, id: "ref-lamp", name: "Lamp", intendedUse: ["product"] },];initial.generationJobs[0].referenceIds = ["ref-lamp"];+ initial.generationJobs[0].shots![0].action = "@[ref:ref-lamp] on a table";return initial;};diff --git a/src/components/workspace/ReferencesView.tsx b/src/components/workspace/ReferencesView.tsxindex 5d785ec..0f58756 100644--- a/src/components/workspace/ReferencesView.tsx+++ b/src/components/workspace/ReferencesView.tsx@@ -1,7 +1,7 @@import { Add16, Audio22, ArrowDown12, ArrowUp12, ChevronLeft16, ChevronRight16, Copy16, CursorClick32, Delete14, Delete16, FolderOpen16, GridView16, GridView16Filled, ImageAdd14, ImageAdd16, Images32, ListView16, ListView16Filled, OpenExternal16, Refresh16, Refresh20, Rename16, Search16, TextFile14, TextFile16, TextFile24 } from "../ui/icons";import { invoke } from "@tauri-apps/api/core";import { useEffect, useMemo, useRef, useState, useSyncExternalStore, type KeyboardEvent, type MouseEvent } from "react";-import { isReferenceDescribed, projectItemPath, referenceImages, type ProjectConfig, type ProjectReference, type ProjectReferenceImage } from "../../lib/project";+import { isReferenceDescribed, projectItemPath, referenceImages, sceneFrameInputs, type ProjectConfig, type ProjectReference, type ProjectReferenceImage } from "../../lib/project";import { activeReferenceRefmods, isVideoReference } from "../../lib/project";import {composeLocationPrompt,@@ -136,8 +136,11 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,? clothingSelectionFromPrompt(selected.description): undefined, [selected]);const selectedPresetIcon = selectedImages.length === 0 && hasPresetIcon(selectedPreset) ? selectedPreset : undefined;- const usedBy = (id: string | undefined) => config.generationJobs.filter((job) => job.referenceIds.includes(id ?? ""));- const jobs = useMemo(() => usedBy(selectedId), [config.generationJobs, selectedId]);+ const referenceUsage = useMemo(() => config.generationJobs.map((job) => ({+ job, ids: new Set(sceneFrameInputs(job, config).references.map((reference) => reference.id)),+ })), [config.generationJobs, config.references]);+ const usedBy = (id: string | undefined) => referenceUsage.filter(({ ids }) => ids.has(id ?? "")).map(({ job }) => job);+ const jobs = usedBy(selectedId);const selection = [...selectedIds].filter((id) => config.references.some((reference) => reference.id === id));/* Details view order. Icons keep the project's own order. */@@ -148,7 +151,7 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,case "name": return reference.name.toLocaleLowerCase();case "type": return referenceTypeLabel(referenceType(reference)).toLocaleLowerCase();case "contents": return referenceKindLabel(reference).toLocaleLowerCase();- case "usedBy": return config.generationJobs.filter((job) => job.referenceIds.includes(reference.id)).length;+ case "usedBy": return usedBy(reference.id).length;}};const sorted = [...config.references].sort((a, b) => {@@ -157,7 +160,7 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,return typeof left === "number" && typeof right === "number" ? left - right : String(left).localeCompare(String(right));});return sort.descending ? sorted.reverse() : sorted;- }, [config.references, config.generationJobs, view, sort]);+ }, [config.references, referenceUsage, view, sort]);const update = (id: string, patch: Partial<ProjectReference>) => {const current = configRef.current;diff --git a/src/components/workspace/SceneEditor.tsx b/src/components/workspace/SceneEditor.tsxindex 02598ec..00d8031 100644--- a/src/components/workspace/SceneEditor.tsx+++ b/src/components/workspace/SceneEditor.tsx@@ -64,7 +64,7 @@ export const citableReferences = (references: readonly ProjectReference[]): Proj* The board and the panel both read this, because "Reference 2" on a card and* "Reference 2" in the field have to be the same reference. */export function referenceOrder(job: GenerationJob, shots: readonly SceneShot[], references: readonly ProjectReference[]): string[] {- const boundIds = job.sceneType === "pose" ? sceneGenerationReferences(job, [...references]).map((reference) => reference.id) : job.referenceIds;+ const boundIds = sceneGenerationReferences({ ...job, shots: [...shots] }, [...references]).map((reference) => reference.id);const order = citableReferences(references).filter((reference) => boundIds.includes(reference.id)).map((reference) => reference.id);for (const shot of shots) {for (const id of actionReferenceIds(shot.action)) if (!order.includes(id)) order.push(id);diff --git a/src/lib/imagePrompt.test.ts b/src/lib/imagePrompt.test.tsindex 2aff018..1f303e9 100644--- a/src/lib/imagePrompt.test.ts+++ b/src/lib/imagePrompt.test.ts@@ -130,6 +130,10 @@ describe("MiniMax H3 still-image prompts", () => {scene.nodes.at(-1)!.description = "@[ref:hero] waving";config.imageScene = { ...scene, background: "A @[ref:sky] over the hills" };expect(compileImagePrompt(config).references.map((reference) => reference.id)).toEqual(["hero", "sky"]);+ config.imageScene.nodes.at(-1)!.description = "A traveler waving";+ expect(compileImagePrompt(config).references.map((reference) => reference.id)).toEqual(["sky"]);+ config.imageScene.background = "Hills";+ expect(compileImagePrompt(config).references).toEqual([]);config.imageScene.background = "@[ref:clip]";expect(() => compileImagePrompt(config)).toThrow("the prompt cites the video reference 'Clip'");});diff --git a/src/lib/project.test.ts b/src/lib/project.test.tsindex ef8c446..6a39bed 100644--- a/src/lib/project.test.ts+++ b/src/lib/project.test.ts@@ -499,6 +499,26 @@ describe("project schema", () => {.toContain("<Subject 1> is the content shown in <Picture 1> and <Picture 2>.");});+ it("ignores stale saved bindings and uses only current citations and explicit frame inputs", () => {+ const references = ["image", "video", "audio", "text"].map((kind) => projectReferenceSchema.parse({+ id: kind, kind, name: kind, description: "Guidance", intendedUse: [], createdAt: createdFixture.createdAt,+ ...(kind === "text" ? { refmods: [{ id: "mod", name: "Style", sourcePath: "C:/style.safetensors", strength: 1, copies: 1 }] }+ : { sourcePath: `C:/reference.${kind === "image" ? "png" : kind === "video" ? "mp4" : "wav"}` }),+ }));+ const job = createDraftGenerationJob(references.map(({ id }) => referenceToken(id)).join(" "), {+ referenceIds: references.map(({ id }) => id),+ });+ expect(sceneGenerationReferences(job, references)).toEqual(references);+ job.shots![0].action = "A quiet landscape.";+ expect(sceneGenerationReferences(job, references)).toEqual([]);+ job.startFrameReferenceId = "image";+ expect(sceneGenerationReferences(job, references).map(({ id }) => id)).toEqual(["image"]);+ job.startFrameReferenceId = undefined;+ job.referenceIds = [];+ job.shots![0].action = referenceToken("video");+ expect(sceneGenerationReferences(job, references).map(({ id }) => id)).toEqual(["video"]);+ });+it("uses a dedicated image as Picture 1 and the scene's first frame", () => {const image = (id: string, name: string, path: string): ProjectReference => projectReferenceSchema.parse({id, kind: "image", name, description: "", relativePath: path,@@ -506,7 +526,7 @@ describe("project schema", () => {});const opening = image("opening", "Opening still", "references/opening.jpg");const subject = image("subject", "Product", "references/product.jpg");- const job = createDraftGenerationJob("The product turns towards camera.", {+ const job = createDraftGenerationJob("@[ref:subject] turns towards camera.", {id: "scene-with-frame",references: [opening, subject],referenceIds: ["subject"],@@ -529,7 +549,7 @@ describe("project schema", () => {images: [1, 2].map((n) => ({ id: `${id}-${n}`, name: id, relativePath: `references/${id}-${n}.png` })),});const references = [image("subject"), image("end"), image("start")];- const job = createDraftGenerationJob("The subject turns.", { startFrameReferenceId: "start", endFrameReferenceId: "end", referenceIds: ["subject", "start", "end"] });+ const job = createDraftGenerationJob("@[ref:subject] turns.", { startFrameReferenceId: "start", endFrameReferenceId: "end", referenceIds: ["subject", "start", "end"] });const ordered = sceneGenerationReferences(job, references);expect(usableReferenceImages(ordered).map((image) => image.relativePath)).toEqual(["references/start-1.png", "references/end-1.png", "references/subject-1.png", "references/subject-2.png",@@ -542,7 +562,7 @@ describe("project schema", () => {expect(prompt).toContain("The closing frame matches <Picture 2>.");const endOnly = { ...job, startFrameReferenceId: undefined, referenceIds: [] };expect(compileGenerationJobPrompt(endOnly, sceneGenerationReferences(endOnly, references))).toContain("<Picture 1> is the last frame of the video.");- const same = { ...job, endFrameReferenceId: "start", referenceIds: [] };+ const same = { ...job, shots: [{ id: "shot", startSeconds: 0, action: "The subject turns." }], endFrameReferenceId: "start", referenceIds: [] };expect(usableReferenceImages(sceneGenerationReferences(same, references))).toHaveLength(1);expect(compileGenerationJobPrompt(same, sceneGenerationReferences(same, references))).toContain("<Picture 1> is the last frame of the video.");});diff --git a/src/lib/project.ts b/src/lib/project.tsindex 2aa27a0..0369099 100644--- a/src/lib/project.ts+++ b/src/lib/project.ts@@ -904,7 +904,7 @@ export function audioReferenceBlocker(job: GenerationJob, bound: ProjectReferencreturn anchored ? null : "Sound references need an image or video reference in the same scene.";}-/** Opening and closing pictures come first, then bound references in project+/** Opening and closing pictures come first, then prompt references in project* order. Frame anchors use their first image, even on a multi-image reference;* the same anchor selected for both ends is sent only once. */export function sceneGenerationReferences(job: GenerationJob, references: ProjectReference[]): ProjectReference[] {@@ -933,7 +933,10 @@ export function sceneGenerationReferences(job: GenerationJob, references: Projecconst end = references.find((reference) => reference.id === job.endFrameReferenceId && referenceImages(reference).length > 0 && isReferenceUsable(reference));const anchors = [start, end].filter((reference, index, all): reference is ProjectReference => Boolean(reference) && all.indexOf(reference) === index).map((reference) => ({ ...reference, kind: "text" as const, video: undefined, relativePath: null, sourcePath: null, intendedUse: [], images: referenceImages(reference).slice(0, 1) }));- return [...anchors, ...references.filter((reference) => job.referenceIds.includes(reference.id) && !anchors.some((anchor) => anchor.id === reference.id))];+ // Animate stores its dedicated motion/frame selections in referenceIds.+ // Other scenes take guidance from their current prompts, never stale bindings.+ const ids = job.sceneType === "animate" ? job.referenceIds : sceneShots(job).flatMap((shot) => actionReferenceIds(shot.action));+ return [...anchors, ...references.filter((reference) => ids.includes(reference.id) && !anchors.some((anchor) => anchor.id === reference.id))];}/** Resolve the adjacent scene when preparing a request; queued work captures