AI media harness for planning, generating, and editing locally
TypeScript
Rebuild References as Icons/Details library with multi-select and menus
Bitti851a8a6799d6
diff --git a/src/components/workspace/ReferenceVideo.test.tsx b/src/components/workspace/ReferenceVideo.test.tsxindex cf9f7fa..d489016 100644--- a/src/components/workspace/ReferenceVideo.test.tsx+++ b/src/components/workspace/ReferenceVideo.test.tsx@@ -109,7 +109,7 @@ it("opens clip settings in a dialog and preserves edits after closing", async ()const reopened = await ready();expect(reopened.currentTime).toBe(105);expect(saved()).toMatchObject({ startSeconds: 105, durationSeconds: 15 });- fireEvent.click(screen.getByRole("button", { name: "Close video clip settings" }));+ fireEvent.click(screen.getByRole("button", { name: "Done" }));expect(screen.queryByRole("dialog")).not.toBeInTheDocument();});diff --git a/src/components/workspace/ReferenceVideo.tsx b/src/components/workspace/ReferenceVideo.tsxindex 8b894a5..d0850f0 100644--- a/src/components/workspace/ReferenceVideo.tsx+++ b/src/components/workspace/ReferenceVideo.tsx@@ -1,6 +1,6 @@-import { Pause, Play, Scissors, X } from "lucide-react";+import { Pause, Play, Scissors } from "lucide-react";import { useEffect, useRef, useState, type KeyboardEvent, type PointerEvent } from "react";-import { createPortal } from "react-dom";+import { ContentDialog } from "../ui";import { readMediaFileUrl } from "../../lib/persistence";import type { ProjectReference } from "../../lib/project";import { editReferenceVideoTrim, initialReferenceVideoTrim, normalizeReferenceVideoTrim, referenceTime, type ReferenceVideoTrim, type TrimAction } from "../../lib/referenceVideoTrim";@@ -16,36 +16,16 @@ export function ReferenceVideo(props: ReferenceVideoProps) {return <>{!open && <div className="reference-trim__summary"><strong>{referenceTime(start)} – {referenceTime(start + length)}</strong><span>{Number(length.toFixed(2))} s selected</span></div>}<button type="button" className="secondary-button" onClick={() => setOpen(true)}><Scissors size={16} /> Edit video clip</button>- {open && createPortal(<ReferenceVideoDialog {...props} onClose={() => setOpen(false)} />, document.body)}+ {open && <ReferenceVideoDialog {...props} onClose={() => setOpen(false)} />}</>;}+/** Clip settings in a ContentDialog: the preview is large, so it is a modal+ * rather than something squeezed into the inspector. */function ReferenceVideoDialog({ onClose, ...props }: ReferenceVideoProps & { onClose: () => void }) {- const dialog = useRef<HTMLDivElement>(null);- useEffect(() => {- const opener = document.activeElement as HTMLElement | null;- const workspace = document.querySelector<HTMLElement>(".references-view");- const wasInert = workspace?.inert ?? false;- if (workspace) workspace.inert = true;- dialog.current?.querySelector<HTMLButtonElement>("button")?.focus();- return () => {- if (workspace) workspace.inert = wasInert;- if (opener?.isConnected) opener.focus();- };- }, []);- return <div className="reference-video-dialog-overlay" onKeyDown={(event) => {- event.stopPropagation();- if (event.key === "Escape") { event.preventDefault(); onClose(); }- if (event.key !== "Tab") return;- const controls = Array.from(dialog.current?.querySelectorAll<HTMLElement>('button:not(:disabled), input:not(:disabled), video[controls]') ?? []);- if (event.shiftKey && document.activeElement === controls[0]) { event.preventDefault(); controls.at(-1)?.focus(); }- else if (!event.shiftKey && document.activeElement === controls.at(-1)) { event.preventDefault(); controls[0]?.focus(); }- }}>- <div ref={dialog} className="reference-video-dialog" role="dialog" aria-modal="true" aria-labelledby="reference-video-heading">- <header><h2 id="reference-video-heading">{props.reference.name} — Video clip</h2><button type="button" className="icon-button" aria-label="Close video clip settings" onClick={onClose}><X size={18} /></button></header>- <div className="reference-video"><ReferenceVideoEditor {...props} /></div>- </div>- </div>;+ return <ContentDialog title={`${props.reference.name} — Video clip`} closeText="Done" onClose={onClose} width={1100} className="reference-video-dialog">+ <div className="reference-video"><ReferenceVideoEditor {...props} /></div>+ </ContentDialog>;}function ReferenceVideoEditor({ folderPath, reference, onChange }: ReferenceVideoProps) {diff --git a/src/components/workspace/ReferencesView.builtins.test.tsx b/src/components/workspace/ReferencesView.builtins.test.tsxindex 6019e15..d465ccf 100644--- a/src/components/workspace/ReferencesView.builtins.test.tsx+++ b/src/components/workspace/ReferencesView.builtins.test.tsx@@ -1,6 +1,6 @@// @vitest-environment jsdomimport "@testing-library/jest-dom/vitest";-import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";+import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";import { invoke } from "@tauri-apps/api/core";import { afterEach, beforeEach, expect, it, vi } from "vitest";import { createProjectConfig } from "../../lib/project";@@ -49,11 +49,11 @@ it("generates a preset icon without selecting its card and supports regeneratingit("asks on the first Add reference visit, explains video priority, and remembers Start", async () => {const view = open();- expect(screen.queryByRole("alertdialog")).toBeNull();+ expect(screen.queryByRole("dialog", { name: /reference icons/ })).toBeNull();fireEvent.click(screen.getByRole("button", { name: /^Add a reference/ }));- const prompt = await screen.findByRole("alertdialog", { name: "Generate built-in reference icons?" });+ const prompt = await screen.findByRole("dialog", { name: "Generate built-in reference icons?" });expect(prompt).toHaveTextContent("take a long time");- expect(prompt).toHaveTextContent("pauses for normal video generation");+ expect(prompt).toHaveTextContent("pauses for video generation");expect(view.generate).not.toHaveBeenCalled();fireEvent.click(screen.getByRole("checkbox", { name: /Don't ask again/ }));fireEvent.click(screen.getByRole("button", { name: "Start generation" }));@@ -63,13 +63,13 @@ it("asks on the first Add reference visit, explains video priority, and rememberopen(view.generate);fireEvent.click(screen.getByRole("button", { name: /^Add a reference/ }));await waitFor(() => expect(view.generate).toHaveBeenCalledTimes(2));- expect(screen.queryByRole("alertdialog")).toBeNull();+ expect(screen.queryByRole("dialog", { name: /reference icons/ })).toBeNull();});it("remembers Cancel across sessions without starting generation", async () => {const view = open();fireEvent.click(screen.getByRole("button", { name: /^Add a reference/ }));- await screen.findByRole("alertdialog");+ await screen.findByRole("dialog");fireEvent.click(screen.getByRole("checkbox", { name: /Don't ask again/ }));fireEvent.click(screen.getByRole("button", { name: "Cancel" }));sessionStorage.clear();@@ -80,11 +80,11 @@ it("remembers Cancel across sessions without starting generation", async () => {it("does not ask again on another visit in the same session when Cancel is not remembered", async () => {open();fireEvent.click(screen.getByRole("button", { name: /^Add a reference/ }));- await screen.findByRole("alertdialog");+ await screen.findByRole("dialog");fireEvent.click(screen.getByRole("button", { name: "Cancel" }));- fireEvent.click(screen.getByRole("button", { name: "Close type picker" }));+ fireEvent.click(within(screen.getByRole("dialog", { name: "Add a reference" })).getByRole("button", { name: "Cancel" }));fireEvent.click(screen.getByRole("button", { name: /^Add a reference/ }));await waitFor(() => expect(invoke).toHaveBeenCalledWith("list_builtin_reference_icons"));- expect(screen.queryByRole("alertdialog")).toBeNull();+ expect(screen.queryByRole("dialog", { name: /reference icons/ })).toBeNull();expect(localStorage.getItem("slopus.builtin-reference-icons.v1")).toBeNull();});diff --git a/src/components/workspace/ReferencesView.test.tsx b/src/components/workspace/ReferencesView.test.tsxindex 93c572b..a130d47 100644--- a/src/components/workspace/ReferencesView.test.tsx+++ b/src/components/workspace/ReferencesView.test.tsx@@ -7,6 +7,7 @@ import { useState } from "react";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { createProjectConfig, parseProjectConfig, referenceImages, type ProjectConfig } from "../../lib/project";import { ReferencesView } from "./ReferencesView";+import { choose, chooseOption, comboValue } from "./comboTestUtils";import { referenceIconPrompt } from "../../lib/referenceIcons";import { saveDebugOptionsEnabled } from "../../lib/settings";import { REFERENCE_PRESETS } from "../../lib/reference-presets";@@ -77,9 +78,9 @@ describe("Reference type presets", () => {fireEvent.click(previous());expect(inspector.getByText("Image 1 of 3")).toBeInTheDocument();fireEvent.click(next());- fireEvent.click(screen.getByRole("button", { name: /Other 3 images/ }));+ fireEvent.click(screen.getByRole("option", { name: /Other 3 images/ }));expect(inspector.getByText("Image 1 of 3")).toBeInTheDocument();- fireEvent.click(screen.getByRole("button", { name: /Hero 3 images/ }));+ fireEvent.click(screen.getByRole("option", { name: /Hero 3 images/ }));fireEvent.click(next());remove();expect(inspector.getByText("Image 2 of 2")).toBeInTheDocument();@@ -115,28 +116,26 @@ describe("Reference type presets", () => {it("shows the exact icon regeneration prompt in a debug-only footer dialog", () => {const regenerate = vi.fn();const state = setup(project(), regenerate);- expect(screen.queryByRole("button", { name: "Debug Icon Prompt" })).not.toBeInTheDocument();+ expect(screen.queryByRole("button", { name: "Debug icon prompt" })).not.toBeInTheDocument();act(() => saveDebugOptionsEnabled(true));- const button = screen.getByRole("button", { name: "Debug Icon Prompt" });+ const button = screen.getByRole("button", { name: "Debug icon prompt" });expect(button.closest(".reference-inspector")?.lastElementChild).toBe(button.parentElement);button.focus();fireEvent.click(button);- const dialog = screen.getByRole("dialog", { name: "Debug Icon Prompt" });+ const dialog = screen.getByRole("dialog", { name: "Debug icon prompt" });expect(dialog.closest("aside")).toBeNull();- expect(within(dialog).getByLabelText("The reference icon generation prompt").textContent).toBe(referenceIconPrompt(state.latest().references[0]));- expect(within(dialog).getByRole("button", { name: "Close debug icon prompt" })).toHaveFocus();+ const prompt = within(dialog).getByLabelText("The reference icon generation prompt");+ expect(prompt.textContent).toBe(referenceIconPrompt(state.latest().references[0]));+ expect(prompt).toHaveFocus();expect(regenerate).not.toHaveBeenCalled();- fireEvent.keyDown(window, { key: "Tab" });- expect(within(dialog).getByLabelText("The reference icon generation prompt")).toHaveFocus();- fireEvent.keyDown(window, { key: "a", metaKey: true });+ fireEvent.keyDown(prompt, { key: "a", metaKey: true });expect(window.getSelection()?.toString()).toBe(referenceIconPrompt(state.latest().references[0]));- fireEvent.keyDown(window, { key: "Escape" });- expect(screen.queryByRole("dialog", { name: "Debug Icon Prompt" })).not.toBeInTheDocument();- expect(button).toHaveFocus();+ fireEvent.keyDown(prompt, { key: "Escape" });+ expect(screen.queryByRole("dialog", { name: "Debug icon prompt" })).not.toBeInTheDocument();fireEvent.click(button);act(() => saveDebugOptionsEnabled(false));- expect(screen.queryByRole("dialog", { name: "Debug Icon Prompt" })).not.toBeInTheDocument();- expect(screen.queryByRole("button", { name: "Debug Icon Prompt" })).not.toBeInTheDocument();+ expect(screen.queryByRole("dialog", { name: "Debug icon prompt" })).not.toBeInTheDocument();+ expect(screen.queryByRole("button", { name: "Debug icon prompt" })).not.toBeInTheDocument();});it("uses the selected reference's latest name, category, subcategory and description", () => {@@ -144,22 +143,22 @@ describe("Reference type presets", () => {const initial = project();initial.references.push({ ...initial.references[0], id: "ref-animal", name: "Pet", intendedUse: ["animal"], subcategory: "Pets", description: "A golden retriever." });const state = setup(initial);- fireEvent.click(screen.getByRole("button", { name: /Pet A golden retriever/ }));+ fireEvent.click(screen.getByRole("option", { name: /^Pet / }));fireEvent.change(screen.getByRole("textbox", { name: "Reference name" }), { target: { value: "Buddy" } });fireEvent.change(screen.getByRole("textbox", { name: "Prompt" }), { target: { value: "A sleepy golden retriever.\nSoft light." } });- fireEvent.click(screen.getByRole("button", { name: "Debug Icon Prompt" }));+ fireEvent.click(screen.getByRole("button", { name: "Debug icon prompt" }));const prompt = screen.getByLabelText("The reference icon generation prompt");expect(prompt.textContent).toBe(referenceIconPrompt(state.latest().references[1]));expect(prompt.textContent).toContain("animal with its whole body visible");expect(prompt.textContent).toContain("Subcategory: Pets");- fireEvent.click(screen.getByRole("button", { name: "Close debug icon prompt" }));- expect(screen.queryByRole("dialog", { name: "Debug Icon Prompt" })).not.toBeInTheDocument();+ fireEvent.click(within(screen.getByRole("dialog", { name: "Debug icon prompt" })).getByRole("button", { name: "Close" }));+ expect(screen.queryByRole("dialog", { name: "Debug icon prompt" })).not.toBeInTheDocument();});it("does not show icon debugging without a selected reference", () => {saveDebugOptionsEnabled(true);setup({ ...project(), references: [] });- expect(screen.queryByRole("button", { name: "Debug Icon Prompt" })).not.toBeInTheDocument();+ expect(screen.queryByRole("button", { name: "Debug icon prompt" })).not.toBeInTheDocument();});it("requests an icon refresh for the selected reference and disables duplicate requests", () => {@@ -182,11 +181,11 @@ describe("Reference type presets", () => {fireEvent.click(screen.getByRole("button", { name: /Add a reference/ }));const dialog = screen.getByRole("dialog", { name: "Add a reference" });fireEvent.click(within(dialog).getByRole("button", { name: "Animal" }));- fireEvent.click(within(dialog).getByRole("button", { name: "Pets" }));+ fireEvent.click(within(dialog).getByRole("tab", { name: "Pets" }));fireEvent.change(within(dialog).getByRole("textbox", { name: "Search reference options" }), { target: { value: "retriever" } });fireEvent.click(within(dialog).getByRole("button", { name: /Golden retriever/ }));expect(state.latest().references[0]).toMatchObject({ name: "Golden retriever", intendedUse: ["animal"], subcategory: "Pets", description: "Golden retriever." });- expect(screen.getByRole("combobox", { name: "Category" })).toHaveValue("animal");+ expect(comboValue(screen.getByRole("combobox", { name: "Category" }))).toBe("animal");expect(screen.getByRole("textbox", { name: "Prompt" })).toHaveValue("Golden retriever.");});@@ -201,12 +200,12 @@ describe("Reference type presets", () => {fireEvent.click(screen.getByRole("button", { name: /Add a reference/ }));const dialog = screen.getByRole("dialog", { name: "Add a reference" });fireEvent.click(within(dialog).getByRole("button", { name: label }));- fireEvent.click(within(dialog).getByRole("button", { name: subcategory }));+ fireEvent.click(within(dialog).getByRole("tab", { name: subcategory }));fireEvent.click(within(dialog).getByRole("button", { name: "New" }));expect(screen.queryByRole("dialog")).not.toBeInTheDocument();expect(state.latest().references).toHaveLength(2);expect(state.latest().references[0]).toMatchObject({ description: "", content: null, intendedUse: [category], subcategory });- expect(screen.getByRole("combobox", { name: "Subcategory" })).toHaveValue(subcategory);+ expect(comboValue(screen.getByRole("combobox", { name: "Subcategory" }))).toBe(subcategory);fireEvent.change(screen.getByRole("textbox", { name: "Reference name" }), { target: { value: "My reference" } });fireEvent.change(screen.getByRole("textbox", { name: "Prompt" }), { target: { value: "Keep the cool blue colors." } });const saved = parseProjectConfig(state.latest());@@ -214,12 +213,12 @@ describe("Reference type presets", () => {const restored = setup(saved);expect(screen.getByRole("textbox", { name: "Reference name" })).toHaveValue("My reference");expect(screen.getByRole("textbox", { name: "Prompt" })).toHaveValue("Keep the cool blue colors.");- expect(screen.getByRole("combobox", { name: "Category" })).toHaveValue(category);- expect(screen.getByRole("combobox", { name: "Subcategory" })).toHaveValue(subcategory);- fireEvent.change(screen.getByRole("combobox", { name: "Subcategory" }), { target: { value: "" } });+ expect(comboValue(screen.getByRole("combobox", { name: "Category" }))).toBe(category);+ expect(comboValue(screen.getByRole("combobox", { name: "Subcategory" }))).toBe(subcategory);+ choose("Subcategory", "None");expect(restored.latest().references[0].subcategory).toBe("");const nextCategory = category === "product" ? "style" : "product";- fireEvent.change(screen.getByRole("combobox", { name: "Category" }), { target: { value: nextCategory } });+ choose("Category", nextCategory === "style" ? "Style" : "Product");expect(restored.latest().references[0]).toMatchObject({ intendedUse: [nextCategory], subcategory: "", description: "Keep the cool blue colors." });});@@ -230,14 +229,14 @@ describe("Reference type presets", () => {expect(name).toHaveValue("Hero");expect(header).not.toBeNull();- expect(within(header!).getByRole("button", { name: "Remove reference" })).toHaveClass("inspector-remove-button");+ expect(within(header!).getByRole("button", { name: "Delete reference" })).toHaveClass("icon-button");fireEvent.change(name, { target: { value: "Lead traveler" } });expect(state.latest().references[0].name).toBe("Lead traveler");- expect(screen.getByRole("button", { name: /Lead traveler/ })).toBeInTheDocument();+ expect(screen.getByRole("option", { name: /Lead traveler/ })).toBeInTheDocument();});- it("opens the new-reference picker from the add card", () => {+ it("opens the new-reference picker from the command bar", () => {const state = setup();expect(screen.queryByRole("button", { name: "New definition" })).not.toBeInTheDocument();expect(screen.queryByRole("button", { name: "Add image" })).not.toBeInTheDocument();@@ -255,7 +254,7 @@ describe("Reference type presets", () => {it("keeps legacy uncategorized references editable", () => {setup();- expect(screen.getByRole("combobox", { name: "Category" })).toHaveValue("custom");+ expect(comboValue(screen.getByRole("combobox", { name: "Category" }))).toBe("custom");expect(screen.queryByRole("button", { name: "Choose preset" })).not.toBeInTheDocument();expect(screen.queryByText("Intended use")).not.toBeInTheDocument();expect(screen.queryByText(/Select any that apply/)).not.toBeInTheDocument();@@ -267,11 +266,11 @@ describe("Reference type presets", () => {fireEvent.click(screen.getByRole("button", { name: /Add a reference/ }));const dialog = screen.getByRole("dialog", { name: "Add a reference" });fireEvent.click(within(dialog).getByRole("button", { name: "Character" }));- const groups = within(dialog).getByRole("group", { name: "Character subcategories" });- expect(within(groups).getByRole("button", { name: "Film" })).toBeInTheDocument();- expect(within(groups).getByRole("button", { name: "Television" })).toBeInTheDocument();- expect(within(groups).getByRole("button", { name: "Public figures" })).toBeInTheDocument();- fireEvent.click(within(groups).getByRole("button", { name: "Television" }));+ const groups = within(dialog).getByRole("tablist", { name: "Character subcategories" });+ expect(within(groups).getByRole("tab", { name: "Film" })).toBeInTheDocument();+ expect(within(groups).getByRole("tab", { name: "Television" })).toBeInTheDocument();+ expect(within(groups).getByRole("tab", { name: "Public figures" })).toBeInTheDocument();+ fireEvent.click(within(groups).getByRole("tab", { name: "Television" }));expect(within(dialog).getByRole("button", { name: /Sherlock Holmes · Benedict Cumberbatch/ })).toBeInTheDocument();fireEvent.click(within(dialog).getByRole("button", { name: /Sherlock Holmes · Benedict Cumberbatch/ }));@@ -279,7 +278,7 @@ describe("Reference type presets", () => {expect(reference.intendedUse).toEqual(["character"]);expect(reference.description).toBe("Sherlock Holmes, Benedict Cumberbatch portrayal.");expect(screen.getByRole("textbox", { name: "Prompt" })).toHaveValue(reference.description);- expect(screen.getByRole("combobox", { name: "Subcategory" })).toHaveValue("Television");+ expect(comboValue(screen.getByRole("combobox", { name: "Subcategory" }))).toBe("Television");fireEvent.change(screen.getByRole("textbox", { name: "Prompt" }), { target: { value: "Sherlock in a blue coat." } });expect(state.latest().references[0]).toMatchObject({ intendedUse: ["character"], subcategory: "Television", description: "Sherlock in a blue coat." });});@@ -307,8 +306,8 @@ describe("Reference type presets", () => {fireEvent.click(screen.getByRole("button", { name: /Add a reference/ }));const dialog = screen.getByRole("dialog", { name: "Add a reference" });fireEvent.click(within(dialog).getByRole("button", { name: "Location" }));- const groups = within(dialog).getByRole("group", { name: "Location subcategories" });- fireEvent.click(within(groups).getByRole("button", { name: "Sci-fi" }));+ const groups = within(dialog).getByRole("tablist", { name: "Location subcategories" });+ fireEvent.click(within(groups).getByRole("tab", { name: "Sci-fi" }));fireEvent.change(within(dialog).getByRole("textbox", { name: "Search reference options" }), { target: { value: "lunar" } });expect(within(dialog).getByRole("button", { name: /Lunar base/ })).toBeInTheDocument();expect(within(dialog).queryByRole("button", { name: /Victorian manor/ })).not.toBeInTheDocument();@@ -317,8 +316,8 @@ describe("Reference type presets", () => {expect(screen.queryByRole("dialog")).not.toBeInTheDocument();const settings = screen.getByRole("region", { name: "Location settings" });expect(settings.closest("aside")).not.toBeNull();- fireEvent.change(within(settings).getByRole("combobox", { name: "Time of day" }), { target: { value: "night" } });- fireEvent.change(within(settings).getByRole("combobox", { name: "Season" }), { target: { value: "winter" } });+ chooseOption(within(settings).getByRole("combobox", { name: "Time of day" }), "Night");+ chooseOption(within(settings).getByRole("combobox", { name: "Season" }), "Winter");expect(state.latest().references[0]).toMatchObject({intendedUse: ["location"],@@ -342,18 +341,18 @@ describe("Reference type presets", () => {fireEvent.click(within(dialog).getByRole("button", { name: /Coastal village/ }));expect(screen.queryByRole("dialog")).not.toBeInTheDocument();expect(state.latest().references).toHaveLength(2);- expect(screen.getByRole("combobox", { name: "Weather" })).toHaveValue("");- fireEvent.change(screen.getByRole("combobox", { name: "Time of day" }), { target: { value: "night" } });- fireEvent.change(screen.getByRole("combobox", { name: "Weather" }), { target: { value: "rain" } });- fireEvent.change(screen.getByRole("combobox", { name: "Season" }), { target: { value: "winter" } });+ expect(comboValue(screen.getByRole("combobox", { name: "Weather" }))).toBe("");+ chooseOption(screen.getByRole("combobox", { name: "Time of day" }), "Night");+ chooseOption(screen.getByRole("combobox", { name: "Weather" }), "Rain");+ chooseOption(screen.getByRole("combobox", { name: "Season" }), "Winter");const saved = parseProjectConfig(state.latest());expect(saved.references[0].description).toBe("Coastal village, at night, in rain, in winter.");cleanup();const restored = setup(saved);- expect(screen.getByRole("combobox", { name: "Time of day" })).toHaveValue("night");- expect(screen.getByRole("combobox", { name: "Weather" })).toHaveValue("rain");- expect(screen.getByRole("combobox", { name: "Season" })).toHaveValue("winter");- fireEvent.change(screen.getByRole("combobox", { name: "Weather" }), { target: { value: "" } });+ expect(comboValue(screen.getByRole("combobox", { name: "Time of day" }))).toBe("night");+ expect(comboValue(screen.getByRole("combobox", { name: "Weather" }))).toBe("rain");+ expect(comboValue(screen.getByRole("combobox", { name: "Season" }))).toBe("winter");+ chooseOption(screen.getByRole("combobox", { name: "Weather" }), "None");expect(restored.latest().references[0]).toMatchObject({description: "Coastal village, at night, in winter.",content: "Coastal village, at night, in winter.",@@ -370,7 +369,7 @@ describe("Reference type presets", () => {fireEvent.click(within(newPicker).getByRole("button", { name: "Location" }));fireEvent.click(within(newPicker).getByRole("button", { name: /Coastal village/ }));expect(restored.latest().references[0].description).toBe("Coastal village.");- expect(screen.getByRole("combobox", { name: "Time of day" })).toHaveValue("");+ expect(comboValue(screen.getByRole("combobox", { name: "Time of day" }))).toBe("");});it("attaches multiple images to a new product without changing its category or prompt", async () => {@@ -402,3 +401,78 @@ describe("Reference type presets", () => {expect(state.latest().references[0]).not.toHaveProperty("relativePath");});});++describe("Reference library views and selection", () => {+ const three = () => {+ const initial = project();+ const base = initial.references[0];+ initial.references = [+ base,+ { ...base, id: "ref-cat", name: "Cat", intendedUse: ["animal"] },+ { ...base, id: "ref-lamp", name: "Lamp", intendedUse: ["product"] },+ ];+ initial.generationJobs[0].referenceIds = ["ref-lamp"];+ return initial;+ };++ it("switches to a sortable Details view and remembers the choice", () => {+ setup(three());+ fireEvent.click(screen.getByRole("button", { name: "Details" }));+ expect(localStorage.getItem("slopus.references.view")).toBe("details");+ const grid = screen.getByRole("grid", { name: "References" });+ const names = () => within(grid).getAllByRole("row").slice(1).map((row) => row.querySelector("td")?.textContent);+ expect(within(grid).getAllByRole("columnheader").map((header) => header.textContent)).toEqual(["Name", "Type", "Contents", "Used by"]);+ expect(names()).toEqual(["Cat", "Hero", "Lamp"]);+ fireEvent.click(within(grid).getByRole("button", { name: /Name/ }));+ expect(names()).toEqual(["Lamp", "Hero", "Cat"]);+ fireEvent.click(within(grid).getByRole("button", { name: /Used by/ }));+ expect(names()[2]).toBe("Lamp");+ expect(within(grid).getByText("1 scene")).toBeInTheDocument();+ });++ it("multi-selects with Ctrl and Shift and deletes the selection", () => {+ const state = setup(three());+ fireEvent.click(screen.getByRole("option", { name: /^Hero/ }));+ fireEvent.click(screen.getByRole("option", { name: /^Lamp/ }), { shiftKey: true });+ expect(screen.getAllByRole("option").filter((option) => option.getAttribute("aria-selected") === "true")).toHaveLength(3);+ fireEvent.click(screen.getByRole("option", { name: /^Cat/ }), { ctrlKey: true });+ expect(screen.getByRole("region", { name: "References status" })).toHaveTextContent("2 selected");+ // The inspector still edits one reference: the last one clicked.+ expect(screen.getByRole("textbox", { name: "Reference name" })).toHaveValue("Cat");+ const lamp = screen.getByRole("option", { name: /^Lamp/ });+ lamp.focus();+ fireEvent.keyDown(lamp, { key: "Delete" });+ expect(state.latest().references.map((reference) => reference.id)).toEqual(["ref-cat"]);+ expect(state.latest().generationJobs[0].referenceIds).toEqual([]);+ });++ it("moves through the library with the arrow keys and renames with F2", async () => {+ setup(three());+ const hero = screen.getByRole("option", { name: /^Hero/ });+ expect(hero).toHaveAttribute("tabindex", "0");+ expect(screen.getByRole("option", { name: /^Cat/ })).toHaveAttribute("tabindex", "-1");+ hero.focus();+ fireEvent.keyDown(hero, { key: "ArrowRight" });+ expect(screen.getByRole("option", { name: /^Cat/ })).toHaveAttribute("aria-selected", "true");+ fireEvent.keyDown(screen.getByRole("option", { name: /^Cat/ }), { key: "F2" });+ await waitFor(() => expect(screen.getByRole("textbox", { name: "Reference name" })).toHaveFocus());+ expect(screen.getByRole("textbox", { name: "Reference name" })).toHaveValue("Cat");+ });++ it("opens a reference menu that lists the scenes using it", () => {+ const open = vi.fn();+ const initial = three();+ render(<ReferencesView config={initial} folderPath="C:\project" onChange={vi.fn()} onOpenGenerator={open} />);+ fireEvent.contextMenu(screen.getByRole("option", { name: /^Lamp/ }));+ const menu = screen.getByRole("menu", { name: "Lamp actions" });+ expect(within(menu).getByRole("menuitem", { name: /Show in File Explorer/ })).toBeDisabled();+ fireEvent.click(within(menu).getByRole("menuitem", { name: `Open ${initial.generationJobs[0].title}` }));+ expect(open).toHaveBeenCalledWith(initial.generationJobs[0].id);+ });++ it("says so in one line when nothing is selected", () => {+ setup({ ...project(), references: [] });+ expect(screen.getByText("Select a reference to see its details.")).toBeInTheDocument();+ expect(screen.getByText("No references yet.")).toBeInTheDocument();+ });+});diff --git a/src/components/workspace/ReferencesView.tsx b/src/components/workspace/ReferencesView.tsxindex 7d1c6ec..3c4b5b2 100644--- a/src/components/workspace/ReferencesView.tsx+++ b/src/components/workspace/ReferencesView.tsx@@ -1,7 +1,7 @@-import { BookOpen, ChevronLeft, ChevronRight, FileText, ImagePlus, Plus, RefreshCw, Search, Trash2, Users, X } from "lucide-react";+import { ArrowDown, ArrowUp, ChevronLeft, ChevronRight, ExternalLink, FileText, FolderOpen, ImagePlus, LayoutGrid, List, Pencil, Plus, RefreshCw, Search, Trash2 } from "lucide-react";import { invoke } from "@tauri-apps/api/core";-import { useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";-import { isReferenceDescribed, referenceImages, type ProjectConfig, type ProjectReference, type ProjectReferenceImage } from "../../lib/project";+import { useEffect, useId, useMemo, useRef, useState, useSyncExternalStore, type KeyboardEvent, type MouseEvent } from "react";+import { isReferenceDescribed, projectItemPath, referenceImages, type ProjectConfig, type ProjectReference, type ProjectReferenceImage } from "../../lib/project";import { activeReferenceRefmods } from "../../lib/project";import {composeLocationPrompt,@@ -19,6 +19,8 @@ import {} from "../../lib/reference-presets";import { LOCATION_SETTING_GROUPS } from "../../lib/expanded-reference-options";import { isTauri } from "../../lib/persistence";+import { useShortcut } from "../../lib/commands";+import { revealInExplorer } from "../../lib/nativeShell";import { ReferenceImage } from "./ReferenceImage";import { PresetIcon } from "./PresetIcon";import { ReferenceIconGenerationDialog } from "../ReferenceIconGenerationDialog";@@ -30,6 +32,11 @@ import { inspectReferenceVideo } from "../../lib/referenceVideo";import { DebugPromptDialog } from "./DebugPromptDialog";import { referenceIconPrompt } from "../../lib/referenceIcons";import { loadDebugOptionsEnabled, subscribeDebugOptions } from "../../lib/settings";+import {+ CommandBar, CommandBarButton, CommandBarSeparator, ComboBox, ContentDialog, InfoBar, PropRow, SelectorBar, Splitter, StatusBar,+ tooltipProps, useContextMenu, usePaneSize, type MenuEntry,+} from "../ui";+import { isMenuKey } from "./SceneBoard";const PICKER_TYPES: ReadonlyArray<{ id: ReferenceType; label: string }> = [...REFERENCE_TYPES, { id: "custom", label: "Other" },@@ -46,6 +53,22 @@ const referenceKindLabel = (reference: ProjectReference) => {return `${count} image${count === 1 ? "" : "s"}${isReferenceDescribed(reference) ? " + text" : ""}`;};+/** The file a reference is made of, for "Show in File Explorer". */+const referenceFile = (folderPath: string, reference: ProjectReference): string | null => {+ const image = referenceImages(reference)[0];+ if (reference.kind === "video") return projectItemPath(folderPath, reference);+ if (image) return projectItemPath(folderPath, image);+ const refmod = reference.refmods?.[0];+ return refmod ? projectItemPath(folderPath, refmod) : null;+};++type LibraryView = "icons" | "details";+type SortKey = "name" | "type" | "contents" | "usedBy";+const VIEW_KEY = "slopus.references.view";+const readView = (): LibraryView => {+ try { return localStorage.getItem(VIEW_KEY) === "details" ? "details" : "icons"; } catch { return "icons"; }+};+export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon, onGenerateBuiltinIcons, onRegenerateBuiltinIcon, pendingBuiltinIconIds = new Set<string>(), pendingIconIds = new Set<string>(), onOpenGenerator }: {config: ProjectConfig;folderPath: string;@@ -58,6 +81,11 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,onOpenGenerator?: (jobId: string) => void;}) {const [selectedId, setSelectedId] = useState<string | undefined>(config.references[0]?.id);+ /* Ctrl/Shift multi-select. `selectedId` stays the one reference the+ inspector edits (the last one clicked); `selectedIds` is what Delete acts+ on. A plain click makes them the same single reference again. */+ const [selectedIds, setSelectedIds] = useState<ReadonlySet<string>>(() => new Set(config.references[0] ? [config.references[0].id] : []));+ const anchorId = useRef<string | undefined>(selectedId);const [imagePage, setImagePage] = useState(0);useEffect(() => setImagePage(0), [selectedId]);const configRef = useRef(config);@@ -79,6 +107,15 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,const [pickerType, setPickerType] = useState<ReferenceType>("character");const [pickerSubcategory, setPickerSubcategory] = useState("all");const [presetSearch, setPresetSearch] = useState("");+ const [view, setView] = useState<LibraryView>(readView);+ const [sort, setSort] = useState<{ key: SortKey; descending: boolean }>({ key: "name", descending: false });+ const inspectorPane = usePaneSize("references.inspector", 380, { min: 280, max: 640 });+ const root = useRef<HTMLDivElement>(null);+ const library = useRef<HTMLDivElement>(null);+ const nameInput = useRef<HTMLInputElement>(null);+ const menu = useContextMenu();+ const inspectorTitleId = useId();+const selected = config.references.find((ref) => ref.id === selectedId);const selectedImages = selected ? referenceImages(selected) : [];const currentImagePage = Math.min(imagePage, Math.max(0, selectedImages.length - 1));@@ -93,11 +130,65 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,? locationSelectionFromPrompt(selected.description): undefined, [selected]);const selectedPresetIcon = selectedImages.length === 0 && hasPresetIcon(selectedPreset) ? selectedPreset : undefined;- const jobs = useMemo(() => config.generationJobs.filter((job) => job.referenceIds.includes(selectedId ?? "")), [config.generationJobs, selectedId]);+ const usedBy = (id: string | undefined) => config.generationJobs.filter((job) => job.referenceIds.includes(id ?? ""));+ const jobs = useMemo(() => usedBy(selectedId), [config.generationJobs, selectedId]);+ const selection = [...selectedIds].filter((id) => config.references.some((reference) => reference.id === id));++ /* Details view order. Icons keep the project's own order. */+ const ordered = useMemo(() => {+ if (view !== "details") return config.references;+ const value = (reference: ProjectReference): string | number => {+ switch (sort.key) {+ case "name": return reference.name.toLocaleLowerCase();+ case "type": return referenceTypeLabel(referenceType(reference)).toLocaleLowerCase();+ case "contents": return referenceKindLabel(reference).toLocaleLowerCase();+ case "usedBy": return config.generationJobs.filter((job) => job.referenceIds.includes(reference.id)).length;+ }+ };+ const sorted = [...config.references].sort((a, b) => {+ const left = value(a);+ const right = value(b);+ return typeof left === "number" && typeof right === "number" ? left - right : String(left).localeCompare(String(right));+ });+ return sort.descending ? sorted.reverse() : sorted;+ }, [config.references, config.generationJobs, view, sort]);+const update = (id: string, patch: Partial<ProjectReference>) => {const current = configRef.current;onChange({ ...current, references: current.references.map((ref) => ref.id === id ? { ...ref, ...patch } : ref) });};+ const selectOnly = (id: string | undefined) => {+ setSelectedId(id);+ setSelectedIds(new Set(id ? [id] : []));+ anchorId.current = id;+ };+ /* Windows list selection: click selects one, Ctrl+click toggles, Shift+click+ selects the range from the anchor (Ctrl+Shift adds the range). */+ const pick = (id: string, event: { ctrlKey: boolean; metaKey: boolean; shiftKey: boolean }) => {+ const toggle = event.ctrlKey || event.metaKey;+ if (event.shiftKey && anchorId.current) {+ const ids = ordered.map((reference) => reference.id);+ const from = ids.indexOf(anchorId.current);+ const to = ids.indexOf(id);+ if (from >= 0 && to >= 0) {+ const range = ids.slice(Math.min(from, to), Math.max(from, to) + 1);+ setSelectedIds((current) => new Set(toggle ? [...current, ...range] : range));+ setSelectedId(id);+ return;+ }+ }+ if (toggle) {+ setSelectedIds((current) => {+ const next = new Set(current);+ if (next.has(id) && next.size > 1) next.delete(id); else next.add(id);+ return next;+ });+ setSelectedId(id);+ anchorId.current = id;+ return;+ }+ selectOnly(id);+ };const removeImage = () => {if (!selected || !selectedImage) return;const current = configRef.current.references.find((ref) => ref.id === selected.id);@@ -117,7 +208,7 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,const id = `ref-${crypto.randomUUID()}`;const reference: ProjectReference = { id, kind: "text", name, description, content: description || null, intendedUse: type === "custom" ? [] : [type], subcategory, createdAt: new Date().toISOString() };onChange({ ...config, references: [reference, ...config.references] });- setSelectedId(id);+ selectOnly(id);return id;};const openNewReference = () => {@@ -135,18 +226,31 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,else if (action === "generate") onGenerateBuiltinIcons();}).catch((reason) => setIconError(String(reason)));};- const remove = () => {- if (!selected) return;- onChange({ ...config, ...(config.imageScene ? { imageScene: { ...config.imageScene, referenceIds: config.imageScene.referenceIds.filter((id) => id !== selected.id) } } : {}), references: config.references.filter((ref) => ref.id !== selected.id), generationJobs: config.generationJobs.map((job) => ({- ...job,- referenceIds: job.referenceIds.filter((id) => id !== selected.id),- startFrameReferenceId: job.startFrameReferenceId === selected.id ? undefined : job.startFrameReferenceId,- endFrameReferenceId: job.endFrameReferenceId === selected.id ? undefined : job.endFrameReferenceId,- })) });- setSelectedId(config.references.find((ref) => ref.id !== selected.id)?.id);+ /** Delete references (the selection by default) and every place that points+ * at them: scene bindings, start/end frames and the image scene. */+ const remove = (ids: readonly string[] = selection.length ? selection : selected ? [selected.id] : []) => {+ if (!ids.length) return;+ const gone = new Set(ids);+ const current = configRef.current;+ onChange({+ ...current,+ ...(current.imageScene ? { imageScene: { ...current.imageScene, referenceIds: current.imageScene.referenceIds.filter((id) => !gone.has(id)) } } : {}),+ references: current.references.filter((ref) => !gone.has(ref.id)),+ generationJobs: current.generationJobs.map((job) => ({+ ...job,+ referenceIds: job.referenceIds.filter((id) => !gone.has(id)),+ startFrameReferenceId: job.startFrameReferenceId && gone.has(job.startFrameReferenceId) ? undefined : job.startFrameReferenceId,+ endFrameReferenceId: job.endFrameReferenceId && gone.has(job.endFrameReferenceId) ? undefined : job.endFrameReferenceId,+ })),+ });+ const list = ordered.map((reference) => reference.id);+ const at = Math.min(...ids.map((id) => list.indexOf(id)).filter((index) => index >= 0));+ const remaining = list.filter((id) => !gone.has(id));+ selectOnly(remaining[Math.min(Number.isFinite(at) ? at : 0, remaining.length - 1)]);};- const addFiles = async () => {- if (!selected || hasRefmods || importingFiles) return;+ const addFiles = async (id = selected?.id) => {+ const chosen = configRef.current.references.find((reference) => reference.id === id);+ if (!chosen || chosen.refmods?.length || importingFiles) return;setImportError(null);if (!isTauri()) { setImportError("File import is available in the desktop app."); return; }setImportingFiles(true);@@ -156,7 +260,7 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,const clip = files.find((file) => file.kind === "video");const video = clip ? { startSeconds: 0, ...await inspectReferenceVideo(folderPath, clip.sourcePath!) } : undefined;const current = configRef.current;- const target = current.references.find((reference) => reference.id === selected.id);+ const target = current.references.find((reference) => reference.id === chosen.id);if (!target) throw new Error("The reference was removed while the files were importing.");if (target.refmods?.length) throw new Error("Remove the refmods before adding more files.");const images: ProjectReferenceImage[] = files.filter((file) => file.kind === "image").map((file) => ({@@ -184,6 +288,7 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,addTextReference(preset.name, prompt, preset.type, preset.subcategory);setPresetDialog(false);};+ const closePicker = () => { catalogVisit.current += 1; setPresetDialog(false); };const visiblePresets = REFERENCE_PRESETS.filter((preset) => {if (preset.type !== pickerType) return false;if (pickerSubcategory !== "all" && preset.subcategory !== pickerSubcategory) return false;@@ -192,69 +297,216 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,});const subcategories = referenceSubcategories(pickerType);- return <div className="references-view">+ const rename = (id?: string) => {+ if (id) selectOnly(id);+ requestAnimationFrame(() => { nameInput.current?.focus(); nameInput.current?.select(); });+ };+ const chooseView = (next: LibraryView) => {+ setView(next);+ try { localStorage.setItem(VIEW_KEY, next); } catch { /* storage unavailable */ }+ };+ const focusItem = (id: string) => requestAnimationFrame(() =>+ library.current?.querySelector<HTMLElement>(`[data-reference-id="${CSS.escape(id)}"]`)?.focus());++ /* --- Keyboard: F2 renames, Delete deletes the selection, Ctrl+A selects the+ whole library. Scoped to this screen and ignored while typing. */+ useShortcut("F2", () => { if (!selected) return false; rename(); }, { scope: root, enabled: Boolean(selected) });+ useShortcut("Delete", () => { if (!selection.length) return false; remove(); }, { scope: root, enabled: selection.length > 0 });+ useShortcut("Ctrl+A", () => { setSelectedIds(new Set(config.references.map((reference) => reference.id))); }, { scope: library, enabled: config.references.length > 0 });++ /* Arrow keys move the focus and the selection through the library (one Tab+ stop — the roving tabindex); Shift+arrows extend it. The icon grid's Up+ and Down pick the nearest tile in the next row. */+ const libraryKeys = (event: KeyboardEvent<HTMLElement>, id: string) => {+ if (isMenuKey(event)) {+ event.preventDefault();+ openMenu(event, id);+ return;+ }+ if (event.key === " " && (event.ctrlKey || event.metaKey)) {+ event.preventDefault();+ pick(id, { ctrlKey: true, metaKey: false, shiftKey: false });+ return;+ }+ const ids = ordered.map((reference) => reference.id);+ const at = ids.indexOf(id);+ let next = -1;+ if (event.key === "Home") next = 0;+ else if (event.key === "End") next = ids.length - 1;+ else if (view === "icons" && (event.key === "ArrowLeft" || event.key === "ArrowRight")) next = at + (event.key === "ArrowRight" ? 1 : -1);+ else if (event.key === "ArrowUp" || event.key === "ArrowDown") {+ const down = event.key === "ArrowDown";+ next = at + (down ? 1 : -1);+ if (view === "icons") {+ const tiles = [...(library.current?.querySelectorAll<HTMLElement>("[data-reference-id]") ?? [])];+ const here = tiles[at]?.getBoundingClientRect();+ if (here && here.width > 0) {+ const row = tiles.map((tile, index) => ({ index, box: tile.getBoundingClientRect() }))+ .filter(({ box }) => (down ? box.top > here.top + 1 : box.top < here.top - 1));+ if (row.length) {+ const edge = down ? Math.min(...row.map(({ box }) => box.top)) : Math.max(...row.map(({ box }) => box.top));+ next = row.filter(({ box }) => box.top === edge)+ .reduce((best, candidate) => Math.abs(candidate.box.left - here.left) < Math.abs(best.box.left - here.left) ? candidate : best).index;+ } else next = at;+ }+ }+ } else return;+ event.preventDefault();+ if (next < 0 || next >= ids.length || next === at) return;+ pick(ids[next], { ctrlKey: false, metaKey: false, shiftKey: event.shiftKey });+ focusItem(ids[next]);+ };++ const referenceMenu = (reference: ProjectReference): MenuEntry[] => {+ const users = usedBy(reference.id);+ const file = referenceFile(folderPath, reference);+ const many = selection.length > 1 && selection.includes(reference.id);+ return [+ { id: "rename", label: "Rename", icon: <Pencil size={16} />, shortcut: "F2", disabled: many, onSelect: () => rename(reference.id) },+ { id: "add-file", label: "Add file…", icon: <ImagePlus size={16} />, disabled: many || Boolean(reference.refmods?.length) || importingFiles, onSelect: () => { selectOnly(reference.id); void addFiles(reference.id); } },+ { id: "reveal", label: "Show in File Explorer", icon: <FolderOpen size={16} />, disabled: many || !file || !isTauri(), onSelect: () => { if (file) void revealInExplorer(file).catch((reason) => setImportError(String(reason))); } },+ { separator: true },+ ...(users.length+ ? users.map((job): MenuEntry => ({ id: `open-${job.id}`, label: `Open ${job.title}`, icon: <ExternalLink size={16} />, disabled: !onOpenGenerator, onSelect: () => onOpenGenerator?.(job.id) }))+ : [{ id: "unused", label: "Not used by any scene", disabled: true, onSelect: () => undefined } as MenuEntry]),+ { separator: true },+ { id: "delete", label: many ? `Delete ${selection.length} references` : "Delete", icon: <Trash2 size={16} />, shortcut: "Delete", danger: true, onSelect: () => remove(many ? selection : [reference.id]) },+ ];+ };+ const openMenu = (source: MouseEvent | KeyboardEvent, id: string) => {+ if (!selectedIds.has(id)) selectOnly(id);+ else setSelectedId(id);+ const reference = config.references.find((item) => item.id === id);+ if (reference) menu.open(source, referenceMenu(reference), { "aria-label": `${reference.name} actions` });+ };++ const art = (ref: ProjectReference) => {+ const images = referenceImages(ref);+ const cover = images[0];+ const matchedPreset = selectedReferencePreset(ref);+ const presetIcon = hasPresetIcon(matchedPreset) ? matchedPreset : undefined;+ return ref.kind === "video"+ ? <span className="reference-art reference-art--photo"><MediaThumbnail+ key={JSON.stringify([folderPath, ref.sourcePath, ref.relativePath])}+ folderPath={folderPath}+ asset={{ id: ref.id, kind: "video", name: ref.name, sourcePath: ref.sourcePath, relativePath: ref.relativePath, mimeType: "video/mp4", createdAt: ref.createdAt }}+ posterTimeSeconds={0}+ /></span>+ : ref.refmods?.length && ref.iconRelativePath+ ? <span className="reference-art reference-art--photo"><ReferenceImage folderPath={folderPath} relativePath={ref.iconRelativePath} alt={`${ref.name} icon`} /></span>+ : cover+ ? <span className="reference-art reference-art--photo"><ReferenceImage folderPath={folderPath} relativePath={cover.relativePath} sourcePath={cover.sourcePath} alt={cover.name} /></span>+ : ref.iconRelativePath+ ? <span className="reference-art reference-art--photo"><ReferenceImage folderPath={folderPath} relativePath={ref.iconRelativePath} alt={`${ref.name} icon`} /></span>+ : presetIcon+ ? <span className="reference-art reference-art--photo"><PresetIcon preset={presetIcon} /></span>+ : <span className="reference-art reference-art--text"><FileText size={24} aria-hidden="true" /></span>;+ };++ const rovingId = selectedId && ordered.some((reference) => reference.id === selectedId) ? selectedId : ordered[0]?.id;+ const itemProps = (ref: ProjectReference) => ({+ "data-reference-id": ref.id,+ tabIndex: ref.id === rovingId ? 0 : -1,+ "aria-selected": selectedIds.has(ref.id),+ onClick: (event: MouseEvent) => pick(ref.id, event),+ onContextMenu: (event: MouseEvent) => openMenu(event, ref.id),+ onKeyDown: (event: KeyboardEvent<HTMLElement>) => libraryKeys(event, ref.id),+ });+ const sortHeader = (key: SortKey, label: string) => {+ const active = sort.key === key;+ return <th scope="col" aria-sort={active ? (sort.descending ? "descending" : "ascending") : "none"}>+ <button type="button" onClick={() => setSort((current) => ({ key, descending: current.key === key ? !current.descending : false }))}>+ {label}{active && (sort.descending ? <ArrowDown size={12} aria-hidden="true" /> : <ArrowUp size={12} aria-hidden="true" />)}+ </button>+ </th>;+ };++ return <div ref={root} className="references-view" style={inspectorPane.style}><main className="references-main">- <header className="references-heading">- <div className="references-heading__title">- <h1>References</h1>- <p>{config.references.length === 1 ? "1 reference" : `${config.references.length} references`}</p>- </div>- </header>- <section className="reference-library" aria-labelledby="reference-library-heading">- {/* Both regions used to start at h3, so the outline jumped h1 → h3. */}+ <CommandBar+ aria-label="References"+ className="references-command"+ end={<>+ <CommandBarButton icon={<LayoutGrid size={16} />} label="Icons" pressed={view === "icons"} onClick={() => chooseView("icons")} />+ <CommandBarButton icon={<List size={16} />} label="Details" pressed={view === "details"} onClick={() => chooseView("details")} />+ </>}+ >+ <CommandBarButton icon={<Plus size={16} />} label="Add a reference" tooltip="Add reference" showLabel onClick={openNewReference} />+ <CommandBarSeparator />+ <CommandBarButton icon={<ImagePlus size={16} />} label="Add file" showLabel disabled={!selected || importingFiles || hasRefmods || selection.length > 1} onClick={() => void addFiles()} />+ <CommandBarButton icon={<Trash2 size={16} />} label="Delete" shortcut="Delete" disabled={!selection.length} onClick={() => remove()} />+ </CommandBar>+ {importError && <InfoBar severity="error" title="Couldn’t add reference" message={importError} onClose={() => setImportError(null)} />}+ {iconError && <InfoBar severity="error" title="Couldn’t regenerate icon" message={iconError} onClose={() => setIconError(null)} />}+ <section ref={library} className="reference-library" aria-labelledby="reference-library-heading"><h2 className="sr-only" id="reference-library-heading">Reference library</h2>- <div className="reference-grid">- {config.references.map((ref) => {- const images = referenceImages(ref);- const cover = images[0];- const matchedPreset = selectedReferencePreset(ref);- const presetIcon = hasPresetIcon(matchedPreset) ? matchedPreset : undefined;- return <button key={ref.id} className={selectedId === ref.id ? "selected" : ""} onClick={() => setSelectedId(ref.id)}>- {ref.kind === "video"- ? <span className="reference-art reference-art--photo"><MediaThumbnail- key={JSON.stringify([folderPath, ref.sourcePath, ref.relativePath])}- folderPath={folderPath}- asset={{ id: ref.id, kind: "video", name: ref.name, sourcePath: ref.sourcePath, relativePath: ref.relativePath, mimeType: "video/mp4", createdAt: ref.createdAt }}- posterTimeSeconds={0}- /></span>- : ref.refmods?.length && ref.iconRelativePath- ? <span className="reference-art reference-art--photo"><ReferenceImage folderPath={folderPath} relativePath={ref.iconRelativePath} alt={`${ref.name} icon`} /></span>- : cover- ? <span className="reference-art reference-art--photo"><ReferenceImage folderPath={folderPath} relativePath={cover.relativePath} sourcePath={cover.sourcePath} alt={cover.name} /></span>- : ref.iconRelativePath- ? <span className="reference-art reference-art--photo"><ReferenceImage folderPath={folderPath} relativePath={ref.iconRelativePath} alt={`${ref.name} icon`} /></span>- : presetIcon- ? <span className="reference-art reference-art--photo"><PresetIcon preset={presetIcon} /></span>- : <span className="reference-copy-art"><FileText size={26} /></span>}- <span className="reference-card__body"><span><b>{ref.name}</b>{(images.length > 0 || ref.refmods?.length || ref.kind === "video" || ref.kind === "audio") && <small>{referenceKindLabel(ref)}</small>}</span>{isReferenceDescribed(ref)- ? <p>{ref.description}</p>- : <p className="reference-card__incomplete">{ref.refmods?.length ? "Pre-encoded reference." : ref.kind === "video" ? "The clip is sent as a reference. Add a prompt to describe what to keep." : images.length > 0- ? "Not described yet — the picture is sent, but nothing tells the engine what to keep."- : "Not described yet — it won’t be used until you add a definition."}</p>}<span className="use-tags"><i>{referenceTypeLabel(referenceType(ref))}</i></span></span>- </button>;- })}- <button className="reference-add-card" onClick={openNewReference}><span><Plus size={22} /></span><b>Add a reference</b><small>Add images, video, or a definition</small></button>- </div>+ {config.references.length === 0+ ? <p className="reference-library__empty">No references yet.</p>+ : view === "icons"+ ? <div className="reference-grid" role="listbox" aria-label="References" aria-multiselectable="true" aria-orientation="horizontal">+ {ordered.map((ref) => <div+ key={ref.id}+ role="option"+ className={`reference-tile${selectedIds.has(ref.id) ? " reference-tile--selected" : ""}`}+ aria-label={`${ref.name} ${referenceKindLabel(ref)}`}+ data-tooltip={isReferenceDescribed(ref) ? ref.description : `${ref.name} · not described yet`}+ {...itemProps(ref)}+ >+ {art(ref)}+ <span className="reference-tile__name">{ref.name}</span>+ </div>)}+ </div>+ : <div className="reference-details">+ <table role="grid" aria-label="References" aria-multiselectable="true">+ <thead>+ <tr>+ {sortHeader("name", "Name")}+ {sortHeader("type", "Type")}+ {sortHeader("contents", "Contents")}+ {sortHeader("usedBy", "Used by")}+ </tr>+ </thead>+ <tbody>+ {ordered.map((ref) => {+ const users = usedBy(ref.id).length;+ return <tr key={ref.id} className={selectedIds.has(ref.id) ? "reference-row--selected" : undefined} aria-label={`${ref.name} ${referenceKindLabel(ref)}`} {...itemProps(ref)}>+ <td><span className="reference-row__name"><span className="reference-row__icon" aria-hidden="true">{referenceImages(ref).length || ref.kind === "video" ? <ImagePlus size={14} /> : <FileText size={14} />}</span><span>{ref.name}</span></span></td>+ <td>{referenceTypeLabel(referenceType(ref))}</td>+ <td>{referenceKindLabel(ref)}</td>+ <td>{users === 0 ? "—" : users === 1 ? "1 scene" : `${users} scenes`}</td>+ </tr>;+ })}+ </tbody>+ </table>+ </div>}</section>+ <StatusBar aria-label="References status" className="references-status">+ <span>{config.references.length === 1 ? "1 reference" : `${config.references.length} references`}</span>+ {selection.length > 1 && <span>{selection.length} selected</span>}+ </StatusBar>+ {menu.element}</main>- <aside className="reference-inspector">- <header className="reference-inspector__head">{selected ? <>+ <Splitter {...inspectorPane.splitterProps} reverse aria-label="Resize inspector" aria-controls="reference-inspector" />++ <aside id="reference-inspector" className="reference-inspector" aria-labelledby={selected ? undefined : inspectorTitleId} aria-label={selected ? `Reference: ${selected.name}` : undefined}>+ {selected ? <header className="reference-inspector__head"><h2><input- className="reference-title__name"+ ref={nameInput}+ className="panel-title__name reference-title__name"value={selected.name}aria-label="Reference name"- title="Rename this reference"+ aria-keyshortcuts="F2"onChange={(event) => update(selected.id, { name: event.target.value || "Untitled reference" })}/></h2>- <button className="inspector-remove-button" onClick={remove} aria-label="Remove reference" title="Remove this reference"><Trash2 size={16} aria-hidden="true" /></button>- </> : <h2>Reference details</h2>}</header>+ <button className="icon-button" onClick={() => remove([selected.id])} aria-label="Delete reference" {...tooltipProps("Delete reference", "Delete")}><Trash2 size={16} aria-hidden="true" /></button>+ </header> : <header className="reference-inspector__head"><h2 id={inspectorTitleId} className="reference-inspector__title">Details</h2></header>}<div className="reference-inspector__scroll">{selected ? <>{selected.kind === "video" && <section className="reference-video" aria-label="Video reference"><ReferenceVideo key={`${selected.id}:${selected.sourcePath ?? selected.relativePath}`} folderPath={folderPath} reference={selected}onChange={(video) => update(selected.id, { video })} />- <button className="secondary-button" onClick={() => update(selected.id, { kind: "text", sourcePath: null, relativePath: null, video: undefined })}><Trash2 size={16} /> Remove video</button>+ <button className="secondary-button" onClick={() => update(selected.id, { kind: "text", sourcePath: null, relativePath: null, video: undefined })}><Trash2 size={16} aria-hidden="true" /> Remove video</button></section>}{(selected.kind !== "video" || showImages || hasRefmods) && <div className={`reference-detail-art${showImages || selected.iconRelativePath || (!hasRefmods && selectedPresetIcon) ? " reference-detail-art--photo" : " reference-detail-art--text"}${showImages ? " reference-detail-art--images" : (!hasRefmods && selectedPresetIcon) || selected.iconRelativePath ? " reference-detail-art--preset" : ""}`}>{showImages@@ -263,17 +515,15 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,? <ReferenceImage className="reference-detail-preset-icon" folderPath={folderPath} relativePath={selected.iconRelativePath} alt={`${selected.name} reference icon`} />: !hasRefmods && selectedPresetIcon? <PresetIcon className="reference-detail-preset-icon" preset={selectedPresetIcon} alt={`${selected.name} reference icon`} />- : <span><Users size={30} /></span>}- {/* A caption only where there is no picture to look at. It used- to print the file's path over the thumbnail, which is neither- what the reference IS nor anything the user acts on. */}+ : <span><FileText size={16} aria-hidden="true" /></span>}+ {/* A caption only where there is no picture to look at. */}{!showImages && !selected.iconRelativePath && (hasRefmods || !selectedPresetIcon) && <em>{referenceKindLabel(selected)}</em>}- {showImages && <button type="button" className="reference-image-remove" aria-label="Remove reference image" title={`Remove ${selectedImage.name}`} onClick={removeImage}><Trash2 size={14} aria-hidden="true" /></button>}+ {showImages && <button type="button" className="reference-image-remove" aria-label="Remove reference image" {...tooltipProps(`Remove ${selectedImage.name}`)} onClick={removeImage}><Trash2 size={14} aria-hidden="true" /></button>}{!showImages && onRegenerateIcon && <buttontype="button"className="reference-icon-refresh"aria-label="Regenerate reference icon"- title={pendingIconIds.has(selected.id) ? "Icon generation queued or running" : canGenerateIcon ? "Regenerate reference icon" : hasRefmods ? "Enable a refmod to generate an icon" : "Add a prompt to generate an icon"}+ data-tooltip={pendingIconIds.has(selected.id) ? "Icon generation queued or running" : canGenerateIcon ? "Regenerate reference icon" : hasRefmods ? "Enable a refmod to generate an icon" : "Add a prompt to generate an icon"}disabled={!canGenerateIcon || pendingIconIds.has(selected.id)}onClick={() => {setIconError(null);@@ -283,69 +533,79 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,><RefreshCw size={14} aria-hidden="true" /></button>}</div>}{showImages && <div className="reference-image-controls" role="group" aria-label="Reference images">- <button type="button" className="secondary-button" aria-label="Previous reference image" title="Previous image" disabled={currentImagePage === 0} onClick={() => setImagePage(currentImagePage - 1)}><ChevronLeft size={16} aria-hidden="true" /></button>+ <button type="button" className="icon-button" aria-label="Previous reference image" data-tooltip="Previous image" disabled={currentImagePage === 0} onClick={() => setImagePage(currentImagePage - 1)}><ChevronLeft size={16} aria-hidden="true" /></button><span aria-live="polite">Image {currentImagePage + 1} of {selectedImages.length}</span>- <button type="button" className="secondary-button" aria-label="Next reference image" title="Next image" disabled={currentImagePage === selectedImages.length - 1} onClick={() => setImagePage(currentImagePage + 1)}><ChevronRight size={16} aria-hidden="true" /></button>+ <button type="button" className="icon-button" aria-label="Next reference image" data-tooltip="Next image" disabled={currentImagePage === selectedImages.length - 1} onClick={() => setImagePage(currentImagePage + 1)}><ChevronRight size={16} aria-hidden="true" /></button></div>}<div className="reference-fields">- <label><span>Prompt</span><textarea disabled={hasRefmods} value={selected.description} placeholder="Describe what should stay consistent — the traits, materials, colours, or wardrobe Slopus should preserve across shots." onChange={(event) => update(selected.id, { description: event.target.value, content: event.target.value || null, subcategory: selectedSubcategory })} /></label>- <div className="reference-fields__actions">- <button className="secondary-button" disabled={importingFiles || hasRefmods} onClick={() => void addFiles()}><ImagePlus size={16} /> {importingFiles ? "Adding files…" : "Add file"}</button>- </div>+ <label><span>Prompt</span><textarea className="text-field" disabled={hasRefmods} value={selected.description} placeholder="Describe what should stay consistent — the traits, materials, colours, or wardrobe Slopus should preserve across shots." onChange={(event) => update(selected.id, { description: event.target.value, content: event.target.value || null, subcategory: selectedSubcategory })} /></label>{hasRefmods && <p>Remove the refmods to edit the prompt or add files.</p>}</div>{hasRefmods && <section className="reference-refmods" aria-label="Refmod attachments"><header><h3>Refmods</h3>- <button type="button" className="inspector-remove-button" aria-label="Remove refmods" title="Remove all refmods" onClick={() => update(selected.id, { iconRelativePath: undefined, refmods: [] })}><Trash2 size={16} aria-hidden="true" /></button>+ <button type="button" className="icon-button" aria-label="Remove refmods" data-tooltip="Remove all refmods" onClick={() => update(selected.id, { iconRelativePath: undefined, refmods: [] })}><Trash2 size={16} aria-hidden="true" /></button></header>- <p>Requires a Ref2VA generator. Strength 0 disables a refmod. More copies use more GPU memory.</p>+ <p>Needs a Ref2VA generator. Strength 0 turns a refmod off; more copies use more GPU memory.</p>{selected.refmods!.map((refmod) => <div key={refmod.id}>- <b title={refmod.name}>{refmod.name}</b>- <label>Strength<input aria-label={`${refmod.name} strength`} type="number" min={0} max={1} step={0.05} value={refmod.strength} onChange={(event) => {+ <b data-tooltip={refmod.name}>{refmod.name}</b>+ <PropRow label="Strength" htmlFor={`${refmod.id}-strength`}><input id={`${refmod.id}-strength`} className="text-field" aria-label={`${refmod.name} strength`} type="number" min={0} max={1} step={0.05} value={refmod.strength} onChange={(event) => {const strength = Number(event.target.value);if (event.target.value && Number.isFinite(strength) && strength >= 0 && strength <= 1) update(selected.id, { iconRelativePath: undefined, refmods: selected.refmods!.map((entry) => entry.id === refmod.id ? { ...entry, strength } : entry) });- }} /></label>- <label>Copies<input aria-label={`${refmod.name} copies`} type="number" min={1} max={10} step={1} value={refmod.copies} onChange={(event) => {+ }} /></PropRow>+ <PropRow label="Copies" htmlFor={`${refmod.id}-copies`}><input id={`${refmod.id}-copies`} className="text-field" aria-label={`${refmod.name} copies`} type="number" min={1} max={10} step={1} value={refmod.copies} onChange={(event) => {const copies = Number(event.target.value);if (Number.isInteger(copies) && copies >= 1 && copies <= 10) update(selected.id, { iconRelativePath: undefined, refmods: selected.refmods!.map((entry) => entry.id === refmod.id ? { ...entry, copies } : entry) });- }} /></label>+ }} /></PropRow></div>)}</section>}{selectedLocation && <section className="reference-location-settings" aria-label="Location settings">- {LOCATION_SETTING_GROUPS.map((group) => <label key={group.id} className="reference-location-settings__group">- <span>{group.label}</span>- <select disabled={hasRefmods} value={selectedLocation.settings[group.id] ?? ""} onChange={(event) => {- const prompt = composeLocationPrompt(selectedLocation.preset, { ...selectedLocation.settings, [group.id]: event.target.value || undefined });- update(selected.id, { description: prompt, content: prompt });- }}>- <option value="">None</option>- {group.options.map((option) => <option key={option.id} value={option.id}>{option.label}</option>)}- </select>- </label>)}+ {LOCATION_SETTING_GROUPS.map((group) => <PropRow key={group.id} label={group.label}>+ <ComboBox+ aria-label={group.label}+ disabled={hasRefmods}+ value={selectedLocation.settings[group.id] ?? ""}+ options={[{ value: "", label: "None" }, ...group.options.map((option) => ({ value: option.id, label: option.label }))]}+ onChange={(value) => {+ const prompt = composeLocationPrompt(selectedLocation.preset, { ...selectedLocation.settings, [group.id]: value || undefined });+ update(selected.id, { description: prompt, content: prompt });+ }}+ />+ </PropRow>)}</section>}<section className="reference-type" aria-label="Reference classification">- <label><span>Category</span><select value={selectedType} onChange={(event) => update(selected.id, { intendedUse: [event.target.value as PresetReferenceType], subcategory: "" })}>- {selectedType === "custom" && <option value="custom" disabled>Uncategorized</option>}- {REFERENCE_TYPES.map((type) => <option key={type.id} value={type.id}>{type.label}</option>)}- </select></label>- {selectedType !== "custom" && <label><span>Subcategory</span><select value={selectedSubcategory} onChange={(event) => update(selected.id, { subcategory: event.target.value })}>- <option value="">None</option>- {referenceSubcategories(selectedType).map((subcategory) => <option key={subcategory} value={subcategory}>{subcategory}</option>)}- </select></label>}+ <PropRow label="Category">+ <ComboBox+ aria-label="Category"+ value={selectedType}+ options={[+ ...(selectedType === "custom" ? [{ value: "custom", label: "Uncategorized", disabled: true }] : []),+ ...REFERENCE_TYPES.map((type) => ({ value: type.id, label: type.label })),+ ]}+ onChange={(value) => update(selected.id, { intendedUse: [value as PresetReferenceType], subcategory: "" })}+ />+ </PropRow>+ {selectedType !== "custom" && <PropRow label="Subcategory">+ <ComboBox+ aria-label="Subcategory"+ value={selectedSubcategory}+ options={[{ value: "", label: "None" }, ...referenceSubcategories(selectedType).map((subcategory) => ({ value: subcategory, label: subcategory }))]}+ onChange={(value) => update(selected.id, { subcategory: value })}+ />+ </PropRow>}</section><section className="reference-used-by"><h3>Used by <span>{jobs.length}</span></h3>- {jobs.length ? jobs.map((job) => <button type="button" key={job.id} onClick={() => onOpenGenerator?.(job.id)} title={`Open ${job.title}`}><b>{job.title}</b><ChevronRight size={16} aria-hidden="true" /></button>) : <p>No shots use this reference yet. Each new shot picks up the first two it can use from this list, so it will be used once it reaches the top two of those.</p>}+ {jobs.length ? jobs.map((job) => <button type="button" key={job.id} onClick={() => onOpenGenerator?.(job.id)} data-tooltip={`Open ${job.title}`}><b>{job.title}</b><ChevronRight size={16} aria-hidden="true" /></button>) : <p>No scenes yet.</p>}</section>- </> : <div className="reference-empty"><BookOpen size={26} /><b>Select a reference</b><p>Pick one from the library, or add a new one, to edit its definition and see which generations use it.</p></div>}+ </> : <p className="reference-empty">Select a reference to see its details.</p>}</div>{debugEnabled && selected && <div className="debug-prompt">- <button type="button" className="secondary-button debug-prompt__toggle" aria-haspopup="dialog" aria-expanded={showDebugIconPrompt} onClick={() => setShowDebugIconPrompt(true)}>Debug Icon Prompt</button>+ <button type="button" className="secondary-button debug-prompt__toggle" aria-haspopup="dialog" aria-expanded={showDebugIconPrompt} onClick={() => setShowDebugIconPrompt(true)}>Debug icon prompt</button></div>}</aside>{debugEnabled && showDebugIconPrompt && selected && <DebugPromptDialog- title="Debug Icon Prompt"+ title="Debug icon prompt"promptLabel="The reference icon generation prompt"sceneTitle={selected.name}segments={[{ kind: "brief", value: referenceIconPrompt(selected) }]}@@ -359,42 +619,48 @@ export function ReferencesView({ config, folderPath, onChange, onRegenerateIcon,catch (reason) { setIconError(String(reason)); }}}} />}- {presetDialog && builtinConfirmationCount === 0 && <div className="reference-dialog-backdrop"><div className="reference-preset-dialog" role="dialog" aria-modal="true" aria-labelledby="reference-preset-title">- <header>- <div><h2 id="reference-preset-title">Add a reference</h2><p>Choose a preset or create a new reference, then add a prompt, images, or video.</p></div>- <button onClick={() => { catalogVisit.current += 1; setPresetDialog(false); }} aria-label="Close type picker"><X size={18} /></button>- </header>+ {presetDialog && builtinConfirmationCount === 0 && <ContentDialog+ title="Add a reference"+ className="reference-preset-dialog"+ width={920}+ primaryText="New"+ onPrimary={createEmptyReference}+ closeText="Cancel"+ onClose={closePicker}+ >+ <p className="reference-preset-dialog__lead">Choose a preset, or start a new reference and add a prompt, images or video.</p><div className="reference-preset-dialog__body"><nav aria-label="Reference types">- {PICKER_TYPES.map((type) => <button key={type.id} className={pickerType === type.id ? "active" : ""} aria-pressed={pickerType === type.id} onClick={() => { setPickerType(type.id); setPickerSubcategory("all"); setPresetSearch(""); }}>{type.label}<ChevronRight size={16} /></button>)}+ {PICKER_TYPES.map((type) => <button key={type.id} type="button" className={pickerType === type.id ? "active" : ""} aria-pressed={pickerType === type.id} onClick={() => { setPickerType(type.id); setPickerSubcategory("all"); setPresetSearch(""); }}>{type.label}</button>)}</nav><section>- <div className="reference-preset-toolbar">- {pickerType !== "custom" && <label className="reference-preset-search"><Search size={17} /><input value={presetSearch} onChange={(event) => setPresetSearch(event.target.value)} placeholder={`Search ${referenceTypeLabel(pickerType).toLocaleLowerCase()} options`} aria-label="Search reference options" /></label>}- <button className="primary-button" onClick={createEmptyReference}><Plus size={16} aria-hidden="true" /> New</button>- </div>- {pickerType !== "custom" && <><div className="reference-subcategories" role="group" aria-label={`${referenceTypeLabel(pickerType)} subcategories`}>- <button className={pickerSubcategory === "all" ? "active" : ""} aria-pressed={pickerSubcategory === "all"} onClick={() => setPickerSubcategory("all")}>All</button>- {subcategories.map((subcategory) => <button key={subcategory} className={pickerSubcategory === subcategory ? "active" : ""} aria-pressed={pickerSubcategory === subcategory} onClick={() => setPickerSubcategory(subcategory)}>{subcategory}</button>)}- </div>+ {pickerType !== "custom" && <>+ <label className="reference-preset-search"><Search size={16} aria-hidden="true" /><input value={presetSearch} onChange={(event) => setPresetSearch(event.target.value)} placeholder={`Search ${referenceTypeLabel(pickerType).toLocaleLowerCase()}`} aria-label="Search reference options" /></label>+ <SelectorBar+ className="reference-subcategories"+ aria-label={`${referenceTypeLabel(pickerType)} subcategories`}+ value={pickerSubcategory}+ onChange={setPickerSubcategory}+ items={[{ value: "all", label: "All" }, ...subcategories.map((subcategory) => ({ value: subcategory, label: subcategory }))]}+ /><div className="reference-preset-grid">{visiblePresets.map((preset) => <div className="reference-preset-card" key={preset.id}><button type="button" className={`reference-preset-select${hasPresetIcon(preset) || onRegenerateBuiltinIcon ? " reference-preset-card--with-icon" : ""}`} onClick={() => choosePreset(preset)}>{(hasPresetIcon(preset) || onRegenerateBuiltinIcon) && <PresetIcon className="reference-preset-icon" preset={preset} />}<small>{preset.subcategory}</small><b>{preset.name}</b><span>{preset.prompt}</span></button>- {onRegenerateBuiltinIcon && <button type="button" className="reference-preset-generate" aria-label={`${hasPresetIcon(preset) ? "Regenerate" : "Generate"} icon for ${preset.name}`} title={pendingBuiltinIconIds.has(preset.id) ? "Icon generation queued or running" : `${hasPresetIcon(preset) ? "Regenerate" : "Generate"} icon`} disabled={pendingBuiltinIconIds.has(preset.id)} onClick={() => {+ {onRegenerateBuiltinIcon && <button type="button" className="reference-preset-generate" aria-label={`${hasPresetIcon(preset) ? "Regenerate" : "Generate"} icon for ${preset.name}`} data-tooltip={pendingBuiltinIconIds.has(preset.id) ? "Icon generation queued or running" : `${hasPresetIcon(preset) ? "Regenerate" : "Generate"} icon`} disabled={pendingBuiltinIconIds.has(preset.id)} onClick={() => {setIconError(null);try { onRegenerateBuiltinIcon(preset.id); }catch (reason) { setIconError(reason instanceof Error ? reason.message : String(reason)); }}}><RefreshCw size={20} aria-hidden="true" /></button>}</div>)}- {visiblePresets.length === 0 && <p>No options match that search.</p>}- </div></>}+ {visiblePresets.length === 0 && <p>No results for “{presetSearch.trim()}”.</p>}+ </div>+ </>}+ {pickerType === "custom" && <p className="reference-preset-dialog__lead">Start an uncategorized reference with New.</p>}</section></div>- </div></div>}- {importError && <div className="toast" role="alert"><strong>Couldn’t add reference</strong><span>{importError}</span><button onClick={() => setImportError(null)}>Dismiss</button></div>}- {iconError && <div className="toast" role="alert"><strong>Couldn’t regenerate icon</strong><span>{iconError}</span><button onClick={() => setIconError(null)}>Dismiss</button></div>}+ </ContentDialog>}</div>;}diff --git a/src/components/workspace/ReferencesView.video.test.tsx b/src/components/workspace/ReferencesView.video.test.tsxindex 784d5a9..5bb38af 100644--- a/src/components/workspace/ReferencesView.video.test.tsx+++ b/src/components/workspace/ReferencesView.video.test.tsx@@ -82,7 +82,7 @@ it("shows an existing refmod icon only in the normal inspector slot and clears iconst { container } = render(<ReferencesView folderPath="C:/project" config={config} onChange={onChange} onRegenerateIcon={vi.fn()} pendingIconIds={new Set(["ref"])} />);expect(container.querySelector(".reference-detail-art .reference-detail-preset-icon")).toBeInTheDocument();expect(within(screen.getByRole("region", { name: "Refmod attachments" })).queryByRole("img")).not.toBeInTheDocument();- expect(screen.getByTitle(filename)).toHaveTextContent(filename);+ expect(screen.getByText(filename)).toHaveAttribute("data-tooltip", filename);expect(screen.getByRole("button", { name: "Regenerate reference icon" })).toBeDisabled();fireEvent.click(screen.getByRole("button", { name: "Remove refmods" }));expect(onChange.mock.calls[0][0].references[0]).toMatchObject({ description: "Existing description", refmods: [], iconRelativePath: undefined });@@ -121,7 +121,7 @@ it("imports a video, edits its saved trim and soundtrack, then removes its attacname: "Uncategorized", intendedUse: [], kind: "video", sourcePath: "C:/motion.mp4", video: { startSeconds: 2, durationSeconds: 4, includeAudio: false },});expect(screen.getByRole("img", { name: "Frame from Uncategorized" })).toHaveAttribute("src", "test:C:/motion.mp4:0");- fireEvent.click(screen.getByRole("button", { name: "Close video clip settings" }));+ fireEvent.click(screen.getByRole("button", { name: "Done" }));expect(screen.getByLabelText("Prompt")).toBeEnabled();expect(screen.queryByText(/Long videos are welcome/)).not.toBeInTheDocument();vi.mocked(invoke).mockResolvedValueOnce([{ kind: "video", name: "replacement.mp4", sourcePath: "C:/replacement.mp4" }]);diff --git a/src/styles/references.css b/src/styles/references.cssindex 3ae4159..afaaa62 100644--- a/src/styles/references.css+++ b/src/styles/references.css@@ -1,219 +1,304 @@/* ============================================================================- references.css — reference library, reference inspector, add-reference dialog.+ references.css — the reference library (a command bar, an Icons or Details+ view and a status bar), the reference inspector pane, and the add-reference+ dialog.Sizing contract (see tokens.css): no literal px type sizes, nothing below--text-2xs (12px), standard controls --control-md (32px), compact ones--control-sm (24px).========================================================================== */+/* The library, the splitter and the inspector. The inspector's width is the+ user's (usePaneSize → --pane-references-inspector); there are no width+ breakpoints, so a narrow window narrows the library instead. */.references-view {height: 100%;min-height: 0;display: grid;- grid-template-columns: minmax(0, 1fr) 380px;- background: var(--bg);+ grid-template-columns: minmax(0, 1fr) auto var(--pane-references-inspector, 380px);+ background: var(--layer);}.references-main {min-width: 0;min-height: 0;- overflow-y: auto;- padding: var(--space-6) var(--space-7) var(--space-8);+ display: flex;+ flex-direction: column;}-.references-heading {- max-width: var(--content-max);- margin: 0 auto var(--space-5);- display: flex;- justify-content: space-between;- align-items: flex-end;- gap: var(--space-5);+.references-command {+ flex: 0 0 auto;+ min-height: var(--space-7);+ border-bottom: 1px solid var(--line);}-.references-heading__actions {+.references-main > .ui-infobar {flex: 0 0 auto;- display: flex;- flex-wrap: wrap;- gap: var(--space-2);+ margin: var(--space-2) var(--space-3) 0;}-.references-heading h1 {- margin: var(--space-2) 0 var(--space-1);- font-size: var(--text-2xl);- font-weight: var(--weight-semibold);- line-height: var(--leading-tight);+.reference-library {+ flex: 1 1 auto;+ min-width: 0;+ min-height: 0;+ overflow-y: auto;+ padding: var(--space-2) var(--space-3);}-.references-heading__title p {- margin: 0;+.reference-library__empty {+ margin: var(--space-2) 0;color: var(--text-muted);font-size: var(--text-sm);- line-height: var(--leading-snug);}-/* --- Layout ---------------------------------------------------------------- */--.reference-library {- max-width: var(--content-max);- margin: 0 auto;- min-width: 0;- padding-bottom: var(--space-5);+.references-status {+ flex: 0 0 auto;}-/* The selected reference owns the inspector header, like the editable scene- and shot names in the Generator. */-.reference-inspector__head {- flex: 0 0 auto;- min-height: var(--control-lg);- display: flex;- align-items: center;- justify-content: space-between;+/* --- Icons view ---------------------------------------------------------------+ Auto-filling 120px tiles: a square picture and a 12px name. Hover is a fill;+ selection an accent fill with an accent edge, like any Windows grid view.+ ========================================================================== */++.reference-grid {+ display: grid;+ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));gap: var(--space-2);- padding: var(--space-3);- border-bottom: 1px solid var(--line);}-.reference-inspector__head h2 {+.reference-tile {min-width: 0;- flex: 1 1 auto;- margin: 0;+ display: flex;+ flex-direction: column;+ gap: var(--space-1);+ padding: var(--space-1);+ border: 1px solid transparent;+ border-radius: var(--radius-sm);color: var(--text-primary);- font-size: var(--text-md);- font-weight: var(--weight-semibold);- line-height: var(--leading-snug);+ transition: var(--transition-control);}-.reference-title__name {- width: 100%;- min-width: 0;- padding: 2px var(--space-1);- margin-left: calc(var(--space-1) * -1);- border: 1px solid transparent;- border-radius: var(--radius-sm);- color: inherit;- background: none;- font: inherit;- letter-spacing: inherit;+.reference-tile:hover {+ background: var(--fill-subtle-hover);}-.reference-title__name:hover,-.reference-title__name:focus {- border-color: var(--accent-bright);- background: var(--panel-2);- outline: none;+.reference-tile--selected,+.reference-tile--selected:hover {+ border-color: var(--accent);+ background: var(--accent-soft);}-/* --- Reference cards ------------------------------------------------------- */+.reference-tile:focus-visible {+ outline: 2px solid var(--focus-outer);+ outline-offset: -2px;+ box-shadow: inset 0 0 0 3px var(--focus-inner);+}-.reference-grid {+.reference-tile__name {+ min-width: 0;+ overflow: hidden;+ font-size: var(--text-xs);+ line-height: 16px;+ text-align: center;+ text-overflow: ellipsis;+ white-space: nowrap;+}++/* The picture: the user's own image (contain, so portrait and landscape stay+ comparable), a video's first frame, a generated icon — or, for a written+ definition with no file at all, a document glyph on a plain plate. */+.reference-art {+ position: relative;+ aspect-ratio: 1;+ overflow: hidden;display: grid;- grid-template-columns: repeat(2, minmax(0, 1fr));- gap: var(--space-3);- padding: 0;+ place-items: center;+ border-radius: 2px;+ color: var(--text-muted);+ background: var(--panel-3);+}++.reference-art--text {+ color: var(--accent-bright);+}++.reference-art--photo img {+ width: 100%;+ height: 100%;+ object-fit: contain;}-.reference-grid > button {+.reference-art--photo .media-thumb {+ width: 100%;+ height: 100%;+}++/* --- Details view ---------------------------------------------------------------+ 28px rows, sortable columns, the same fill/accent selection as the icons.+ ========================================================================== */++.reference-details {min-width: 0;- height: 156px;- display: grid;- grid-template-columns: 156px minmax(0, 1fr);- overflow: hidden;+ overflow-x: auto;+}++.reference-details table {+ width: 100%;+ border-collapse: separate;+ border-spacing: 0 2px;+ font-size: var(--text-xs);+ line-height: 16px;+}++.reference-details th {+ position: sticky;+ top: 0;+ z-index: 1;padding: 0;- border: 1px solid var(--line);- border-radius: var(--radius-md);+ border-bottom: 1px solid var(--line);+ background: var(--layer);+ font-weight: var(--weight-regular);text-align: left;- color: var(--text-muted);- background: var(--panel-2);}-.reference-grid > button:hover {- border-color: var(--line-strong);+.reference-details th button {+ width: 100%;+ height: 28px;+ display: flex;+ align-items: center;+ gap: var(--space-1);+ padding: 0 var(--space-2);+ border: 0;+ border-radius: var(--radius-sm);+ color: var(--text-secondary);+ background: none;+ font: inherit;+ text-align: left;}-.reference-grid > button.selected {- border-color: var(--accent-bright);+.reference-details th button:hover {+ color: var(--text-primary);+ background: var(--fill-subtle-hover);}-/* The plate a reference sits on: a hatched panel with its kind lettered on it.- It was once the whole story — "Slopus cannot render image previews yet",- which stopped being true when `.reference-art--photo` below started painting- the user's own picture, and stayed in the file for a while afterwards. What- it is now is the BACKDROP: it shows through a transparent PNG, and it is all- there is for a reference with no picture to show — one still being described,- or a written definition, which has no file at all. */-.reference-art,-.reference-copy-art {- position: relative;- height: 100%;+.reference-details td {+ height: 28px;+ max-width: 0;+ padding: 0 var(--space-2);overflow: hidden;+ color: var(--text-secondary);+ text-overflow: ellipsis;+ white-space: nowrap;+}++.reference-details td:first-child {+ width: 40%;+ border-radius: var(--radius-sm) 0 0 var(--radius-sm);+ color: var(--text-primary);+}++.reference-details td:last-child {+ border-radius: 0 var(--radius-sm) var(--radius-sm) 0;+}++.reference-details tbody tr:hover td {+ background: var(--fill-subtle-hover);+}++.reference-details tbody tr.reference-row--selected td {+ background: var(--accent-soft);+}++.reference-details tbody tr:focus-visible {+ outline: 2px solid var(--focus-outer);+ outline-offset: -2px;+}++.reference-row__name {+ min-width: 0;display: flex;- flex-direction: column;align-items: center;- justify-content: center;gap: var(--space-2);- padding: var(--space-3);- border-right: 1px solid var(--line);+}++.reference-row__name > span:last-child {+ min-width: 0;+ overflow: hidden;+ text-overflow: ellipsis;+}++.reference-row__icon {+ flex: 0 0 auto;+ display: grid;color: var(--text-muted);- background-color: var(--panel-3);- background-image: repeating-linear-gradient(- 135deg,- var(--hatch) 0 6px,- transparent 6px 12px- );}-.reference-copy-art {- color: var(--accent-bright);+/* --- Reference inspector ------------------------------------------------------ */++.reference-inspector {+ min-width: 0;+ min-height: 0;+ display: flex;+ flex-direction: column;+ overflow: hidden;+ background: var(--panel);}-.reference-art em,-.reference-copy-art em {- color: var(--text-secondary);- font-size: var(--text-xs);- font-style: normal;- font-weight: var(--weight-medium);- line-height: var(--leading-snug);- text-align: center;+/* The selected reference owns the pane header, like the editable scene and+ shot names in the Generator: 14px semibold, 40px. */+.reference-inspector__head {+ flex: 0 0 auto;+ min-height: var(--space-7);+ display: flex;+ align-items: center;+ gap: var(--space-1);+ padding: 0 var(--space-1) 0 var(--space-2);+ border-bottom: 1px solid var(--line);}-/* --- Real reference artwork -------------------------------------------------- The picture the user imported, read out of the project folder and shown at- the two places that used to display a striped placeholder plate: the library- card and the detail pane. `contain` on the card so a portrait and a landscape- reference stay comparable; `cover` would crop the subject out of one of them.- The striped plate stays as the backdrop, so a transparent PNG still reads. */+.reference-inspector__head h2 {+ min-width: 0;+ flex: 1 1 auto;+ margin: 0;+ color: var(--text-primary);+ font-size: var(--text-base);+ font-weight: var(--weight-semibold);+ line-height: var(--leading-snug);+}-.reference-art--photo {- padding: 0;+.reference-inspector__title {+ padding-left: var(--space-2);}-.reference-art--photo img {- width: 100%;- height: 100%;- object-fit: contain;+.reference-inspector__scroll {+ min-height: 0;+ flex: 1 1 auto;+ overflow-y: auto;}-.reference-art--photo .media-thumb {- width: 100%;- height: 100%;+/* Nothing selected: one caption line, not a centred hero. */+.reference-empty {+ margin: 0;+ padding: var(--space-3);+ color: var(--text-muted);+ font-size: var(--text-xs);}-.reference-refmods, .reference-refmods > div { display: grid; grid-template-columns: minmax(0, 1fr); min-width: 0; gap: var(--space-2); }-.reference-refmods { padding: var(--space-4); border-top: 1px solid var(--line); }-.reference-refmods > header { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }-.reference-refmods > div > b { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }-.reference-refmods h3, .reference-refmods p { margin: 0; }-.reference-refmods p { color: var(--text-muted); font-size: var(--text-sm); }-.reference-refmods label { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }-.reference-refmods input { width: 88px; min-height: var(--field-height); padding: var(--space-2); color: inherit; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); }-.reference-fields > p { margin: 0; color: var(--text-muted); font-size: var(--text-sm); }+.reference-detail-art {+ position: relative;+ height: 128px;+ display: grid;+ place-items: center;+ overflow: hidden;+ border-bottom: 1px solid var(--line);+ background: var(--panel-3);+}.reference-detail-art--photo img {width: 100%;height: 100%;object-fit: contain;- /* Clear of the path caption pinned along the bottom. */- padding: var(--space-2) var(--space-2) var(--space-7);+ padding: var(--space-2);}.reference-detail-art--photo .reference-detail-preset-icon {@@ -233,8 +318,59 @@.reference-detail-art--preset > .reference-image-fallback {width: 100%;height: 100%;- border: 0;- border-radius: 0;+}++.reference-detail-art.reference-detail-art--images {+ display: block;+ height: auto;+}++.reference-detail-images {+ width: 100%;+}++.reference-detail-art--photo .reference-detail-images img {+ display: block;+ width: 100%;+ height: auto;+ padding: 0;+}++.reference-detail-images .reference-image-fallback { min-height: 128px; }++/* A written definition: one 32px caption row with a document glyph. */+.reference-detail-art--text {+ height: var(--control-md);+ display: flex;+ justify-content: flex-start;+ gap: var(--space-2);+ padding: 0 var(--space-3);+ background: transparent;+}++.reference-detail-art--text > span {+ display: grid;+ color: var(--accent-bright);+}++.reference-detail-art em {+ position: absolute;+ z-index: 3;+ left: var(--space-3);+ right: var(--space-3);+ bottom: var(--space-2);+ overflow: hidden;+ color: var(--text-secondary);+ font-size: var(--text-xs);+ font-style: normal;+ text-align: center;+ text-overflow: ellipsis;+ white-space: nowrap;+}++.reference-detail-art.reference-detail-art--text em {+ position: static;+ text-align: left;}.reference-detail-art :is(.reference-icon-refresh, .reference-image-remove) {@@ -247,13 +383,17 @@width: var(--control-sm);height: var(--control-sm);padding: 0;- border: 1px solid var(--line-strong);+ border: 1px solid var(--stroke-control);border-radius: var(--radius-sm);color: var(--text-primary);- background: var(--panel-2);+ background: var(--fill-control);opacity: 0;pointer-events: none;- transition: opacity var(--motion-fast);+ transition: opacity var(--motion-fast) linear, background-color var(--motion-fast) linear;+}++.reference-detail-art--text :is(.reference-icon-refresh, .reference-image-remove) {+ top: calc(50% - var(--control-sm) / 2);}.reference-detail-art:hover :is(.reference-icon-refresh, .reference-image-remove),@@ -263,13 +403,11 @@}.reference-detail-art :is(.reference-icon-refresh, .reference-image-remove):hover:not(:disabled) {- background: var(--panel-3);- border-color: var(--accent);+ background: var(--fill-control-hover);}.reference-detail-art .reference-icon-refresh:disabled {- color: var(--text-muted);- cursor: default;+ color: var(--text-disabled);}@media (hover: none) {@@ -279,42 +417,21 @@}}-.reference-detail-art.reference-detail-art--images {- display: block;- height: auto;-}--.reference-detail-images {- width: 100%;-}--.reference-detail-art--photo .reference-detail-images img {- display: block;- width: 100%;- height: auto;- padding: 0;- background: var(--panel-3);-}--.reference-detail-images .reference-image-fallback { min-height: 128px; }-.reference-image-controls {display: flex;align-items: center;justify-content: center;gap: var(--space-2);- padding: var(--space-2) var(--space-3);+ padding: var(--space-1) var(--space-3);border-bottom: 1px solid var(--line);}.reference-image-controls > span {color: var(--text-secondary);- font-size: var(--text-sm);+ font-size: var(--text-xs);font-variant-numeric: tabular-nums;}-.reference-image-controls > button:disabled { opacity: 0.5; cursor: default; }-/* Loading, or the file is not where the project says it is. Two states, saidplainly, rather than one placeholder that could mean either. */.reference-image-fallback {@@ -334,192 +451,13 @@line-height: var(--leading-snug);}-.reference-card__body {- min-width: 0;- display: block;- padding: var(--space-3) var(--space-4);-}--.reference-card__body > span:first-child,-.reference-card__body > span:first-child b,-.reference-card__body > span:first-child small {- display: block;- overflow: hidden;- white-space: nowrap;- text-overflow: ellipsis;-}--.reference-card__body b {- color: var(--text-primary);- font-size: var(--text-base);- font-weight: var(--weight-semibold);- line-height: var(--leading-snug);-}--.reference-card__body small {- margin-top: var(--space-1);- color: var(--text-faint);- font: var(--weight-medium) var(--text-xs) / var(--leading-snug) var(--font-mono);-}--/* Two lines keep the reference cards compact without clipping mid-glyph. */-.reference-card__body p {- display: -webkit-box;- -webkit-line-clamp: 2;- -webkit-box-orient: vertical;- overflow: hidden;- margin: var(--space-2) 0;- color: var(--text-secondary);- font-size: var(--text-sm);- line-height: var(--leading-normal);-}--.use-tags {- display: flex;- flex-wrap: wrap;- gap: var(--space-1);-}--.use-tags i {- padding: var(--space-1) var(--space-2);- border: 1px solid var(--line-strong);- border-radius: var(--radius-xs);- color: var(--text-secondary);- background: var(--panel-3);- font-family: var(--font-sans);- font-size: var(--text-2xs);- font-style: normal;- font-weight: var(--weight-medium);- line-height: var(--leading-snug);- text-transform: capitalize;-}--.reference-grid .reference-add-card {- display: flex;- flex-direction: column;- align-items: center;- justify-content: center;- border-style: dashed;- color: var(--text-muted);- background: none;-}--.reference-add-card > span {- width: var(--control-lg);- height: var(--control-lg);- display: grid;- place-items: center;- margin-bottom: var(--space-2);- border: 1px solid var(--line-strong);- border-radius: var(--radius-md);- color: var(--accent-bright);- background: var(--accent-soft);-}--.reference-add-card b {- color: var(--text-primary);- font-size: var(--text-base);- font-weight: var(--weight-semibold);- line-height: var(--leading-snug);-}--.reference-add-card small {- margin-top: var(--space-1);- color: var(--text-muted);- font-size: var(--text-sm);- line-height: var(--leading-snug);-}--/* --- Reference inspector --------------------------------------------------- */--.reference-inspector {- min-width: 0;- min-height: 0;- display: flex;- flex-direction: column;- overflow: hidden;- border-left: 1px solid var(--line);- background: var(--panel);-}--.reference-inspector__scroll {- min-height: 0;- flex: 1 1 auto;- overflow-y: auto;-}--.reference-detail-art {- height: 128px;- position: relative;- display: grid;- place-items: center;- overflow: hidden;- border-bottom: 1px solid var(--line);- background-color: var(--panel-3);- background-image: repeating-linear-gradient(- 135deg,- var(--hatch) 0 8px,- transparent 8px 16px- );-}--.reference-detail-art > span {- position: relative;- z-index: 2;- width: var(--space-9);- height: var(--space-9);- display: grid;- place-items: center;- border: 1px solid var(--line-strong);- border-radius: 50%;- color: var(--text-muted);- background: var(--panel-2);-}--.reference-detail-art--text > span {- width: 24px;- height: 24px;- border: 0;- background: transparent;- color: var(--accent-bright);-}--.reference-detail-art--text {- height: var(--control-lg);- display: flex;- justify-content: flex-start;- gap: var(--space-2);- padding: 0 var(--space-3);- background: transparent;-}--.reference-detail-art--text > span svg {- width: 20px;- height: 20px;-}--.reference-detail-art.reference-detail-art--text em {- position: static;- text-align: left;-}--.reference-detail-art em {- position: absolute;- z-index: 3;- left: var(--space-3);- right: var(--space-3);- bottom: var(--space-3);- overflow: hidden;- white-space: nowrap;- text-overflow: ellipsis;- color: var(--text-secondary);- font: var(--weight-medium) var(--text-xs) / var(--leading-snug) var(--font-mono);- font-style: normal;- text-align: center;+/* A tile is too small for the words; the icon still tells the states apart. */+.reference-tile .reference-image-fallback em {+ display: none;}.reference-fields {- padding: var(--space-3);+ padding: var(--space-2) var(--space-3) var(--space-3);border-bottom: 1px solid var(--line);}@@ -528,257 +466,91 @@margin: 0;}-.reference-fields label > span {+.reference-fields label > span,+.reference-used-by h3,+.reference-refmods h3 {display: block;- margin-bottom: var(--space-1);+ margin: 0 0 var(--space-1);color: var(--text-secondary);- font-size: var(--text-sm);- font-weight: var(--weight-medium);+ font-size: var(--text-xs);+ font-weight: var(--weight-semibold);line-height: var(--leading-snug);}-.reference-fields input,.reference-fields textarea {width: 100%;- height: var(--field-height);- padding: 0 var(--space-3);- border: 1px solid var(--line);- border-radius: var(--radius-sm);- color: var(--text-primary);- background: var(--field-bg);+ height: 160px;+ min-height: 96px;+ padding: var(--space-2);font-family: var(--font-sans);- font-size: var(--text-base);-}--.reference-fields input:focus,-.reference-fields textarea:focus {- border-color: var(--accent);-}--.reference-fields textarea {- height: 192px;- min-height: 192px;- padding: var(--space-2) var(--space-3);- resize: vertical;line-height: var(--leading-normal);+ resize: vertical;}-/* --- Reference type / usage list ------------------------------------------- */--.reference-type,-.reference-used-by {- padding: var(--space-3);- border-bottom: 1px solid var(--line);-}--.reference-type h3,-.reference-used-by h3 {- margin: 0 0 var(--space-2);- color: var(--text-primary);- font-size: var(--text-sm);- font-weight: var(--weight-semibold);- line-height: var(--leading-snug);+.reference-fields > p {+ margin: var(--space-2) 0 0;+ color: var(--text-muted);+ font-size: var(--text-xs);}-.reference-type {+/* Inspector rows: classification, location settings and refmod numbers are+ PropRows (104px label, 24px control). */+.reference-type,+.reference-location-settings {display: grid;- gap: var(--space-2);+ gap: 2px;+ padding: var(--space-2) var(--space-3);+ border-bottom: 1px solid var(--line);}-.reference-type label {+.reference-refmods,+.reference-refmods > div {display: grid;- grid-template-columns: 96px minmax(0, 1fr);- align-items: center;- gap: var(--space-3);- color: var(--text-secondary);- font-size: var(--text-sm);-}--.reference-type select {+ grid-template-columns: minmax(0, 1fr);min-width: 0;- width: 100%;- height: var(--control-sm);- padding: 0 var(--space-2);- border: 1px solid var(--line-strong);- border-radius: var(--radius-sm);- color: var(--text-primary);- background: var(--field-bg);- font: inherit;+ gap: 2px;}-.reference-video {- display: grid;- gap: var(--space-3);- padding: var(--space-4);-}--.reference-video-dialog-overlay {- position: fixed;- z-index: 100;- inset: 0;- display: grid;- place-items: center;- padding: var(--space-5);- background: var(--scrim);-}--.reference-video-dialog {- display: flex;- flex-direction: column;- width: min(1100px, 100%);- min-width: 0;- max-height: calc(100dvh - var(--space-5) * 2);- overflow: hidden;- border: 1px solid var(--stroke-surface);- border-radius: var(--radius-xl);- background: var(--dialog-bg);- box-shadow: var(--shadow);+.reference-refmods {+ gap: var(--space-2);+ padding: var(--space-2) var(--space-3);+ border-bottom: 1px solid var(--line);}-.reference-video-dialog > header {+.reference-refmods > header {display: flex;- flex-shrink: 0;align-items: center;justify-content: space-between;- gap: var(--space-3);- padding: var(--space-4);- border-bottom: 1px solid var(--line);+ gap: var(--space-2);}-.reference-video-dialog h2 {+.reference-refmods > header h3 {margin: 0;- overflow-wrap: anywhere;- font-size: var(--text-lg);}-.reference-video-dialog > .reference-video { min-height: 0; overflow-y: auto; }--.reference-video-preview {+.reference-refmods > div > b {display: block;- width: 100%;- max-height: min(50vh, 460px);- background: var(--field-bg);- border-radius: var(--radius-sm);-}--.reference-trim { display: grid; gap: var(--space-2); min-width: 0; }-.reference-trim__summary { display: flex; flex-direction: column; gap: 4px; font-variant-numeric: tabular-nums; }-.reference-trim__summary span, .reference-trim__ticks { color: var(--text-muted); font-size: var(--text-xs); }-.reference-trim__scroll { min-width: 0; overflow-x: auto; padding-bottom: var(--space-2); }-.reference-trim__track { width: 100%; padding: 2px 4px; }-.reference-trim__ticks { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }-.reference-trim__bar { position: relative; height: 40px; margin: 8px 7px 0; border-radius: var(--radius-sm); background: var(--panel-3); touch-action: none; user-select: none; }-.reference-trim__selection { position: absolute; top: 0; bottom: 0; display: flex; border: 2px solid var(--accent); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--accent) 20%, var(--panel-2)); }-.reference-trim__selection button { touch-action: none; border: 0; padding: 0; }-.reference-trim__handle { position: absolute; top: -2px; bottom: -2px; width: 14px; border-radius: 3px; background: var(--accent); cursor: ew-resize; z-index: 1; }-.reference-trim__handle:first-child { left: -7px; }-.reference-trim__handle:last-child { right: -7px; }-.reference-trim__handle::after { content: ""; position: absolute; left: 6px; top: 11px; width: 2px; height: 14px; background: var(--panel-2); }-.reference-trim__move { width: 100%; min-width: 0; overflow: hidden; font-size: var(--text-xs); color: var(--text-primary); background: transparent; cursor: grab; }-.reference-trim__move:active { cursor: grabbing; }-.reference-trim__selection button:focus-visible { outline: 2px solid var(--text-primary); outline-offset: 3px; }-.reference-trim__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }--.reference-video p {- color: var(--text-muted);+ min-width: 0;+ overflow: hidden;font-size: var(--text-xs);+ text-overflow: ellipsis;+ white-space: nowrap;}-.reference-video label {- display: flex;- align-items: center;- gap: var(--space-2);-}--.reference-fields__actions {- display: flex;- flex-wrap: wrap;- gap: var(--space-2);- margin-top: var(--space-2);-}--.reference-type h3 {- flex: 0 0 auto;+.reference-refmods p {margin: 0;+ color: var(--text-muted);+ font-size: var(--text-xs);}-.reference-type .reference-type__trigger {- flex: 1;- min-width: 0;- width: auto;-}--.reference-type__trigger {- width: 100%;- min-height: var(--control-md);- display: flex;- align-items: center;- justify-content: space-between;- padding: 0 var(--space-3);- border: 1px solid var(--line-strong);- border-radius: var(--radius-sm);- color: var(--text-primary);- background: var(--field-bg);- font-size: var(--text-base);- font-weight: var(--weight-semibold);-}--.reference-type__trigger:hover {- border-color: var(--accent);-}--.reference-preset-summary > span {- display: block;- margin-bottom: var(--space-1);- color: var(--text-secondary);- font-size: var(--text-sm);- font-weight: var(--weight-medium);-}--.reference-preset-summary > button {- width: 100%;- min-height: 64px;- display: flex;- align-items: center;- justify-content: space-between;- gap: var(--space-3);- padding: var(--space-3);- border: 1px solid var(--line);- border-radius: var(--radius-sm);- color: var(--text-primary);- background: var(--field-bg);- text-align: left;-}--.reference-preset-summary > button:hover {- border-color: var(--accent);-}--.reference-preset-summary b,-.reference-preset-summary small {- display: block;-}--.reference-preset-summary small {- display: -webkit-box;- margin-top: var(--space-1);- overflow: hidden;- -webkit-box-orient: vertical;- -webkit-line-clamp: 3;- color: var(--text-muted);- font-size: var(--text-sm);- line-height: var(--leading-normal);+.reference-used-by {+ padding: var(--space-2) var(--space-3) var(--space-3);}.reference-used-by h3 span {float: right;- min-width: var(--space-5);- padding: 0 var(--space-2);- border-radius: var(--radius-pill);- color: var(--text-secondary);- background: var(--panel-3);- font-size: var(--text-sm);- text-align: center;+ color: var(--text-muted);+ font-weight: var(--weight-regular);}.reference-used-by > button {@@ -787,258 +559,154 @@align-items: center;gap: var(--space-2);width: 100%;- min-height: var(--control-sm);- margin-top: var(--space-1);- padding: var(--space-1) var(--space-2);- border: 1px solid transparent;+ min-height: 28px;+ padding: 0 var(--space-2);+ border: 0;border-radius: var(--radius-sm);color: var(--text-secondary);background: transparent;text-align: left;}-.reference-used-by > button:hover {- border-color: var(--line);- background: var(--panel-3);-}--.reference-used-by > button:focus-visible {- outline: 2px solid var(--accent);- outline-offset: 1px;-}--.reference-used-by b {- overflow-wrap: anywhere;- color: var(--text-primary);- font-size: var(--text-base);- font-weight: var(--weight-semibold);- line-height: var(--leading-snug);-}--.reference-used-by > p {- margin: 0;- color: var(--text-muted);- font-size: var(--text-sm);- line-height: var(--leading-normal);-}--/* --- Portable path --------------------------------------------------------- */--/* --- Empty state ----------------------------------------------------------- */--.reference-empty {- min-height: 280px;- display: flex;- flex-direction: column;- align-items: center;- justify-content: center;- padding: var(--space-5);- text-align: center;- color: var(--text-muted);-}--.reference-empty b {- margin: var(--space-3) 0 var(--space-2);- color: var(--text-primary);- font-size: var(--text-md);- font-weight: var(--weight-semibold);- line-height: var(--leading-snug);-}--.reference-empty p {- margin: 0;- max-width: 34ch;- color: var(--text-muted);- font-size: var(--text-base);- line-height: var(--leading-normal);-}--/* --- Add-reference dialog -------------------------------------------------- */--.reference-dialog-backdrop {- position: fixed;- z-index: 100;- inset: 0;- display: grid;- place-items: center;- background: var(--scrim);+.reference-used-by > button:hover {+ color: var(--text-primary);+ background: var(--fill-subtle-hover);}-.reference-dialog {- width: min(560px, calc(100vw - var(--space-6)));- padding: var(--space-6);- border: 1px solid var(--stroke-surface);- border-radius: var(--radius-xl);- background: var(--dialog-bg);- box-shadow: var(--shadow);+.reference-used-by b {+ min-width: 0;+ overflow: hidden;+ color: var(--text-primary);+ font-size: var(--text-base);+ font-weight: var(--weight-regular);+ text-overflow: ellipsis;+ white-space: nowrap;}-.reference-dialog h2 {+.reference-used-by > p {margin: 0;- color: var(--text-primary);- font-size: var(--text-xl);- font-weight: var(--weight-semibold);- line-height: var(--leading-tight);+ color: var(--text-muted);+ font-size: var(--text-xs);}-.reference-dialog p {- margin: var(--space-2) 0 var(--space-5);- color: var(--text-secondary);- font-size: var(--text-base);- line-height: var(--leading-normal);-}+/* --- Video reference ---------------------------------------------------------- */-.reference-dialog label {- display: block;- margin-top: var(--space-4);+.reference-video {+ display: grid;+ gap: var(--space-3);+ padding: var(--space-3);}-.reference-dialog label > span {- display: block;- margin-bottom: var(--space-1);- color: var(--text-secondary);- font-size: var(--text-sm);- font-weight: var(--weight-medium);- line-height: var(--leading-snug);+.reference-video-dialog .reference-video {+ padding: 0;}-.reference-dialog input,-.reference-dialog textarea {+.reference-video-preview {+ display: block;width: 100%;- height: var(--field-height);- padding: 0 var(--space-3);- border: 1px solid var(--line);+ max-height: min(50vh, 460px);+ background: var(--layer-alt);border-radius: var(--radius-sm);- color: var(--text-primary);- background: var(--field-bg);- font-family: var(--font-sans);- font-size: var(--text-base);}-.reference-dialog input:focus,-.reference-dialog textarea:focus {- border-color: var(--accent);-}+.reference-trim { display: grid; gap: var(--space-2); min-width: 0; }+.reference-trim__summary { display: flex; flex-direction: column; gap: 4px; font-variant-numeric: tabular-nums; }+.reference-trim__summary span, .reference-trim__ticks { color: var(--text-muted); font-size: var(--text-xs); }+.reference-trim__scroll { min-width: 0; overflow-x: auto; padding-bottom: var(--space-2); }+.reference-trim__track { width: 100%; padding: 2px 4px; }+.reference-trim__ticks { display: flex; justify-content: space-between; font-variant-numeric: tabular-nums; }+.reference-trim__bar { position: relative; height: 40px; margin: 8px 7px 0; border-radius: var(--radius-sm); background: var(--panel-3); touch-action: none; user-select: none; }+.reference-trim__selection { position: absolute; top: 0; bottom: 0; display: flex; border: 2px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft); }+.reference-trim__selection button { touch-action: none; border: 0; padding: 0; }+.reference-trim__handle { position: absolute; top: -2px; bottom: -2px; width: 14px; border-radius: 3px; background: var(--accent); cursor: ew-resize; z-index: 1; }+.reference-trim__handle:first-child { left: -7px; }+.reference-trim__handle:last-child { right: -7px; }+.reference-trim__handle::after { content: ""; position: absolute; left: 6px; top: 11px; width: 2px; height: 14px; background: var(--panel-2); }+.reference-trim__move { width: 100%; min-width: 0; overflow: hidden; font-size: var(--text-xs); color: var(--text-primary); background: transparent; cursor: grab; }+.reference-trim__move:active { cursor: grabbing; }+.reference-trim__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }-.reference-dialog textarea {- height: 136px;- padding: var(--space-2) var(--space-3);- resize: none;- line-height: var(--leading-normal);+.reference-video p {+ color: var(--text-muted);+ font-size: var(--text-xs);}-.reference-dialog > div {+.reference-video label {display: flex;- justify-content: flex-end;+ align-items: center;gap: var(--space-2);- margin-top: var(--space-5);-}--.reference-dialog .primary-button:disabled {- opacity: 0.5;-}--/* --- Preset picker --------------------------------------------------------- */--.reference-preset-dialog {- width: min(920px, calc(100vw - var(--space-6)));- height: min(680px, calc(100vh - var(--space-6)));- display: flex;- flex-direction: column;- overflow: hidden;- border: 1px solid var(--stroke-surface);- border-radius: var(--radius-xl);- background: var(--dialog-bg);- box-shadow: var(--shadow);-}--.reference-preset-dialog > header {- flex-shrink: 0;- min-height: 82px;- display: flex;- align-items: flex-start;- justify-content: space-between;- gap: var(--space-4);- padding: var(--space-5);- border-bottom: 1px solid var(--line);-}--.reference-preset-dialog h2,-.reference-preset-dialog h3,-.reference-preset-dialog p {- margin: 0;-}--.reference-preset-dialog h2 {- color: var(--text-primary);- font-size: var(--text-xl);- line-height: var(--leading-tight);}-.reference-preset-dialog > header p {- margin-top: var(--space-1);- color: var(--text-muted);- font-size: var(--text-sm);-}+/* --- Add-reference dialog (a wide ContentDialog) --------------------------------+ A type list on the left, and on the right a search box, the subcategory+ SelectorBar and the presets. The dialog body scrolls the preset grid only. */-.reference-preset-dialog > header > button {- width: var(--control-sm);- height: var(--control-sm);- display: grid;- flex: 0 0 auto;- place-items: center;- border: 1px solid var(--line);- border-radius: var(--radius-sm);- color: var(--text-muted);- background: var(--panel-3);+.reference-preset-dialog__lead {+ margin: 0 0 var(--space-3);+ color: var(--text-secondary);}.reference-preset-dialog__body {+ height: min(480px, 56vh);min-height: 0;- flex: 1 1 auto;display: grid;- grid-template-columns: 190px minmax(0, 1fr);+ grid-template-columns: 168px minmax(0, 1fr);+ gap: var(--space-3);}.reference-preset-dialog__body > nav {- padding: var(--space-3);- border-right: 1px solid var(--line);- background: var(--panel);+ display: flex;+ flex-direction: column;+ gap: 2px;+ overflow-y: auto;}.reference-preset-dialog__body > nav button {+ position: relative;width: 100%;min-height: var(--control-md);display: flex;align-items: center;- justify-content: space-between;padding: 0 var(--space-3);border: 0;border-radius: var(--radius-sm);- color: var(--text-secondary);+ color: var(--text-primary);background: transparent;font-size: var(--text-base);- font-weight: var(--weight-medium);+ text-align: left;}-.reference-preset-dialog__body > nav button:hover,-.reference-preset-dialog__body > nav button.active {- color: var(--text-primary);- background: var(--accent-soft);+.reference-preset-dialog__body > nav button:hover {+ background: var(--fill-subtle-hover);}+/* Selected: a subtle fill and the 3×16px accent pill. */.reference-preset-dialog__body > nav button.active {- box-shadow: inset 2px 0 var(--accent-bright);+ background: var(--fill-subtle-hover);+}++.reference-preset-dialog__body > nav button.active::before {+ content: "";+ position: absolute;+ left: 0;+ top: calc(50% - 8px);+ width: 3px;+ height: 16px;+ border-radius: 2px;+ background: var(--accent);}.reference-preset-dialog__body > section {min-width: 0;min-height: 0;- padding: var(--space-4);+ display: flex;+ flex-direction: column;+ gap: var(--space-2);overflow-y: auto;}.reference-preset-search {+ flex: 0 0 auto;height: var(--field-height);display: flex;align-items: center;@@ -1059,22 +727,6 @@box-shadow: inset 0 -1px 0 var(--field-focus-line);}-.reference-preset-toolbar {- display: flex;- align-items: center;- gap: var(--space-3);- margin-bottom: var(--space-4);-}--.reference-preset-toolbar .reference-preset-search {- flex: 1;- min-width: 0;-}--.reference-preset-toolbar > button {- flex-shrink: 0;-}-.reference-preset-search input {min-width: 0;flex: 1 1 auto;@@ -1087,34 +739,14 @@}.reference-subcategories {- display: flex;+ flex: 0 0 auto;flex-wrap: wrap;- gap: var(--space-2);- margin-bottom: var(--space-4);-}--.reference-subcategories button {- min-height: var(--control-sm);- padding: 0 var(--space-3);- border: 1px solid var(--line);- border-radius: var(--radius-pill);- color: var(--text-secondary);- background: var(--panel-3);- font-size: var(--text-sm);- font-weight: var(--weight-medium);-}--.reference-subcategories button:hover,-.reference-subcategories button.active {- border-color: var(--accent);- color: var(--accent-bright);- background: var(--accent-soft);}.reference-preset-grid {display: grid;- grid-template-columns: repeat(2, minmax(0, 1fr));- gap: var(--space-3);+ grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));+ gap: var(--space-2);}.reference-preset-card { position: relative; min-width: 0; }@@ -1122,33 +754,41 @@.reference-preset-select {width: 100%;height: 100%;- min-height: 104px;- padding: var(--space-4);- border: 1px solid var(--line);- border-radius: var(--radius-md);+ min-height: 88px;+ padding: var(--space-3);+ border: 1px solid var(--stroke-card);+ border-radius: var(--radius-sm);color: var(--text-primary);- background: var(--panel-3);+ background: var(--card);text-align: left;overflow: hidden;+ transition: var(--transition-control);+}++.reference-preset-select:hover {+ background: var(--card-hover);+}++.reference-preset-select:active {+ background: var(--card-pressed);}.reference-preset-select.reference-preset-card--with-icon {display: grid;- grid-template-columns: 80px minmax(0, 1fr);+ grid-template-columns: 64px minmax(0, 1fr);grid-template-rows: auto auto 1fr;column-gap: var(--space-3);align-content: center;}.reference-preset-icon {- width: 80px;- height: 80px;+ width: 64px;+ height: 64px;grid-column: 1;grid-row: 1 / 4;align-self: center;object-fit: cover;object-position: center;- border: 1px solid var(--line);border-radius: var(--radius-sm);}@@ -1161,30 +801,20 @@.reference-preset-select > .reference-preset-icon { grid-column: 1; margin: 0; }-.reference-preset-select:hover {- border-color: var(--accent);- background: var(--accent-soft);-}--.reference-preset-select.active {- border-color: var(--accent-bright);- background: var(--accent-soft);-}-/* A sibling of the selection button: hovering this area never hovers the card. */.reference-preset-generate {position: absolute;- left: var(--space-4);+ left: var(--space-3);top: 50%;transform: translateY(-50%);- width: 80px;- height: 80px;+ width: 64px;+ height: 64px;display: grid;place-items: center;- border: 1px solid var(--line-strong);+ border: 1px solid var(--stroke-control);border-radius: var(--radius-sm);color: var(--text-primary);- background: var(--panel-2);+ background: var(--fill-control);opacity: 0;}@@ -1193,39 +823,6 @@.reference-preset-generate:disabled:hover { opacity: 1; cursor: progress; }-.reference-location-settings {- display: flex;- flex-direction: column;- gap: var(--space-2);- padding: var(--space-3);- border-bottom: 1px solid var(--line);-}--.reference-location-settings__group {- display: grid;- grid-template-columns: 96px minmax(0, 1fr);- align-items: center;- gap: var(--space-3);-}--.reference-location-settings__group > span {- color: var(--text-secondary);- font-size: var(--text-sm);- font-weight: var(--weight-medium);-}--.reference-location-settings__group select {- min-width: 0;- width: 100%;- height: var(--control-sm);- padding: 0 var(--space-2);- border: 1px solid var(--line-strong);- border-radius: var(--radius-sm);- color: var(--text-primary);- background: var(--field-bg);- font-size: var(--text-sm);-}-.reference-preset-grid b,.reference-preset-grid span,.reference-preset-grid small {@@ -1233,124 +830,30 @@}.reference-preset-grid small {- margin-bottom: var(--space-1);- color: var(--accent-bright);+ margin-bottom: 2px;+ color: var(--text-muted);font-size: var(--text-2xs);- font-weight: var(--weight-semibold);}.reference-preset-grid b {+ overflow: hidden;font-size: var(--text-base);+ font-weight: var(--weight-semibold);+ text-overflow: ellipsis;+ white-space: nowrap;}.reference-preset-grid span {- margin-top: var(--space-2);- color: var(--text-muted);- font-size: var(--text-sm);- line-height: var(--leading-normal);+ display: -webkit-box;+ margin-top: 2px;+ overflow: hidden;+ -webkit-box-orient: vertical;+ -webkit-line-clamp: 2;+ color: var(--text-secondary);+ font-size: var(--text-xs);+ line-height: 16px;}.reference-preset-grid > p {color: var(--text-muted);}--.reference-custom-option {- min-height: 100%;- display: flex;- flex-direction: column;- align-items: center;- justify-content: center;- padding: var(--space-8);- text-align: center;-}--.reference-custom-option > svg {- color: var(--accent-bright);-}--.reference-custom-option h3 {- margin-top: var(--space-3);- color: var(--text-primary);- font-size: var(--text-lg);-}--.reference-custom-option p {- max-width: 44ch;- margin: var(--space-2) 0 var(--space-5);- color: var(--text-muted);- line-height: var(--leading-normal);-}--.reference-image-option > small {- margin: calc(var(--space-3) * -1) 0 var(--space-4);- color: var(--text-secondary);- font-size: var(--text-sm);-}--.reference-image-option .primary-button {- gap: var(--space-2);-}--/* --- Responsive ------------------------------------------------------------ */--@media (max-width: 1180px) {- .references-view {- grid-template-columns: minmax(0, 1fr) 340px;- }-- .reference-grid > button {- grid-template-columns: 156px minmax(0, 1fr);- }-- .references-main {- padding-inline: var(--space-5);- }-}--@media (max-width: 1040px) {- .references-main {- padding: var(--space-5) var(--space-4) var(--space-7);- }-}--@media (max-width: 960px) {- .references-view {- grid-template-columns: minmax(0, 1fr);- grid-template-rows: minmax(0, 1fr) auto;- }-- .reference-inspector {- max-height: 60vh;- border-left: 0;- border-top: 1px solid var(--line);- }-}--@media (max-width: 900px) {- .references-heading {- flex-direction: column;- align-items: flex-start;- }-- .references-main {- padding-inline: var(--space-4);- }-- .reference-grid {- grid-template-columns: minmax(0, 1fr);- }-- .reference-preset-dialog__body {- grid-template-columns: 150px minmax(0, 1fr);- }-- .reference-preset-grid {- grid-template-columns: minmax(0, 1fr);- }-}--/* A blank reference is a legitimate in-progress state, but it must be visibly- inert: binding skips it, so the card says so rather than looking finished. */-.reference-card__incomplete {- color: var(--warning);-}