Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Persist image root names

Bitti08a879ab74cd
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md
index 091607d..7f989e8 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
+- Renamed image roots on the still image creation page now retain their names when switching images and reopening projects.
- Image edits keep the original as the parent with its saved prompt and settings. Child results open as normal images ready for further edits; selecting images does not create editing copies.
- Whole-image edits disable feathering at the native generation boundary, including requests with missing or previously saved feather settings.
- 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.
diff --git a/src/components/workspace/ImageEditor.test.tsx b/src/components/workspace/ImageEditor.test.tsx
index 7a49ba5..06bdb7e 100644
--- a/src/components/workspace/ImageEditor.test.tsx
+++ b/src/components/workspace/ImageEditor.test.tsx
@@ -457,6 +457,26 @@ it("starts an image root from the thumbnail Edit menu with edit tools and no typ
expect(current().imageScene!.sourceImage?.name).toBe("Saved");
});
+it.each([false, true])("retains a renamed image root after switching images and reopening (draft: %s)", (imageDraft) => {
+ const initial = parseProjectConfig(fixture);
+ const snapshot = imageGenerationSnapshot(initial, imageDraft ? "" : "Original prompt", defaultGeneratorTemplate().id);
+ initial.assets = ["First", "Second"].map((name) => ({ id: name, name, kind: "image", imageDraft,
+ relativePath: `media/generated/${name}.jpg`, mimeType: "image/jpeg", createdAt: initial.createdAt,
+ imageGeneration: structuredClone(snapshot) }));
+ initial.imageScene!.outputAssetId = "First";
+ const current = setup(initial);
+ fireEvent.change(screen.getByRole("textbox", { name: "Name" }), { target: { value: "Cover image" } });
+ fireEvent.click(screen.getByRole("button", { name: "View Second" }));
+ expect(screen.getByRole("textbox", { name: "Name" })).toHaveValue(snapshot.scene.nodes[0].name);
+ fireEvent.click(screen.getByRole("button", { name: "View First" }));
+ expect(screen.getByRole("textbox", { name: "Name" })).toHaveValue("Cover image");
+ const reopened = parseProjectConfig(JSON.parse(JSON.stringify(current())));
+ expect(restoreGeneratedImage(reopened, "First").imageScene!.nodes[0].name).toBe("Cover image");
+ expect(reopened.assets).toHaveLength(2);
+ expect(reopened.assets[0].imageGeneration).toEqual({ ...snapshot,
+ scene: { ...snapshot.scene, nodes: snapshot.scene.nodes.map((node) => node.kind === "root" ? { ...node, name: "Cover image" } : node) } });
+});
+
it("restores the hierarchy, prompts, settings and generator when selecting a saved result", () => {
const initial = parseProjectConfig(fixture);
const original = imageGenerationSnapshot(initial, "Original prompt", defaultGeneratorTemplate().id);
diff --git a/src/lib/imageHistory.ts b/src/lib/imageHistory.ts
index d129624..2100527 100644
--- a/src/lib/imageHistory.ts
+++ b/src/lib/imageHistory.ts
@@ -73,7 +73,18 @@ export function saveImageDraft(config: ProjectConfig, generatorTemplateId?: stri
const templateDraft = selected?.imageDraft && selected.imageGeneration?.template;
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;
+ if (!source && !selected?.imageDraft) {
+ const generation = selected?.imageGeneration;
+ const root = scene.nodes.find((node) => node.kind === "root");
+ const savedRoot = generation?.scene.nodes.find((node) => node.kind === "root");
+ if (!generation || generation.scene.rootType === "image" || !root || !savedRoot || root.name === savedRoot.name) return config;
+ // A root rename is metadata: retain it when reopening the result while
+ // keeping the original generation prompt and settings intact.
+ return { ...config, assets: config.assets.map((asset) => asset.id === selected.id ? { ...asset,
+ imageGeneration: { ...generation, scene: { ...generation.scene,
+ nodes: generation.scene.nodes.map((node) => node.kind === "root" ? { ...node, name: root.name } : node) } },
+ } : asset) };
+ }
const saved = selected && !selected.imageDraft ? imageEditingSnapshot(config, selected) : selected?.imageGeneration;
const snapshot = imageGenerationSnapshot(config, "", generatorTemplateId || saved?.generatorTemplateId || selected?.imageGeneration?.generatorTemplateId || "image-draft");
// Merely viewing a finished edit (including session autosave) must not create