AI media harness for planning, generating, and editing locally
TypeScript
Add empty image drafts from the image bar
Bitti5553f4f4d521
diff --git a/README.md b/README.mdindex 55ebb0a..93aa264 100644--- a/README.md+++ b/README.md@@ -29,6 +29,8 @@ The inspector offers **Prompt root** for a new composition and **Image root** toAn **Editing** thumbnail holds the pending image version. Select other thumbnails to browse results, then select Editing to return to its hierarchy and prompts. Saving the project also saves this draft. Successful generation replaces the temporary thumbnail with the finished image; failed or cancelled generation keeps it available for retry.+Right-click the image bar or a thumbnail and choose **New empty image** to add a blank Prompt draft. Its thumbnail keeps the new composition available while browsing and is replaced by the generated image when finished.+The Agent can add, edit, reorder, reparent, duplicate and remove image nodes, and adjust prompts, style, placement, palettes, references, steps and seeds. Edits are transactional and preserve generated images. See the [image command guide](src-tauri/assets/agent-image.md) for the command vocabulary and examples.> **GPU recommendation:** A GPU with **24 GB of VRAM or more** is currently recommended for local video generation. We plan to reduce VRAM usage in future updates.diff --git a/src-tauri/src/project/validation/assets.rs b/src-tauri/src/project/validation/assets.rsindex 0af7cc5..d77eacc 100644--- a/src-tauri/src/project/validation/assets.rs+++ b/src-tauri/src/project/validation/assets.rs@@ -3,8 +3,8 @@ use crate::project::paths::*;use crate::project::*;pub(super) fn validate(config: &mut ProjectConfig) -> Result<(), String> {for asset in &mut config.assets {- if asset.image_draft == Some(true) && (asset.kind != "image" || !asset.image_generation.as_ref().is_some_and(|snapshot| snapshot.scene.root_type.as_deref() == Some("image") && snapshot.scene.source_image.is_some())) {- return Err("Image drafts require an image-root snapshot.".into());+ if asset.image_draft == Some(true) && (asset.kind != "image" || !asset.image_generation.as_ref().is_some_and(|snapshot| snapshot.scene.root_type.as_deref() != Some("image") || snapshot.scene.source_image.is_some())) {+ return Err("Image drafts require a scene snapshot and image roots require a source.".into());}if let Some(snapshot) = &mut asset.image_generation {snapshot.scene.validate()?;@@ -55,10 +55,9 @@ pub(super) fn validate(config: &mut ProjectConfig) -> Result<(), String> {.as_deref().map(normalize_external_path).transpose()?;- // A Generator scene can be cut before it is rendered. Its generated- // asset deliberately has no file until the render completes, while- // every imported asset still has exactly one stored location.- if asset.kind != "generated" || asset.relative_path.is_some() || asset.source_path.is_some()+ // Generated scenes and blank image drafts have no file until generation+ // completes. Imported assets still have exactly one stored location.+ if (asset.kind != "generated" && asset.image_draft != Some(true)) || asset.relative_path.is_some() || asset.source_path.is_some(){check_one_location(&format!("Asset '{}'", asset.id),diff --git a/src-tauri/src/tests/images.rs b/src-tauri/src/tests/images.rsindex 89fb9aa..4f65d80 100644--- a/src-tauri/src/tests/images.rs+++ b/src-tauri/src/tests/images.rs@@ -14,10 +14,18 @@ fn image_editing_draft_survives_save_and_reopen() {"id":"draft", "kind":"image", "name":"Editing Source", "relativePath":"media/imported/source.png", "mimeType":"image/png","width":65, "height":41, "createdAt":config.created_at, "imageDraft":true, "imageGeneration":snapshot})).unwrap());+ snapshot["scene"]["rootType"] = serde_json::json!("prompt");+ snapshot["scene"]["sourceImage"] = serde_json::Value::Null;+ snapshot["scene"]["nodes"].as_array_mut().unwrap().truncate(1);+ snapshot["scene"]["nodes"][0]["description"] = serde_json::json!("");+ config.assets.push(serde_json::from_value(serde_json::json!({+ "id":"empty-draft", "kind":"image", "name":"New image", "mimeType":"image/jpeg",+ "createdAt":config.created_at, "imageDraft":true, "imageGeneration":snapshot+ })).unwrap());let root = tempfile::tempdir().unwrap();let created = create_project_in(root.path(), &config).unwrap();let opened = read_project(Path::new(&created.folder_path)).unwrap();- assert_eq!(opened.config.assets[0], config.assets[0]);+ assert_eq!(opened.config.assets, config.assets);let mut invalid = opened.config;invalid.assets[0].image_generation = None;assert!(validate_and_normalize_config(invalid).is_err());diff --git a/src/components/workspace/ImageEditor.test.tsx b/src/components/workspace/ImageEditor.test.tsxindex b01b1c1..75d3096 100644--- a/src/components/workspace/ImageEditor.test.tsx+++ b/src/components/workspace/ImageEditor.test.tsx@@ -130,11 +130,41 @@ it("removes generated images through their context menu and keeps the preview anexpect(current().assets).toHaveLength(0);expect(current().imageScene!.outputAssetId).toBeNull();expect(current().thumbnail).toBeNull();- expect(screen.queryByLabelText("Generated images")).not.toBeInTheDocument();+ expect(within(screen.getByLabelText("Generated images")).queryByRole("button")).not.toBeInTheDocument();expect(screen.getByText("Compose your image")).toBeInTheDocument();expect(parseProjectConfig(JSON.parse(JSON.stringify(current()))).imageScene).toEqual(current().imageScene);});+it("creates a blank draft from the image bar and preserves it while browsing", () => {+ const initial = parseProjectConfig(fixture);+ initial.assets = [{ id: "saved", name: "Saved", kind: "image", relativePath: "media/generated/saved.jpg", mimeType: "image/jpeg", width: 101, height: 77, createdAt: initial.createdAt }];+ const current = setup(initial);+ fireEvent.contextMenu(screen.getByRole("button", { name: "View Saved" }));+ fireEvent.click(screen.getByRole("menuitem", { name: "New empty image" }));+ expect(screen.getByLabelText("Type")).toHaveValue("prompt");+ expect(screen.getByLabelText("Prompt (high-level description)")).toHaveValue("");+ expect(current().imageScene!.nodes).toHaveLength(1);+ expect(screen.getByRole("button", { name: "View New image" })).toHaveAttribute("aria-pressed", "true");+ fireEvent.change(screen.getByLabelText("Prompt (high-level description)"), { target: { value: "A green forest" } });+ fireEvent.click(screen.getByRole("button", { name: "View Saved" }));+ fireEvent.click(screen.getByRole("button", { name: "View New image" }));+ expect(screen.getByLabelText("Prompt (high-level description)")).toHaveValue("A green forest");+ expect(parseProjectConfig(JSON.parse(JSON.stringify(current()))).assets).toEqual(current().assets);+ fireEvent.contextMenu(screen.getByLabelText("Generated images"));+ expect(screen.queryByRole("menuitem", { name: "Remove" })).not.toBeInTheDocument();+ fireEvent.click(screen.getByRole("menuitem", { name: "New empty image" }));+ expect(current().assets).toHaveLength(3);+ expect(screen.getByLabelText("Prompt (high-level description)")).toHaveValue("");+});++it("creates an image from the empty bar's keyboard context menu", () => {+ const current = setup();+ fireEvent.keyDown(screen.getByLabelText("Generated images"), { key: "F10", shiftKey: true });+ fireEvent.click(screen.getByRole("menuitem", { name: "New empty image" }));+ expect(current().assets).toHaveLength(1);+ expect(current().assets[0]).toMatchObject({ name: "New image", imageDraft: true });+});+it("edits ordered style chips with suggestions, custom tags, removal, undo, and mode-specific choices", () => {const current = setup();expect(screen.getByRole("button", { name: "Aesthetics tag: Minimal poster" })).toBeInTheDocument();diff --git a/src/components/workspace/ImageEditor.tsx b/src/components/workspace/ImageEditor.tsxindex 5b417cc..5abbb50 100644--- a/src/components/workspace/ImageEditor.tsx+++ b/src/components/workspace/ImageEditor.tsx@@ -5,7 +5,7 @@ import { addImageNode, createImageEditScene, createImageScene, duplicateImageNodimport { compileImageEdits, editGeneratedImage, imageEditDebugPrompt } from "../../lib/imageEditing";import { outputDimensions } from "../../lib/export";import { compileImagePrompt } from "../../lib/imagePrompt";-import { restoreGeneratedImage, saveImageDraft } from "../../lib/imageHistory";+import { createEmptyImage, restoreGeneratedImage, saveImageDraft } from "../../lib/imageHistory";import { isTauri } from "../../lib/persistence";import { PROJECT_RESOLUTIONS, type ProjectConfig } from "../../lib/project";import { defaultGeneratorTemplate, loadDebugOptionsEnabled, loadGeneratorTemplateSettings, subscribeDebugOptions, subscribeGeneratorTemplates, templateNeedsDownload, type GeneratorTemplate } from "../../lib/settings";@@ -41,7 +41,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGeneconst [draggedNode, setDraggedNode] = useState<string | null>(null);const [treeDrop, setTreeDrop] = useState<{ id: string; placement: "before" | "inside" | "after" } | null>(null);const [contextMenu, setContextMenu] = useState<{ x: number; y: number } | null>(null);- const [imageMenu, setImageMenu] = useState<{ id: string; x: number; y: number } | null>(null);+ const [imageMenu, setImageMenu] = useState<{ id: string | null; x: number; y: number } | null>(null);const imageResults = useRef<HTMLDivElement>(null);const [renaming, setRenaming] = useState<{ id: string; value: string } | null>(null);const renameEnding = useRef(false);@@ -166,7 +166,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGeneconst closeContextMenu = () => { setContextMenu(null); focusNode(selected.id); };const closeImageMenu = () => {const button = [...(imageResults.current?.querySelectorAll<HTMLButtonElement>("button") ?? [])].find((element) => element.dataset.imageAsset === imageMenu?.id);- setImageMenu(null); button?.focus();+ setImageMenu(null); (button ?? imageResults.current)?.focus();};const resetImageEditing = (id: string) => {const snapshot = config.assets.find((asset) => asset.id === id)?.imageGeneration;@@ -202,7 +202,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene: remaining.find((asset) => asset.id === currentScene.outputAssetId);const updated = { ...current,assets: current.assets.filter((asset) => asset.id !== id),- imageScene: removingSelected && removed.imageDraft && !next ? createImageEditScene(null, currentScene) : { ...currentScene, outputAssetId: removingSelected ? next?.id ?? null : currentScene.outputAssetId },+ imageScene: removingSelected && removed.imageDraft && !next ? currentScene.rootType === "image" ? createImageEditScene(null, currentScene) : createImageScene() : { ...currentScene, outputAssetId: removingSelected ? next?.id ?? null : currentScene.outputAssetId },thumbnail: removingSelected || current.thumbnail === removed.relativePath ? next?.relativePath ?? null : current.thumbnail,timeline: { ...current.timeline, tracks: current.timeline.tracks.map((track) => ({ ...track, clips: track.clips.filter((clip) => clip.assetId !== id) })) },};@@ -357,8 +357,14 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene{ label: "Delete", icon: <Trash2 size={15} />, shortcut: "Delete", separator: true, danger: true, disabled: selected.kind === "root", action: removeSelected },]} />}{imageMenu && <HierarchyContextMenu {...imageMenu} label="Generated image actions" onClose={closeImageMenu} items={[- { label: "Edit", icon: <Pencil size={15} />, action: () => attempt(() => config.assets.find((asset) => asset.id === imageMenu.id)?.imageDraft ? selectImage(imageMenu.id) : replaceScene(editGeneratedImage(config, imageMenu.id).imageScene!)) },- { label: "Remove", icon: <Trash2 size={15} />, danger: true, disabled: Boolean(active && work.imageDraftId === imageMenu.id), action: () => removeImage(imageMenu.id) },+ { label: "New empty image", icon: <Plus size={15} />, 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));+ }) },+ ...(imageMenu.id ? [+ { label: "Edit", icon: <Pencil size={15} />, action: () => attempt(() => config.assets.find((asset) => asset.id === imageMenu.id)?.imageDraft ? selectImage(imageMenu.id!) : replaceScene(editGeneratedImage(config, imageMenu.id!).imageScene!)) },+ { label: "Remove", icon: <Trash2 size={15} />, danger: true, disabled: Boolean(active && work.imageDraftId === imageMenu.id), action: () => removeImage(imageMenu.id!) },+ ] : []),]} />}<section className="image-center" aria-label="Image panel"><div className="image-canvas-tools">@@ -389,7 +395,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGeneonPointerUpCapture={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 ? <ReferenceImage folderPath={folderPath} relativePath={output.relativePath} sourcePath={output.sourcePath} alt={output.name} /> : <div className="image-empty"><Image size={42} /><strong>{imageRoot ? "Open an image to edit" : "Compose your image"}</strong><span>{imageRoot ? "Choose Open image in the inspector, then add Object nodes for edits." : "Add objects, text, and groups, then describe them in the inspector."}</span></div>}+ {imageRoot && scene.sourceImage ? <ReferenceImage folderPath={folderPath} relativePath={scene.sourceImage.relativePath} alt={scene.sourceImage.name} /> : output && !imageRoot && (output.relativePath || output.sourcePath) ? <ReferenceImage folderPath={folderPath} relativePath={output.relativePath} sourcePath={output.sourcePath} alt={output.name} /> : <div className="image-empty"><Image size={42} /><strong>{imageRoot ? "Open an image to edit" : "Compose your image"}</strong><span>{imageRoot ? "Choose Open image in the inspector, then add Object nodes for edits." : "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!;@@ -401,8 +407,12 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene</div></div><div className="image-status" role="status">{active && <progress value={work.progress} max="1" />}<span>{active ? work.detail : imageRoot ? editPlan?.error ?? `${width} × ${height} · ${editPlan?.edits.length} edits in hierarchy order` : !isTauri() ? "Image generation is available in the desktop app." : `${width} × ${height} · Placement boxes guide the prompt.`}</span></div>{(error || work?.error) && <p className="image-error" role="alert">{error ?? work?.error}</p>}- {images.length > 0 && <div ref={imageResults} className="image-results" aria-label="Generated images">{images.map((asset) => <button key={asset.id} data-image-asset={asset.id} title={asset.name} aria-label={`View ${asset.name}`} aria-pressed={asset.id === scene.outputAssetId}- onContextMenu={(event) => { event.preventDefault(); setContextMenu(null); setImageMenu({ id: asset.id, x: event.clientX, y: event.clientY }); }}+ <div ref={imageResults} tabIndex={0} className="image-results" aria-label="Generated images" onContextMenu={(event) => { event.preventDefault(); setContextMenu(null); setImageMenu({ id: null, x: event.clientX, y: event.clientY }); }} onKeyDown={(event) => {+ if (event.target === event.currentTarget && (event.key === "ContextMenu" || event.shiftKey && event.key === "F10")) {+ event.preventDefault(); const bounds = event.currentTarget.getBoundingClientRect(); setContextMenu(null); setImageMenu({ id: null, x: bounds.left, y: bounds.top });+ }+ }}>{images.map((asset) => <button key={asset.id} data-image-asset={asset.id} title={asset.name} aria-label={`View ${asset.name}`} aria-pressed={asset.id === scene.outputAssetId}+ onContextMenu={(event) => { event.preventDefault(); event.stopPropagation(); setContextMenu(null); setImageMenu({ id: asset.id, x: event.clientX, y: event.clientY }); }}onKeyDown={(event) => {if (event.key === "ContextMenu" || (event.shiftKey && event.key === "F10")) {event.preventDefault();@@ -410,7 +420,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGenesetContextMenu(null); setImageMenu({ id: asset.id, x: bounds.left, y: bounds.bottom });}}}- onClick={() => selectImage(asset.id)}><ReferenceImage folderPath={folderPath} relativePath={asset.relativePath} sourcePath={asset.sourcePath} alt={asset.name} />{asset.imageDraft && <span className="image-draft-badge"><Pencil size={11} />Editing</span>}</button>)}</div>}+ onClick={() => selectImage(asset.id)}>{asset.relativePath || asset.sourcePath ? <ReferenceImage folderPath={folderPath} relativePath={asset.relativePath} sourcePath={asset.sourcePath} alt={asset.name} /> : <Image size={24} aria-hidden="true" />}{asset.imageDraft && <span className="image-draft-badge"><Pencil size={11} />{asset.imageGeneration?.scene.rootType === "image" ? "Editing" : "Draft"}</span>}</button>)}</div></section><aside className="image-inspector" aria-label="Image node inspector"><header><strong>Inspector</strong><span>{selected.kind}</span></header><div className="image-inspector__fields">{selected.kind === "root" && <label>Type<select value={imageRoot ? "image" : "prompt"} onChange={(event) => replaceScene(event.target.value === "image" ? createImageEditScene(null, scene) : { ...createImageScene(), steps: scene.steps, seed: scene.seed })}><option value="prompt">Prompt</option><option value="image">Image</option></select></label>}diff --git a/src/lib/imageHistory.ts b/src/lib/imageHistory.tsindex 77adeef..a992c79 100644--- a/src/lib/imageHistory.ts+++ b/src/lib/imageHistory.ts@@ -18,20 +18,31 @@ export function imageGenerationSnapshot(config: ProjectConfig, prompt: string, g/** Keep the editable version in history without creating another image file. */export function saveImageDraft(config: ProjectConfig, generatorTemplateId?: string): ProjectConfig {const scene = config.imageScene;- if (config.generationType !== "image" || scene?.rootType !== "image" || !scene.sourceImage) return config;+ if (config.generationType !== "image" || !scene) return config;const selected = config.assets.find((asset) => asset.id === scene.outputAssetId);+ const source = scene.rootType === "image" ? scene.sourceImage : null;+ if (!source && !selected?.imageDraft) return config;if (!selected?.imageDraft && scene.outputAssetId && scene.nodes.length === 1) return config;const existing = selected?.imageDraft ? selected : undefined;const id = existing?.id ?? `image-draft-${crypto.randomUUID()}`;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 source = scene.sourceImage;- const asset = { id, kind: "image" as const, ...source, name: existing?.name ?? `Editing ${source.name}`,- imageDraft: true, mimeType: /\.png$/i.test(source.relativePath) ? "image/png" : "image/jpeg",+ 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, createdAt: existing?.createdAt ?? new Date().toISOString() };return { ...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 {+ config = saveImageDraft(config);+ 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,+ imageGeneration: imageGenerationSnapshot(next, "", generatorTemplateId || "image-draft"), createdAt: new Date().toISOString() };+ return { ...next, assets: [...config.assets, asset] };+}+export function completeImageDraft(config: ProjectConfig, id: string, result: ProjectAsset): ProjectConfig {const draft = config.assets.find((asset) => asset.id === id && asset.imageDraft);const selected = config.imageScene?.outputAssetId === id;diff --git a/src/lib/project.ts b/src/lib/project.tsindex de72216..caf161f 100644--- a/src/lib/project.ts+++ b/src/lib/project.ts@@ -183,16 +183,15 @@ export const projectAssetSchema = z.object({createdAt: isoDateSchema,}).superRefine((asset, context) => {checkOneLocation(asset, context, `Asset '${asset.id}'`);- if (asset.imageDraft && (asset.kind !== "image" || !asset.imageGeneration?.scene.sourceImage || asset.imageGeneration.scene.rootType !== "image")) {- context.addIssue({ code: z.ZodIssueCode.custom, message: "Image drafts require an image-root snapshot." });+ if (asset.imageDraft && (asset.kind !== "image" || !asset.imageGeneration || (asset.imageGeneration.scene.rootType === "image" && !asset.imageGeneration.scene.sourceImage))) {+ context.addIssue({ code: z.ZodIssueCode.custom, message: "Image drafts require a scene snapshot and image roots require a source." });}if (asset.imageGeneration && asset.kind !== "image") {context.addIssue({ code: z.ZodIssueCode.custom, path: ["imageGeneration"], message: "Only image assets can store image generation history." });}- /* A scene may be arranged on the timeline before it has been rendered. Its- * generated asset is the stable thing the clip points at while the file is- * still absent; WorkQueue fills the path in when rendering ends. */- if (asset.kind !== "generated" && !asset.relativePath && !asset.sourcePath) {+ /* Generated scenes and blank image drafts can exist before rendering.+ * WorkQueue fills their file paths in when generation ends. */+ if (asset.kind !== "generated" && !asset.imageDraft && !asset.relativePath && !asset.sourcePath) {context.addIssue({code: z.ZodIssueCode.custom, path: ["relativePath"],message: `Asset '${asset.id}' must have either a project-relative path or an external source path.`,diff --git a/src/lib/workQueue.test.ts b/src/lib/workQueue.test.tsindex 475d2e3..6a8b33e 100644--- a/src/lib/workQueue.test.ts+++ b/src/lib/workQueue.test.ts@@ -14,7 +14,7 @@ import { prepareReferenceVideos, releaseReferenceVideos } from "./referenceVideoimport { downloadTemplateWeights, getWeightDownloadState } from "./weightDownloads";import { compileImagePrompt } from "./imagePrompt";import { addImageNode, createImageEditScene } from "./imageScene";-import { restoreGeneratedImage } from "./imageHistory";+import { createEmptyImage, restoreGeneratedImage } from "./imageHistory";vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn() }));@@ -136,6 +136,25 @@ describe("image generation work", () => {}expect(parseProjectConfig(JSON.parse(JSON.stringify(config))).assets).toEqual(config.assets);});+ it("replaces an empty-image draft with its generated JPEG", async () => {+ const { queue } = setup();+ const record = imageProject();+ record.config = createEmptyImage(record.config, template.id);+ record.config.imageScene!.nodes[0].description = "A forest";+ const draftId = record.config.imageScene!.outputAssetId;+ const session = queue.project(record);+ vi.mocked(invoke).mockResolvedValue({ relativePath: "media/generated/forest.jpg", width: 768, height: 768 });+ queue.enqueueImage(session, template);+ await waitFor(() => expect(enqueueSlopfabGeneration).toHaveBeenCalledOnce());+ const request = vi.mocked(enqueueSlopfabGeneration).mock.calls[0][0];+ expect(request.imageEdit).toBeUndefined();+ await finish(queue, request.jobId);+ const config = session.getSnapshot().config;+ expect(config.assets).toHaveLength(1);+ expect(config.assets[0]).toMatchObject({ id: draftId, imageDraft: false, relativePath: "media/generated/forest.jpg", mimeType: "image/jpeg" });+ expect(config.imageScene!.nodes[0].description).toBe("A forest");+ expect(config.imageScene!.outputAssetId).toBe(draftId);+ });it("forwards selected refmods to still-image planning and generation with their strength and copies", async () => {const { queue } = setup();const project = imageProject();diff --git a/src/lib/workQueue.ts b/src/lib/workQueue.tsindex 8d3ba99..2fa4746 100644--- a/src/lib/workQueue.ts+++ b/src/lib/workQueue.ts@@ -216,7 +216,7 @@ export class WorkQueue {const { prompt, references } = compileImagePrompt(current);const { width, height } = edit?.source ?? outputDimensions(current.settings.resolution, current.settings.aspectRatio);const id = `image-${crypto.randomUUID()}`;- const imageDraftId = edit ? scene.outputAssetId ?? undefined : undefined;+ const imageDraftId = current.assets.find((asset) => asset.id === scene.outputAssetId && asset.imageDraft)?.id;let finish!: () => void;const done = new Promise<void>((resolve) => { finish = resolve; });const request: SlopfabGenerationRequest = { jobId: id, stillImage: true, frames: 1, prompt: edit ? edit.edits[0].prompt : prompt,@@ -409,7 +409,7 @@ export class WorkQueue {const saved = await invoke<{ relativePath: string; width: number; height: number }>("save_generated_image", { folderPath: work.session.record.folderPath, jobId: work.id, ...(work.request.imageEdit ? { format: "png" } : {}) });work.session.update((current) => work.imageDraftId ? completeImageDraft(current, work.imageDraftId, {id: work.imageDraftId, kind: "image", name: `Image ${current.assets.filter((asset) => asset.kind === "image" && !asset.imageDraft).length + 1}`,- ...saved, imageGeneration: work.imageGeneration, mimeType: "image/png", createdAt: new Date().toISOString(),+ ...saved, imageGeneration: work.imageGeneration, mimeType: work.request.imageEdit ? "image/png" : "image/jpeg", createdAt: new Date().toISOString(),}) : ({ ...current, thumbnail: saved.relativePath,imageScene: { ...(work.request.imageEdit && JSON.stringify(current.imageScene) === work.snapshot ? createImageEditScene({ ...saved, name: "Edited image" }, current.imageScene ?? undefined) : current.imageScene ?? createImageScene()), outputAssetId: work.id },assets: [...current.assets, { id: work.id, kind: "image", name: `Image ${current.assets.filter((asset) => asset.kind === "image").length + 1}`, ...saved, imageGeneration: work.imageGeneration, mimeType: work.request.imageEdit ? "image/png" : "image/jpeg", createdAt: new Date().toISOString() }],diff --git a/src/styles/image-editor.css b/src/styles/image-editor.cssindex 74e73e4..f97c003 100644--- a/src/styles/image-editor.css+++ b/src/styles/image-editor.css@@ -50,7 +50,7 @@.image-status { display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-2) var(--space-3); font-size: var(--text-xs); border-top: 1px solid var(--line-solid); }.image-status progress { width: 100%; height: var(--space-1); accent-color: var(--accent); }.image-error { margin: 0; padding: var(--space-2) var(--space-3); color: var(--danger); }-.image-results { display: flex; gap: var(--space-2); overflow-x: auto; padding: var(--space-2); border-top: 1px solid var(--line-solid); }+.image-results { display: flex; min-height: 82px; gap: var(--space-2); overflow-x: auto; padding: var(--space-2); border-top: 1px solid var(--line-solid); }.image-results button { position: relative; flex: 0 0 72px; height: 64px; padding: 0; overflow: hidden; border: 2px solid transparent; background: var(--panel); }.image-draft-badge { position: absolute; bottom: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: 3px; padding: 2px; background: var(--glass); color: var(--text); font-size: 10px; }.image-results button[aria-pressed="true"] { border-color: var(--accent); }