AI media harness for planning, generating, and editing locally
TypeScript
Keep lasso size fixed and show edit source during generation
Bitti4488e823339d
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex e387186..f731a01 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -24,6 +24,8 @@ This alpha update adds Prompt video scenes, agent image drafts, Sol attention an## Fixes and improvements+- Lasso selections can be moved but not scaled. Image edits keep the source visible during generation and display the edited result when complete.+- Generation effects reuse VAE fingerprints between jobs, removing repeated full-file calibration checks for unchanged VAEs. Changed or replaced VAEs are verified again; saved calibrations remain reusable after restarting.- Renamed image roots on the still image creation page now retain their names when switching images and reopening projects.diff --git a/src/components/workspace/ImageEditor.test.tsx b/src/components/workspace/ImageEditor.test.tsxindex 0b69b46..f00fc63 100644--- a/src/components/workspace/ImageEditor.test.tsx+++ b/src/components/workspace/ImageEditor.test.tsx@@ -38,11 +38,6 @@ it.each(["queued", "generating"] as const)("shows a separate empty %s entry withconst original = { id: "original", kind: "image" as const, name: "Original", relativePath: "media/original.png", width: 512, height: 512,mimeType: "image/png", createdAt: config.createdAt, imageGeneration: imageGenerationSnapshot(config, "Compiled forest", "default") };config.assets = [original];- // Also cover hiding the source thumbnail while an image edit generates.- if (status === "generating") {- config.imageScene = createImageEditScene(original);- config.imageScene.nodes[0].description = "Add snow";- }config.imageScene.outputAssetId = original.id;const pending = saveImageDraft(config, "default", true, "pending");const current = setup(pending, [{ id: "job", imageAssetId: original.id, imageDraftId: "pending", status, progress: 0.25, detail: "Working" } as WorkItem]);@@ -1173,6 +1168,7 @@ it("draws a lasso, edits its prompt, moves its outline, and saves it independentpointer("pointerDown", 100, 80); pointer("pointerMove", 400, 80); pointer("pointerUp", 100, 320);expect(screen.getByRole("radio", { name: "Select" })).toHaveAttribute("aria-checked", "true");expect(screen.getByRole("button", { name: "Lasso" })).toBeInTheDocument();+ expect(canvas.querySelector("[data-resize]")).toBeNull();const lasso = current().imageScene!.nodes[1];expect(lasso).toMatchObject({ name: "Lasso", box: { x: 100, y: 100, width: 300, height: 300 }, lasso: [{ x: 0, y: 0 }, { x: 1000, y: 0 }, { x: 0, y: 1000 }] });typePrompt(screen.getByLabelText("Edit prompt"), "Add a red flower");@@ -1192,3 +1188,26 @@ it("draws a lasso, edits its prompt, moves its outline, and saves it independentpointer("pointerDown", 10, 10); pointer("pointerUp", 200, 200);expect(current().imageScene!.nodes).toHaveLength(2);});++it.each(["queued", "generating", "encoding"] as const)("keeps the edit source visible while %s, then displays the completed image", async (status) => {+ vi.spyOn(persistence, "readMediaFileUrl").mockImplementation(async (_folder, location) => `blob:${location.relativePath}`);+ vi.stubGlobal("URL", class extends URL { static revokeObjectURL = vi.fn(); });+ const config = parseProjectConfig(fixture);+ const source = { id: "source", kind: "image" as const, name: "Original", relativePath: "media/source.png", width: 512, height: 512, mimeType: "image/png", createdAt: config.createdAt };+ config.assets = [source];+ config.imageScene = createImageEditScene(source);+ config.imageScene.nodes[0].description = "Add snow";+ const pending = saveImageDraft(config, "default", true, "pending");+ const work = { id: "job", imageAssetId: source.id, imageDraftId: "pending", status, progress: 0.25, detail: "Working" } as WorkItem;+ const props = { folderPath: "D:/Images", onChange: vi.fn(), onGenerate: vi.fn(), onCancel: vi.fn() };+ const { rerender } = render(<ImageEditor {...props} config={pending} workItems={[work]} />);+ await waitFor(() => expect(document.querySelector(".image-frame img")).toHaveAttribute("src", "blob:media/source.png"));+ expect(document.querySelector(".image-frame .image-empty")).toBeNull();+ expect(screen.getByRole("progressbar", { name: "Image generation progress" })).toBeInTheDocument();+ const result = { ...source, id: "pending", name: "Edited image", relativePath: "media/result.png", imageGeneration: pending.assets[1].imageGeneration };+ const completed = completeImageDraft(pending, result.id, result);+ rerender(<ImageEditor {...props} config={completed} workItems={[{ ...work, status: "completed", progress: 1 }]} />);+ await waitFor(() => expect(document.querySelector(".image-frame img")).toHaveAttribute("src", "blob:media/result.png"));+ expect(screen.queryByRole("progressbar", { name: "Image generation progress" })).not.toBeInTheDocument();+ expect(completed.assets[0]).toEqual(source);+});diff --git a/src/components/workspace/ImageEditor.tsx b/src/components/workspace/ImageEditor.tsxindex 51d1d0d..69ccdbf 100644--- a/src/components/workspace/ImageEditor.tsx+++ b/src/components/workspace/ImageEditor.tsx@@ -357,7 +357,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGeneif (id) setSelection(id);const at = point(event);if (!Number.isFinite(at.x) || !Number.isFinite(at.y)) return;- pointer.current = { ...at, scene, id, resize: target.dataset.resize === "true", ...(drawKind === "lasso" ? { lasso: [at] } : {}) };+ pointer.current = { ...at, scene, id, resize: target.dataset.resize === "true" && !scene.nodes.find((node) => node.id === id)?.lasso, ...(drawKind === "lasso" ? { lasso: [at] } : {}) };if (drawKind === "lasso") setDraftLasso([at]);event.currentTarget.setPointerCapture(event.pointerId);};@@ -734,11 +734,11 @@ 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}>- {active && output?.imageDraft ? <div className="image-empty" role="status"><Image32 aria-hidden="true" /><strong>{work.status === "queued" ? "Queued" : "Generating"}</strong><span>The generated image will appear here.</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>}+ {active && output?.imageDraft && !(imageRoot && scene.sourceImage) ? <div className="image-empty" role="status"><Image32 aria-hidden="true" /><strong>{work.status === "queued" ? "Queued" : "Generating"}</strong><span>The generated image will appear here.</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); setDraftLasso(null); }}>{boxes && scene.nodes.filter((node) => node.box).map((node) => {const box = pointer.current?.id === node.id && draftBox ? draftBox : node.box!;- return <g key={node.id} className={selected.id === node.id ? "selected" : ""}>{node.lasso ? <polygon data-node={node.id} points={imageLassoPoints(node, box).map(({ x, y }) => `${x},${y}`).join(" ")} fillRule="evenodd" vectorEffect="non-scaling-stroke" /> : <rect data-node={node.id} x={box.x} y={box.y} width={box.width} height={box.height} vectorEffect="non-scaling-stroke" />}{selected.id === node.id && <rect className="image-box-handle" data-node={node.id} data-resize="true" x={box.x + box.width - 16} y={box.y + box.height - 16} width="16" height="16" />}</g>;+ return <g key={node.id} className={selected.id === node.id ? "selected" : ""}>{node.lasso ? <polygon data-node={node.id} points={imageLassoPoints(node, box).map(({ x, y }) => `${x},${y}`).join(" ")} fillRule="evenodd" vectorEffect="non-scaling-stroke" /> : <rect data-node={node.id} x={box.x} y={box.y} width={box.width} height={box.height} vectorEffect="non-scaling-stroke" />}{selected.id === node.id && !node.lasso && <rect className="image-box-handle" data-node={node.id} data-resize="true" x={box.x + box.width - 16} y={box.y + box.height - 16} width="16" height="16" />}</g>;})}{draftLasso && <polygon className="image-box-draft" points={draftLasso.map(({ x, y }) => `${x},${y}`).join(" ")} fillRule="evenodd" vectorEffect="non-scaling-stroke" />}{draftBox && !pointer.current?.id && <rect className="image-box-draft" {...{ x: draftBox.x, y: draftBox.y, width: draftBox.width, height: draftBox.height }} />}@@ -816,9 +816,9 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene<GenerationEffects key={selected.id} value={scene.generationEffects} supported={model.generationEffects} disabled={active} onChange={(generationEffects) => commit({ ...scene, generationEffects })} /></>}{!isMiniMaxH3 && selected.kind !== "root" && <PropSection title="Placement (0–1000)" persistKey="image.placement">- <label className="image-check"><input type="checkbox" checked={Boolean(selected.box)} onChange={(event) => patchNode({ box: event.target.checked ? { x: 250, y: 250, width: 500, height: 500 } : null })} />Explicit placement</label>+ <label className="image-check"><input type="checkbox" disabled={Boolean(selected.lasso)} checked={Boolean(selected.box)} onChange={(event) => patchNode({ box: event.target.checked ? { x: 250, y: 250, width: 500, height: 500 } : null })} />Explicit placement</label>{selected.box && (["x", "y", "width", "height"] as const).map((field) => <PropRow key={field} label={field === "x" ? "X" : field === "y" ? "Y" : field === "width" ? "Width" : "Height"} htmlFor={rootField(field)}>- <input id={rootField(field)} className="text-field" type="number" min={field === "x" || field === "y" ? 0 : 1} max="1000" value={selected.box![field]} onChange={(event) => { const value = Number(event.target.value); const box = { ...selected.box!, [field]: value }; if (Number.isFinite(value) && box.x >= 0 && box.y >= 0 && box.width > 0 && box.height > 0 && box.x + box.width <= 1000 && box.y + box.height <= 1000) commit(resizeImageNode(scene, selected.id, box)); }} />+ <input id={rootField(field)} className="text-field" type="number" min={field === "x" || field === "y" ? 0 : 1} max="1000" disabled={Boolean(selected.lasso) && (field === "width" || field === "height")} value={selected.box![field]} onChange={(event) => { const value = Number(event.target.value); const box = { ...selected.box!, [field]: value }; if (Number.isFinite(value) && box.x >= 0 && box.y >= 0 && box.width > 0 && box.height > 0 && box.x + box.width <= 1000 && box.y + box.height <= 1000) commit(resizeImageNode(scene, selected.id, box)); }} /></PropRow>)}</PropSection>}{!isMiniMaxH3 && (!imageRoot || selected.colors.length > 0) && <PropSection title="Color palette" persistKey="image.palette">