AI media harness for planning, generating, and editing locally
TypeScript
Show artwork for reference presets
Bitti611168ed0418
diff --git a/src/components/workspace/ReferencesView.test.tsx b/src/components/workspace/ReferencesView.test.tsxindex 51c6fc7..fcf5221 100644--- a/src/components/workspace/ReferencesView.test.tsx+++ b/src/components/workspace/ReferencesView.test.tsx@@ -107,6 +107,24 @@ describe("Reference type presets", () => {expect(screen.getByText("Sherlock Holmes · Benedict Cumberbatch")).toBeInTheDocument();});+ it("shows a bundled MiniMax icon for an illustrated character preset", () => {+ setup();+ fireEvent.click(screen.getByRole("button", { name: "Text" }));+ 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" } });+ const preset = within(dialog).getByRole("button", { name: /Abby Sciuto/ });+ expect(preset).toHaveClass("reference-preset-card--with-icon");+ expect(preset.querySelector(".reference-preset-icon")).toHaveAttribute("src");+ fireEvent.click(preset);++ // Choosing a preset changes the definition, not the user's own reference+ // name. The selected preset still supplies the matching artwork.+ const detailIcon = screen.getByAltText("Hero reference icon");+ expect(detailIcon).toHaveAttribute("src");+ expect(detailIcon.parentElement).toHaveClass("reference-detail-art--preset");+ });+it("searches location templates and can return to a custom prompt", () => {const state = setup();fireEvent.click(screen.getByRole("button", { name: "Text" }));diff --git a/src/components/workspace/ReferencesView.tsx b/src/components/workspace/ReferencesView.tsxindex 94abd02..d3aa273 100644--- a/src/components/workspace/ReferencesView.tsx+++ b/src/components/workspace/ReferencesView.tsx@@ -40,6 +40,8 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Projeconst [locationSettings, setLocationSettings] = useState<LocationSettings>({});const selected = config.references.find((ref) => ref.id === selectedId);const selectedImages = selected ? referenceImages(selected) : [];+ const selectedPreset = selected ? selectedReferencePreset(selected) : undefined;+ const selectedPresetIcon = selectedImages.length === 0 ? selectedPreset?.icon : undefined;const jobs = useMemo(() => config.generationJobs.filter((job) => job.referenceIds.includes(selectedId ?? "")), [config.generationJobs, selectedId]);const update = (id: string, patch: Partial<ProjectReference>) => onChange({ ...config, references: config.references.map((ref) => ref.id === id ? { ...ref, ...patch } : ref) });// Starts empty on purpose. Seeding it with the instruction text meant an@@ -165,9 +167,12 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje{config.references.map((ref) => {const images = referenceImages(ref);const cover = images[0];+ const presetIcon = selectedReferencePreset(ref)?.icon;return <button key={ref.id} className={selectedId === ref.id ? "selected" : ""} onClick={() => setSelectedId(ref.id)}>{cover? <span className="reference-art reference-art--photo"><ReferenceImage folderPath={folderPath} relativePath={cover.relativePath} sourcePath={cover.sourcePath} alt={cover.name} /></span>+ : presetIcon+ ? <span className="reference-art reference-art--photo"><img src={presetIcon} alt="" /></span>: <span className="reference-copy-art"><FileText size={26} /><em>Text definition</em></span>}<span className="reference-card__body"><span><b>{ref.name}</b><small>{referenceKindLabel(ref)}</small></span>{isReferenceDescribed(ref)? <p>{ref.description}</p>@@ -194,14 +199,16 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje</> : <h2>Reference details</h2>}</header><div className="reference-inspector__scroll">{selected ? <>- <div className={`reference-detail-art${selectedImages.length > 0 ? " reference-detail-art--photo" : " reference-detail-art--text"}`}>+ <div className={`reference-detail-art${selectedImages.length > 0 || selectedPresetIcon ? " reference-detail-art--photo" : " reference-detail-art--text"}${selectedPresetIcon ? " reference-detail-art--preset" : ""}`}>{selectedImages.length > 0? <div className="reference-detail-images">{selectedImages.map((image) => <ReferenceImage key={image.id} folderPath={folderPath} relativePath={image.relativePath} sourcePath={image.sourcePath} alt={image.name} />)}</div>+ : selectedPresetIcon+ ? <img className="reference-detail-preset-icon" src={selectedPresetIcon} alt={`${selected.name} reference icon`} />: <span><Users size={30} /></span>}{/* A caption only where there is no picture to look at. It usedto print the file's path over the thumbnail, which is neitherwhat the reference IS nor anything the user acts on. */}- {selectedImages.length === 0 && <em>{referenceKindLabel(selected)}</em>}+ {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 PolStudio should preserve across shots." onChange={(event) => update(selected.id, { description: event.target.value, content: event.target.value || null })} /></label> : <div className="reference-preset-summary">@@ -268,7 +275,8 @@ export function ReferencesView({ config, folderPath, onChange }: { config: Proje<small className="reference-location-settings__preview">{composeLocationPrompt(chosenLocationPreset, locationSettings)}</small></div>}<div className="reference-preset-grid">- {visiblePresets.map((preset) => <button key={preset.id} className={preset.id === locationPresetId ? "active" : ""} aria-pressed={preset.type === "location" ? preset.id === locationPresetId : undefined} onClick={() => choosePreset(preset)}>+ {visiblePresets.map((preset) => <button key={preset.id} className={`${preset.id === locationPresetId ? "active" : ""}${preset.icon ? " reference-preset-card--with-icon" : ""}`.trim()} aria-pressed={preset.type === "location" ? preset.id === locationPresetId : undefined} onClick={() => choosePreset(preset)}>+ {preset.icon && <img className="reference-preset-icon" src={preset.icon} alt="" loading="lazy" />}<small>{preset.subcategory}</small><b>{preset.name}</b><span>{preset.prompt}</span></button>)}{visiblePresets.length === 0 && <p>No options match that search.</p>}diff --git a/src/lib/reference-presets.test.ts b/src/lib/reference-presets.test.tsindex c62d0d5..3161eb4 100644--- a/src/lib/reference-presets.test.ts+++ b/src/lib/reference-presets.test.ts@@ -31,6 +31,12 @@ describe("reference preset catalog", () => {expect(Math.max(...REFERENCE_PRESETS.map((preset) => preset.prompt.length))).toBeLessThanOrEqual(100);});+ it("bundles an icon for every concrete visual preset without treating it as a generation reference", () => {+ const visual = REFERENCE_PRESETS.filter((preset) => preset.type === "character" || preset.type === "product" || preset.type === "location" || preset.type === "style");+ expect(visual).toHaveLength(810);+ expect(visual.every((preset) => typeof preset.icon === "string" && preset.icon.length > 0)).toBe(true);+ });+it("does not multiply products or styles by adjectives", () => {expect(REFERENCE_PRESETS.some((preset) => /^(Eco|Premium|Rugged|Textured|Bright) /.test(preset.name))).toBe(false);});diff --git a/src/lib/reference-presets.ts b/src/lib/reference-presets.tsindex 77d9b94..d7be500 100644--- a/src/lib/reference-presets.ts+++ b/src/lib/reference-presets.ts@@ -12,8 +12,22 @@ export interface ReferencePreset {name: string;prompt: string;searchTerms?: string;+ /** A build-time MiniMax render bundled by Vite. It is presentation only and+ * is never silently attached to a generation as a reference image. */+ icon?: string;}+const referenceIconModules = import.meta.glob("../assets/reference-icons/*.jpg", {+ eager: true,+ query: "?url",+ import: "default",+}) as Record<string, string>;++const iconForPreset = (id: string): string | undefined =>+ referenceIconModules[`../assets/reference-icons/${id}.jpg`];++const withIcon = (preset: ReferencePreset): ReferencePreset => ({ ...preset, icon: iconForPreset(preset.id) });+export const REFERENCE_TYPES: ReadonlyArray<{ id: ReferenceType; label: string }> = [{ id: "custom", label: "Text" },{ id: "character", label: "Character" },@@ -60,7 +74,7 @@ const safeId = (value: string) => value.toLocaleLowerCase().normalize("NFKD")const duplicateNames = new Map<string, number>();for (const [name] of KNOWN_CHARACTERS) duplicateNames.set(name, (duplicateNames.get(name) ?? 0) + 1);-const knownCharacterPresets: ReferencePreset[] = KNOWN_CHARACTERS.map(([name, actor, franchise], index) => ({+const knownCharacterPresets: ReferencePreset[] = KNOWN_CHARACTERS.map<ReferencePreset>(([name, actor, franchise], index) => ({id: `character-known-${safeId(name)}-${index + 1}`,type: "character",subcategory: characterSubcategory(franchise),@@ -69,7 +83,7 @@ const knownCharacterPresets: ReferencePreset[] = KNOWN_CHARACTERS.map(([name, ac? `${name}.`: (duplicateNames.get(name) ?? 0) > 1 ? `${name}, ${actor} portrayal.` : `${name} from ${franchise}.`,searchTerms: `${actor} ${franchise}`,-}));+})).map(withIcon);/** Product, location and style catalogs contain unique subjects. Qualifying* adjectives no longer multiply each subject into five near-duplicates. */@@ -82,9 +96,9 @@ const optionsAsPresets = (type: PresetReferenceType, groups: readonly OptionGrouprompt: `${option}.`,})));-const productPresets = optionsAsPresets("product", PRODUCT_GROUPS);-const locationPresets = optionsAsPresets("location", LOCATION_GROUPS);-const stylePresets = optionsAsPresets("style", STYLE_GROUPS);+const productPresets = optionsAsPresets("product", PRODUCT_GROUPS).map(withIcon);+const locationPresets = optionsAsPresets("location", LOCATION_GROUPS).map(withIcon);+const stylePresets = optionsAsPresets("style", STYLE_GROUPS).map(withIcon);export type LocationSettings = Partial<Record<(typeof LOCATION_SETTING_GROUPS)[number]["id"], string>>;@@ -124,7 +138,7 @@ export function locationSelectionFromPrompt(prompt: string): LocationSelection |return undefined;}-const curatedCharacterPresets: ReferencePreset[] = [+const curatedCharacterPresets: ReferencePreset[] = ([{ id: "character-alice", type: "character", subcategory: "Literature & legend", name: "Alice in Wonderland", prompt: "Alice in her blue dress and white apron." },{ id: "character-dracula", type: "character", subcategory: "Literature & legend", name: "Count Dracula", prompt: "Count Dracula in formal black evening wear." },{ id: "character-robin-hood", type: "character", subcategory: "Literature & legend", name: "Robin Hood", prompt: "Robin Hood in practical forest-green clothing." },@@ -132,7 +146,7 @@ const curatedCharacterPresets: ReferencePreset[] = [{ id: "character-frankenstein", type: "character", subcategory: "Literature & legend", name: "Frankenstein's Creature", prompt: "Frankenstein's towering, solemn creature." },{ id: "character-dorothy-gale", type: "character", subcategory: "Literature & legend", name: "Dorothy Gale", prompt: "Dorothy Gale in a blue gingham dress." },{ id: "character-king-arthur", type: "character", subcategory: "Literature & legend", name: "King Arthur", prompt: "King Arthur in polished medieval armor." },-];+] as ReferencePreset[]).map(withIcon);export const REFERENCE_PRESETS: readonly ReferencePreset[] = [...knownCharacterPresets,diff --git a/src/styles/references.css b/src/styles/references.cssindex f7150f7..e838b92 100644--- a/src/styles/references.css+++ b/src/styles/references.css@@ -115,9 +115,9 @@.reference-grid > button {min-width: 0;- min-height: 208px;+ height: 156px;display: grid;- grid-template-columns: 140px minmax(0, 1fr);+ grid-template-columns: 156px minmax(0, 1fr);overflow: hidden;padding: 0;border: 1px solid var(--line);@@ -203,6 +203,20 @@padding: var(--space-2) var(--space-2) var(--space-7);}+.reference-detail-art--photo .reference-detail-preset-icon {+ width: 100%;+ height: 100%;+ aspect-ratio: 1;+ padding: 0;+ object-fit: contain;+}++.reference-detail-art--preset {+ width: 100%;+ height: auto;+ aspect-ratio: 1;+}+.reference-detail-images {width: 100%;height: 100%;@@ -271,13 +285,13 @@font: var(--weight-medium) var(--text-xs) / var(--leading-snug) var(--font-mono);}-/* Clamp to three lines instead of a fixed pixel height that clipped mid-glyph. */+/* Two lines keep the reference cards compact without clipping mid-glyph. */.reference-card__body p {display: -webkit-box;- -webkit-line-clamp: 3;+ -webkit-line-clamp: 2;-webkit-box-orient: vertical;overflow: hidden;- margin: var(--space-3) 0;+ margin: var(--space-2) 0;color: var(--text-secondary);font-size: var(--text-sm);line-height: var(--leading-normal);@@ -859,13 +873,41 @@}.reference-preset-grid > button {- min-height: 112px;+ min-height: 104px;padding: var(--space-4);border: 1px solid var(--line);border-radius: var(--radius-md);color: var(--text-primary);background: var(--panel-3);text-align: left;+ overflow: hidden;+}++.reference-preset-grid > button.reference-preset-card--with-icon {+ display: grid;+ grid-template-columns: 80px minmax(0, 1fr);+ grid-template-rows: auto auto 1fr;+ column-gap: var(--space-3);+ align-content: center;+}++.reference-preset-icon {+ width: 80px;+ height: 80px;+ 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);+}++.reference-preset-card--with-icon > small,+.reference-preset-card--with-icon > b,+.reference-preset-card--with-icon > span {+ min-width: 0;+ grid-column: 2;}.reference-preset-grid > button:hover {@@ -1021,7 +1063,7 @@}.reference-grid > button {- grid-template-columns: 116px minmax(0, 1fr);+ grid-template-columns: 156px minmax(0, 1fr);}.references-main {