AI media harness for planning, generating, and editing locally
TypeScript
Keep new empty images in their family
Bittie24800fba71b
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex d33eacc..af71e2a 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -35,6 +35,7 @@ This alpha update adds DMAD LoRA support, resumable model downloads, and improve## Fixes and improvements+- New empty images created while browsing child images stay in the same image family.- Colour correction includes a Brightness control for preview and export.- Continue preserves the full joined video and audio from Slopfab. Adjacent source and continuation scenes use that shared decode in preview and export, preserving context across the cut. Regenerate older Continue scenes to apply the fix.- The timeline playhead follows playback without waiting for editor updates.diff --git a/src/components/workspace/ImageEditor.test.tsx b/src/components/workspace/ImageEditor.test.tsxindex 69b17ce..db46372 100644--- a/src/components/workspace/ImageEditor.test.tsx+++ b/src/components/workspace/ImageEditor.test.tsx@@ -309,9 +309,8 @@ it("starts an image root from the thumbnail Edit menu with edit tools and no typfireEvent.click(screen.getByRole("menuitem", { name: "New empty image" }));expect(screen.getByLabelText("Prompt (high-level description)")).toBeInTheDocument();expect(screen.getByRole("radio", { name: "Draw object" })).toBeInTheDocument();- // The edit is in Saved's family, which the bar opens from Saved.- expect(screen.queryByRole("button", { name: "Back to all images" })).not.toBeInTheDocument();- fireEvent.click(screen.getByRole("button", { name: "View Saved, 2 versions" }));+ // The empty image stays in Saved's family alongside the edit.+ expect(screen.getByRole("button", { name: "Back to all images" })).toBeInTheDocument();fireEvent.click(screen.getByRole("button", { name: "View Editing Saved" }));expect(current().imageScene!.sourceImage?.name).toBe("Saved");});@@ -753,6 +752,43 @@ it.each(["Create Scene", "Create Reference"])("uses the chosen primary for %s frexpect(reopened.assets.find((asset) => asset.id === "Chosen")?.parentAssetId).toBeUndefined();});+it.each(["thumbnail", "bar", "keyboard"])("creates an empty child in the browsed family from the %s menu", (target) => {+ const initial = parseProjectConfig(fixture);+ const image = (id: string, parentAssetId?: string) => ({ id, name: id, kind: "image" as const,+ relativePath: `media/generated/${id}.jpg`, mimeType: "image/jpeg", createdAt: initial.createdAt, parentAssetId });+ initial.assets = [image("Original"), image("Child", "Original"), image("Unrelated")];+ initial.imageScene!.outputAssetId = "Child";+ const current = setup(initial);+ expect(screen.getByRole("button", { name: "Back to all images" })).toBeInTheDocument();+ if (target === "thumbnail") fireEvent.contextMenu(screen.getByRole("button", { name: "View Child" }));+ else if (target === "keyboard") fireEvent.keyDown(screen.getByLabelText("Generated images"), { key: "F10", shiftKey: true });+ else fireEvent.contextMenu(screen.getByLabelText("Generated images"));+ fireEvent.click(screen.getByRole("menuitem", { name: "New empty image" }));+ const draft = current().assets.at(-1)!;+ expect(draft).toMatchObject({ imageDraft: true, parentAssetId: "Original" });+ expect(current().imageScene).toMatchObject({ outputAssetId: draft.id });+ expect(current().imageScene!.rootType ?? "prompt").toBe("prompt");+ expect(current().imageScene!.sourceImage).toBeUndefined();+ expect(current().imageScene!.nodes).toHaveLength(1);+ expect(promptValue(screen.getByLabelText("Prompt (high-level description)"))).toBe("");+ expect(screen.getByRole("button", { name: "View New image" })).toHaveAttribute("aria-pressed", "true");+ expect(screen.getByRole("button", { name: "Back to all images" })).toBeInTheDocument();+ expect(screen.queryByRole("button", { name: "View Unrelated" })).not.toBeInTheDocument();+ typePrompt(screen.getByLabelText("Prompt (high-level description)"), "A new variation");+ fireEvent.click(screen.getByRole("button", { name: "View Child" }));+ fireEvent.click(screen.getByRole("button", { name: "View New image" }));+ expect(promptValue(screen.getByLabelText("Prompt (high-level description)"))).toBe("A new variation");+ expect(parseProjectConfig(JSON.parse(JSON.stringify(current()))).assets.find(({ id }) => id === draft.id)?.parentAssetId).toBe("Original");++ // Returning to the main bar makes New empty image create a new primary again.+ fireEvent.click(screen.getByRole("button", { name: "Back to all images" }));+ fireEvent.contextMenu(screen.getByLabelText("Generated images"));+ fireEvent.click(screen.getByRole("menuitem", { name: "New empty image" }));+ expect(current().assets.at(-1)?.parentAssetId).toBeUndefined();+ expect(screen.queryByRole("button", { name: "Back to all images" })).not.toBeInTheDocument();+ expect(screen.getByRole("button", { name: "View Unrelated" })).toBeInTheDocument();+});+it("removes an original with a family only from inside the family, and the leftmost image takes its place", () => {const initial = parseProjectConfig(fixture);const image = (id: string, parentAssetId?: string) => ({ id, name: id, kind: "image" as const, relativePath: `media/generated/${id}.jpg`, mimeType: "image/jpeg", createdAt: initial.createdAt, ...(parentAssetId ? { parentAssetId } : {}) });diff --git a/src/components/workspace/ImageEditor.tsx b/src/components/workspace/ImageEditor.tsxindex 93336a0..16869b7 100644--- a/src/components/workspace/ImageEditor.tsx+++ b/src/components/workspace/ImageEditor.tsx@@ -583,7 +583,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene...(imageMenu.source === "bar" ? [{ label: "New empty image", icon: <Add16 />, action: () => attempt(() => {undo.current = []; redo.current = []; pointer.current = null; setDraftBox(null); setDrawKind(null); setRenaming(null); setCollapsed(new Set()); setSelection("image-root");- onChange((current) => createEmptyImage(current, template?.id));+ onChange((current) => createEmptyImage(current, template?.id, imageMenu.inFamily ? imageMenu.id ?? current.imageScene?.outputAssetId : undefined));}) },{ label: "Add image file", icon: <FolderOpen16 />, disabled: !isTauri(), action: () => attempt(async () => {const source = await invoke<ImageSource | null>("open_image_source", { folderPath });diff --git a/src/lib/imageHistory.ts b/src/lib/imageHistory.tsindex c43503c..498b652 100644--- a/src/lib/imageHistory.ts+++ b/src/lib/imageHistory.ts@@ -76,12 +76,14 @@ export function saveImageDraft(config: ProjectConfig, generatorTemplateId?: strireturn { ...config, imageScene: { ...scene, outputAssetId: id }, assets: existing ? config.assets.map((item) => item.id === id ? asset : item) : [...config.assets, asset] };}-export function createEmptyImage(config: ProjectConfig, generatorTemplateId?: string): ProjectConfig {+export function createEmptyImage(config: ProjectConfig, generatorTemplateId?: string, familyAssetId?: string | null): ProjectConfig {config = saveImageDraft(config);+ const parentAssetId = imageFamilyRoot(config.assets, familyAssetId);const id = `image-draft-${crypto.randomUUID()}`;const scene = { ...createImageScene(), steps: config.imageScene?.steps ?? 20, outputAssetId: id };const next = { ...config, imageScene: scene };const asset: ProjectAsset = { id, kind: "image", name: "New image", mimeType: "image/jpeg", imageDraft: true,+ ...(parentAssetId ? { parentAssetId } : {}),imageGeneration: imageGenerationSnapshot(next, "", generatorTemplateId || "image-draft"), createdAt: new Date().toISOString() };return { ...next, assets: [...config.assets, asset] };}