AI media harness for planning, generating, and editing locally
TypeScript
Rebuild image editor panes, tree keys, tool strip and token box
Bittic89d95feb87b
diff --git a/src/components/workspace/ImageEditor.test.tsx b/src/components/workspace/ImageEditor.test.tsxindex 75d3096..811094c 100644--- a/src/components/workspace/ImageEditor.test.tsx+++ b/src/components/workspace/ImageEditor.test.tsx@@ -4,6 +4,7 @@ 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 { choose, comboValue } from "./comboTestUtils";import { imageGenerationSnapshotSchema, parseProjectConfig, type ProjectConfig } from "../../lib/project";import { imageGenerationSnapshot } from "../../lib/imageHistory";import { defaultGeneratorTemplate, saveGeneratorTemplateSettings } from "../../lib/settings";@@ -45,9 +46,9 @@ it("starts an image root from the thumbnail Edit menu and hides root text controexpect(current().assets.filter((asset) => asset.imageDraft)).toHaveLength(1);expect(parseProjectConfig(JSON.parse(JSON.stringify(current()))).assets).toEqual(current().assets);expect(screen.getByLabelText("Image placement canvas").parentElement!.style.getPropertyValue("--image-ratio")).toBe(String(101 / 77));- fireEvent.change(screen.getByLabelText("Type"), { target: { value: "prompt" } });+ choose("Type", "Prompt");expect(screen.getByLabelText("Prompt (high-level description)")).toBeInTheDocument();- fireEvent.change(screen.getByLabelText("Type"), { target: { value: "image" } });+ choose("Type", "Image");expect(current().imageScene!.sourceImage).toBeNull();});@@ -64,7 +65,7 @@ it("restores the hierarchy, prompts, settings and generator when selecting a savfireEvent.click(screen.getByRole("button", { name: "View Result 1" }));expect(screen.getByLabelText("Prompt (high-level description)")).toHaveValue(saved.scene.nodes[0].description);expect(screen.getByLabelText("Steps")).toHaveValue(30);- expect(screen.getByLabelText("Generator")).toHaveValue(saved.generatorTemplateId);+ expect(comboValue(screen.getByRole("combobox", { name: "Generator" }))).toBe(saved.generatorTemplateId);expect(screen.getByRole("button", { name: "Lantern" })).toBeInTheDocument();expect(screen.getByRole("button", { name: "Lettering" })).toBeInTheDocument();expect(current().references).toEqual(saved.references);@@ -73,7 +74,7 @@ it("restores the hierarchy, prompts, settings and generator when selecting a savfireEvent.change(screen.getByLabelText("Prompt (high-level description)"), { target: { value: "Another edit" } });fireEvent.click(screen.getByRole("button", { name: "View Result 0" }));expect(current().imageScene).toEqual({ ...original.scene, outputAssetId: "result-0" });- expect(screen.getByLabelText("Generator")).toHaveValue(original.generatorTemplateId);+ expect(comboValue(screen.getByRole("combobox", { name: "Generator" }))).toBe(original.generatorTemplateId);fireEvent.click(screen.getByRole("button", { name: "View Result 1" }));expect(current().imageScene).toEqual({ ...saved.scene, outputAssetId: "result-1" });expect(current().assets[1].imageGeneration).toEqual(saved);@@ -89,8 +90,8 @@ it("displays each generated image at its saved aspect ratio independently of futconst current = setup(initial);const frame = screen.getByLabelText("Image placement canvas").parentElement!;expect(frame.style.getPropertyValue("--image-ratio")).toBe(String(1376 / 768));- fireEvent.change(screen.getByLabelText("Resolution"), { target: { value: "1344p" } });- fireEvent.change(screen.getByLabelText("Aspect ratio"), { target: { value: "1:1" } });+ choose("Resolution", /^\d+ × 1344$|^1344 × \d+$|1344/);+ choose("Aspect ratio", "1:1");expect(current().settings).toMatchObject({ resolution: "1344p", aspectRatio: "1:1" });expect(frame.style.getPropertyValue("--image-ratio")).toBe(String(1376 / 768));fireEvent.click(screen.getByRole("button", { name: "View Tall" }));@@ -141,7 +142,7 @@ it("creates a blank draft from the image bar and preserves it while browsing", (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(comboValue(screen.getByRole("combobox", { name: "Type" }))).toBe("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");@@ -165,39 +166,44 @@ it("creates an image from the empty bar's keyboard context menu", () => {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", () => {+it("edits ordered style tokens with suggestions, custom tags, removal, undo, and mode-specific choices", () => {const current = setup();expect(screen.getByRole("button", { name: "Aesthetics tag: Minimal poster" })).toBeInTheDocument();- fireEvent.click(screen.getByRole("button", { name: "Add Aesthetics tag" }));- const popup = within(screen.getByRole("dialog", { name: "Add Aesthetics tag" }));- expect(popup.getByRole("button", { name: "whimsical" })).toBeInTheDocument();- fireEvent.click(popup.getByRole("button", { name: "vibrant" }));- expect(popup.queryByRole("button", { name: "vibrant" })).not.toBeInTheDocument();- const custom = popup.getByRole("textbox", { name: "Custom Aesthetics tags" });- fireEvent.change(custom, { target: { value: " VIBRANT, intricate, custom finish, , " } });- fireEvent.keyDown(custom, { key: "Enter" });+ const aesthetics = screen.getByRole("combobox", { name: "Add Aesthetics tag" });+ fireEvent.focus(aesthetics);+ const list = () => within(screen.getByRole("listbox", { name: "Aesthetics suggestions" }));+ expect(list().getByRole("option", { name: "whimsical" })).toBeInTheDocument();+ fireEvent.change(aesthetics, { target: { value: "vibr" } });+ fireEvent.click(list().getByRole("option", { name: "vibrant" }));+ fireEvent.change(aesthetics, { target: { value: "vibr" } });+ expect(screen.queryByRole("option", { name: "vibrant" })).not.toBeInTheDocument();+ fireEvent.change(aesthetics, { target: { value: " intricate" } });+ fireEvent.keyDown(aesthetics, { key: "Enter" });+ fireEvent.change(aesthetics, { target: { value: "custom finish, " } });expect(current().imageScene!.style.aesthetics).toBe("Minimal poster, vibrant, intricate, custom finish");- expect(custom).toHaveValue("");- fireEvent.keyDown(window, { key: "Escape" });- expect(screen.getByRole("button", { name: "Add Aesthetics tag" })).toHaveFocus();+ expect(aesthetics).toHaveValue("");+ fireEvent.keyDown(aesthetics, { key: "Escape" });+ expect(screen.queryByRole("listbox")).not.toBeInTheDocument();fireEvent.click(screen.getByRole("button", { name: "Remove vibrant from Aesthetics" }));fireEvent.keyDown(screen.getByRole("button", { name: "Aesthetics tag: intricate" }), { key: "ArrowLeft", altKey: true });expect(current().imageScene!.style.aesthetics).toBe("intricate, Minimal poster, custom finish");fireEvent.click(screen.getByRole("button", { name: "Undo image edit" }));expect(current().imageScene!.style.aesthetics).toBe("Minimal poster, intricate, custom finish");- fireEvent.change(screen.getByLabelText("Mode"), { target: { value: "photo" } });- fireEvent.click(screen.getByRole("button", { name: "Add Lighting tag" }));- fireEvent.click(screen.getByRole("button", { name: "golden hour" }));- fireEvent.keyDown(window, { key: "Escape" });- fireEvent.click(screen.getByRole("button", { name: "Add Camera / lens tag" }));- fireEvent.click(screen.getByRole("button", { name: "35mm" }));+ choose("Mode", "Photo");+ const lighting = screen.getByRole("combobox", { name: "Add Lighting tag" });+ fireEvent.change(lighting, { target: { value: "golden" } });+ fireEvent.keyDown(lighting, { key: "ArrowDown" });+ fireEvent.keyDown(lighting, { key: "Enter" });+ const camera = screen.getByRole("combobox", { name: "Add Camera / lens tag" });+ fireEvent.change(camera, { target: { value: "35mm" } });+ fireEvent.click(screen.getByRole("option", { name: "35mm" }));expect(imageScenePrompt(current().imageScene!)).toContain("A still photograph with Minimal poster, intricate, custom finish aesthetics, Sunrise, golden hour lighting, Screen print, 35mm camera and lens characteristics.");- fireEvent.keyDown(window, { key: "Escape" });- fireEvent.click(screen.getByRole("button", { name: "Add Aesthetics tag" }));- expect(screen.getByRole("button", { name: "photorealistic" })).toBeInTheDocument();- expect(screen.queryByRole("button", { name: "whimsical" })).not.toBeInTheDocument();- fireEvent.pointerDown(screen.getByLabelText("Mode"));- expect(screen.queryByRole("dialog")).not.toBeInTheDocument();+ fireEvent.blur(camera);+ fireEvent.focus(aesthetics);+ expect(screen.getByRole("option", { name: "photorealistic" })).toBeInTheDocument();+ expect(screen.queryByRole("option", { name: "whimsical" })).not.toBeInTheDocument();+ fireEvent.keyDown(aesthetics, { key: "Backspace" });+ expect(current().imageScene!.style.aesthetics).toBe("Minimal poster, intricate");expect(parseProjectConfig(JSON.parse(JSON.stringify(current()))).imageScene).toEqual(current().imageScene);});@@ -311,3 +317,67 @@ it("supports menu keyboard navigation and tree shortcuts without intercepting nafireEvent.click(screen.getByRole("menuitem", { name: "New Group" }));expect(current().imageScene!.nodes.at(-1)).toMatchObject({ kind: "group", parentId: "image-root" });});++it("walks the tree with arrow keys as a single tab stop and duplicates with Ctrl+D", () => {+ const current = setup();+ const image = screen.getByRole("button", { name: "Image" });+ expect(image).toHaveAttribute("tabindex", "0");+ expect(screen.getByRole("button", { name: "Rocket" })).toHaveAttribute("tabindex", "-1");+ fireEvent.keyDown(image, { key: "ArrowDown" });+ expect(screen.getByRole("button", { name: "Rocket" })).toHaveAttribute("tabindex", "0");+ fireEvent.keyDown(screen.getByRole("button", { name: "Rocket" }), { key: "ArrowLeft" });+ expect(screen.queryByRole("button", { name: "Title" })).not.toBeInTheDocument();+ fireEvent.keyDown(screen.getByRole("button", { name: "Rocket" }), { key: "ArrowRight" });+ fireEvent.keyDown(screen.getByRole("button", { name: "Rocket" }), { key: "ArrowRight" });+ expect(screen.getByRole("button", { name: "Title" })).toHaveAttribute("tabindex", "0");+ fireEvent.keyDown(screen.getByRole("button", { name: "Title" }), { key: "d", ctrlKey: true });+ expect(current().imageScene!.nodes.map((node) => node.name)).toContain("Title copy");+ expect(screen.getByRole("button", { name: "Title copy" })).toHaveAttribute("tabindex", "0");+ fireEvent.keyDown(screen.getByRole("button", { name: "Title copy" }), { key: "Home" });+ expect(screen.getByRole("button", { name: "Image" })).toHaveAttribute("tabindex", "0");+});++it("undoes and redoes image edits with the keyboard inside the editor only", () => {+ const current = setup();+ const before = current().imageScene!.nodes.length;+ const rocket = screen.getByRole("button", { name: "Rocket" });+ fireEvent.click(rocket);+ fireEvent.keyDown(rocket, { key: "d", ctrlKey: true });+ expect(current().imageScene!.nodes).toHaveLength(before + 2);+ const tree = screen.getByRole("tree", { name: "Image nodes" });+ fireEvent.keyDown(tree, { key: "z", ctrlKey: true });+ expect(current().imageScene!.nodes).toHaveLength(before);+ fireEvent.keyDown(tree, { key: "y", ctrlKey: true });+ expect(current().imageScene!.nodes).toHaveLength(before + 2);+ // Outside the editor Ctrl+Z is the project's, not this editor's.+ fireEvent.keyDown(document.body, { key: "z", ctrlKey: true });+ expect(current().imageScene!.nodes).toHaveLength(before + 2);+});++it("picks canvas tools from a radio group or their letter keys and zooms from the keyboard", () => {+ setup();+ const tools = screen.getByRole("radiogroup", { name: "Canvas tool" });+ expect(within(tools).getByRole("radio", { name: "Select" })).toHaveAttribute("aria-checked", "true");+ fireEvent.click(within(tools).getByRole("radio", { name: "Draw text" }));+ expect(within(tools).getByRole("radio", { name: "Draw text" })).toHaveAttribute("aria-checked", "true");+ const canvas = screen.getByLabelText("Image placement canvas");+ fireEvent.keyDown(canvas, { key: "g" });+ expect(within(tools).getByRole("radio", { name: "Draw group" })).toHaveAttribute("aria-checked", "true");+ fireEvent.keyDown(canvas, { key: "v" });+ expect(within(tools).getByRole("radio", { name: "Select" })).toHaveAttribute("aria-checked", "true");+ expect(within(tools).getByRole("radio", { name: "Draw object" })).toHaveAttribute("data-tooltip-shortcut", "O");++ const zoom = screen.getByRole("combobox", { name: "Image zoom" });+ const frame = canvas.parentElement!;+ expect(zoom).toHaveTextContent("Fit");+ fireEvent.keyDown(canvas, { key: "=", ctrlKey: true });+ expect(frame.style.getPropertyValue("--image-zoom")).toBe("1.5");+ expect(zoom).toHaveTextContent("150%");+ fireEvent.keyDown(canvas, { key: "-", ctrlKey: true });+ fireEvent.keyDown(canvas, { key: "-", ctrlKey: true });+ expect(frame.style.getPropertyValue("--image-zoom")).toBe("0.75");+ choose("Image zoom", "200%");+ expect(frame.style.getPropertyValue("--image-zoom")).toBe("2");+ fireEvent.keyDown(canvas, { key: "0", ctrlKey: true });+ expect(zoom).toHaveTextContent("Fit");+});diff --git a/src/components/workspace/ImageEditor.tsx b/src/components/workspace/ImageEditor.tsxindex 5abbb50..8cd5fcb 100644--- a/src/components/workspace/ImageEditor.tsx+++ b/src/components/workspace/ImageEditor.tsx@@ -1,5 +1,5 @@-import { useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, type CSSProperties, type DragEvent, type PointerEvent } from "react";-import { Box, ChevronDown, ChevronRight, ClipboardPaste, Copy, FolderOpen, FolderPlus, Image, Pencil, Plus, Redo2, Sparkles, Square, Trash2, Type, Undo2 } from "lucide-react";+import { useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore, type CSSProperties, type DragEvent, type KeyboardEvent as ReactKeyboardEvent, type PointerEvent } from "react";+import { Box, ChevronDown, ChevronRight, ClipboardPaste, Copy, FolderOpen, FolderPlus, Group, Image, MousePointer2, Pencil, Plus, Redo2, Sparkles, Square, Trash2, Type, Undo2 } from "lucide-react";import { invoke } from "@tauri-apps/api/core";import { addImageNode, createImageEditScene, createImageScene, duplicateImageNode, imageDescendants, imageScenePrompt, removeImageNode, resizeImageNode, type ImageBox, type ImageNode, type ImageScene, type ImageSource } from "../../lib/imageScene";import { compileImageEdits, editGeneratedImage, imageEditDebugPrompt } from "../../lib/imageEditing";@@ -18,6 +18,8 @@ import styleSuggestions from "../../lib/imageStyleSuggestions.json";import { applyImageCommand } from "../../lib/imageCommands";import { copyImageNode, getImageNodeClipboard, pasteImageNode, subscribeImageNodeClipboard } from "../../lib/imageNodeClipboard";import { HierarchyContextMenu } from "./HierarchyContextMenu";+import { useShortcut } from "../../lib/commands";+import { ComboBox, InfoBar, PaneHeader, ProgressBar, PropRow, PropSection, Splitter, tooltipProps, usePaneSize } from "../ui";import "../../styles/image-editor.css";const MIN_IMAGE_ZOOM = 0.1;@@ -46,6 +48,10 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGeneconst [renaming, setRenaming] = useState<{ id: string; value: string } | null>(null);const renameEnding = useRef(false);const hierarchy = useRef<HTMLElement>(null);+ const editorRoot = useRef<HTMLDivElement>(null);+ const editorId = useId();+ const treePane = usePaneSize("image.tree", 240, { min: 180, max: 420 });+ const inspectorPane = usePaneSize("image.inspector", 300, { min: 240, max: 520 });const clipboard = useSyncExternalStore(subscribeImageNodeClipboard, getImageNodeClipboard);const [templates, setTemplates] = useState(loadGeneratorTemplateSettings);const [templateId, setTemplateId] = useState(() => localStorage.getItem("slopus.image-generator-template.v1") ?? defaultGeneratorTemplate().id);@@ -285,11 +291,105 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGeneconst before = placement === "before" ? target.id : placement === "after" ? siblings[siblings.findIndex((node) => node.id === target.id) + 1]?.id : undefined;return { id: target.id, placement, parent, before } as const;};+ /* --- Keyboard ---------------------------------------------------------------+ The tree is one Tab stop (roving tabindex): Up/Down walk the visible rows,+ Right opens a node or steps into it, Left closes it or steps out,+ Home/End jump. F2, Delete, Ctrl+C/V/D and Shift+F10 act on the selection.+ Undo and redo are this editor's own history, bound to its root so they+ never reach the project's undo while focus is in here. */+ const visibleNodes = (): ImageNode[] => {+ const out: ImageNode[] = [];+ const walk = (node: ImageNode) => {+ out.push(node);+ if (collapsed.has(node.id)) return;+ scene.nodes.filter((child) => child.parentId === node.id).forEach(walk);+ };+ walk(root);+ return out;+ };+ const selectAndFocus = (id: string) => { setSelection(id); requestAnimationFrame(() => focusNode(id)); };+ const treeKeys = (event: ReactKeyboardEvent<HTMLElement>) => {+ if ((event.target as HTMLElement).closest("input, textarea, select, [contenteditable=true]") || contextMenu) return;+ const key = event.key.toLowerCase();+ const handled = () => { event.preventDefault(); event.stopPropagation(); };+ if ((event.ctrlKey || event.metaKey) && (key === "c" || key === "v")) {+ handled();+ attempt(() => key === "c" ? copyImageNode(scene, selected.id) : paste());+ } else if ((event.ctrlKey || event.metaKey) && key === "d") { handled(); attempt(duplicate); }+ else if (key === "delete") { handled(); removeSelected(); }+ else if (key === "f2") { handled(); startRename(); }+ else if (event.key === "ContextMenu" || (event.shiftKey && event.key === "F10")) {+ handled();+ const bounds = (event.target as HTMLElement).getBoundingClientRect();+ setContextMenu({ x: bounds.left, y: bounds.bottom });+ } else if (["ArrowUp", "ArrowDown", "Home", "End", "ArrowLeft", "ArrowRight"].includes(event.key) && !event.altKey && !event.ctrlKey) {+ const rows = visibleNodes();+ const at = rows.findIndex((node) => node.id === selected.id);+ const children = scene.nodes.filter((child) => child.parentId === selected.id);+ const open = children.length > 0 && !collapsed.has(selected.id);+ let next: ImageNode | undefined;+ if (event.key === "ArrowUp") next = rows[at - 1];+ else if (event.key === "ArrowDown") next = rows[at + 1];+ else if (event.key === "Home") next = rows[0];+ else if (event.key === "End") next = rows.at(-1);+ else if (event.key === "ArrowRight") {+ if (children.length && !open) { handled(); setCollapsed((current) => { const set = new Set(current); set.delete(selected.id); return set; }); return; }+ next = open ? children[0] : undefined;+ } else if (event.key === "ArrowLeft") {+ if (open) { handled(); setCollapsed((current) => new Set(current).add(selected.id)); return; }+ next = scene.nodes.find((node) => node.id === selected.parentId);+ }+ handled();+ if (next) selectAndFocus(next.id);+ }+ };+ 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 });++ /* Canvas tools: a radio group of icon toggles with one-letter keys. */+ const TOOLS = [+ { id: null, label: "Select", key: "V", icon: <MousePointer2 size={16} /> },+ { id: "object", label: "Draw object", key: "O", icon: <Box size={16} /> },+ { id: "text", label: "Draw text", key: "T", icon: <Type size={16} /> },+ { id: "group", label: "Draw group", key: "G", icon: <Group size={16} /> },+ ] as const;+ const chooseTool = (id: typeof drawKind) => { setDrawKind(id); if (id) setBoxes(true); };+ useShortcut("V", () => chooseTool(null), { scope: editorRoot });+ useShortcut("O", () => chooseTool("object"), { scope: editorRoot });+ useShortcut("T", () => chooseTool("text"), { scope: editorRoot });+ useShortcut("G", () => chooseTool("group"), { scope: editorRoot });+ useShortcut("Escape", () => { if (!drawKind) return false; chooseTool(null); }, { scope: editorRoot });++ /* Zoom: Fit is the frame fitted to the viewport (100% of the fit); the+ percentages scale from there. */+ const ZOOM_STEPS = [0.1, 0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4, 8];+ const zoomTo = (zoom: number) => setView((current) => {+ const next = Math.max(MIN_IMAGE_ZOOM, Math.min(MAX_IMAGE_ZOOM, zoom));+ return { zoom: next, x: current.x * next / current.zoom, y: current.y * next / current.zoom };+ });+ const fit = () => setView({ zoom: 1, x: 0, y: 0 });+ const zoomStep = (direction: 1 | -1) => {+ const next = direction > 0 ? ZOOM_STEPS.find((step) => step > view.zoom + 1e-6) : [...ZOOM_STEPS].reverse().find((step) => step < view.zoom - 1e-6);+ if (next) zoomTo(next);+ };+ useShortcut("Ctrl+0", fit, { scope: editorRoot });+ useShortcut("Ctrl+1", () => zoomTo(1), { scope: editorRoot });+ useShortcut(["Ctrl+=", "Ctrl++", "Ctrl+Shift+="], () => zoomStep(1), { scope: editorRoot });+ useShortcut("Ctrl+-", () => zoomStep(-1), { scope: editorRoot });+ const fitted = view.zoom === 1 && view.x === 0 && view.y === 0;+ const zoomPresets = [0.25, 0.5, 0.75, 1, 1.5, 2];+ const zoomValue = fitted ? "fit" : zoomPresets.find((step) => Math.abs(step - view.zoom) < 1e-6)?.toString() ?? "custom";+ const zoomOptions = [+ { value: "fit", label: "Fit" },+ ...(zoomValue === "custom" ? [{ value: "custom", label: `${Math.round(view.zoom * 100)}%`, disabled: true }] : []),+ ...zoomPresets.map((step) => ({ value: String(step), label: `${step * 100}%` })),+ ];+const tree = (node: ImageNode, depth: number) => {const children = scene.nodes.filter((child) => child.parentId === node.id);const open = !collapsed.has(node.id);- return <div key={node.id} role="treeitem" aria-selected={selected.id === node.id} aria-expanded={children.length ? open : undefined}>- <div className={`image-tree__row ${selected.id === node.id ? "selected" : ""}${draggedNode === node.id ? " dragging" : ""}${treeDrop?.id === node.id ? ` image-tree__drop--${treeDrop.placement}` : ""}`} style={{ paddingLeft: `calc(var(--space-2) + ${depth} * var(--space-4))` }}+ return <div key={node.id} role="treeitem" aria-selected={selected.id === node.id} aria-expanded={children.length ? open : undefined} aria-level={depth + 1}>+ <div className={`image-tree__row ${selected.id === node.id ? "selected" : ""}${draggedNode === node.id ? " dragging" : ""}${treeDrop?.id === node.id ? ` image-tree__drop--${treeDrop.placement}` : ""}`} style={{ paddingLeft: `calc(var(--space-1) + ${depth} * 12px)` }}data-image-node={node.id}onContextMenu={(event) => { if ((event.target as HTMLElement).closest("input, textarea, [contenteditable=true]")) return; event.preventDefault(); event.stopPropagation(); setSelection(node.id); setContextMenu({ x: event.clientX, y: event.clientY }); }}draggable={node.kind !== "root" && renaming?.id !== node.id}@@ -317,34 +417,28 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene});setDraggedNode(null); setTreeDrop(null);}}>- {children.length ? <button className="icon-button" aria-label={`${open ? "Collapse" : "Expand"} ${node.name}`} onClick={() => setCollapsed((current) => { const next = new Set(current); if (open) next.add(node.id); else next.delete(node.id); return next; })}>{open ? <ChevronDown size={14} /> : <ChevronRight size={14} />}</button> : <span className="image-tree__spacer" />}+ {children.length+ ? <button className="image-tree__chevron" tabIndex={-1} aria-label={`${open ? "Collapse" : "Expand"} ${node.name}`} onClick={() => setCollapsed((current) => { const next = new Set(current); if (open) next.add(node.id); else next.delete(node.id); return next; })}>{open ? <ChevronDown size={14} aria-hidden="true" /> : <ChevronRight size={14} aria-hidden="true" />}</button>+ : <span className="image-tree__spacer" />}{renaming?.id === node.id ? <input className="image-tree__rename" aria-label="Rename image node" maxLength={120} ref={(element) => { if (element && document.activeElement !== element) { element.focus(); element.select(); } }} value={renaming.value} onChange={(event) => setRenaming({ ...renaming, value: event.target.value })} onBlur={() => finishRename(true, false)} onKeyDown={(event) => {event.stopPropagation();if (event.key === "Enter" && !event.nativeEvent.isComposing) { event.preventDefault(); finishRename(true); }if (event.key === "Escape") { event.preventDefault(); finishRename(false); }- }} /> : <button className="image-tree__select" onFocus={() => setSelection(node.id)} onClick={() => setSelection(node.id)}><span aria-hidden="true">{node.kind === "text" ? "T" : node.kind === "root" ? <Image size={16} /> : <Box size={16} />}</span><span>{node.name}</span></button>}+ }} /> : <button className="image-tree__select" tabIndex={selected.id === node.id ? 0 : -1} data-tooltip={node.name} onFocus={() => setSelection(node.id)} onClick={() => setSelection(node.id)}><span className="image-tree__icon" aria-hidden="true">{node.kind === "text" ? <Type size={16} /> : node.kind === "root" ? <Image size={16} /> : node.kind === "group" ? <Group size={16} /> : <Box size={16} />}</span><span>{node.name}</span></button>}</div>{open && children.length > 0 && <div role="group">{children.map((child) => tree(child, depth + 1))}</div>}</div>;};- return <div className="image-editor">- <aside ref={hierarchy} className="image-tree" aria-label="Image hierarchy" onContextMenu={(event) => { if ((event.target as HTMLElement).closest("input, textarea, [contenteditable=true]")) return; event.preventDefault(); setSelection(root.id); setContextMenu({ x: event.clientX, y: event.clientY }); }} onKeyDown={(event) => {- if ((event.target as HTMLElement).closest("input, textarea, select, [contenteditable=true]") || contextMenu) return;- const key = event.key.toLowerCase();- if ((event.ctrlKey || event.metaKey) && (key === "c" || key === "v")) {- event.preventDefault(); event.stopPropagation();- attempt(() => key === "c" ? copyImageNode(scene, selected.id) : paste());- } else if (key === "delete") { event.preventDefault(); event.stopPropagation(); removeSelected(); }- else if (key === "f2") { event.preventDefault(); event.stopPropagation(); startRename(); }- else if (event.key === "ContextMenu" || (event.shiftKey && event.key === "F10")) {- event.preventDefault(); event.stopPropagation();- const bounds = (event.target as HTMLElement).getBoundingClientRect();- setContextMenu({ x: bounds.left, y: bounds.bottom });- }- }}>- <header><strong>Scene</strong><div className="image-editor__actions"><button className="icon-button" title="Undo" aria-label="Undo image edit" disabled={!undo.current.length} onClick={() => history(true)}><Undo2 size={16} /></button><button className="icon-button" title="Redo" aria-label="Redo image edit" disabled={!redo.current.length} onClick={() => history(false)}><Redo2 size={16} /></button></div></header>+ const rootField = (field: string) => `${editorId}-${field}`;+ return <div ref={editorRoot} className="image-editor" style={{ ...treePane.style, ...inspectorPane.style }}>+ <aside ref={hierarchy} className="image-tree" aria-label="Image hierarchy" onContextMenu={(event) => { if ((event.target as HTMLElement).closest("input, textarea, [contenteditable=true]")) return; event.preventDefault(); setSelection(root.id); setContextMenu({ x: event.clientX, y: event.clientY }); }} onKeyDown={treeKeys}>+ <PaneHeader title="Scene" actions={<>+ <button className="icon-button image-pane-button" aria-label="Undo image edit" aria-keyshortcuts="Control+Z" {...tooltipProps("Undo", "Ctrl+Z")} disabled={!undo.current.length} onClick={() => history(true)}><Undo2 size={16} aria-hidden="true" /></button>+ <button className="icon-button image-pane-button" aria-label="Redo image edit" aria-keyshortcuts="Control+Y" {...tooltipProps("Redo", "Ctrl+Y")} disabled={!redo.current.length} onClick={() => history(false)}><Redo2 size={16} aria-hidden="true" /></button>+ </>} /><div role="tree" aria-label="Image nodes">{tree(root, 0)}</div></aside>+ <Splitter {...treePane.splitterProps} aria-label="Resize hierarchy" />{contextMenu && <HierarchyContextMenu {...contextMenu} onClose={closeContextMenu} items={[{ label: "New Object", icon: <Box size={15} />, action: () => attempt(() => add("object")) },{ label: "New Text", icon: <Type size={15} />, action: () => attempt(() => add("text")) },@@ -353,7 +447,7 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene{ label: "Rename", icon: <Pencil size={15} />, shortcut: "F2", separator: true, action: startRename },{ label: "Copy", icon: <Copy size={15} />, shortcut: "Ctrl+C", separator: true, disabled: selected.kind === "root", action: () => copyImageNode(scene, selected.id) },{ label: "Paste", icon: <ClipboardPaste size={15} />, shortcut: "Ctrl+V", disabled: !clipboard, action: () => attempt(paste) },- { label: "Duplicate", icon: <Copy size={15} />, disabled: selected.kind === "root", action: () => attempt(duplicate) },+ { label: "Duplicate", icon: <Copy size={15} />, shortcut: "Ctrl+D", disabled: selected.kind === "root", action: () => attempt(duplicate) },{ 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={[@@ -367,16 +461,52 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene] : []),]} />}<section className="image-center" aria-label="Image panel">- <div className="image-canvas-tools">- <button className="primary-button image-generate-button" title={editPlan?.error ?? undefined} disabled={active ? work.cancelling || work.status === "encoding" : !isTauri() || !template || templateNeedsDownload(template) || (imageRoot ? Boolean(editPlan?.error) : !imageScenePrompt(scene))} onClick={() => attempt(() => active ? onCancel(work.id) : onGenerate(template!))}><Sparkles size={16} />{active ? work.cancelling ? "Cancelling…" : "Cancel" : "Generate"}</button>- <label className="image-generator">Generator<select aria-label="Generator" value={template?.id ?? ""} disabled={Boolean(active)} onChange={(event) => { setTemplateId(event.target.value); localStorage.setItem("slopus.image-generator-template.v1", event.target.value); const next = imageTemplates.find((candidate) => candidate.id === event.target.value); if (next) commit({ ...scene, steps: next.defaultSteps }); }}>- {!imageTemplates.length && <option value="">No MiniMax H3 templates</option>}{imageTemplates.map((item) => <option key={item.id} value={item.id} disabled={templateNeedsDownload(item)}>{item.name}{templateNeedsDownload(item) ? " (download in Settings)" : ""}</option>)}- </select></label>- <button className={`icon-button ${boxes ? "active" : ""}`} aria-label="Show placement boxes" aria-pressed={boxes} onClick={() => { setBoxes(!boxes); setDrawKind(null); }}><Square size={16} /></button>- <select aria-label="Canvas tool" value={drawKind ?? "select"} onChange={(event) => { setDrawKind(event.target.value === "select" ? null : event.target.value as typeof drawKind); setBoxes(true); }}><option value="select">Select / move</option><option value="object">Draw object</option><option value="text">Draw text</option><option value="group">Draw group</option></select>- <button className="secondary-button" onClick={() => setView({ zoom: 1, x: 0, y: 0 })}>Fit</button><input aria-label="Image zoom" type="range" min={MIN_IMAGE_ZOOM} max={MAX_IMAGE_ZOOM} step="0.01" value={view.zoom} onChange={(event) => { const zoom = Number(event.target.value); setView((current) => ({ zoom, x: current.x * zoom / current.zoom, y: current.y * zoom / current.zoom })); }} /><span>{Math.round(view.zoom * 100)}%</span>+ <div className="image-canvas-tools" role="toolbar" aria-label="Image tools">+ <button className="primary-button image-generate-button" data-tooltip={editPlan?.error ?? undefined} disabled={active ? work.cancelling || work.status === "encoding" : !isTauri() || !template || templateNeedsDownload(template) || (imageRoot ? Boolean(editPlan?.error) : !imageScenePrompt(scene))} onClick={() => attempt(() => active ? onCancel(work.id) : onGenerate(template!))}>{active ? <Square size={14} aria-hidden="true" /> : <Sparkles size={16} aria-hidden="true" />}{active ? work.cancelling ? "Cancelling…" : "Cancel" : "Generate"}</button>+ <ComboBox+ className="image-generator"+ aria-label="Generator"+ data-tooltip="Generator"+ value={template?.id ?? ""}+ disabled={Boolean(active) || !imageTemplates.length}+ placeholder="No MiniMax H3 templates"+ options={imageTemplates.map((item) => ({ value: item.id, label: item.name, disabled: templateNeedsDownload(item), description: templateNeedsDownload(item) ? "Download in Settings" : undefined }))}+ onChange={(id) => { setTemplateId(id); localStorage.setItem("slopus.image-generator-template.v1", id); const next = imageTemplates.find((candidate) => candidate.id === id); if (next) commit({ ...scene, steps: next.defaultSteps }); }}+ />+ <span className="image-tools__separator" role="separator" aria-orientation="vertical" />+ <button className={`image-tool${boxes ? " image-tool--on" : ""}`} aria-label="Show placement boxes" aria-pressed={boxes} data-tooltip="Show placement boxes" onClick={() => { setBoxes(!boxes); setDrawKind(null); }}><Square size={16} aria-hidden="true" /></button>+ <div className="image-tools__group" role="radiogroup" aria-label="Canvas tool" onKeyDown={(event) => {+ if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;+ event.preventDefault();+ const at = TOOLS.findIndex((tool) => tool.id === drawKind);+ const next = TOOLS[(at + (event.key === "ArrowRight" ? 1 : -1) + TOOLS.length) % TOOLS.length];+ chooseTool(next.id);+ requestAnimationFrame(() => event.currentTarget.querySelector<HTMLButtonElement>('[aria-checked="true"]')?.focus());+ }}>+ {TOOLS.map((tool) => <button+ key={tool.label}+ type="button"+ role="radio"+ aria-checked={drawKind === tool.id}+ aria-label={tool.label}+ aria-keyshortcuts={tool.key}+ tabIndex={drawKind === tool.id ? 0 : -1}+ className={`image-tool${drawKind === tool.id ? " image-tool--on" : ""}`}+ {...tooltipProps(tool.label, tool.key)}+ onClick={() => chooseTool(tool.id)}+ ><span aria-hidden="true">{tool.icon}</span></button>)}+ </div>+ <span className="image-tools__separator" role="separator" aria-orientation="vertical" />+ <ComboBox+ className="image-zoom"+ aria-label="Image zoom"+ data-tooltip="Zoom (Ctrl+0 fit, Ctrl+1 100%, Ctrl+= in, Ctrl+- out)"+ value={zoomValue}+ options={zoomOptions}+ onChange={(value) => { if (value === "fit") fit(); else if (value !== "custom") zoomTo(Number(value)); }}+ /></div>- <div ref={viewport} tabIndex={-1} className={`image-viewport${panning ? " panning" : ""}`} title="Scroll to zoom · Drag with the middle mouse button to pan"+ <div ref={viewport} tabIndex={-1} className={`image-viewport${panning ? " panning" : ""}`} data-tooltip="Scroll to zoom · drag with the middle button to pan"onPointerDownCapture={(event) => {if (event.button !== 1 || pointer.current || pan.current) return;event.preventDefault(); event.stopPropagation();@@ -395,7 +525,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 && (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>}+ {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={32} aria-hidden="true" /><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!;@@ -405,13 +535,13 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGene</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 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>}+ {(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} · Placement boxes guide the prompt`}</span></div><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}+ }}>{images.map((asset) => <button key={asset.id} data-image-asset={asset.id} data-tooltip={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")) {@@ -420,38 +550,58 @@ export function ImageEditor({ config, folderPath, onChange: changeConfig, onGenesetContextMenu(null); setImageMenu({ id: asset.id, x: bounds.left, y: bounds.bottom });}}}- 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>+ 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} aria-hidden="true" />{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>}- {selected.kind === "root" && imageRoot ? <>- <button className="secondary-button" disabled={!isTauri()} onClick={() => attempt(async () => {- const source = await invoke<ImageSource | null>("open_image_source", { folderPath });- if (source) replaceScene(createImageEditScene(source, scene));- })}><FolderOpen size={16} />Open image</button>- {scene.sourceImage && <p>{scene.sourceImage.name} · {scene.sourceImage.width} × {scene.sourceImage.height}</p>}- </> : <>- <label>Name<input value={selected.name} maxLength={120} onChange={(event) => { if (event.target.value.trim()) patchNode({ name: event.target.value }); }} /></label>- <label>{selected.kind === "root" ? "Prompt (high-level description)" : "Description"}<textarea rows={4} value={selected.description} onChange={(event) => patchNode({ description: event.target.value })} /></label>- </>}- {selected.kind === "text" && <label>Text to render<input value={selected.text} onChange={(event) => patchNode({ text: event.target.value })} /></label>}- {selected.kind === "root" && !imageRoot && <>- <label>Background (environment)<textarea rows={3} value={scene.background} onChange={(event) => commit({ ...scene, background: event.target.value })} /></label>- <h3>Image generation</h3><label>Steps<input type="number" min="2" max="1000" value={scene.steps} onChange={(event) => { const value = Number(event.target.value); if (Number.isInteger(value) && value >= 2 && value <= 1000) commit({ ...scene, steps: value }); }} /></label>- <label>Seed (−1 = random)<input type="number" min="-1" max={Number.MAX_SAFE_INTEGER} value={scene.seed} onChange={(event) => { const value = Number(event.target.value); if (Number.isSafeInteger(value) && value >= -1) commit({ ...scene, seed: value }); }} /></label>- <label>Aspect ratio<select value={config.settings.aspectRatio} onChange={(event) => { const aspectRatio = event.target.value as ProjectConfig["settings"]["aspectRatio"]; onChange((current) => ({ ...current, settings: { ...current.settings, aspectRatio }, brief: { ...current.brief, aspectRatio } })); }}>{["16:9", "9:16", "1:1", "4:5"].map((ratio) => <option key={ratio}>{ratio}</option>)}</select></label>- <label>Resolution<select value={config.settings.resolution} onChange={(event) => { const resolution = event.target.value as ProjectConfig["settings"]["resolution"]; onChange((current) => ({ ...current, settings: { ...current.settings, resolution }, brief: { ...current.brief, resolution } })); }}>{[...new Set([...PROJECT_RESOLUTIONS, config.settings.resolution])].map((resolution) => { const size = outputDimensions(resolution, config.settings.aspectRatio); return <option key={resolution} value={resolution}>{size.width} × {size.height}</option>; })}</select></label>- <h3>Style</h3><label>Mode<select value={scene.style.mode} onChange={(event) => commit({ ...scene, style: { ...scene.style, mode: event.target.value as "photo" | "art" } })}><option value="photo">Photo</option><option value="art">Art</option></select></label>- <TagEditor label="Aesthetics" value={scene.style.aesthetics} suggestions={scene.style.mode === "photo" ? styleSuggestions.PhotoAestheticsSuggestions : styleSuggestions.ArtAestheticsSuggestions} onChange={(aesthetics) => commit({ ...scene, style: { ...scene.style, aesthetics } })} />- <TagEditor label="Lighting" value={scene.style.lighting} suggestions={scene.style.mode === "photo" ? styleSuggestions.PhotoLightingSuggestions : styleSuggestions.ArtLightingSuggestions} onChange={(lighting) => commit({ ...scene, style: { ...scene.style, lighting } })} />- {scene.style.mode === "art" && <TagEditor label="Medium" value={scene.style.medium} suggestions={styleSuggestions.MediumSuggestions} onChange={(medium) => commit({ ...scene, style: { ...scene.style, medium } })} />}- <TagEditor key={scene.style.mode} label={scene.style.mode === "photo" ? "Camera / lens" : "Art style"} value={scene.style.detail} suggestions={scene.style.mode === "photo" ? styleSuggestions.PhotoSuggestions : styleSuggestions.ArtSuggestions} onChange={(detail) => commit({ ...scene, style: { ...scene.style, detail } })} />- <h3>References</h3>{config.references.filter((reference) => reference.kind === "image" || reference.kind === "text").map((reference) => <label className="image-check" key={reference.id}><input type="checkbox" checked={scene.referenceIds.includes(reference.id)} onChange={(event) => commit({ ...scene, referenceIds: event.target.checked ? [...scene.referenceIds, reference.id] : scene.referenceIds.filter((id) => id !== reference.id) })} />{reference.name}</label>)}{!config.references.length && <p>Add image or text references in the References tab.</p>}- </>}- {selected.kind !== "root" && <><h3>Placement (0–1000)</h3><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>{selected.box && <div className="image-box-fields">{(["x", "y", "width", "height"] as const).map((field) => <label key={field}>{field}<input 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)); }} /></label>)}</div>}</>}- {!(selected.kind === "root" && imageRoot) && <><h3>Color palette</h3><div className="image-palette">{selected.colors.map((color, index) => <div key={index}><input aria-label={`Palette color ${index + 1}`} type="color" value={color} onChange={(event) => patchNode({ colors: selected.colors.map((old, i) => i === index ? event.target.value : old) })} /><button className="icon-button" aria-label={`Remove color ${index + 1}`} onClick={() => patchNode({ colors: selected.colors.filter((_, i) => i !== index) })}><Trash2 size={13} /></button></div>)}<button className="secondary-button" disabled={selected.colors.length >= (selected.kind === "root" ? 16 : 5)} onClick={() => patchNode({ colors: [...selected.colors, "#808080"] })}><Plus size={14} />Color</button></div></>}- </div>- {debugEnabled && <div className="debug-prompt"><button type="button" className="secondary-button debug-prompt__toggle" aria-haspopup="dialog" onClick={() => attempt(() => setDebugPrompt(imageRoot ? imageEditDebugPrompt(compileImageEdits(config).edits) : compileImagePrompt(config).prompt))}>Debug Prompt</button></div>}+ <Splitter {...inspectorPane.splitterProps} reverse aria-label="Resize inspector" />+ <aside className="image-inspector" aria-label="Image node inspector">+ <PaneHeader title={<>Inspector <span className="image-inspector__kind">{selected.kind}</span></>} />+ <div className="image-inspector__fields">+ {selected.kind === "root" && <PropRow label="Type" htmlFor={rootField("type")}>+ <ComboBox id={rootField("type")} aria-label="Type" value={imageRoot ? "image" : "prompt"} options={[{ value: "prompt", label: "Prompt" }, { value: "image", label: "Image" }]}+ onChange={(value) => replaceScene(value === "image" ? createImageEditScene(null, scene) : { ...createImageScene(), steps: scene.steps, seed: scene.seed })} />+ </PropRow>}+ {selected.kind === "root" && imageRoot ? <>+ <button className="secondary-button" disabled={!isTauri()} onClick={() => attempt(async () => {+ const source = await invoke<ImageSource | null>("open_image_source", { folderPath });+ if (source) replaceScene(createImageEditScene(source, scene));+ })}><FolderOpen size={16} aria-hidden="true" />Open image</button>+ {scene.sourceImage && <p className="image-inspector__caption">{scene.sourceImage.name} · {scene.sourceImage.width} × {scene.sourceImage.height}</p>}+ </> : <>+ <PropRow label="Name" htmlFor={rootField("name")}><input id={rootField("name")} className="text-field" value={selected.name} maxLength={120} onChange={(event) => { if (event.target.value.trim()) patchNode({ name: event.target.value }); }} /></PropRow>+ <label className="image-inspector__area">{selected.kind === "root" ? "Prompt (high-level description)" : "Description"}<textarea className="text-field" rows={4} value={selected.description} onChange={(event) => patchNode({ description: event.target.value })} /></label>+ </>}+ {selected.kind === "text" && <PropRow label="Text to render" htmlFor={rootField("text")}><input id={rootField("text")} className="text-field" value={selected.text} onChange={(event) => patchNode({ text: event.target.value })} /></PropRow>}+ {selected.kind === "root" && !imageRoot && <>+ <label className="image-inspector__area">Background (environment)<textarea className="text-field" rows={3} value={scene.background} onChange={(event) => commit({ ...scene, background: event.target.value })} /></label>+ <PropSection title="Image generation" persistKey="image.generation">+ <PropRow label="Steps" htmlFor={rootField("steps")}><input id={rootField("steps")} className="text-field" type="number" min="2" max="1000" value={scene.steps} onChange={(event) => { const value = Number(event.target.value); if (Number.isInteger(value) && value >= 2 && value <= 1000) commit({ ...scene, steps: value }); }} /></PropRow>+ <PropRow label="Seed" htmlFor={rootField("seed")}><input id={rootField("seed")} className="text-field" type="number" min="-1" max={Number.MAX_SAFE_INTEGER} value={scene.seed} data-tooltip="-1 picks a random seed" onChange={(event) => { const value = Number(event.target.value); if (Number.isSafeInteger(value) && value >= -1) commit({ ...scene, seed: value }); }} /></PropRow>+ <PropRow label="Aspect ratio" htmlFor={rootField("ratio")}><ComboBox id={rootField("ratio")} aria-label="Aspect ratio" value={config.settings.aspectRatio} options={["16:9", "9:16", "1:1", "4:5"].map((ratio) => ({ value: ratio, label: ratio }))} onChange={(value) => { const aspectRatio = value as ProjectConfig["settings"]["aspectRatio"]; onChange((current) => ({ ...current, settings: { ...current.settings, aspectRatio }, brief: { ...current.brief, aspectRatio } })); }} /></PropRow>+ <PropRow label="Resolution" htmlFor={rootField("resolution")}><ComboBox id={rootField("resolution")} aria-label="Resolution" value={config.settings.resolution} options={[...new Set([...PROJECT_RESOLUTIONS, config.settings.resolution])].map((resolution) => { const size = outputDimensions(resolution, config.settings.aspectRatio); return { value: resolution, label: `${size.width} × ${size.height}` }; })} onChange={(value) => { const resolution = value as ProjectConfig["settings"]["resolution"]; onChange((current) => ({ ...current, settings: { ...current.settings, resolution }, brief: { ...current.brief, resolution } })); }} /></PropRow>+ </PropSection>+ <PropSection title="Style" persistKey="image.style">+ <PropRow label="Mode" htmlFor={rootField("mode")}><ComboBox id={rootField("mode")} aria-label="Mode" value={scene.style.mode} options={[{ value: "photo", label: "Photo" }, { value: "art", label: "Art" }]} onChange={(value) => commit({ ...scene, style: { ...scene.style, mode: value as "photo" | "art" } })} /></PropRow>+ <TagEditor label="Aesthetics" value={scene.style.aesthetics} suggestions={scene.style.mode === "photo" ? styleSuggestions.PhotoAestheticsSuggestions : styleSuggestions.ArtAestheticsSuggestions} onChange={(aesthetics) => commit({ ...scene, style: { ...scene.style, aesthetics } })} />+ <TagEditor label="Lighting" value={scene.style.lighting} suggestions={scene.style.mode === "photo" ? styleSuggestions.PhotoLightingSuggestions : styleSuggestions.ArtLightingSuggestions} onChange={(lighting) => commit({ ...scene, style: { ...scene.style, lighting } })} />+ {scene.style.mode === "art" && <TagEditor label="Medium" value={scene.style.medium} suggestions={styleSuggestions.MediumSuggestions} onChange={(medium) => commit({ ...scene, style: { ...scene.style, medium } })} />}+ <TagEditor key={scene.style.mode} label={scene.style.mode === "photo" ? "Camera / lens" : "Art style"} value={scene.style.detail} suggestions={scene.style.mode === "photo" ? styleSuggestions.PhotoSuggestions : styleSuggestions.ArtSuggestions} onChange={(detail) => commit({ ...scene, style: { ...scene.style, detail } })} />+ </PropSection>+ <PropSection title="References" persistKey="image.references">+ {config.references.filter((reference) => reference.kind === "image" || reference.kind === "text").map((reference) => <label className="image-check" key={reference.id}><input type="checkbox" checked={scene.referenceIds.includes(reference.id)} onChange={(event) => commit({ ...scene, referenceIds: event.target.checked ? [...scene.referenceIds, reference.id] : scene.referenceIds.filter((id) => id !== reference.id) })} />{reference.name}</label>)}+ {!config.references.length && <p className="image-inspector__caption">None yet — add them under References.</p>}+ </PropSection>+ </>}+ {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>+ {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)); }} />+ </PropRow>)}+ </PropSection>}+ {!(selected.kind === "root" && imageRoot) && <PropSection title="Color palette" persistKey="image.palette">+ <div className="image-palette">{selected.colors.map((color, index) => <div key={index}><input aria-label={`Palette color ${index + 1}`} type="color" value={color} onChange={(event) => patchNode({ colors: selected.colors.map((old, i) => i === index ? event.target.value : old) })} /><button className="icon-button image-pane-button" aria-label={`Remove color ${index + 1}`} data-tooltip="Remove color" onClick={() => patchNode({ colors: selected.colors.filter((_, i) => i !== index) })}><Trash2 size={14} aria-hidden="true" /></button></div>)}<button className="secondary-button" disabled={selected.colors.length >= (selected.kind === "root" ? 16 : 5)} onClick={() => patchNode({ colors: [...selected.colors, "#808080"] })}><Plus size={14} aria-hidden="true" />Color</button></div>+ </PropSection>}+ </div>+ {debugEnabled && <div className="debug-prompt"><button type="button" className="secondary-button debug-prompt__toggle" aria-haspopup="dialog" onClick={() => attempt(() => setDebugPrompt(imageRoot ? imageEditDebugPrompt(compileImageEdits(config).edits) : compileImagePrompt(config).prompt))}>Debug prompt</button></div>}</aside>{debugEnabled && debugPrompt !== null && <DebugPromptDialog sceneTitle={config.name} segments={[{ kind: "brief", value: debugPrompt }]} onClose={() => setDebugPrompt(null)} />}</div>;diff --git a/src/components/workspace/TagEditor.tsx b/src/components/workspace/TagEditor.tsxindex 21abc02..468ffb8 100644--- a/src/components/workspace/TagEditor.tsx+++ b/src/components/workspace/TagEditor.tsx@@ -1,33 +1,47 @@-import { Plus, X } from "lucide-react";-import { useEffect, useId, useLayoutEffect, useRef, useState } from "react";+import { X } from "lucide-react";+import { useId, useLayoutEffect, useRef, useState } from "react";import { createPortal } from "react-dom";import "../../styles/tag-editor.css";-/** ImgFab's ordered style chips, stored as the existing comma-separated string. */+const MAX_SUGGESTIONS = 8;++/** ImgFab's ordered style tokens, stored as the existing comma-separated string.+ *+ * A token box, the way Windows mail "To" fields work: the tokens, then an+ * inline text box. Typing filters the suggestions under it; Enter (or a+ * comma) commits what was typed or the highlighted suggestion as a token;+ * Backspace in an empty box removes the last token. Tokens reorder by drag+ * or Alt+Left/Right. */export function TagEditor({ label, value, suggestions, onChange }: {label: string; value: string; suggestions: readonly string[]; onChange: (value: string) => void;}) {const id = useId();const tags = value.split(",").map((tag) => tag.trim()).filter(Boolean);+ const [text, setText] = useState("");const [open, setOpen] = useState(false);- const [custom, setCustom] = useState("");- const [position, setPosition] = useState({ left: 0, top: 0 });+ const [active, setActive] = useState(-1);+ const [position, setPosition] = useState<{ left: number; top: number; width: number }>({ left: 0, top: 0, width: 0 });const [dragging, setDragging] = useState<number | null>(null);const host = useRef<HTMLDivElement>(null);- const addButton = useRef<HTMLButtonElement>(null);- const popup = useRef<HTMLDivElement>(null);+ const field = useRef<HTMLDivElement>(null);const input = useRef<HTMLInputElement>(null);const drag = useRef<{ index: number; x: number; y: number; active: boolean } | null>(null);- const available = suggestions.filter((suggestion) => !tags.some((tag) => tag.toLowerCase() === suggestion.toLowerCase()));- const close = () => { setOpen(false); addButton.current?.focus(); };+ const query = text.trim().toLowerCase();+ const available = suggestions+ .filter((suggestion) => !tags.some((tag) => tag.toLowerCase() === suggestion.toLowerCase()))+ .filter((suggestion) => !query || suggestion.toLowerCase().includes(query))+ .slice(0, MAX_SUGGESTIONS);+ const listOpen = open && available.length > 0;+ const listId = `${id}-suggestions`;+const add = (raw: string) => {const next = [...tags];for (const tag of raw.split(",").map((part) => part.trim()).filter(Boolean)) {if (!next.some((existing) => existing.toLowerCase() === tag.toLowerCase())) next.push(tag);}if (next.length !== tags.length) onChange(next.join(", "));- setCustom("");- input.current?.focus();+ setText("");+ setActive(-1);};const move = (from: number, to: number) => {if (from === to || to < 0 || to >= tags.length) return;@@ -35,46 +49,37 @@ export function TagEditor({ label, value, suggestions, onChange }: {next.splice(to, 0, next.splice(from, 1)[0]);onChange(next.join(", "));};+ const removeAt = (index: number) => onChange(tags.filter((_, i) => i !== index).join(", "));+useLayoutEffect(() => {- if (!open) return;+ if (!listOpen) return;const place = () => {- const anchor = addButton.current!.getBoundingClientRect();- const bounds = popup.current!.getBoundingClientRect();- const top = anchor.bottom + 6 + bounds.height <= window.innerHeight - 8 ? anchor.bottom + 6 : anchor.top - bounds.height - 6;- setPosition({ left: Math.max(8, Math.min(anchor.left, window.innerWidth - bounds.width - 8)), top: Math.max(8, top) });+ const box = field.current?.getBoundingClientRect();+ if (box) setPosition({ left: box.left, top: box.bottom + 2, width: box.width });};place();window.addEventListener("resize", place);window.addEventListener("scroll", place, true);return () => { window.removeEventListener("resize", place); window.removeEventListener("scroll", place, true); };- }, [open, available.length]);- useEffect(() => {- if (!open) return;- input.current?.focus();- const outside = (event: PointerEvent) => {- if (event.target instanceof Node && !host.current?.contains(event.target) && !popup.current?.contains(event.target)) setOpen(false);- };- const escape = (event: KeyboardEvent) => {- if (event.key === "Escape") { event.preventDefault(); event.stopPropagation(); close(); }- };- document.addEventListener("pointerdown", outside);- window.addEventListener("keydown", escape, true);- return () => { document.removeEventListener("pointerdown", outside); window.removeEventListener("keydown", escape, true); };- }, [open]);+ }, [listOpen]);- return <div className="tag-editor" ref={host} role="group" aria-labelledby={`${id}-label`} onBlur={(event) => {- const next = event.relatedTarget;- if (next instanceof Node && !host.current?.contains(next) && !popup.current?.contains(next)) setOpen(false);- }}>+ return <div className="tag-editor" ref={host} role="group" aria-labelledby={`${id}-label`}><span className="tag-editor__label" id={`${id}-label`}>{label}</span>- <div className="tag-editor__chips">+ <div className="tag-editor__field" ref={field} onMouseDown={(event) => {+ // A click on the field's empty space puts the caret in the text box.+ if (event.target === event.currentTarget) { event.preventDefault(); input.current?.focus(); }+ }}>{tags.map((tag, index) => <span key={`${index}-${tag}`} data-tag-index={index} className={`tag-editor__chip${dragging === index ? " dragging" : ""}`}>- <button type="button" className="tag-editor__drag" aria-label={`${label} tag: ${tag}`} title="Drag to reorder, or use Alt + Left/Right" onKeyDown={(event) => {+ <button type="button" className="tag-editor__drag" aria-label={`${label} tag: ${tag}`} aria-keyshortcuts="Alt+ArrowLeft Alt+ArrowRight" data-tooltip="Drag to reorder" data-tooltip-shortcut="Alt+Left, Alt+Right" onKeyDown={(event) => {if (event.altKey && (event.key === "ArrowLeft" || event.key === "ArrowRight")) {event.preventDefault(); event.stopPropagation();const to = index + (event.key === "ArrowLeft" ? -1 : 1);move(index, to);if (to >= 0 && to < tags.length) requestAnimationFrame(() => host.current?.querySelector<HTMLButtonElement>(`[data-tag-index="${to}"] .tag-editor__drag`)?.focus());+ } else if (event.key === "Delete" || event.key === "Backspace") {+ event.preventDefault(); event.stopPropagation();+ removeAt(index);+ requestAnimationFrame(() => input.current?.focus());}}} onPointerDown={(event) => {if (event.button !== 0) return;@@ -96,16 +101,70 @@ export function TagEditor({ label, value, suggestions, onChange }: {}drag.current = null; setDragging(null);}} onLostPointerCapture={() => { drag.current = null; setDragging(null); }}>{tag}</button>- <button type="button" className="tag-editor__remove" aria-label={`Remove ${tag} from ${label}`} onClick={() => onChange(tags.filter((_, i) => i !== index).join(", "))}><X size={12} /></button>+ <button type="button" className="tag-editor__remove" aria-label={`Remove ${tag} from ${label}`} tabIndex={-1} onClick={() => removeAt(index)}><X size={12} aria-hidden="true" /></button></span>)}- <button ref={addButton} type="button" className="tag-editor__add" aria-label={`Add ${label} tag`} aria-haspopup="dialog" aria-expanded={open} aria-controls={open ? `${id}-popup` : undefined} onClick={() => setOpen(!open)}><Plus size={13} /> Add</button>+ <input+ ref={input}+ className="tag-editor__input"+ role="combobox"+ aria-label={`Add ${label} tag`}+ aria-autocomplete="list"+ aria-expanded={listOpen}+ aria-controls={listOpen ? listId : undefined}+ aria-activedescendant={listOpen && active >= 0 ? `${listId}-${active}` : undefined}+ placeholder={tags.length ? "" : "Add a tag…"}+ value={text}+ onChange={(event) => {+ const next = event.target.value;+ // A typed comma commits everything before it.+ if (next.includes(",")) { add(next); return; }+ setText(next);+ setOpen(true);+ setActive(-1);+ }}+ onFocus={() => setOpen(true)}+ onBlur={() => { setOpen(false); setActive(-1); }}+ onKeyDown={(event) => {+ if (event.nativeEvent.isComposing) return;+ if (event.key === "Enter") {+ event.preventDefault();+ event.stopPropagation();+ if (listOpen && active >= 0) add(available[active]);+ else if (text.trim()) add(text);+ } else if (event.key === "ArrowDown" || event.key === "ArrowUp") {+ event.preventDefault();+ if (!available.length) return;+ setOpen(true);+ const step = event.key === "ArrowDown" ? 1 : -1;+ setActive((current) => (current + step + available.length + (current < 0 && step < 0 ? 1 : 0)) % available.length);+ } else if (event.key === "Escape" && (listOpen || text)) {+ event.preventDefault();+ event.stopPropagation();+ if (listOpen) setOpen(false); else setText("");+ } else if (event.key === "Backspace" && !text && tags.length) {+ event.preventDefault();+ removeAt(tags.length - 1);+ }+ }}+ /></div>- {open && createPortal(<div ref={popup} id={`${id}-popup`} className="tag-editor__popup" role="dialog" aria-label={`Add ${label} tag`} style={position}>- <strong>Add tag</strong>- <div className="tag-editor__custom"><input ref={input} aria-label={`Custom ${label} tags`} placeholder="Custom tag…" value={custom} onChange={(event) => setCustom(event.target.value)} onKeyDown={(event) => {- if (event.key === "Enter" && !event.nativeEvent.isComposing) { event.preventDefault(); event.stopPropagation(); add(custom); }- }} /><button type="button" className="secondary-button" disabled={!custom.trim()} onClick={() => add(custom)}>Add</button></div>- {available.length > 0 && <><span className="tag-editor__hint">Suggestions</span><div className="tag-editor__suggestions">{available.map((tag) => <button type="button" key={tag} onClick={() => add(tag)}>{tag}</button>)}</div></>}+ {listOpen && createPortal(<div+ id={listId}+ role="listbox"+ className="tag-editor__suggestions"+ aria-label={`${label} suggestions`}+ style={{ left: position.left, top: position.top, minWidth: position.width }}+ onMouseDown={(event) => event.preventDefault()}+ >+ {available.map((suggestion, index) => <div+ key={suggestion}+ id={`${listId}-${index}`}+ role="option"+ aria-selected={index === active}+ className={`tag-editor__suggestion${index === active ? " tag-editor__suggestion--active" : ""}`}+ onMouseMove={() => setActive(index)}+ onClick={() => add(suggestion)}+ >{suggestion}</div>)}</div>, document.body)}</div>;}diff --git a/src/styles/image-editor.css b/src/styles/image-editor.cssindex ee9068d..b91403e 100644--- a/src/styles/image-editor.css+++ b/src/styles/image-editor.css@@ -1,70 +1,87 @@+/* ============================================================================+ image-editor.css — the image project's editor: the node tree, the canvas+ with its tool strip, and the inspector. Both side panes are resizable+ (usePaneSize → --pane-image-tree / --pane-image-inspector) instead of+ stepping at width breakpoints.+ ========================================================================== */+.project-content--editor { padding: 0; overflow: hidden; }-.image-editor { display: grid; grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) minmax(220px, 300px); height: 100%; min-height: 0; }-.image-editor input:not([type="checkbox"]):not([type="range"]):not([type="color"]), .image-editor select, .image-editor textarea { min-height: var(--field-height); padding: var(--space-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--field-bg); color: var(--text-primary); }-.image-editor header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-3); border-bottom: 1px solid var(--line-solid); }-.image-tree, .image-inspector { min-height: 0; overflow: auto; background: var(--panel); }-.image-tree { display: flex; flex-direction: column; border-right: 1px solid var(--line-solid); }-.image-tree > [role="tree"] { flex: 1; overflow: auto; }-.image-inspector { display: flex; flex-direction: column; border-left: 1px solid var(--line-solid); }-.image-inspector > header { flex-shrink: 0; }+.image-editor { display: grid; grid-template-columns: var(--pane-image-tree, 240px) auto minmax(0, 1fr) auto var(--pane-image-inspector, 300px); height: 100%; min-height: 0; background: var(--layer); }+.image-tree, .image-inspector { min-width: 0; min-height: 0; overflow: auto; background: var(--panel); }+.image-tree { display: flex; flex-direction: column; }+.image-tree > .ui-pane-header, .image-inspector > .ui-pane-header { flex-shrink: 0; border-bottom: 1px solid var(--line); }+.image-tree > [role="tree"] { flex: 1; overflow: auto; padding: var(--space-1) 0; }+.image-inspector { display: flex; flex-direction: column; }.image-inspector > .debug-prompt { margin-top: auto; }-.image-editor__actions { display: flex; align-items: center; gap: var(--space-1); }-.image-tree__row { position: relative; display: flex; align-items: center; min-height: var(--control-md); }+.image-inspector__kind { margin-left: var(--space-1); color: var(--text-muted); font-weight: var(--weight-regular); text-transform: capitalize; }+.image-pane-button.icon-button { width: var(--control-sm); height: var(--control-sm); }++/* --- Tree rows -----------------------------------------------------------------+ 28px rows inset 4px with 4px corners, a 20px chevron, 12px per level.+ Selection is a subtle fill and the 3×16px accent pill; the drop indicators+ are 2px accent bars (before/after) or an accent outline (inside). */+.image-tree__row { position: relative; display: flex; align-items: center; gap: 2px; height: 28px; margin: 2px var(--space-1); padding-right: var(--space-2); border-radius: var(--radius-sm); color: var(--text-primary); font-size: var(--text-base); transition: background-color var(--motion-fast) linear; }+.image-tree__row:hover { background: var(--fill-subtle-hover); }+.image-tree__row.selected { background: var(--fill-subtle-hover); }+.image-tree__row.selected::before { content: ""; position: absolute; left: 0; top: 6px; width: 3px; height: 16px; border-radius: 2px; background: var(--accent); }.image-tree__row[draggable="true"] .image-tree__select { cursor: grab; }.image-tree__row.dragging { opacity: 0.45; }-.image-tree__drop--inside { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--panel-3); }-.image-tree__drop--before::before, .image-tree__drop--after::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; background: var(--accent); pointer-events: none; }-.image-tree__drop--before::before { top: 0; }-.image-tree__drop--after::after { bottom: 0; }-.image-tree__row.selected { background: var(--panel-3); color: var(--text-primary); box-shadow: inset 3px 0 var(--accent); }-.image-tree__select { display: flex; gap: var(--space-2); align-items: center; flex: 1; min-width: 0; padding: var(--space-2); text-align: left; border: 0; background: transparent; color: inherit; }+.image-tree__drop--inside { outline: 2px solid var(--accent); outline-offset: -2px; }+.image-tree__drop--before::after, .image-tree__drop--after::after { content: ""; position: absolute; left: 0; right: 0; height: 2px; border-radius: 1px; background: var(--accent); pointer-events: none; }+.image-tree__drop--before::after { top: -2px; }+.image-tree__drop--after::after { bottom: -2px; }+.image-tree__chevron { display: grid; place-items: center; flex: 0 0 20px; width: 20px; height: 20px; padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); }+.image-tree__chevron:hover { background: var(--fill-subtle-hover); color: var(--text-primary); }+.image-tree__spacer { flex: 0 0 20px; }+.image-tree__select { display: flex; gap: var(--space-2); align-items: center; flex: 1; min-width: 0; height: 100%; padding: 0 var(--space-1); text-align: left; border: 0; border-radius: var(--radius-sm); background: transparent; color: inherit; font: inherit; }+.image-tree__icon { display: grid; flex: 0 0 auto; color: var(--text-secondary); }.image-tree__select span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }-.image-tree__spacer { width: var(--control-sm); flex-shrink: 0; }-.image-editor .image-tree__rename { flex: 1; min-width: 0; width: 100%; margin: var(--space-1); padding: var(--space-1); min-height: var(--control-sm); }-.image-hierarchy-menu { position: fixed; z-index: 115; width: 220px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px); overflow: auto; padding: var(--space-1); border: 1px solid var(--stroke-surface); border-radius: var(--radius-lg); background: var(--acrylic); backdrop-filter: var(--acrylic-filter); box-shadow: var(--shadow-sm); }-.image-hierarchy-menu button { display: flex; align-items: center; gap: var(--space-2); width: 100%; padding: var(--space-2); border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-primary); text-align: left; font-size: var(--text-sm); }-.image-hierarchy-menu button:hover:not(:disabled), .image-hierarchy-menu button:focus-visible { background: var(--panel-3); }-.image-hierarchy-menu button:disabled { opacity: 0.4; }-.image-hierarchy-menu button.danger { color: var(--danger); }-.image-hierarchy-menu kbd { margin-left: auto; color: var(--text-muted); font: inherit; font-size: var(--text-xs); }-.image-hierarchy-menu [role="separator"] { height: 1px; margin: var(--space-1); background: var(--line-solid); }-.image-center { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--bg); }-.image-canvas-tools { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-2); border-bottom: 1px solid var(--line-solid); font-size: var(--text-xs); }-.image-generator { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }-.image-generate-button { width: 144px; flex-shrink: 0; justify-content: center; white-space: nowrap; }-.image-canvas-tools input[type="range"] { width: 72px; min-width: 0; }-.image-canvas-tools select { width: auto; max-width: 160px; }-.image-canvas-tools .active { color: var(--accent); }+.image-editor .image-tree__rename { flex: 1; min-width: 0; width: 100%; height: var(--control-sm); padding: 0 var(--space-1); }++/* --- Canvas and its tool strip ------------------------------------------------ */+.image-center { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--layer); }+.image-canvas-tools { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-1); min-height: var(--space-7); padding: var(--space-1) var(--space-2); border-bottom: 1px solid var(--line); }+.image-generate-button { flex-shrink: 0; white-space: nowrap; }+.image-generator { width: 200px; max-width: 32%; }+.image-zoom { width: 96px; min-width: 96px; }+.image-tools__separator { width: 1px; height: 20px; margin: 0 var(--space-1); background: var(--line); }+.image-tools__group { display: inline-flex; gap: 2px; }+/* 32px icon toggles; the checked tool is an accent-soft fill. */+.image-tool { display: grid; place-items: center; width: var(--icon-button); height: var(--icon-button); padding: 0; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--text-primary); background: transparent; transition: var(--transition-control); }+.image-tool:hover { background: var(--fill-subtle-hover); }+.image-tool:active { background: var(--fill-subtle-pressed); }+.image-tool--on, .image-tool--on:hover { border-color: var(--accent-line); color: var(--accent-on-soft); background: var(--accent-soft); }+.image-tool > span { display: grid; }.image-viewport { position: relative; flex: 1; min-height: 0; overflow: clip; container-type: size; user-select: none; }.image-viewport.panning, .image-viewport.panning * { cursor: grabbing; }.image-frame { position: absolute; left: 50%; top: 50%; transform: translate(calc(-50% + var(--image-pan-x)), calc(-50% + var(--image-pan-y))); width: calc(min(100cqw, 100cqh * var(--image-ratio)) * var(--image-zoom)); aspect-ratio: var(--image-ratio); background: var(--panel); box-shadow: 0 0 0 1px var(--line-solid); }.image-frame > img, .image-frame > .reference-image { position: absolute; width: 100%; height: 100%; object-fit: contain; inset: 0; }-.image-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-3); text-align: center; padding: var(--space-4); color: var(--text-faint); }-.image-empty span { max-width: 300px; font-size: var(--text-sm); }+.image-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-2); text-align: center; padding: var(--space-4); color: var(--text-muted); }+.image-empty strong { color: var(--text-primary); font-size: var(--text-base); font-weight: var(--weight-semibold); }+.image-empty span { max-width: 300px; font-size: var(--text-xs); }.image-overlay { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }.image-overlay rect { fill: color-mix(in srgb, var(--accent) 8%, transparent); stroke: var(--accent); stroke-width: 1.5; cursor: move; }.image-overlay .selected > rect { stroke-width: 3; }.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; }-.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; 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-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); }+.image-results button { position: relative; flex: 0 0 72px; height: 64px; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: var(--radius-sm); 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-primary); font-size: var(--text-2xs); }.image-results button[aria-pressed="true"] { border-color: var(--accent); }.image-results img { width: 100%; height: 100%; object-fit: cover; }-.image-inspector__fields { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-3); }-.image-inspector label { display: flex; flex-direction: column; gap: var(--space-1); font-size: var(--text-sm); }-.image-inspector input, .image-inspector textarea, .image-inspector select { width: 100%; min-width: 0; }-.image-inspector textarea { resize: vertical; }-.image-inspector h3 { margin: var(--space-2) 0 0; font-size: var(--text-sm); color: var(--text-primary); }-.image-inspector p { font-size: var(--text-sm); margin: 0; }-.image-inspector .image-check { flex-direction: row; align-items: center; gap: var(--space-2); }-.image-check input[type="checkbox"] { width: var(--check-size); }-.image-box-fields { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-2); }-.image-palette { display: flex; flex-wrap: wrap; gap: var(--space-2); }-.image-palette > div { display: flex; align-items: center; }-.image-palette input[type="color"] { width: var(--control-sm); height: var(--control-sm); padding: var(--space-1); }-@media (max-width: 1100px) { .image-editor { grid-template-columns: 180px minmax(0, 1fr) 240px; } }++/* --- Inspector -------------------------------------------------------------------+ Label + control pairs are PropRows; the free-text fields stay full width+ with a 12px label above. */+.image-inspector__fields { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-2) var(--space-3) var(--space-3); }+.image-inspector__area { display: flex; flex-direction: column; gap: var(--space-1); color: var(--text-secondary); font-size: var(--text-xs); font-weight: var(--weight-semibold); }+.image-inspector__area textarea { width: 100%; height: auto; min-width: 0; padding: var(--space-2); font-weight: var(--weight-regular); line-height: var(--leading-normal); resize: vertical; }+.image-inspector__caption { margin: 0; color: var(--text-muted); font-size: var(--text-xs); }+.image-inspector .ui-prop-section__content { padding-inline: 0; }+.image-inspector .image-check { display: flex; align-items: center; gap: var(--space-2); min-height: 28px; font-size: var(--text-base); }+.image-palette { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }+.image-palette > div { display: flex; align-items: center; gap: 2px; }+.image-palette input[type="color"] { width: var(--control-sm); height: var(--control-sm); padding: 2px; border: 1px solid var(--stroke-control); border-radius: var(--radius-sm); background: var(--fill-control); }diff --git a/src/styles/tag-editor.css b/src/styles/tag-editor.cssindex 34db9fe..b5a4779 100644--- a/src/styles/tag-editor.css+++ b/src/styles/tag-editor.css@@ -1,18 +1,18 @@-.tag-editor { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; font-size: var(--text-sm); }-.tag-editor__chips, .tag-editor__suggestions { display: flex; flex-wrap: wrap; gap: var(--space-1); align-items: center; }-.tag-editor__chip { display: inline-flex; align-items: center; max-width: 100%; border-radius: 14px; background: var(--panel-3); border: 1px solid var(--line); }-.tag-editor__chip:hover { border-color: var(--line-strong); }+/* The style token box: a TextBox holding 4px tokens (24px, 12px text, a small+ square remove button) followed by an inline input; suggestions drop down+ as an acrylic list under the field. */+.tag-editor { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; font-size: var(--text-xs); }+.tag-editor__label { color: var(--text-secondary); font-size: var(--text-xs); font-weight: var(--weight-semibold); }+.tag-editor__field { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); min-height: var(--field-height); padding: 3px var(--space-1); border: 1px solid var(--stroke-control); border-bottom-color: var(--stroke-strong); border-radius: var(--radius-sm); background: var(--fill-control); cursor: text; transition: var(--transition-control); }+.tag-editor__field:hover { background: var(--fill-control-hover); }+.tag-editor__field:focus-within { border-bottom-color: var(--field-focus-line); background: var(--fill-input-focus); box-shadow: inset 0 -1px 0 var(--field-focus-line); }+.tag-editor__chip { display: inline-flex; align-items: center; max-width: 100%; height: var(--control-sm); border: 1px solid var(--stroke-control); border-radius: var(--radius-sm); background: var(--fill-control-alt); }.tag-editor__chip.dragging { opacity: 0.45; }-.tag-editor__drag { min-width: 0; padding: 4px 3px 4px 9px; border: 0; background: transparent; color: var(--text-primary); font-size: inherit; text-align: left; overflow-wrap: anywhere; cursor: grab; touch-action: none; user-select: none; }+.tag-editor__drag { min-width: 0; height: 100%; padding: 0 2px 0 var(--space-2); overflow: hidden; border: 0; border-radius: var(--radius-sm) 0 0 var(--radius-sm); background: transparent; color: var(--text-primary); font-size: var(--text-xs); text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: grab; touch-action: none; user-select: none; }.tag-editor__drag:active { cursor: grabbing; }-.tag-editor__remove { display: grid; place-items: center; flex: 0 0 24px; align-self: stretch; padding: 3px; border: 0; border-radius: 50%; background: transparent; color: var(--text-muted); }-.tag-editor__remove:hover { color: var(--danger); }-.tag-editor__add { display: inline-flex; align-items: center; gap: 3px; padding: 4px 9px; border: 1px solid var(--line-strong); border-radius: 14px; background: transparent; color: var(--text-muted); font-size: inherit; }-.tag-editor__add:hover, .tag-editor__add[aria-expanded="true"] { background: var(--panel-3); color: var(--text-primary); }-.tag-editor__popup { position: fixed; z-index: 115; width: min(280px, calc(100vw - 16px)); max-height: calc(100dvh - 16px); overflow: auto; display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); border: 1px solid var(--stroke-surface); border-radius: var(--radius-lg); background: var(--acrylic); backdrop-filter: var(--acrylic-filter); color: var(--text-primary); box-shadow: var(--shadow-sm); font-size: var(--text-sm); }-.tag-editor__custom { display: flex; gap: var(--space-1); }-.tag-editor__custom input { width: 100%; min-width: 0; min-height: var(--field-height); padding: var(--space-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--field-bg); color: var(--text-primary); }-.tag-editor__custom button { flex-shrink: 0; }-.tag-editor__hint { color: var(--text-muted); font-size: var(--text-xs); }-.tag-editor__suggestions button { padding: 4px 8px; border: 1px solid transparent; border-radius: 12px; background: var(--panel-2); color: var(--text-primary); font-size: inherit; }-.tag-editor__suggestions button:hover { background: var(--panel-3); border-color: var(--line-strong); }+.tag-editor__remove { display: grid; place-items: center; flex: 0 0 20px; width: 20px; height: 20px; margin-right: 1px; padding: 0; border: 0; border-radius: 2px; background: transparent; color: var(--text-secondary); }+.tag-editor__remove:hover { color: var(--text-primary); background: var(--fill-subtle-hover); }+.tag-editor__input { flex: 1 0 64px; min-width: 64px; height: var(--control-sm); padding: 0 var(--space-1); border: 0; outline: 0; box-shadow: none; background: transparent; color: var(--text-primary); font-size: var(--text-sm); }+.tag-editor__suggestions { position: fixed; z-index: 960; max-height: 264px; overflow-y: auto; padding: var(--space-1); border: 1px solid var(--stroke-surface); border-radius: var(--radius-lg); background: var(--acrylic); backdrop-filter: var(--acrylic-filter); box-shadow: var(--shadow-sm); color: var(--text-primary); font-size: var(--text-base); }+.tag-editor__suggestion { display: flex; align-items: center; min-height: var(--control-md); padding: 0 var(--space-3); border-radius: var(--radius-sm); }+.tag-editor__suggestion--active { background: var(--fill-subtle-hover); }