Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Preserve image edit sources and variants

Bitti6d5173c08ef9
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 73af4e2..86e22d4 100644
--- a/RELEASE_NOTES.md
+++ b/RELEASE_NOTES.md
@@ -12,6 +12,7 @@ This alpha update adds Prompt video scenes, agent image drafts, Sol attention an
## Fixes and improvements
+- Image edits keep the original as the parent and save results as child versions. Selecting a result restores its edit prompt, source and settings for rerunning or creating another variation.
- Whole-image edits now reach every edge without feathering.
- Imported still images now have steps, seed and resolution controls. Resolution defaults to the source dimensions rounded down to multiples of 32, with additional sizes matching the source aspect ratio.
- Fixed CUDA transformer-loading memory failures with bounded upload buffers, more accurate memory budgeting and automatic retries with more CPU offloading, while preserving precision and output settings.
diff --git a/src/components/workspace/ImageEditor.test.tsx b/src/components/workspace/ImageEditor.test.tsx
index 0384521..ccbd650 100644
--- a/src/components/workspace/ImageEditor.test.tsx
+++ b/src/components/workspace/ImageEditor.test.tsx
@@ -108,6 +108,38 @@ it.each(["extend", "character-sheet"] as const)("returns from %s settings to nor
/* Undo lives in the title bar; inside the editor it is Ctrl+Z. */
const undoImageEdit = () => fireEvent.keyDown(screen.getByRole("tree", { name: "Image nodes" }), { key: "z", code: "KeyZ", ctrlKey: true });
+it("shows an edited child with its saved prompt and creates another draft on the original when changed", async () => {
+ vi.spyOn(persistence, "readMediaFileUrl").mockImplementation(async (_folder, location) => `blob:${location.relativePath}`);
+ vi.stubGlobal("URL", class extends URL { static revokeObjectURL = vi.fn(); });
+ const initial = parseProjectConfig(fixture);
+ const original = { id: "original", name: "Original", kind: "image" as const, relativePath: "media/original.png", mimeType: "image/png", width: 1001, height: 809, createdAt: initial.createdAt };
+ initial.imageScene = createImageEditScene({ name: original.name, relativePath: original.relativePath, width: original.width, height: original.height });
+ initial.imageScene.nodes[0].description = "Warm up the lighting";
+ initial.imageScene.outputSize = { width: 672, height: 544 };
+ const result = { ...original, id: "edited", name: "Edited", relativePath: "media/edited.png", width: 672, height: 544, parentAssetId: original.id,
+ imageGeneration: { ...imageGenerationSnapshot(initial, "Compiled edit", defaultGeneratorTemplate().id), usedSeed: 42 } };
+ initial.assets = [original, result];
+ const current = setup(restoreGeneratedImage(initial, result.id));
+ expect(promptValue(screen.getByLabelText("Edit prompt"))).toBe("Warm up the lighting");
+ expect(screen.getByLabelText("Seed")).toHaveValue(-1);
+ expect(screen.getByLabelText("Used seed")).toHaveValue("42");
+ const preview = () => document.querySelector<HTMLImageElement>(".image-frame img");
+ await waitFor(() => expect(preview()).toHaveAttribute("src", "blob:media/edited.png"));
+ expect(preview()!.parentElement!.style.getPropertyValue("--image-ratio")).toBe(String(672 / 544));
+ fireEvent.click(screen.getByRole("button", { name: "View Original" }));
+ fireEvent.click(screen.getByRole("button", { name: "View Edited" }));
+ fireEvent.click(screen.getByRole("button", { name: "View Edited" }));
+ expect(current().assets).toEqual([original, result]);
+ expect(promptValue(screen.getByLabelText("Edit prompt"))).toBe("Warm up the lighting");
+ typePrompt(screen.getByLabelText("Edit prompt"), "Make it moonlit");
+ expect(current().assets.slice(0, 2)).toEqual([original, result]);
+ expect(current().assets[2]).toMatchObject({ imageDraft: true, parentAssetId: "original", imageGeneration: {
+ scene: { sourceImage: { relativePath: "media/original.png" }, nodes: [{ description: "Make it moonlit" }] } } });
+ await waitFor(() => expect(preview()).toHaveAttribute("src", "blob:media/original.png"));
+ fireEvent.click(screen.getByRole("button", { name: "View Edited" }));
+ expect(promptValue(screen.getByLabelText("Edit prompt"))).toBe("Warm up the lighting");
+});
+
it("edits imported-image generation settings and restores them with the draft", () => {
const initial = parseProjectConfig(fixture);
initial.assets = [{ id: "imported", name: "Imported", kind: "image", relativePath: "media/source.png", mimeType: "image/png", width: 1001, height: 809, createdAt: initial.createdAt }];
@@ -339,6 +371,9 @@ it("adds image files in edit mode and saves whole-image and drawn edits with sep
vi.mocked(invoke).mockResolvedValueOnce(source);
addFile();
await waitFor(() => expect(current().imageScene?.sourceImage).toEqual(source));
+ const original = current().assets.find((asset) => !asset.imageDraft && asset.relativePath === source.relativePath)!;
+ expect(original).toMatchObject(source);
+ expect(current().assets.find((asset) => asset.imageDraft)?.parentAssetId).toBe(original.id);
expect(screen.queryByRole("combobox", { name: "Type" })).not.toBeInTheDocument();
// References come from what each prompt cites; there is no list to tick.
expect(screen.queryByRole("checkbox", { name: "Mood" })).not.toBeInTheDocument();
diff --git a/src/components/workspace/ImageEditor.tsx b/src/components/workspace/ImageEditor.tsx
index 57399c7..87d2875 100644
--- a/src/components/workspace/ImageEditor.tsx
+++ b/src/components/workspace/ImageEditor.tsx
@@ -175,7 +175,8 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene
const canUseMenuImage = Boolean(menuImage?.relativePath || menuImage?.sourcePath);
// Generated assets retain the dimensions returned by the native encoder.
// Image settings size only the empty canvas and future generation requests.
- const { width, height } = imageRoot && scene.sourceImage ? scene.sourceImage : output?.width && output?.height
+ const showResult = Boolean(output && !output.imageDraft && output.imageGeneration && (output.relativePath || output.sourcePath));
+ const { width, height } = showResult && output?.width && output.height ? { width: output.width, height: output.height } : imageRoot && scene.sourceImage ? scene.sourceImage : output?.width && output?.height
? { width: output.width, height: output.height }
: outputDimensions(settings.resolution, settings.aspectRatio);
useEffect(() => subscribeGeneratorTemplates(() => setTemplates(loadGeneratorTemplateSettings())), []);
@@ -674,7 +675,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene
onPointerUpCapture={endPan} onPointerCancelCapture={endPan} onLostPointerCapture={endPan}
onAuxClick={(event) => { if (event.button === 1) event.preventDefault(); }}>
<div className="image-frame" style={{ "--image-ratio": width / height, "--image-zoom": view.zoom, "--image-pan-x": `${view.x}px`, "--image-pan-y": `${view.y}px` } as CSSProperties}>
- {imageRoot && scene.sourceImage ? <ReferenceImage folderPath={folderPath} relativePath={scene.sourceImage.relativePath} alt={scene.sourceImage.name} /> : output && !imageRoot && (output.relativePath || output.sourcePath) ? <ReferenceImage key={output.id} folderPath={folderPath} relativePath={output.relativePath} sourcePath={output.sourcePath} alt={output.name} onMeasured={!output.imageGeneration ? (size) => measureImportedImage(output.id, size) : undefined} /> : <div className="image-empty"><Image32 aria-hidden="true" /><strong>{templateSnapshot ? output!.name : imageRoot ? "Add an image to edit" : "Compose your image"}</strong><span>{templateSnapshot ? active ? "The generated image will appear here." : "No generated image yet." : imageRoot ? "Choose Add image file in the image bar menu, then enter an edit prompt." : "Add objects, text and groups, then describe them in the inspector."}</span></div>}
+ {showResult ? <ReferenceImage key={output!.id} folderPath={folderPath} relativePath={output!.relativePath} sourcePath={output!.sourcePath} alt={output!.name} /> : imageRoot && scene.sourceImage ? <ReferenceImage folderPath={folderPath} relativePath={scene.sourceImage.relativePath} alt={scene.sourceImage.name} /> : output && !imageRoot && (output.relativePath || output.sourcePath) ? <ReferenceImage key={output.id} folderPath={folderPath} relativePath={output.relativePath} sourcePath={output.sourcePath} alt={output.name} onMeasured={!output.imageGeneration ? (size) => measureImportedImage(output.id, size) : undefined} /> : <div className="image-empty"><Image32 aria-hidden="true" /><strong>{templateSnapshot ? output!.name : imageRoot ? "Add an image to edit" : "Compose your image"}</strong><span>{templateSnapshot ? active ? "The generated image will appear here." : "No generated image yet." : imageRoot ? "Choose Add image file in the image bar menu, then enter an edit prompt." : "Add objects, text and groups, then describe them in the inspector."}</span></div>}
<svg className={`image-overlay ${drawKind ? "drawing" : ""}`} viewBox="0 0 1000 1000" preserveAspectRatio="none" aria-label="Image placement canvas" onPointerDown={pointerDown} onPointerMove={pointerMove} onPointerUp={pointerUp} onPointerCancel={() => { pointer.current = null; setDraftBox(null); }}>
{boxes && scene.nodes.filter((node) => node.box).map((node) => {
const box = pointer.current?.id === node.id && draftBox ? draftBox : node.box!;
diff --git a/src/lib/imageHistory.test.ts b/src/lib/imageHistory.test.ts
index 5614a7d..434b97d 100644
--- a/src/lib/imageHistory.test.ts
+++ b/src/lib/imageHistory.test.ts
@@ -125,7 +125,11 @@ describe("generated image history", () => {
expect(parseProjectConfig(JSON.parse(JSON.stringify(done))).assets).toEqual(done.assets);
// An imported file starts a family of its own.
config.imageScene = createImageEditScene({ relativePath: "media/imported/photo.png", name: "photo", width: 101, height: 77 });
- expect(saveImageDraft(config, "test").assets.find((asset) => asset.imageDraft)!.parentAssetId).toBeUndefined();
+ const imported = saveImageDraft(config, "test");
+ const original = imported.assets.find((asset) => asset.relativePath === "media/imported/photo.png" && !asset.imageDraft)!;
+ expect(original).toMatchObject({ name: "photo", width: 101, height: 77 });
+ expect(imported.assets.find((asset) => asset.imageDraft)!.parentAssetId).toBe(original.id);
+ expect(saveImageDraft(imported, "test").assets).toEqual(imported.assets);
});
it("keeps a family together when its original is removed", () => {
diff --git a/src/lib/imageHistory.ts b/src/lib/imageHistory.ts
index 0d15cdb..6b506e3 100644
--- a/src/lib/imageHistory.ts
+++ b/src/lib/imageHistory.ts
@@ -57,7 +57,7 @@ export function removeImageAsset(assets: readonly ProjectAsset[], id: string): P
}
/** Keep the editable version in history without creating another image file. */
-export function saveImageDraft(config: ProjectConfig, generatorTemplateId?: string): ProjectConfig {
+export function saveImageDraft(config: ProjectConfig, generatorTemplateId?: string, regenerate = false): ProjectConfig {
const scene = config.imageScene;
if (!scene) return config;
const selected = config.assets.find((asset) => asset.id === scene.outputAssetId);
@@ -67,13 +67,24 @@ export function saveImageDraft(config: ProjectConfig, generatorTemplateId?: stri
if (templateDraft && JSON.stringify({ ...scene, outputAssetId: null }) === JSON.stringify(selected.imageGeneration!.scene)) return config;
const source = scene.rootType === "image" ? scene.sourceImage : null;
if (!source && !selected?.imageDraft) return config;
+ const snapshot = imageGenerationSnapshot(config, "", generatorTemplateId || selected?.imageGeneration?.generatorTemplateId || "image-draft");
+ const saved = selected?.imageGeneration;
+ // Merely viewing a finished edit (including session autosave) must not create
+ // a draft. Generate explicitly forks it, even when its inputs are unchanged.
+ if (!regenerate && selected && !selected.imageDraft && saved && !saved.template
+ && Object.entries(snapshot).every(([key, value]) => key === "prompt" || JSON.stringify(value) === JSON.stringify(saved[key as keyof ImageGenerationSnapshot]))) return config;
+ // Direct imports and older edit drafts may not have a separate source entry.
+ // Retain that file as the original before its draft becomes a generated result.
+ if (source && !config.assets.some((asset) => asset.kind === "image" && !asset.imageDraft && asset.relativePath === source.relativePath)) {
+ config = { ...config, assets: [...config.assets, { id: `image-source-${crypto.randomUUID()}`, kind: "image", ...source,
+ mimeType: /\.png$/i.test(source.relativePath) ? "image/png" : "image/jpeg", createdAt: new Date().toISOString() }] };
+ }
if (!selected?.imageDraft && scene.outputAssetId && scene.nodes.length === 1 && !scene.nodes[0].description.trim()) return config;
const existing = selected?.imageDraft && !templateDraft ? selected : undefined;
const id = existing?.id ?? `image-draft-${crypto.randomUUID()}`;
const edited = source && config.assets.find((asset) => asset.kind === "image" && !asset.imageDraft && asset.relativePath === source.relativePath);
- const parentAssetId = existing ? existing.parentAssetId : imageFamilyRoot(config.assets, templateDraft ? selected.id : edited?.id);
- const snapshot = imageGenerationSnapshot(config, "", generatorTemplateId || existing?.imageGeneration?.generatorTemplateId || selected?.imageGeneration?.generatorTemplateId || "image-draft");
- if (existing && JSON.stringify(existing.imageGeneration) === JSON.stringify(snapshot)) return config;
+ const parentAssetId = existing?.parentAssetId ?? imageFamilyRoot(config.assets, templateDraft ? selected.id : edited?.id);
+ if (existing && existing.parentAssetId === parentAssetId && JSON.stringify(existing.imageGeneration) === JSON.stringify(snapshot)) return config;
const asset = { id, kind: "image" as const, ...source, name: existing?.name ?? (source ? `Editing ${source.name}` : "New image"),
imageDraft: true, mimeType: /\.png$/i.test(source?.relativePath ?? "") ? "image/png" : "image/jpeg",
imageGeneration: snapshot, ...(parentAssetId ? { parentAssetId } : {}), createdAt: existing?.createdAt ?? new Date().toISOString() };
@@ -127,7 +138,7 @@ export function restoreGeneratedImage(config: ProjectConfig, id: string): Projec
if (!snapshot) return { ...config, thumbnail: asset.relativePath ?? null,
imageScene: { ...(config.imageScene?.rootType === "image" ? createImageScene() : config.imageScene ?? createImageScene(config.brief.prompt)), outputAssetId: id } };
const restored = structuredClone(snapshot);
- const scene = !asset.imageDraft && restored.scene.rootType === "image" && asset.relativePath && asset.width && asset.height
+ const scene = !asset.imageDraft && restored.template && restored.scene.rootType === "image" && asset.relativePath && asset.width && asset.height
? createImageEditScene({ relativePath: asset.relativePath, name: asset.name, width: asset.width, height: asset.height }, restored.scene)
: restored.scene;
const references = new Map(restored.references.map((reference) => [reference.id, reference]));
diff --git a/src/lib/workQueue.test.ts b/src/lib/workQueue.test.ts
index 373e982..062a12b 100644
--- a/src/lib/workQueue.test.ts
+++ b/src/lib/workQueue.test.ts
@@ -475,11 +475,11 @@ describe("image generation work", () => {
expect(vi.mocked(resolveSlopfabPlan).mock.calls[0][0].imageEdit).toEqual(request.imageEdit);
await finish(queue, request.jobId);
const result = parseProjectConfig(JSON.parse(JSON.stringify(session.getSnapshot().config)));
- expect(result.assets[0].imageGeneration!.references.map((reference) => reference.id)).toEqual(["Lighting", "Balloon"]);
- expect(result.imageScene!.nodes).toHaveLength(1);
- expect(result.imageScene!.nodes[0].description).toBe("");
+ expect(result.assets[1].imageGeneration!.references.map((reference) => reference.id)).toEqual(["Lighting", "Balloon"]);
+ expect(result.imageScene!.nodes).toEqual(scene.nodes);
+ expect(result.imageScene!.sourceImage).toEqual(scene.sourceImage);
});
- it("submits ordered inpainting as one job, saves PNG, and leaves a clean edit root", async () => {
+ it("submits ordered inpainting as one job, saves a child PNG, and retains its edit recipe", async () => {
const { queue } = setup();
const record = imageProject();
let scene = createImageEditScene({ name: "Source", relativePath: "media/generated/source.jpg", width: 101, height: 77 });
@@ -501,7 +501,7 @@ describe("image generation work", () => {
expect(edit.prompt).toContain("<Subject 1> is Balloon, providing appearance from <Picture 2>");
}
const draftId = session.getSnapshot().config.imageScene!.outputAssetId!;
- expect(session.getSnapshot().config.assets[0]).toMatchObject({ id: draftId, imageDraft: true });
+ expect(session.getSnapshot().config.assets[1]).toMatchObject({ id: draftId, imageDraft: true });
expect(request).toMatchObject({ stillImage: true, frames: 1, canvasWidth: 96, canvasHeight: 64, imageEdit: { sourceRelativePath: "media/generated/source.jpg", edits: [
{ prompt: expect.stringContaining("A red balloon"), x: 24, y: 16, width: 48, height: 32 },
{ prompt: expect.stringContaining("A blue boat"), x: 24, y: 16, width: 48, height: 32 },
@@ -509,13 +509,14 @@ describe("image generation work", () => {
await finish(queue, request.jobId);
expect(invoke).toHaveBeenCalledWith("save_generated_image", { folderPath: record.folderPath, jobId: request.jobId, format: "png" });
const result = session.getSnapshot().config;
- expect(result.imageScene!.nodes).toHaveLength(1);
- expect(result.assets).toHaveLength(1);
- expect(result.assets[0]).toMatchObject({ id: draftId, imageDraft: false, relativePath: "media/generated/edited.png" });
+ expect(result.imageScene!.nodes).toEqual(scene.nodes);
+ expect(result.assets).toHaveLength(2);
+ expect(result.assets[0]).toMatchObject({ relativePath: "media/generated/source.jpg" });
+ expect(result.assets[1]).toMatchObject({ id: draftId, imageDraft: false, relativePath: "media/generated/edited.png", parentAssetId: result.assets[0].id });
expect(result.imageScene!.outputAssetId).toBe(draftId);
- expect(result.imageScene).toMatchObject({ rootType: "image", sourceImage: { relativePath: "media/generated/edited.png", width: 101, height: 77 } });
- expect(result.assets[0]).toMatchObject({ mimeType: "image/png", imageGeneration: { scene, prompt: expect.stringContaining("Edit 2 (24, 16, 48, 32)") } });
- expect(restoreGeneratedImage(result, draftId).imageScene!.nodes).toHaveLength(1);
+ expect(result.imageScene).toMatchObject({ rootType: "image", sourceImage: scene.sourceImage });
+ expect(result.assets[1]).toMatchObject({ mimeType: "image/png", imageGeneration: { scene, prompt: expect.stringContaining("Edit 2 (24, 16, 48, 32)") } });
+ expect(restoreGeneratedImage(result, draftId).imageScene!.nodes).toEqual(scene.nodes);
expect(releaseRendered).toHaveBeenCalledWith(request.jobId);
});
it("submits the selected image edit resolution, steps and seed to planning and generation", async () => {
@@ -534,6 +535,36 @@ describe("image generation work", () => {
expect(request).toMatchObject(expected);
await queue.cancel(request.jobId);
});
+ it("reruns an edit with fresh random seeds and changed prompts as children of the original", async () => {
+ const { queue } = setup();
+ const record = imageProject();
+ record.config.imageScene = createImageEditScene({ name: "Original", relativePath: "media/source.png", width: 1001, height: 809 });
+ record.config.imageScene.outputSize = { width: 672, height: 544 };
+ record.config.imageScene.nodes[0].description = "Warm up the lighting";
+ let seed = 100;
+ vi.spyOn(crypto, "getRandomValues").mockImplementation((array) => { (array as Uint32Array).set([0, ++seed]); return array; });
+ const session = queue.project(record);
+ for (let index = 0; index < 3; index++) {
+ if (index === 2) session.update((config) => ({ ...config, imageScene: { ...config.imageScene!,
+ nodes: config.imageScene!.nodes.map((node) => ({ ...node, description: "Make it moonlit" })) } }));
+ const previous = structuredClone(session.getSnapshot().config.assets.filter((asset) => !asset.imageDraft));
+ queue.enqueueImage(session, template);
+ await waitFor(() => expect(enqueueSlopfabGeneration).toHaveBeenCalledTimes(index + 1));
+ const request = vi.mocked(enqueueSlopfabGeneration).mock.calls[index][0];
+ expect(request).toMatchObject({ seed: 101 + index, canvasWidth: 672, canvasHeight: 544,
+ imageEdit: { sourceRelativePath: "media/source.png", edits: [expect.objectContaining({ prompt: expect.stringContaining(index === 2 ? "Make it moonlit" : "Warm up the lighting") })] } });
+ vi.mocked(invoke).mockResolvedValue({ relativePath: `media/edited-${index}.png`, width: 672, height: 544 });
+ await finish(queue, request.jobId);
+ const config = parseProjectConfig(JSON.parse(JSON.stringify(session.getSnapshot().config)));
+ expect(config.assets).toHaveLength(index + 2);
+ expect(config.assets.slice(0, previous.length)).toEqual(previous);
+ expect(config.assets[0]).toMatchObject({ name: "Original", relativePath: "media/source.png", width: 1001, height: 809 });
+ expect(config.assets.slice(1).every((asset) => asset.parentAssetId === config.assets[0].id && !asset.imageDraft)).toBe(true);
+ expect(config.imageScene).toMatchObject({ seed: -1, sourceImage: { relativePath: "media/source.png" }, outputSize: { width: 672, height: 544 } });
+ session.update(() => restoreGeneratedImage(config, config.assets[1].id));
+ expect(session.getSnapshot().config.imageScene!.nodes[0].description).toBe("Warm up the lighting");
+ }
+ });
it.each(["browse", "modify", "cancel"])("keeps editing versions available during generation: %s", async (action) => {
const { queue } = setup();
const record = imageProject();
@@ -564,7 +595,7 @@ describe("image generation work", () => {
expect(config.imageScene!.outputAssetId).toBe("original");
expect(config.assets).toHaveLength(2);
session.update((current) => restoreGeneratedImage(current, draftId));
- expect(session.getSnapshot().config.imageScene!.nodes).toHaveLength(1);
+ expect(session.getSnapshot().config.imageScene!.nodes[1].description).toBe("A red balloon");
} else {
expect(config.imageScene!.outputAssetId).not.toBe(draftId);
expect(config.assets.filter((asset) => asset.imageDraft)).toHaveLength(1);
diff --git a/src/lib/workQueue.ts b/src/lib/workQueue.ts
index b1ab3e4..27baa53 100644
--- a/src/lib/workQueue.ts
+++ b/src/lib/workQueue.ts
@@ -268,7 +268,7 @@ export class WorkQueue {
enqueueImage(session: ProjectSession, template: GeneratorTemplate) {
if (!isTauri()) throw new Error("Image generation requires the desktop app and MiniMax H3 weights.");
if (template.mode === "animate") throw new Error("Choose a MiniMax H3 prompt template for images.");
- session.update((config) => saveImageDraft(config, template.id));
+ session.update((config) => saveImageDraft(config, template.id, true));
const current = session.getSnapshot().config;
const scene = current.imageScene ?? createImageScene(current.brief.prompt);
const edit = scene.rootType === "image" ? compileImageEdits(current) : null;
@@ -739,7 +739,7 @@ export class WorkQueue {
...saved, mimeType: "image/png", imageGeneration: work.imageGeneration, createdAt: new Date().toISOString() }));
} else {
work.session.update(imageResultUpdate({ id: work.id, imageDraftId: work.imageDraftId, imageParentId: work.imageParentId,
- imageGeneration: work.imageGeneration, snapshot: work.snapshot, outputAssetId: work.config.imageScene?.outputAssetId,
+ imageGeneration: work.imageGeneration, outputAssetId: work.config.imageScene?.outputAssetId,
imageEdit: Boolean(work.request.imageEdit), saved }));
}
try { await work.session.save(); this.patch(work.id, { status: "completed", progress: 1, detail: "Image saved" }); }
@@ -779,8 +779,8 @@ function videoResultUpdate(sceneId: string, assetId: string, media: Omit<Project
});
}
-function imageResultUpdate({ id, imageDraftId, imageParentId, imageGeneration, snapshot, outputAssetId, imageEdit, saved }: {
- id: string; imageDraftId?: string; imageParentId?: string; imageGeneration?: ImageGenerationSnapshot; snapshot: string;
+function imageResultUpdate({ id, imageDraftId, imageParentId, imageGeneration, outputAssetId, imageEdit, saved }: {
+ id: string; imageDraftId?: string; imageParentId?: string; imageGeneration?: ImageGenerationSnapshot;
outputAssetId?: string | null; imageEdit: boolean; saved: { relativePath: string; width: number; height: number };
}) {
const mimeType = imageEdit ? "image/png" : "image/jpeg";
@@ -791,7 +791,7 @@ function imageResultUpdate({ id, imageDraftId, imageParentId, imageGeneration, s
}) : ({ ...current,
...(current.imageScene?.outputAssetId === outputAssetId ? {
thumbnail: saved.relativePath,
- imageScene: { ...(imageEdit && JSON.stringify(current.imageScene) === snapshot ? createImageEditScene({ ...saved, name: "Edited image" }, current.imageScene ?? undefined) : current.imageScene ?? createImageScene()), outputAssetId: id },
+ imageScene: { ...(current.imageScene ?? createImageScene()), outputAssetId: id },
} : {}),
assets: [...current.assets, { id, kind: "image", name: `Image ${current.assets.filter((asset) => asset.kind === "image").length + 1}`, ...saved, imageGeneration, mimeType, ...(imageParentId ? { parentAssetId: imageFamilyRoot(current.assets, imageParentId) } : {}), createdAt: new Date().toISOString() }],
});