Skip to content

AI media harness for planning, generating, and editing locally

TypeScript

Add category-based reference creation

Bitti60ba66fd06dc
diff --git a/src/components/ProjectWorkspace.test.ts b/src/components/ProjectWorkspace.test.ts
index bb8035e..4d6c8e8 100644
--- a/src/components/ProjectWorkspace.test.ts
+++ b/src/components/ProjectWorkspace.test.ts
@@ -1170,11 +1170,15 @@ describe("project workspace timecode", () => {
const config = createProjectConfig({ name: "Ceramic lamp", prompt: "A quiet product film", aspectRatio: "16:9", resolution: "1080p", targetDurationSeconds: 30 });
const onChange = vi.fn();
await asDesktopApp([{ name: "IMG_4821", relativePath: "references/IMG_4821.jpg" }], async () => {
- render(createElement(ReferencesView, { config, folderPath: "C:\\Ceramic Lamp", onChange }));
+ const view = render(createElement(ReferencesView, { config, folderPath: "C:\\Ceramic Lamp", onChange }));
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: "Image" }));
- fireEvent.click(within(dialog).getByRole("button", { name: "Choose images" }));
+ fireEvent.click(within(dialog).getByRole("button", { name: "Product" }));
+ fireEvent.click(within(dialog).getByRole("button", { name: "New" }));
+ const withReference = onChange.mock.calls[0][0];
+ view.rerender(createElement(ReferencesView, { config: withReference, folderPath: "C:\\Ceramic Lamp", onChange }));
+ onChange.mockClear();
+ fireEvent.click(screen.getByRole("button", { name: "Add images" }));
await waitFor(() => expect(onChange).toHaveBeenCalled());
});
diff --git a/src/components/workspace/ReferencesView.test.tsx b/src/components/workspace/ReferencesView.test.tsx
index ca59665..dcad5be 100644
--- a/src/components/workspace/ReferencesView.test.tsx
+++ b/src/components/workspace/ReferencesView.test.tsx
@@ -50,6 +50,38 @@ function setup(initial = project()) {
}
describe("Reference type presets", () => {
+ it.each([
+ ["Character", "character", "Animation"],
+ ["Product", "product", "Technology"],
+ ["Location", "location", "Urban"],
+ ["Style", "style", "Cinematic"],
+ ])("creates and saves an editable %s with its subcategory", (label, category, subcategory) => {
+ const state = setup();
+ 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("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);
+ 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());
+ cleanup();
+ 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(restored.latest().references[0].subcategory).toBe("");
+ const nextCategory = category === "product" ? "style" : "product";
+ fireEvent.change(screen.getByRole("combobox", { name: "Category" }), { target: { value: nextCategory } });
+ expect(restored.latest().references[0]).toMatchObject({ intendedUse: [nextCategory], subcategory: "", description: "Keep the cool blue colors." });
+ });
+
it("renames the selected reference from the inspector header", () => {
const state = setup();
const name = screen.getByRole("textbox", { name: "Reference name" });
@@ -73,15 +105,17 @@ describe("Reference type presets", () => {
const dialog = screen.getByRole("dialog", { name: "Add a reference" });
expect(dialog).toBeInTheDocument();
expect(state.latest().references).toHaveLength(1);
- expect(within(dialog).getByRole("button", { name: "Text" })).toHaveAttribute("aria-pressed", "true");
- fireEvent.click(within(dialog).getByRole("button", { name: "Use Text" }));
- expect(state.latest().references[0]).toMatchObject({ name: "New definition", intendedUse: [] });
+ expect(within(dialog).queryByRole("button", { name: "Text" })).not.toBeInTheDocument();
+ expect(within(dialog).queryByRole("button", { name: "Image" })).not.toBeInTheDocument();
+ expect(within(dialog).getByRole("button", { name: "Character" })).toHaveAttribute("aria-pressed", "true");
+ fireEvent.click(within(dialog).getByRole("button", { name: "New" }));
+ expect(state.latest().references[0]).toMatchObject({ name: "New character", description: "", intendedUse: ["character"] });
});
- it("shows one Type control without the old explanatory copy", () => {
+ it("keeps legacy uncategorized references editable", () => {
setup();
- expect(screen.getByRole("heading", { name: "Type" })).toBeInTheDocument();
- expect(screen.getByRole("button", { name: "Text" })).toBeInTheDocument();
+ expect(screen.getByRole("combobox", { name: "Category" })).toHaveValue("custom");
+ expect(screen.getByRole("button", { name: "Choose preset" })).toBeInTheDocument();
expect(screen.queryByText("Intended use")).not.toBeInTheDocument();
expect(screen.queryByText(/Select any that apply/)).not.toBeInTheDocument();
expect(screen.getByRole("textbox", { name: "Prompt" })).toHaveValue("A traveler with a weathered red coat.");
@@ -89,7 +123,7 @@ describe("Reference type presets", () => {
it("chooses one prepared character from the scalable popup", () => {
const state = setup();
- fireEvent.click(screen.getByRole("button", { name: "Text" }));
+ fireEvent.click(screen.getByRole("button", { name: "Choose preset" }));
const dialog = screen.getByRole("dialog", { name: "Choose a reference type" });
fireEvent.click(within(dialog).getByRole("button", { name: "Character" }));
const groups = within(dialog).getByRole("group", { name: "Character subcategories" });
@@ -103,13 +137,15 @@ describe("Reference type presets", () => {
const reference = state.latest().references[0];
expect(reference.intendedUse).toEqual(["character"]);
expect(reference.description).toBe("Sherlock Holmes, Benedict Cumberbatch portrayal.");
- expect(screen.queryByRole("textbox", { name: "Prompt" })).not.toBeInTheDocument();
- expect(screen.getByText("Sherlock Holmes · Benedict Cumberbatch")).toBeInTheDocument();
+ expect(screen.getByRole("textbox", { name: "Prompt" })).toHaveValue(reference.description);
+ expect(screen.getByRole("combobox", { name: "Subcategory" })).toHaveValue("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." });
});
it("shows a bundled MiniMax icon for an illustrated character preset", () => {
setup();
- fireEvent.click(screen.getByRole("button", { name: "Text" }));
+ fireEvent.click(screen.getByRole("button", { name: "Choose preset" }));
const dialog = screen.getByRole("dialog", { name: "Choose a reference type" });
fireEvent.click(within(dialog).getByRole("button", { name: "Character" }));
fireEvent.change(within(dialog).getByRole("textbox", { name: "Search reference options" }), { target: { value: "Abby Sciuto" } });
@@ -125,9 +161,9 @@ describe("Reference type presets", () => {
expect(detailIcon.parentElement).toHaveClass("reference-detail-art--preset");
});
- it("searches location templates and can return to a custom prompt", () => {
+ it("searches location templates and allows editing their prompt directly", () => {
const state = setup();
- fireEvent.click(screen.getByRole("button", { name: "Text" }));
+ fireEvent.click(screen.getByRole("button", { name: "Choose preset" }));
const dialog = screen.getByRole("dialog", { name: "Choose a reference type" });
fireEvent.click(within(dialog).getByRole("button", { name: "Location" }));
const groups = within(dialog).getByRole("group", { name: "Location subcategories" });
@@ -149,14 +185,10 @@ describe("Reference type presets", () => {
content: "Lunar base, at night, in winter.",
});
- fireEvent.click(screen.getByRole("button", { name: "Location" }));
- const reopened = screen.getByRole("dialog", { name: "Choose a reference type" });
- fireEvent.click(within(reopened).getByRole("button", { name: "Text" }));
- fireEvent.click(within(reopened).getByRole("button", { name: "Use Text" }));
-
- expect(state.latest().references[0].intendedUse).toEqual([]);
+ fireEvent.change(screen.getByRole("textbox", { name: "Prompt" }), { target: { value: "A lunar research outpost in winter." } });
+ expect(state.latest().references[0].intendedUse).toEqual(["location"]);
expect(screen.queryByRole("region", { name: "Location settings" })).not.toBeInTheDocument();
- expect(screen.getByRole("textbox", { name: "Prompt" })).toHaveValue("Lunar base, at night, in winter.");
+ expect(screen.getByRole("textbox", { name: "Prompt" })).toHaveValue("A lunar research outpost in winter.");
});
it("creates locations directly and restores, updates, and clears their saved settings in the inspector", () => {
@@ -185,7 +217,7 @@ describe("Reference type presets", () => {
description: "Coastal village, at night, in winter.",
content: "Coastal village, at night, in winter.",
});
- fireEvent.click(screen.getByRole("button", { name: "Location" }));
+ fireEvent.click(screen.getByRole("button", { name: "Choose preset" }));
const picker = screen.getByRole("dialog", { name: "Choose a reference type" });
fireEvent.change(within(picker).getByRole("textbox", { name: "Search reference options" }), { target: { value: "lunar" } });
fireEvent.click(within(picker).getByRole("button", { name: /Lunar base/ }));
@@ -198,7 +230,7 @@ describe("Reference type presets", () => {
expect(screen.getByRole("combobox", { name: "Time of day" })).toHaveValue("");
});
- it("creates one image-only reference with every selected picture attached", async () => {
+ it("attaches multiple images to a new product without changing its category or prompt", async () => {
(window as unknown as Record<string, unknown>).__TAURI_INTERNALS__ = {};
vi.mocked(invoke).mockResolvedValue([
{ name: "front", relativePath: "references/front.png" },
@@ -208,15 +240,17 @@ 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: "Image" }));
- fireEvent.click(within(dialog).getByRole("button", { name: "Choose images" }));
+ fireEvent.click(within(dialog).getByRole("button", { name: "Product" }));
+ fireEvent.click(within(dialog).getByRole("button", { name: "New" }));
+ fireEvent.click(screen.getByRole("button", { name: "Add images" }));
- await waitFor(() => expect(state.latest().references).toHaveLength(2));
+ await waitFor(() => expect(state.latest().references[0].images).toHaveLength(2));
expect(invoke).toHaveBeenCalledWith("choose_reference_images", { folderPath: "C:\\\\project" });
expect(state.latest().references[0]).toMatchObject({
kind: "text",
- name: "front",
+ name: "New product",
description: "",
+ intendedUse: ["product"],
images: [
{ name: "front", relativePath: "references/front.png" },
{ name: "side", relativePath: "references/side.png" },
diff --git a/src/components/workspace/ReferencesView.tsx b/src/components/workspace/ReferencesView.tsx
index 242d381..b33e45b 100644
--- a/src/components/workspace/ReferencesView.tsx
+++ b/src/components/workspace/ReferencesView.tsx
@@ -1,4 +1,4 @@
-import { BookOpen, ChevronRight, FileText, ImagePlus, Link2, Plus, Search, Trash2, Upload, Users, X } from "lucide-react";
+import { BookOpen, ChevronRight, FileText, ImagePlus, Link2, Plus, Search, Trash2, Users, X } from "lucide-react";
import { invoke } from "@tauri-apps/api/core";
import { useMemo, useState } from "react";
import { isReferenceDescribed, referenceImages, type ProjectConfig, type ProjectReference, type ProjectReferenceImage } from "../../lib/project";
@@ -9,9 +9,10 @@ import {
REFERENCE_TYPES,
referenceType,
referenceTypeLabel,
+ referenceSubcategories,
selectedReferencePreset,
type ReferencePreset,
- type ReferenceType,
+ type PresetReferenceType,
} from "../../lib/reference-presets";
import { LOCATION_SETTING_GROUPS } from "../../lib/expanded-reference-options";
import { isTauri } from "../../lib/persistence";
@@ -31,13 +32,14 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje
const [importError, setImportError] = useState<string | null>(null);
const [presetDialog, setPresetDialog] = useState(false);
const [creatingReference, setCreatingReference] = useState(false);
- const [pickerSection, setPickerSection] = useState<ReferenceType | "image">("custom");
- const [pickerType, setPickerType] = useState<ReferenceType>("custom");
+ const [pickerType, setPickerType] = useState<PresetReferenceType>("character");
const [pickerSubcategory, setPickerSubcategory] = useState("all");
const [presetSearch, setPresetSearch] = useState("");
const selected = config.references.find((ref) => ref.id === selectedId);
const selectedImages = selected ? referenceImages(selected) : [];
const selectedPreset = selected ? selectedReferencePreset(selected) : undefined;
+ const selectedType = selected ? referenceType(selected) : "custom";
+ const selectedSubcategory = selected?.subcategory ?? selectedPreset?.subcategory ?? "";
const selectedLocation = useMemo(() => selected && referenceType(selected) === "location"
? locationSelectionFromPrompt(selected.description)
: undefined, [selected]);
@@ -47,22 +49,22 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje
// Starts empty on purpose. Seeding it with the instruction text meant an
// unedited definition shipped "Describe the traits…" to the model as if the
// user had written it. The guidance lives in the field's placeholder instead.
- const addTextReference = (name = "New definition", description = "", intendedUse: ProjectReference["intendedUse"] = []) => {
- const id = `ref-${Date.now()}`;
- const reference: ProjectReference = { id, kind: "text", name, description, content: description || null, intendedUse, createdAt: new Date().toISOString() };
+ const addTextReference = (name: string, description: string, type: PresetReferenceType, subcategory = "") => {
+ const id = `ref-${crypto.randomUUID()}`;
+ const reference: ProjectReference = { id, kind: "text", name, description, content: description || null, intendedUse: [type], subcategory, createdAt: new Date().toISOString() };
onChange({ ...config, references: [reference, ...config.references] });
setSelectedId(id);
return id;
};
const openNewReference = () => {
setCreatingReference(true);
- setPickerSection("custom");
- setPickerType("custom");
+ setPickerType("character");
setPickerSubcategory("all");
setPresetSearch("");
setPresetDialog(true);
};
const addImages = async () => {
+ if (!selected) return;
setImportError(null);
if (!isTauri()) {
setImportError("Image import is available in the desktop app.");
@@ -77,16 +79,7 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje
name: image.name,
relativePath: image.relativePath,
}));
- if (creatingReference) {
- const id = `ref-${stamp}`;
- const reference: ProjectReference = { id, kind: "text", name: imported[0].name, description: "", content: null, images, intendedUse: [], createdAt: new Date().toISOString() };
- onChange({ ...config, references: [reference, ...config.references] });
- setSelectedId(id);
- setPresetDialog(false);
- setCreatingReference(false);
- } else if (selected) {
- update(selected.id, { images: [...(selected.images ?? []), ...images] });
- }
+ update(selected.id, { images: [...(selected.images ?? []), ...images] });
} catch (reason) {
setImportError(reason instanceof Error ? reason.message : String(reason));
}
@@ -103,16 +96,13 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje
const openPresetPicker = () => {
if (!selected) return;
setCreatingReference(false);
- setPickerSection(referenceType(selected));
- setPickerType(referenceType(selected));
+ setPickerType(selectedType === "custom" ? "character" : selectedType);
setPickerSubcategory("all");
setPresetSearch("");
setPresetDialog(true);
};
- const chooseCustom = () => {
- if (creatingReference) addTextReference();
- else if (selected) update(selected.id, { intendedUse: [] });
- else return;
+ const createEmptyReference = () => {
+ addTextReference(`New ${referenceTypeLabel(pickerType).toLocaleLowerCase()}`, "", pickerType, pickerSubcategory === "all" ? "" : pickerSubcategory);
setPresetDialog(false);
setCreatingReference(false);
};
@@ -120,8 +110,8 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje
const prompt = preset.type === "location"
? composeLocationPrompt(preset, creatingReference ? {} : selectedLocation?.settings ?? {})
: preset.prompt;
- if (creatingReference) addTextReference(preset.name, prompt, [preset.type]);
- else if (selected) update(selected.id, { intendedUse: [preset.type], description: prompt, content: prompt });
+ if (creatingReference) addTextReference(preset.name, prompt, preset.type, preset.subcategory);
+ else if (selected) update(selected.id, { intendedUse: [preset.type], subcategory: preset.subcategory, description: prompt, content: prompt });
else return;
setPresetDialog(false);
setCreatingReference(false);
@@ -132,7 +122,7 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje
const query = presetSearch.trim().toLocaleLowerCase();
return !query || `${preset.name} ${preset.prompt} ${preset.subcategory} ${preset.searchTerms ?? ""}`.toLocaleLowerCase().includes(query);
});
- const subcategories = [...new Set(REFERENCE_PRESETS.filter((preset) => preset.type === pickerType).map((preset) => preset.subcategory))];
+ const subcategories = referenceSubcategories(pickerType);
return <div className="references-view">
<main className="references-main">
@@ -193,13 +183,11 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje
{selectedImages.length === 0 && !selectedPresetIcon && <em>{referenceKindLabel(selected)}</em>}
</div>
<div className="reference-fields">
- {referenceType(selected) === "custom" ? <label><span>Prompt</span><textarea 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 })} /></label> : <div className="reference-preset-summary">
- <span>Selection</span>
- <button onClick={openPresetPicker}>
- <span><b>{selectedReferencePreset(selected)?.name ?? `${referenceTypeLabel(referenceType(selected))} selection`}</b><small>{selected.description}</small></span>
- <ChevronRight size={17} />
- </button>
- </div>}
+ <label><span>Prompt</span><textarea 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" onClick={() => void addImages()}><ImagePlus size={16} /> Add images</button>
+ <button className="secondary-button" onClick={openPresetPicker} aria-haspopup="dialog">Choose preset<ChevronRight size={16} /></button>
+ </div>
</div>
{selectedLocation && <section className="reference-location-settings" aria-label="Location settings">
{LOCATION_SETTING_GROUPS.map((group) => <label key={group.id} className="reference-location-settings__group">
@@ -213,11 +201,15 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje
</select>
</label>)}
</section>}
- <section className="reference-type">
- <h3>Type</h3>
- <button className="reference-type__trigger" onClick={openPresetPicker} aria-haspopup="dialog">
- <span>{referenceTypeLabel(referenceType(selected))}</span><ChevronRight size={17} />
- </button>
+ <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>}
</section>
<section className="reference-used-by">
<h3>Used by <span>{jobs.length}</span></h3>
@@ -228,28 +220,18 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje
</aside>
{presetDialog && (creatingReference || selected) && <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">{creatingReference ? "Add a reference" : "Choose a reference type"}</h2><p>Use text, a prepared definition, images, or any combination of text and images.</p></div>
+ <div><h2 id="reference-preset-title">{creatingReference ? "Add a reference" : "Choose a reference type"}</h2><p>Choose a preset or create a new reference, then add a prompt and images.</p></div>
<button onClick={() => { setPresetDialog(false); setCreatingReference(false); }} aria-label="Close type picker"><X size={18} /></button>
</header>
<div className="reference-preset-dialog__body">
<nav aria-label="Reference types">
- {REFERENCE_TYPES.map((type) => <button key={type.id} className={pickerSection === type.id ? "active" : ""} aria-pressed={pickerSection === type.id} onClick={() => { setPickerSection(type.id); setPickerType(type.id); setPickerSubcategory("all"); setPresetSearch(""); }}>{type.label}<ChevronRight size={16} /></button>)}
- <button className={pickerSection === "image" ? "active" : ""} aria-pressed={pickerSection === "image"} onClick={() => setPickerSection("image")}>Image<ChevronRight size={16} /></button>
+ {REFERENCE_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>)}
</nav>
<section>
- {pickerSection === "image" ? <div className="reference-custom-option reference-image-option">
- <ImagePlus size={28} />
- <h3>Reference images</h3>
- <p>{creatingReference ? "Choose one or more pictures. The new reference starts with an empty text prompt that you can describe later." : `Add one or more pictures to this reference. Its ${isReferenceDescribed(selected!) ? "text prompt is kept" : "text prompt can remain empty"}.`}</p>
- {!creatingReference && selectedImages.length > 0 && <small>{selectedImages.length} image{selectedImages.length === 1 ? "" : "s"} currently attached</small>}
- <button className="primary-button" onClick={() => void addImages()}><Upload size={16} /> {creatingReference ? "Choose images" : "Add images"}</button>
- </div> : pickerType === "custom" ? <div className="reference-custom-option">
- <FileText size={26} />
- <h3>Text prompt</h3>
- <p>{creatingReference ? "Create an empty text definition and write the prompt in Reference details." : "Keep the current prompt and edit it directly in Reference details."}</p>
- <button className="primary-button" onClick={chooseCustom}>Use Text</button>
- </div> : <>
+ <div className="reference-preset-toolbar">
<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>
<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>)}
@@ -261,7 +243,6 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje
</button>)}
{visiblePresets.length === 0 && <p>No options match that search.</p>}
</div>
- </>}
</section>
</div>
</div></div>}
diff --git a/src/styles/references.css b/src/styles/references.css
index 56178e1..ff2190f 100644
--- a/src/styles/references.css
+++ b/src/styles/references.css
@@ -504,9 +504,36 @@
}
.reference-type {
- display: flex;
+ display: grid;
+ gap: var(--space-2);
+}
+
+.reference-type label {
+ 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 {
+ 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;
+}
+
+.reference-fields__actions {
+ display: flex;
+ flex-wrap: wrap;
+ gap: var(--space-2);
+ margin-top: var(--space-2);
}
.reference-type h3 {
@@ -771,6 +798,7 @@
}
.reference-preset-dialog > header {
+ flex-shrink: 0;
min-height: 82px;
display: flex;
align-items: flex-start;
@@ -860,7 +888,7 @@
display: flex;
align-items: center;
gap: var(--space-2);
- margin-bottom: var(--space-4);
+ margin: 0;
padding: 0 var(--space-3);
border: 1px solid var(--line);
border-radius: var(--radius-sm);
@@ -872,6 +900,22 @@
border-color: var(--accent);
}
+.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;