AI media harness for planning, generating, and editing locally
TypeScript
Add Extend template bounding box controls
Bitti3840441b1eae
diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.mdindex 6698075..780e931 100644--- a/RELEASE_NOTES.md+++ b/RELEASE_NOTES.md@@ -4,6 +4,7 @@ This alpha update adds Linux support, LAN generation workers, expanded color gra## What's new+- Extend an image from the Image toolbar's Template menu. Draw, move or resize a bounding box to generate beyond any edge, with optional prompts and references, steps and seed controls. Original pixels inside the box stay unchanged, and the result is saved as a child image in lossless PNG format.- Share URL-based generator templates using Import and Export in Generator settings. Versioned `.slop` JSON bundles include GPU download variants, LoRAs and additional safetensors, preserve existing templates on import, and leave local paths out of shared files.- Renamed Colour correction to Basic Corrections and added temperature, tint, brightness, highlights, shadows, whites and blacks alongside exposure, contrast and saturation.- Added Creative with eight built-in procedural looks and intensity, faded film, sharpen and vibrance controls; RGB and hue/saturation/luma curve editors; and shadow, midtone and highlight Color Wheels with individual lightness controls.diff --git a/src/components/ProjectWorkspace.tsx b/src/components/ProjectWorkspace.tsxindex 5b7d597..f7d116d 100644--- a/src/components/ProjectWorkspace.tsx+++ b/src/components/ProjectWorkspace.tsx@@ -286,7 +286,7 @@ export function ProjectWorkspace({ project, initialView, runtime = null, onBack,<ProjectStatusSlot.Provider value={statusSlot}><div className={`project-body${agentOpen ? " project-body--agent" : ""}`} style={agentPane.style}><div id={`${panelId}-view`} role="tabpanel" aria-label={VIEW_LABELS[view]} className={`project-content project-content--${view}`}>- {view === "editor" && <ImageEditor config={config} folderPath={project.folderPath} onChange={changeConfig} onGenerate={(template) => queue.enqueueImage(session, template)} onGenerateCharacterSheet={(template, sourceId, options) => queue.enqueueCharacterSheet(session, template, sourceId, options)} onCancel={(id) => queue.cancel(id)} workItems={projectItems.filter((item) => item.kind === "image")} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); setView("generator"); }} onOpenReferences={() => setView("references")} />}+ {view === "editor" && <ImageEditor config={config} folderPath={project.folderPath} onChange={changeConfig} onGenerate={(template) => queue.enqueueImage(session, template)} onGenerateCharacterSheet={(template, sourceId, options) => queue.enqueueCharacterSheet(session, template, sourceId, options)} onGenerateExtend={(template, sourceId, options) => queue.enqueueExtendImage(session, template, sourceId, options)} onCancel={(id) => queue.cancel(id)} workItems={projectItems.filter((item) => item.kind === "image")} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); setView("generator"); }} onOpenReferences={() => setView("references")} />}{view === "timeline" && <TimelineView config={config} openSceneId={selectedGenerationJobId} folderPath={project.folderPath} generationCompletionTimes={generationCompletionTimes} onChange={changeConfig} onMeasured={recordMeasurement} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); setView("generator"); }} />}{view === "generator" && <GeneratorView onGenerate={(submissions) => queue.enqueue(session, submissions)} onCancelGeneration={(ids) => queue.cancelScenes(session, ids)} cancellingJobIds={cancellingJobIds} config={config} folderPath={project.folderPath} generationCompletionTimes={generationCompletionTimes} runtime={runtime?.slopfab ?? null} onRuntimeChange={onGeneratorRuntimeChange} onChange={changeConfig} selectedJobId={selectedGenerationJobId} onSelectedJobChange={setSelectedGenerationJobId} onOpenTimeline={() => setView("timeline")} />}{view === "references" && <ReferencesView config={config} folderPath={project.folderPath} onChange={changeConfig} onRegenerateIcon={(id) => queue.regenerateReferenceIcon(session, id)} onExportRefmod={(id, outputPath) => queue.exportReferenceRefmod(session, id, outputPath)} onGenerateBuiltinIcons={() => queue.generateBuiltinReferenceIcons(session)} onRegenerateBuiltinIcon={(id) => queue.regenerateBuiltinReferenceIcon(session, id)} pendingBuiltinIconIds={queue.pendingBuiltinIconIds()} pendingIconIds={new Set(config.references.filter((reference) => queue.isReferenceIconPending(session, reference.id)).map((reference) => reference.id))} onOpenGenerator={(jobId) => { setSelectedGenerationJobId(jobId); setView("generator"); }} />}diff --git a/src/components/workspace/Extend.test.tsx b/src/components/workspace/Extend.test.tsxnew file mode 100644index 0000000..f35acd5--- /dev/null+++ b/src/components/workspace/Extend.test.tsx@@ -0,0 +1,88 @@+// @vitest-environment jsdom+import "@testing-library/jest-dom/vitest";+import { useState } from "react";+import { cleanup, createEvent, fireEvent, render, screen, within } from "@testing-library/react";+import { afterEach, expect, it, vi } from "vitest";+import { ImageEditor } from "./ImageEditor";+import { ExtendCanvas } from "./ExtendCanvas";+import { typePrompt } from "./promptTestUtils";+import { parseProjectConfig } from "../../lib/project";+import { EMPTY_ENGINE_SETTINGS, saveGeneratorTemplateSettings } from "../../lib/settings";+import * as persistence from "../../lib/persistence";+import fixture from "../../../fixtures/project-v1-image.json";+import type { ExtendBounds } from "../../lib/extendImage";++afterEach(() => { cleanup(); localStorage.clear(); vi.restoreAllMocks(); });+const source = { id: "source", name: "Source", kind: "image" as const, relativePath: "media/source.png", mimeType: "image/png", width: 400, height: 300, createdAt: "2026-10-04T00:00:00Z" };++it("activates the box through Template, validates settings and executes without editing the source", () => {+ vi.spyOn(persistence, "isTauri").mockReturnValue(true);+ vi.spyOn(persistence, "readMediaFileUrl").mockResolvedValue(null);+ const template = { id: "test", name: "Test", modelType: "minimax-h3" as const, defaultSteps: 20, attention: "sage2" as const, paths: { ...EMPTY_ENGINE_SETTINGS, transformer: "D:/h3.safetensors" } };+ saveGeneratorTemplateSettings({ defaultTemplateId: "test", templates: [template] });+ const config = parseProjectConfig(fixture); config.assets = [source]; config.imageScene!.outputAssetId = source.id;+ const generate = vi.fn(), change = vi.fn();+ render(<ImageEditor config={config} folderPath="D:/Images" onChange={change} onGenerate={vi.fn()} onCancel={vi.fn()} onGenerateExtend={generate} />);+ fireEvent.click(screen.getByRole("button", { name: "Template" }));+ fireEvent.click(screen.getByRole("menuitem", { name: "Extend" }));+ expect(screen.getByLabelText("Extend bounding box tool")).toBeInTheDocument();+ expect(screen.queryByLabelText("Image placement canvas")).not.toBeInTheDocument();+ const panel = within(screen.getByRole("complementary", { name: "Extend settings" }));+ expect(panel.getByLabelText("Extend x")).toHaveValue(-100);+ expect(panel.getByLabelText("Extend width")).toHaveValue(600);+ fireEvent.keyDown(screen.getByRole("button", { name: "Move Extend box" }), { key: "ArrowLeft", shiftKey: true });+ expect(panel.getByLabelText("Extend x")).toHaveValue(-110);+ fireEvent.change(panel.getByLabelText("Extend x"), { target: { value: "400" } });+ expect(panel.getByRole("button", { name: "Execute" })).toBeDisabled();+ expect(panel.getByText("The box must overlap the original image.")).toBeInTheDocument();+ fireEvent.click(panel.getByRole("button", { name: "Reset box" }));+ fireEvent.change(panel.getByLabelText("Steps"), { target: { value: "31" } });+ fireEvent.change(panel.getByLabelText("Seed"), { target: { value: "0" } });+ typePrompt(panel.getByRole("textbox", { name: "Extend prompt" }), "A forest clearing");+ fireEvent.click(panel.getByRole("button", { name: "Execute" }));+ expect(generate).toHaveBeenCalledWith(expect.objectContaining({ id: template.id }), source.id,+ { bounds: { x: -100, y: -75, width: 600, height: 450 }, steps: 31, seed: 0, prompt: "A forest clearing" });+ expect(screen.getByRole("status")).toHaveTextContent("Extend: 600 × 450 px");+ expect(change).not.toHaveBeenCalled();+ fireEvent.click(panel.getByRole("button", { name: "Close template settings" }));+ expect(screen.queryByLabelText("Extend bounding box tool")).not.toBeInTheDocument();+ const normal = screen.getByLabelText("Image placement canvas").closest(".image-viewport")!;+ const frame = normal.querySelector<HTMLElement>(".image-frame")!;+ const zoom = frame.style.getPropertyValue("--image-zoom");+ fireEvent.wheel(normal, { deltaY: -100 });+ expect(frame.style.getPropertyValue("--image-zoom")).not.toBe(zoom);+});++it("moves, resizes, redraws and cancels box drags in original pixel coordinates", () => {+ vi.spyOn(persistence, "readMediaFileUrl").mockResolvedValue(null);+ let latest: ExtendBounds = { x: -100, y: -75, width: 600, height: 450 };+ function Harness() {+ const [bounds, setBounds] = useState(latest); latest = bounds;+ return <ExtendCanvas source={source} folderPath="D:/Images" bounds={bounds} onChange={setBounds} disabled={false} />;+ }+ render(<Harness />);+ const canvas = screen.getByLabelText("Extend bounding box tool");+ const pointer = (type: "pointerDown" | "pointerMove" | "pointerUp" | "pointerCancel", target: Element, x: number, y: number) => {+ const view = canvas.getAttribute("viewBox")!.split(" ").map(Number);+ vi.spyOn(canvas, "getBoundingClientRect").mockReturnValue({ left: 0, top: 0, width: view[2], height: view[3] } as DOMRect);+ const event = createEvent[type](target);+ Object.defineProperties(event, { button: { value: 0 }, pointerId: { value: 1 }, clientX: { value: x - view[0] }, clientY: { value: y - view[1] } });+ fireEvent(target, event);+ };+ pointer("pointerDown", screen.getByRole("button", { name: "Move Extend box" }), 0, 0);+ pointer("pointerMove", canvas, 20, 10); pointer("pointerUp", canvas, 20, 10);+ expect(latest).toEqual({ x: -80, y: -65, width: 600, height: 450 });+ pointer("pointerDown", canvas.querySelector('[data-handle="nw"]')!, -80, -65);+ pointer("pointerMove", canvas, -110, -90); pointer("pointerUp", canvas, -110, -90);+ expect(latest).toEqual({ x: -110, y: -90, width: 630, height: 475 });+ pointer("pointerDown", canvas, -130, -100);+ pointer("pointerMove", canvas, 200, 200); pointer("pointerUp", canvas, 200, 200);+ expect(latest).toEqual({ x: -130, y: -100, width: 330, height: 300 });+ pointer("pointerDown", canvas.querySelector('[data-handle="se"]')!, 200, 200);+ pointer("pointerMove", canvas, 300, 300); pointer("pointerCancel", canvas, 300, 300);+ expect(latest).toEqual({ x: -130, y: -100, width: 330, height: 300 });+ pointer("pointerDown", canvas.querySelector('[data-handle="e"]')!, 200, 0);+ pointer("pointerMove", canvas, 300, 0);+ fireEvent.keyDown(canvas, { key: "Escape" });+ expect(latest).toEqual({ x: -130, y: -100, width: 330, height: 300 });+});diff --git a/src/components/workspace/ExtendCanvas.tsx b/src/components/workspace/ExtendCanvas.tsxnew file mode 100644index 0000000..130942e--- /dev/null+++ b/src/components/workspace/ExtendCanvas.tsx@@ -0,0 +1,90 @@+import { useEffect, useRef, useState, type CSSProperties, type PointerEvent } from "react";+import type { ExtendBounds } from "../../lib/extendImage";+import type { ProjectAsset } from "../../lib/project";+import { ReferenceImage } from "./ReferenceImage";++function cameraFor(width: number, height: number, box: ExtendBounds) {+ const valid = Object.values(box).every(Number.isFinite) && box.width > 0 && box.height > 0;+ const left = Math.min(0, valid ? box.x : 0), top = Math.min(0, valid ? box.y : 0);+ const right = Math.max(width, valid ? box.x + box.width : width), bottom = Math.max(height, valid ? box.y + box.height : height);+ const margin = Math.max(width, height, right - left, bottom - top) * 0.2;+ return { x: left - margin, y: top - margin, width: right - left + margin * 2, height: bottom - top + margin * 2 };+}+const handles = ["nw", "n", "ne", "e", "se", "s", "sw", "w"] as const;++export function ExtendCanvas({ source, folderPath, bounds, onChange, disabled }: {+ source: ProjectAsset; folderPath: string; bounds: ExtendBounds; onChange: (bounds: ExtendBounds) => void; disabled: boolean;+}) {+ const width = source.width!, height = source.height!;+ const [camera, setCamera] = useState(() => cameraFor(width, height, bounds));+ const [dragging, setDragging] = useState(false);+ const drag = useRef<{ pointerId: number; x: number; y: number; box: ExtendBounds; mode: string } | null>(null);+ useEffect(() => { if (!dragging) setCamera(cameraFor(width, height, bounds)); }, [bounds, width, height, dragging]);+ const point = (event: PointerEvent<SVGSVGElement>) => {+ const rect = event.currentTarget.getBoundingClientRect();+ return { x: Math.round(camera.x + (event.clientX - rect.left) / rect.width * camera.width),+ y: Math.round(camera.y + (event.clientY - rect.top) / rect.height * camera.height) };+ };+ const finish = (event: PointerEvent<SVGSVGElement>, cancel = false) => {+ if (drag.current?.pointerId !== event.pointerId) return;+ if (cancel) onChange(drag.current.box);+ drag.current = null; setDragging(false);+ if (event.currentTarget.hasPointerCapture?.(event.pointerId)) event.currentTarget.releasePointerCapture(event.pointerId);+ };+ const valid = Object.values(bounds).every(Number.isFinite) && bounds.width > 0 && bounds.height > 0;+ const box = valid ? bounds : { x: 0, y: 0, width, height };+ const left = Math.max(0, box.x), top = Math.max(0, box.y), right = Math.min(width, box.x + box.width), bottom = Math.min(height, box.y + box.height);+ const outline = `M${box.x},${box.y}h${box.width}v${box.height}h${-box.width}Z`;+ const hole = right > left && bottom > top ? `M${left},${top}h${right - left}v${bottom - top}h${left - right}Z` : "";+ const handleSize = Math.max(camera.width, camera.height) / 65;+ return <div className="image-viewport extend-viewport">+ <div className="image-frame extend-frame" style={{ "--image-ratio": camera.width / camera.height, "--image-zoom": 1, "--image-pan-x": "0px", "--image-pan-y": "0px" } as CSSProperties}>+ <div className="extend-source" style={{ left: `${-camera.x / camera.width * 100}%`, top: `${-camera.y / camera.height * 100}%`, width: `${width / camera.width * 100}%`, height: `${height / camera.height * 100}%` }}>+ <ReferenceImage folderPath={folderPath} relativePath={source.relativePath} sourcePath={source.sourcePath} alt={source.name} />+ </div>+ <svg className="extend-overlay" viewBox={`${camera.x} ${camera.y} ${camera.width} ${camera.height}`} aria-label="Extend bounding box tool" aria-disabled={disabled}+ onPointerDown={(event) => {+ if (disabled || event.button !== 0) return;+ const at = point(event); if (!Number.isFinite(at.x + at.y)) return;+ event.preventDefault();+ event.currentTarget.querySelector<SVGElement>('[data-handle="move"]')?.focus();+ const mode = (event.target as Element).getAttribute("data-handle") ?? "draw";+ drag.current = { pointerId: event.pointerId, ...at, box: { ...box }, mode };+ setDragging(true); event.currentTarget.setPointerCapture?.(event.pointerId);+ }} onPointerMove={(event) => {+ const start = drag.current; if (!start || disabled || start.pointerId !== event.pointerId) return;+ const at = point(event), dx = at.x - start.x, dy = at.y - start.y;+ let { x, y, width: w, height: h } = start.box;+ if (start.mode === "move") { x += dx; y += dy; }+ else if (start.mode === "draw") { x = Math.min(start.x, at.x); y = Math.min(start.y, at.y); w = Math.max(1, Math.abs(dx)); h = Math.max(1, Math.abs(dy)); }+ else {+ if (start.mode.includes("e")) w = Math.max(1, w + dx);+ if (start.mode.includes("s")) h = Math.max(1, h + dy);+ if (start.mode.includes("w")) { x = Math.min(x + dx, x + w - 1); w += start.box.x - x; }+ if (start.mode.includes("n")) { y = Math.min(y + dy, y + h - 1); h += start.box.y - y; }+ }+ onChange({ x: Math.max(-8192, Math.min(8192, x)), y: Math.max(-8192, Math.min(8192, y)), width: Math.min(8192, w), height: Math.min(8192, h) });+ }} onPointerUp={(event) => finish(event)} onPointerCancel={(event) => finish(event, true)} onLostPointerCapture={(event) => finish(event)}+ onKeyDown={(event) => {+ if (event.key !== "Escape" || !drag.current) return;+ event.preventDefault();+ const start = drag.current; drag.current = null; setDragging(false); onChange(start.box);+ if (event.currentTarget.hasPointerCapture?.(start.pointerId)) event.currentTarget.releasePointerCapture(start.pointerId);+ }}>+ <path className="extend-excluded" d={`M0,0h${width}v${height}h${-width}Z` + hole} fillRule="evenodd" pointerEvents="none" />+ <path className="extend-generated" d={outline + hole} fillRule="evenodd" pointerEvents="none" />+ <rect className="extend-original" x="0" y="0" width={width} height={height} vectorEffect="non-scaling-stroke" pointerEvents="none" />+ <rect className="extend-box" {...box} data-handle="move" vectorEffect="non-scaling-stroke" role="button" tabIndex={disabled ? -1 : 0} aria-label="Move Extend box"+ onKeyDown={(event) => {+ if (disabled || !["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"].includes(event.key)) return;+ event.preventDefault(); const step = event.shiftKey ? 10 : 1;+ onChange({ ...box, x: box.x + (event.key === "ArrowLeft" ? -step : event.key === "ArrowRight" ? step : 0), y: box.y + (event.key === "ArrowUp" ? -step : event.key === "ArrowDown" ? step : 0) });+ }} />+ {handles.map((handle) => <rect key={handle} className="extend-handle" data-handle={handle} style={{ cursor: `${handle}-resize` }}+ x={(handle.includes("w") ? box.x : handle.includes("e") ? box.x + box.width : box.x + box.width / 2) - handleSize / 2}+ y={(handle.includes("n") ? box.y : handle.includes("s") ? box.y + box.height : box.y + box.height / 2) - handleSize / 2}+ width={handleSize} height={handleSize} vectorEffect="non-scaling-stroke" />)}+ </svg>+ </div>+ </div>;+}diff --git a/src/components/workspace/ExtendSettings.tsx b/src/components/workspace/ExtendSettings.tsxnew file mode 100644index 0000000..307b4fb--- /dev/null+++ b/src/components/workspace/ExtendSettings.tsx@@ -0,0 +1,43 @@+import { useMemo } from "react";+import { compileExtendImage, initialExtendBounds, type ExtendOptions } from "../../lib/extendImage";+import type { ProjectAsset, ProjectConfig } from "../../lib/project";+import { InfoBar, ItemHeader, PropRow } from "../ui";+import { Dismiss16, Sparkle16 } from "../ui/icons";+import { PromptTextField, type PromptReference } from "./PromptTextField";++export function ExtendSettings({ config, source, options, onChange, references, missingLabel, busy, disabledReason, onExecute, onClose }: {+ config: ProjectConfig; source: ProjectAsset; options: ExtendOptions; onChange: (options: ExtendOptions) => void;+ references: PromptReference[]; missingLabel: (id: string) => string; busy: boolean; disabledReason: string | null;+ onExecute: () => void; onClose: () => void;+}) {+ const error = useMemo(() => {+ try { compileExtendImage(config, source, "cache/extend-preview.png", options); return null; }+ catch (reason) { return reason instanceof Error ? reason.message : String(reason); }+ }, [config, source, options]);+ return <aside className="image-inspector image-template-settings" aria-label="Extend settings">+ <ItemHeader name="Extend" meta="Template" actions={<button type="button" className="icon-button" aria-label="Close template settings" data-tooltip="Back to image settings" onClick={onClose}><Dismiss16 aria-hidden="true" /></button>} />+ <form className="image-template-settings__form" onSubmit={(event) => { event.preventDefault(); if (!busy && !disabledReason && !error) onExecute(); }}>+ <div className="image-inspector__fields image-template-settings__fields">+ <p className="image-inspector__caption">Drag the box or its handles to set the final image bounds. Drag outside the box to draw a new one. Shaded areas will be generated; original pixels inside the box stay unchanged.</p>+ <p className="image-inspector__caption">Source: {source.name} · {source.width} × {source.height} px</p>+ {(["x", "y", "width", "height"] as const).map((field) => <PropRow key={field} label={field === "x" ? "X" : field === "y" ? "Y" : field === "width" ? "Width" : "Height"} htmlFor={`extend-${field}`}>+ <input id={`extend-${field}`} aria-label={`Extend ${field}`} className="text-field" type="number" step="1" min={field === "x" || field === "y" ? -8192 : 1} max="8192" required disabled={busy}+ value={Number.isNaN(options.bounds[field]) ? "" : options.bounds[field]} onChange={(event) => onChange({ ...options, bounds: { ...options.bounds, [field]: event.target.valueAsNumber } })} />+ </PropRow>)}+ <button type="button" className="secondary-button" disabled={busy} onClick={() => onChange({ ...options, bounds: initialExtendBounds(source.width!, source.height!) })}>Reset box</button>+ <PropRow label="Steps" htmlFor="extend-steps"><input id="extend-steps" className="text-field" type="number" min="2" max="1000" step="1" required disabled={busy}+ value={Number.isNaN(options.steps) ? "" : options.steps} onChange={(event) => onChange({ ...options, steps: event.target.valueAsNumber })} /></PropRow>+ <PropRow label="Seed" htmlFor="extend-seed"><input id="extend-seed" className="text-field" type="number" min="-1" max={Number.MAX_SAFE_INTEGER} step="1" required disabled={busy}+ value={Number.isNaN(options.seed) ? "" : options.seed} onChange={(event) => onChange({ ...options, seed: event.target.valueAsNumber })} /></PropRow>+ <p className="image-inspector__caption">Use -1 for a random seed.</p>+ <div className="image-inspector__area"><span>Prompt</span><PromptTextField aria-label="Extend prompt" value={options.prompt} onChange={(prompt) => onChange({ ...options, prompt })}+ references={references} missingLabel={missingLabel} disabled={busy} placeholder="Describe what should appear beyond the image…" /></div>+ {error && <InfoBar severity="error" title="Adjust the Extend settings" message={error} />}+ </div>+ <div className="image-template-settings__footer">+ {disabledReason && <p className="image-inspector__caption">{disabledReason}</p>}+ <button type="submit" className="primary-button" disabled={busy || Boolean(disabledReason || error)}><Sparkle16 aria-hidden="true" />{busy ? "Executing…" : "Execute"}</button>+ </div>+ </form>+ </aside>;+}diff --git a/src/components/workspace/ImageEditor.tsx b/src/components/workspace/ImageEditor.tsxindex 16869b7..ef54193 100644--- a/src/components/workspace/ImageEditor.tsx+++ b/src/components/workspace/ImageEditor.tsx@@ -16,6 +16,9 @@ import { PromptTextField } from "./PromptTextField";import { ReferenceIcon } from "./ReferenceIcon";import { ImageBar } from "./ImageBar";import { CharacterSheetSettings } from "./CharacterSheetSettings";+import { ExtendSettings } from "./ExtendSettings";+import { ExtendCanvas } from "./ExtendCanvas";+import { initialExtendBounds, type ExtendOptions } from "../../lib/extendImage";import type { CharacterSheetOptions } from "../../lib/characterSheet";import { referenceMediaTypes } from "../../lib/referenceSelection";import { DebugPromptDialog } from "./DebugPromptDialog";@@ -41,10 +44,11 @@ function UsedImageSeed({ id, seed, onError }: { id: string; seed: number | undef</PropRow>;}-export function ImageEditor({ config, folderPath, onChange: changeConfig, onGenerate, onGenerateCharacterSheet, onCancel, onOpenGenerator, onOpenReferences, workItems = [] }: {+export function ImageEditor({ config, folderPath, onChange: changeConfig, onGenerate, onGenerateCharacterSheet, onGenerateExtend, onCancel, onOpenGenerator, onOpenReferences, workItems = [] }: {config: ProjectConfig; folderPath: string; onChange: (update: ConfigUpdate) => void;onGenerate: (template: GeneratorTemplate) => void; onCancel: (id: string) => Promise<void>; workItems?: readonly WorkItem[];onGenerateCharacterSheet?: (template: GeneratorTemplate, sourceId: string, options: CharacterSheetOptions) => void;+ onGenerateExtend?: (template: GeneratorTemplate, sourceId: string, options: ExtendOptions) => void;onOpenGenerator?: (jobId: string) => void;onOpenReferences?: () => void;}) {@@ -68,7 +72,10 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGeneconst [imageMenu, setImageMenu] = useState<{ id: string | null; x: number; y: number; inFamily: boolean; source: "bar" | "canvas" } | null>(null);const templateMenu = useContextMenu();const [templateSourceId, setTemplateSourceId] = useState<string | null>(null);- useEffect(() => setTemplateSourceId(null), [scene.outputAssetId]);+ const [extendSourceId, setExtendSourceId] = useState<string | null>(null);+ const [extendOptions, setExtendOptions] = useState<ExtendOptions | null>(null);+ const extendMode = extendSourceId !== null && extendSourceId === scene.outputAssetId;+ useEffect(() => { setTemplateSourceId(null); setExtendSourceId(null); }, [scene.outputAssetId]);const imageResults = useRef<HTMLDivElement>(null);const [renaming, setRenaming] = useState<{ id: string; value: string } | null>(null);const renameEnding = useRef(false);@@ -134,7 +141,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene};window.addEventListener("blur", stopPan);return () => { element.removeEventListener("wheel", wheel); window.removeEventListener("blur", stopPan); };- }, []);+ }, [extendMode]);const endPan = (event: PointerEvent<HTMLDivElement>) => {if (pan.current?.pointerId !== event.pointerId) return;event.stopPropagation();@@ -391,7 +398,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene};useShortcut(["Ctrl+Z"], () => { if (!undo.current.length) return false; history(true); }, { scope: editorRoot });useShortcut(["Ctrl+Y", "Ctrl+Shift+Z"], () => { if (!redo.current.length) return false; history(false); }, { scope: editorRoot });- useShortcut("Delete", removeSelected, { scope: viewport });+ useShortcut("Delete", removeSelected, { scope: viewport, enabled: !extendMode });/* Canvas tools: a radio group of icon toggles with one-letter keys. */const TOOLS = [@@ -402,7 +409,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene{ id: "group", label: "Draw group", key: "G", icon: <Group16 />, onIcon: <Group16Filled /> },] as const),] as const;- const chooseTool = (id: typeof drawKind) => { setDrawKind(id); if (id) setBoxes(true); };+ const chooseTool = (id: typeof drawKind) => { if (extendMode) return; setDrawKind(id); if (id) setBoxes(true); };useShortcut("V", () => chooseTool(null), { scope: editorRoot });useShortcut("E", () => chooseTool("object"), { scope: editorRoot, enabled: imageRoot });useShortcut("O", () => chooseTool("object"), { scope: editorRoot, enabled: !imageRoot });@@ -501,7 +508,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene{/* Generate and the generator lead; canvas tools and view controlsshare the centered group. */}<div className="image-tools__start">- <button className="primary-button image-generate-button" data-tooltip={editPlan?.error ?? undefined} disabled={active ? work.cancelling || work.status === "encoding" : !isTauri() || !template || !templateUsable(template) || (imageRoot ? Boolean(editPlan?.error) : !imageScenePrompt(scene))} onClick={() => attempt(() => active ? onCancel(work.id) : onGenerate(template!))}>{active ? <Stop14 aria-hidden="true" /> : <Sparkle16 aria-hidden="true" />}{active ? work.cancelling ? "Cancelling…" : "Cancel" : "Generate"}</button>+ {(!extendMode || active) && <button className="primary-button image-generate-button" data-tooltip={editPlan?.error ?? undefined} disabled={active ? work.cancelling || work.status === "encoding" : !isTauri() || !template || !templateUsable(template) || (imageRoot ? Boolean(editPlan?.error) : !imageScenePrompt(scene))} onClick={() => attempt(() => active ? onCancel(work.id) : onGenerate(template!))}>{active ? <Stop14 aria-hidden="true" /> : <Sparkle16 aria-hidden="true" />}{active ? work.cancelling ? "Cancelling…" : "Cancel" : "Generate"}</button>}<ComboBoxclassName="image-generator"aria-label="Generator"@@ -514,6 +521,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene/></div><div className="image-tools__center">+ {extendMode ? <span className="extend-tool-active"><Boxes16Filled aria-hidden="true" /> Extend box</span> : <><div className="image-tools__group" role="radiogroup" aria-label="Canvas tool" onKeyDown={(event) => {if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;event.preventDefault();@@ -548,12 +556,18 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGeneoptions={zoomOptions}onChange={(value) => { if (value === "fit") fit(); else zoomTo(Number(value)); }}/>+ </>}</div><div className="image-tools__end"><button type="button" className="secondary-button" aria-haspopup="menu" aria-expanded={templateMenu.isOpen}disabled={!output || (!output.relativePath && !output.sourcePath)}onClick={(event) => templateMenu.open(event.currentTarget, [{ label: "Character sheet", icon: <Image16 />,- onSelect: () => setTemplateSourceId(output!.id),+ onSelect: () => { setExtendSourceId(null); setTemplateSourceId(output!.id); },+ }, { label: "Extend", icon: <Boxes16 />, disabled: !output?.width || !output?.height || Boolean(output?.imageDraft),+ onSelect: () => {+ setTemplateSourceId(null); setExtendSourceId(output!.id); setDrawKind(null); setContextMenu(null); setImageMenu(null);+ setExtendOptions({ bounds: initialExtendBounds(output!.width!, output!.height!), prompt: "", steps: scene.steps, seed: scene.seed });+ },}], { "aria-label": "Image templates", placement: "bottom-end" })}>Template <ChevronDown14 aria-hidden="true" /></button>@@ -603,6 +617,8 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene] : []),]} />}<section className="image-center" aria-label="Image panel">+ {extendMode && output && extendOptions ? <ExtendCanvas source={output} folderPath={folderPath} bounds={extendOptions.bounds}+ onChange={(bounds) => setExtendOptions((current) => current ? { ...current, bounds } : current)} disabled={Boolean(active)} /> :<div ref={viewport} tabIndex={0} className={`image-viewport${panning ? " panning" : ""}`}onContextMenu={(event) => { event.preventDefault(); openCanvasMenu(event.clientX, event.clientY); }}onKeyDown={(event) => {@@ -638,14 +654,18 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene{draftBox && !pointer.current?.id && <rect className="image-box-draft" {...{ x: draftBox.x, y: draftBox.y, width: draftBox.width, height: draftBox.height }} />}</svg>{boxes && scene.nodes.filter((node) => node.box).map((node) => { const box = pointer.current?.id === node.id && draftBox ? draftBox : node.box!; return <span key={node.id} className="image-box-label" style={{ left: `${box.x / 10}%`, top: `${box.y / 10}%` }}>{node.name}</span>; })}- </div></div>+ </div></div>}{(error || work?.error) && <InfoBar className="image-error" severity="error" title="Couldn’t update the image" message={error ?? work?.error ?? ""} onClose={error ? () => setError(null) : undefined} />}- <div className="image-status" role="status">{active && <ProgressBar value={work.progress * 100} aria-label="Image generation progress" />}<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}${isMiniMaxH3 ? "" : " · Placement boxes guide the prompt"}`}</span></div>+ <div className="image-status" role="status">{active && <ProgressBar value={work.progress * 100} aria-label="Image generation progress" />}<span>{active ? work.detail : extendMode && extendOptions ? `Extend: ${extendOptions.bounds.width || "-"} \u00d7 ${extendOptions.bounds.height || "-"} px` : imageRoot ? editPlan?.error ?? `${width} × ${height} · ${editPlan?.edits.length} edits in hierarchy order` : !isTauri() ? "Image generation is available in the desktop app." : `${width} × ${height}${isMiniMaxH3 ? "" : " · Placement boxes guide the prompt"}`}</span></div><ImageBar ref={imageResults} images={images} selectedId={scene.outputAssetId} folderPath={folderPath} onSelect={selectImage}onMenu={(id, x, y, inFamily) => { setContextMenu(null); setImageMenu({ id, x, y, inFamily, source: "bar" }); }} /></section><Splitter {...inspectorPane.splitterProps} reverse aria-label="Resize inspector" />- {output && templateSourceId === output.id ? <CharacterSheetSettings+ {extendMode && output && extendOptions ? <ExtendSettings config={config} source={output} options={extendOptions} onChange={setExtendOptions}+ references={promptReferences} missingLabel={missingReference} busy={Boolean(active)}+ disabledReason={!isTauri() ? "Template execution is available in the desktop app." : !onGenerateExtend || !template || !templateUsable(template) ? "Choose a downloaded generator to execute this template." : null}+ onExecute={() => attempt(() => onGenerateExtend?.(template!, output.id, extendOptions))} onClose={() => setExtendSourceId(null)}+ /> : output && templateSourceId === output.id ? <CharacterSheetSettingsconfig={config} source={output} references={promptReferences} missingLabel={missingReference} defaultSteps={template?.defaultSteps ?? 20} busy={Boolean(active)}disabledReason={!isTauri() ? "Template execution is available in the desktop app." : !onGenerateCharacterSheet || !template || !templateUsable(template) ? "Choose a downloaded generator to execute this template." : null}onExecute={(options) => onGenerateCharacterSheet?.(template!, output.id, options)} onClose={() => setTemplateSourceId(null)}diff --git a/src/styles/image-editor.css b/src/styles/image-editor.cssindex e015679..81e1b28 100644--- a/src/styles/image-editor.css+++ b/src/styles/image-editor.css@@ -69,6 +69,17 @@.image-box-label { position: absolute; margin: var(--space-1); padding: 0 var(--space-1); border-radius: var(--radius-sm); color: var(--text-primary); background: var(--panel); font-size: var(--text-xs); pointer-events: none; }.image-overlay .image-box-handle { fill: var(--accent); cursor: nwse-resize; }.image-overlay.drawing, .image-overlay.drawing rect { cursor: crosshair; }+.extend-frame { background: transparent; box-shadow: none; }+.extend-source { position: absolute; }+.extend-source img { width: 100%; height: 100%; object-fit: fill; }+.extend-overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }+.extend-generated { fill: color-mix(in srgb, var(--accent) 25%, transparent); }+.extend-excluded { fill: color-mix(in srgb, var(--layer-alt) 70%, transparent); }+.extend-original { fill: none; stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 4 4; }+.extend-box { fill: transparent; stroke: var(--accent); stroke-width: 2; cursor: move; }+.extend-handle { fill: var(--accent); stroke: var(--panel); stroke-width: 1; }+.extend-overlay[aria-disabled="true"] { pointer-events: none; opacity: 0.7; }+.extend-tool-active { display: flex; align-items: center; gap: var(--space-2); color: var(--accent-on-soft); padding: var(--space-1) var(--space-2); background: var(--accent-soft); border-radius: var(--radius-sm); }.image-status { display: flex; flex-direction: column; justify-content: center; gap: var(--space-1); min-height: var(--control-sm); padding: 0 var(--space-3); color: var(--text-secondary); font-size: var(--text-xs); border-top: 1px solid var(--line); }.image-center > .image-error { margin: var(--space-2); }.image-results { display: flex; min-height: 82px; gap: var(--space-2); overflow-x: auto; padding: var(--space-2); border-top: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: transparent transparent; }