AI media harness for planning, generating, and editing locally
TypeScript
Add generator popup and icon template selection
Bitti75c931b85bea
diff --git a/docs/generator-weights.md b/docs/generator-weights.mdindex eacbf19..2f15cf9 100644--- a/docs/generator-weights.md+++ b/docs/generator-weights.md@@ -1,8 +1,17 @@# Generator weights-Settings opens as a full-screen page with sections in the left sidebar. The-sidebar stays available while editing generators and LoRAs. **Back** or Escape-returns to the previous screen, preserving the open project's edits.+Settings opens as a full-screen page with sections in the left sidebar.+Generator templates open in a popup over the page and save edits immediately.+Escape or the popup's close button returns to the generator list. From Settings,+**Back** or Escape returns to the previous screen, preserving project edits.++**Reference icon generator** chooses the template used for automatic, manually+regenerated, and built-in reference icons, independently of the video generator.+Only available text-prompt templates appear; Animate cannot generate still icons.+If only one is available, it is used automatically. Without a valid saved choice,+the video default is used if eligible, otherwise the first available template.+Icons use the selected template's steps, attention, MotionCache and LoRAs,+including their step overrides.## LoRAsdiff --git a/src/components/GeneratorTemplateDialog.tsx b/src/components/GeneratorTemplateDialog.tsxnew file mode 100644index 0000000..75d4606--- /dev/null+++ b/src/components/GeneratorTemplateDialog.tsx@@ -0,0 +1,30 @@+import { ChevronLeft, X } from "lucide-react";+import { useEffect, useRef, type ReactNode } from "react";++export function GeneratorTemplateDialog({ children, footer, onClose }: { children: ReactNode; footer: ReactNode; onClose: () => void }) {+ const dialog = useRef<HTMLDivElement>(null);+ useEffect(() => {+ const opener = document.activeElement as HTMLElement | null;+ dialog.current?.querySelector<HTMLInputElement>('[aria-label="Generator name"]')?.focus();+ return () => { requestAnimationFrame(() => { if (opener?.isConnected) opener.focus(); }); };+ }, []);+ return <div className="generator-dialog-overlay" onKeyDown={(event) => {+ event.stopPropagation();+ if (event.key === "Escape" && !event.defaultPrevented) { event.preventDefault(); onClose(); }+ if (event.key !== "Tab") return;+ const controls = Array.from(dialog.current?.querySelectorAll<HTMLElement>('button:not(:disabled), input:not(:disabled), select:not(:disabled), textarea:not(:disabled), summary') ?? []);+ const first = controls[0], last = controls.at(-1);+ if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last?.focus(); }+ else if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first?.focus(); }+ }}>+ <div ref={dialog} className="generator-dialog" role="dialog" aria-modal="true" aria-labelledby="generator-editor-heading">+ <header className="generator-dialog__head">+ <button type="button" className="secondary-button" onClick={onClose}><ChevronLeft size={16} /> Generators</button>+ <h2 id="generator-editor-heading">Edit generator</h2>+ <button type="button" className="icon-button" aria-label="Close generator settings" onClick={onClose}><X size={18} /></button>+ </header>+ <div className="generator-dialog__body">{children}</div>+ {footer}+ </div>+ </div>;+}diff --git a/src/components/SettingsView.test.tsx b/src/components/SettingsView.test.tsxindex 524ab6d..144e972 100644--- a/src/components/SettingsView.test.tsx+++ b/src/components/SettingsView.test.tsx@@ -4,7 +4,8 @@ import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-liimport { invoke } from "@tauri-apps/api/core";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";import { SettingsView } from "./SettingsView";-import { loadGeneratorTemplateSettings } from "../lib/settings";+import { createGeneratorTemplate, loadGeneratorTemplateSettings, saveGeneratorTemplateSettings } from "../lib/settings";+import { loadReferenceIconGeneratorId } from "../lib/referenceIconSettings";vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));@@ -236,23 +237,46 @@ describe("the settings screen", () => {expect(screen.queryByRole("button", { name: /Clear generator paths/ })).toBeNull();});- it("keeps sidebar tabs available while editing and allows navigating out of the editor", () => {+ it("edits generators in a focused popup and returns to Settings on Escape", async () => {open();expect(screen.queryByText("Changes are saved as you type.")).toBeNull();- editDefaultGenerator();+ const opener = screen.getByRole("button", { name: "Edit Default generator" });+ opener.focus(); fireEvent.click(opener);+ const dialog = screen.getByRole("dialog", { name: "Edit generator" });const back = screen.getByRole("button", { name: "Generators" });- expect(screen.getByRole("tab", { name: "Appearance" })).toBeTruthy();- expect(back.closest(".settings-view__body")).not.toBeNull();+ expect(screen.queryByRole("tab", { name: "Appearance" })).toBeNull();+ expect(document.activeElement).toBe(within(dialog).getByLabelText("Generator name"));+ const last = within(dialog).getByRole("button", { name: /Clear generator paths/ });+ last.focus(); fireEvent.keyDown(last, { key: "Tab" });+ expect(document.activeElement).toBe(back);- fireEvent.click(back);+ fireEvent.keyDown(dialog, { key: "Escape" });+ expect(screen.queryByRole("dialog")).toBeNull();expect(screen.getByRole("tab", { name: "Appearance" })).toBeTruthy();- editDefaultGenerator();+ await waitFor(() => expect(document.activeElement).toBe(opener));fireEvent.click(tab("Appearance"));expect(screen.getByRole("radiogroup", { name: "Appearance" })).toBeTruthy();fireEvent.click(tab("Generator"));expect(screen.queryByLabelText("Generator name")).toBeNull();});+ it("defaults icon generation to the sole available generator and remembers a separate selection", () => {+ const first = createGeneratorTemplate("Video"), second = createGeneratorTemplate("Icons");+ const templates = { templates: [first], defaultTemplateId: first.id, catalogVersion: 9 };+ saveGeneratorTemplateSettings(templates);+ const view = open();+ expect((screen.getByLabelText("Reference icon generator") as HTMLSelectElement).value).toBe(first.id);+ view.unmount();+ saveGeneratorTemplateSettings({ ...templates, templates: [first, second] });+ const reopened = open();+ fireEvent.change(screen.getByLabelText("Reference icon generator"), { target: { value: second.id } });+ expect(loadReferenceIconGeneratorId()).toBe(second.id);+ expect(loadGeneratorTemplateSettings().defaultTemplateId).toBe(first.id);+ reopened.unmount();+ open();+ expect((screen.getByLabelText("Reference icon generator") as HTMLSelectElement).value).toBe(second.id);+ });+it("creates a generator with 20 steps, edits it on its own page, and can make it the default", () => {open();expect(screen.queryByLabelText(/Transformer weights/)).toBeNull();diff --git a/src/components/SettingsView.tsx b/src/components/SettingsView.tsxindex 67dfe85..744a115 100644--- a/src/components/SettingsView.tsx+++ b/src/components/SettingsView.tsx@@ -1,3 +1,4 @@+import { GeneratorTemplateDialog } from "./GeneratorTemplateDialog";import { AdditionalSafetensorsEditor } from "./AdditionalSafetensorsEditor";import { AlertCircle, Check, ChevronLeft, Download, FolderOpen, FolderSearch, LoaderCircle, Monitor, Moon, Plus, RefreshCw, RotateCcw, Sun, Trash2, Video } from "lucide-react";import { useCallback, useEffect, useRef, useState, useSyncExternalStore, type ReactNode } from "react";@@ -21,7 +22,7 @@ import {type EnginePathField, type EnginePathId, type EngineSettings, type GeneratorTemplate, type GeneratorTemplateSettings,} from "../lib/settings";import { MAX_GENERATION_STEPS } from "../lib/project";-import { loadReferenceIconAutomation, saveReferenceIconAutomation, subscribeReferenceIconAutomation } from "../lib/referenceIconSettings";+import { availableReferenceIconGenerators, loadReferenceIconAutomation, loadReferenceIconGeneratorId, referenceIconGenerator, saveReferenceIconAutomation, saveReferenceIconGeneratorId, subscribeReferenceIconAutomation } from "../lib/referenceIconSettings";import {applyTheme, loadTheme, saveTheme, systemTheme, watchSystemTheme,type ResolvedTheme, type ThemeChoice,@@ -69,13 +70,26 @@ const themeOptions: { id: ThemeChoice; label: string; icon: typeof Sun; detail:{ id: "dark", label: "Dark", icon: Moon, detail: () => "Always dark, whatever this computer is set to." },];-function ReferenceIconSetting() {+function ReferenceIconSetting({ templates }: { templates: GeneratorTemplateSettings }) {const automation = useSyncExternalStore(subscribeReferenceIconAutomation, loadReferenceIconAutomation);+ const chosenId = useSyncExternalStore(subscribeReferenceIconAutomation, loadReferenceIconGeneratorId);+ const available = availableReferenceIconGenerators(templates);+ const selected = referenceIconGenerator(templates, chosenId);return (+ <div className="reference-icon-settings"><label className="reference-icon-option"><input type="checkbox" checked={automation !== "disabled"} onChange={(event) => saveReferenceIconAutomation(event.target.checked ? "ask" : "disabled")} aria-labelledby="automatic-reference-icons-label" /><span><b id="automatic-reference-icons-label">Automatic reference icon generation</b></span></label>+ <div className="generator-template-fields">+ <label><span>Reference icon generator</span>+ <select aria-label="Reference icon generator" disabled={!available.length} value={selected?.id ?? ""} onChange={(event) => saveReferenceIconGeneratorId(event.target.value)}>+ {!available.length && <option value="">No available generators</option>}+ {available.map((template) => <option key={template.id} value={template.id}>{template.name}</option>)}+ </select>+ </label>+ </div>+ </div>);}@@ -249,7 +263,7 @@ function DiagnosticsSetting({ desktop, status, onBackendChange }: { desktop: boo</>;}-/* Sidebar navigation remains available inside generator and LoRA editors. */+/* The settings page keeps its section navigation behind the generator popup. */const TABS = [{ id: "engine", label: "Generator" },{ id: "llms", label: "Agents" },@@ -271,6 +285,9 @@ export function SettingsView({ onClose, updates, initialTab = "engine" }: { onClconst downloadState = useSyncExternalStore(subscribeWeightDownloads, getWeightDownloadState);const downloadPercent = downloadState ? weightDownloadProgress(downloadState) : 0;const [editingTemplateId, setEditingTemplateId] = useState<string | null>(null);+ useEffect(() => {+ if (page.current) page.current.inert = Boolean(editingTemplateId);+ }, [editingTemplateId]);const [editingLoraId, setEditingLoraId] = useState<string | null>(null);const [showAdvancedOptions, setShowAdvancedOptions] = useState(false);const [status, setStatus] = useState<SlopfabStatus | null>(null);@@ -421,8 +438,107 @@ export function SettingsView({ onClose, updates, initialTab = "engine" }: { onClsetEditingLoraId(null);};+ const generatorEditor = <div className="generator-editor">+ {error && <p role="alert">{error}</p>}+ <div className="generator-template-fields">+ <label>+ <span>Mode</span>+ <select aria-label="Generator mode" value={selectedTemplate.mode ?? "prompt"}+ onChange={(event) => updateTemplate({ mode: event.target.value === "animate" ? "animate" : "prompt" })}>+ <option value="prompt">Text prompt</option>+ <option value="animate">Animate (reference video)</option>+ </select>+ </label>+ <label>+ <span>Name</span>+ <input aria-label="Generator name" value={selectedTemplate.name} onChange={(event) => updateTemplate({ name: event.target.value })} onBlur={() => { if (!selectedTemplate.name.trim()) updateTemplate({ name: "Untitled generator" }); }} />+ </label>+ <label>+ <span>Default steps</span>+ <input aria-label="Generator default steps" type="number" min={2} max={MAX_GENERATION_STEPS} step={1} value={selectedTemplate.defaultSteps} onChange={(event) => {+ const value = Number(event.target.value);+ if (Number.isInteger(value) && value >= 2 && value <= MAX_GENERATION_STEPS) updateTemplate({ defaultSteps: value });+ }} />+ </label>+ <label>+ <span>Attention</span>+ <select aria-label="Generator attention" value={selectedTemplate.attention} onChange={(event) => updateTemplate({ attention: event.target.value as AttentionMode })}>+ <option value="exact">Exact attention</option>+ <option value="flash2">Flash attention</option>+ <option value="sage2">Sage attention</option>+ </select>+ </label>+ </div>+ <label className="lora-toggle">+ <input type="checkbox" aria-label="Enable MotionCache" aria-describedby="motion-cache-help"+ checked={selectedTemplate.mode !== "animate" && Boolean(selectedTemplate.motionCache)} disabled={selectedTemplate.mode === "animate"}+ onChange={(event) => updateTemplate({ motionCache: event.target.checked })} />+ Enable MotionCache+ </label>+ <p id="motion-cache-help">{selectedTemplate.mode === "animate" ? "MotionCache is unavailable in Animate mode." : "Reuses similar denoising results to reduce computation. May affect detail and motion; short generations may not reuse any steps."}</p>+ <div className={`settings-status settings-status--${status?.state ?? "checking"}`} role="status">+ <span><i />{engineHeadline(status, desktop)}</span>+ <p>{engineDetail(status, desktop, missing.length)}</p>+ {status?.platform && <small className="settings-status__platform"><b>Platform</b>{status.platform}</small>}+ </div>+ {generatorPathFields(selectedTemplate).map((field) => {+ const value = settings[field.id];+ const state = pathState(field, value, status);+ return (+ <div className={`settings-path settings-path--${state}`} key={field.id}>+ <label htmlFor={`engine-${field.id}`}>+ <b>{field.label}{!field.required && <em>Optional</em>}</b>+ </label>+ <div className="settings-path__row">+ <input+ id={`engine-${field.id}`}+ value={value}+ spellCheck={false}+ placeholder={field.directory ? "Folder on this computer or download URL" : "Local path or download URL"}+ disabled={Boolean(downloading)}+ onChange={(event) => update(field.id, event.target.value)}+ onBlur={() => probe(settings)}+ />+ <button+ type="button"+ className="secondary-button"+ onClick={() => void browse(field)}+ disabled={!desktop || Boolean(downloading)}+ title={desktop ? `Browse for ${field.label}` : "Browsing for files is available in the desktop app"}+ >+ <FolderSearch size={16} /> Browse+ </button>+ <span className="settings-path__state">+ {state === "found" ? <Check size={14} aria-hidden="true" /> : state === "missing" ? <AlertCircle size={14} aria-hidden="true" /> : null}+ {stateLabel[state]}+ </span>+ </div>+ {showAdvancedOptions && <WeightSourcesEditor label={field.label} sources={selectedTemplate.sources?.[field.id] ?? []} disabled={Boolean(downloading)} onChange={(sources) => updateSources(field.id, sources)} />}+ </div>+ );+ })}+ <AdditionalSafetensorsEditor key={selectedTemplate.id} value={selectedTemplate.additionalSafetensors ?? []} disabled={Boolean(downloading)} animate={selectedTemplate.mode === "animate"} onChange={(additionalSafetensors) => updateTemplate({ additionalSafetensors })} />+ <TemplateLorasEditor value={selectedTemplate.loras ?? []} onChange={(loras) => updateTemplate({ loras })} />+ <label className="generator-editor__advanced">+ <input type="checkbox" checked={showAdvancedOptions} onChange={(event) => setShowAdvancedOptions(event.target.checked)} />+ <span>Show advanced options</span>+ </label>+ </div>;+ const downloadStatus = downloadState && <div className="weight-download-status" role="status">+ <span>{downloadState.name ?? templateSettings.templates.find((template) => template.id === downloadState.templateId)?.name}: {downloadState.error ?? (downloadState.active ? `${downloadState.completed}/${downloadState.files} files · ${(downloadState.downloaded / 1024 ** 3).toFixed(2)} GB${downloadState.total ? ` / ${(downloadState.total / 1024 ** 3).toFixed(2)} GB` : ""}` : "Download complete")}</span>+ {downloadState.active && <button type="button" className="secondary-button" onClick={() => void cancelWeightDownload().catch((reason) => setError(String(reason)))}>Cancel download</button>}+ {downloadState.error && <button type="button" className="secondary-button" onClick={() => void retryWeightDownload()}>Retry download</button>}+ </div>;+ const generatorFooter = <>{downloadStatus}<footer className="settings-view__foot">+ {/* Clearing the paths is an engine action, so it is only offered+ beside them. */}+ <button className="secondary-button" disabled={Boolean(downloading)} onClick={clearAll}><RotateCcw size={16} /> Clear generator paths</button>+ {templateNeedsDownload(selectedTemplate) && <button type="button" className="primary-button" disabled={!desktop || downloadState?.active} onClick={() => void downloadTemplateWeights(selectedTemplate.id)}><Download size={16} /> Download weights</button>}+ </footer></>;+return (- <main className="settings-view" ref={page} tabIndex={-1} aria-labelledby="settings-heading" onKeyDown={(event) => {+ <>+ <main aria-hidden={editingTemplateId ? true : undefined} className="settings-view" ref={page} tabIndex={-1} aria-labelledby="settings-heading" onKeyDown={(event) => {// The mounted editor must not receive shortcuts while Settings has focus.event.stopPropagation();if (event.key === "Escape" && !event.defaultPrevented) onClose();@@ -465,7 +581,7 @@ export function SettingsView({ onClose, updates, initialTab = "engine" }: { onCl<div className="settings-view__content"><div className="settings-view__body" ref={body}>- {tab === "engine" && (editingTemplateId || editingLoraId) && <button type="button" className="secondary-button generator-editor__back" onClick={() => { setEditingTemplateId(null); setEditingLoraId(null); }}><ChevronLeft size={16} /> Generators</button>}+ {tab === "engine" && editingLoraId && <button type="button" className="secondary-button generator-editor__back" onClick={() => { setEditingTemplateId(null); setEditingLoraId(null); }}><ChevronLeft size={16} /> Generators</button>}{tab === "updates" && <section className="settings-section" id="settings-panel-updates" role="tabpanel" aria-labelledby="settings-tab-updates">{updates ?? <p>Updates are available in the desktop app.</p>}</section>}@@ -502,8 +618,8 @@ export function SettingsView({ onClose, updates, initialTab = "engine" }: { onClrole="tabpanel"aria-labelledby="settings-tab-engine">- {!editingTemplateId && !editingLoraId && <ReferenceIconSetting />}- {editingLoraId ? <LoraEditor key={editingLoraId} loraId={editingLoraId} onDone={() => setEditingLoraId(null)} /> : !editingTemplateId ? <>{generatorSections.filter((section) => section.id === "generators" || section.templates.length > 0).map((section) => <section key={section.id} className="generator-templates" aria-labelledby={`${section.id}-heading`}>+ {!editingLoraId && <ReferenceIconSetting templates={templateSettings} />}+ {editingLoraId ? <LoraEditor key={editingLoraId} loraId={editingLoraId} onDone={() => setEditingLoraId(null)} /> : <>{generatorSections.filter((section) => section.id === "generators" || section.templates.length > 0).map((section) => <section key={section.id} className="generator-templates" aria-labelledby={`${section.id}-heading`}><header><div><h2 id={`${section.id}-heading`}>{section.title}</h2>@@ -539,114 +655,18 @@ export function SettingsView({ onClose, updates, initialTab = "engine" }: { onCl</div>))}</div>- </section>)}<LoraLibrary onAdd={() => setEditingLoraId(`lora-${crypto.randomUUID()}`)} onEdit={setEditingLoraId} /></> : <div className="generator-editor">- <header className="generator-editor__head">- <div>- <h2 id="generator-editor-heading">Edit generator</h2>- </div>- </header>- <div className="generator-template-fields">- <label>- <span>Mode</span>- <select aria-label="Generator mode" value={selectedTemplate.mode ?? "prompt"}- onChange={(event) => updateTemplate({ mode: event.target.value === "animate" ? "animate" : "prompt" })}>- <option value="prompt">Text prompt</option>- <option value="animate">Animate (reference video)</option>- </select>- </label>- <label>- <span>Name</span>- <input aria-label="Generator name" value={selectedTemplate.name} onChange={(event) => updateTemplate({ name: event.target.value })} onBlur={() => { if (!selectedTemplate.name.trim()) updateTemplate({ name: "Untitled generator" }); }} />- </label>- <label>- <span>Default steps</span>- <input aria-label="Generator default steps" type="number" min={2} max={MAX_GENERATION_STEPS} step={1} value={selectedTemplate.defaultSteps} onChange={(event) => {- const value = Number(event.target.value);- if (Number.isInteger(value) && value >= 2 && value <= MAX_GENERATION_STEPS) updateTemplate({ defaultSteps: value });- }} />- </label>- <label>- <span>Attention</span>- <select aria-label="Generator attention" value={selectedTemplate.attention} onChange={(event) => updateTemplate({ attention: event.target.value as AttentionMode })}>- <option value="exact">Exact attention</option>- <option value="flash2">Flash attention</option>- <option value="sage2">Sage attention</option>- </select>- </label>- </div>- <label className="lora-toggle">- <input type="checkbox" aria-label="Enable MotionCache" aria-describedby="motion-cache-help"- checked={selectedTemplate.mode !== "animate" && Boolean(selectedTemplate.motionCache)} disabled={selectedTemplate.mode === "animate"}- onChange={(event) => updateTemplate({ motionCache: event.target.checked })} />- Enable MotionCache- </label>- <p id="motion-cache-help">{selectedTemplate.mode === "animate" ? "MotionCache is unavailable in Animate mode." : "Reuses similar denoising results to reduce computation. May affect detail and motion; short generations may not reuse any steps."}</p>- <div className={`settings-status settings-status--${status?.state ?? "checking"}`} role="status">- <span><i />{engineHeadline(status, desktop)}</span>- <p>{engineDetail(status, desktop, missing.length)}</p>- {status?.platform && <small className="settings-status__platform"><b>Platform</b>{status.platform}</small>}- </div>- {generatorPathFields(selectedTemplate).map((field) => {- const value = settings[field.id];- const state = pathState(field, value, status);- return (- <div className={`settings-path settings-path--${state}`} key={field.id}>- <label htmlFor={`engine-${field.id}`}>- <b>{field.label}{!field.required && <em>Optional</em>}</b>- </label>- <div className="settings-path__row">- <input- id={`engine-${field.id}`}- value={value}- spellCheck={false}- placeholder={field.directory ? "Folder on this computer or download URL" : "Local path or download URL"}- disabled={Boolean(downloading)}- onChange={(event) => update(field.id, event.target.value)}- onBlur={() => probe(settings)}- />- <button- type="button"- className="secondary-button"- onClick={() => void browse(field)}- disabled={!desktop || Boolean(downloading)}- title={desktop ? `Browse for ${field.label}` : "Browsing for files is available in the desktop app"}- >- <FolderSearch size={16} /> Browse- </button>- <span className="settings-path__state">- {state === "found" ? <Check size={14} aria-hidden="true" /> : state === "missing" ? <AlertCircle size={14} aria-hidden="true" /> : null}- {stateLabel[state]}- </span>- </div>- {showAdvancedOptions && <WeightSourcesEditor label={field.label} sources={selectedTemplate.sources?.[field.id] ?? []} disabled={Boolean(downloading)} onChange={(sources) => updateSources(field.id, sources)} />}- </div>- );- })}- <AdditionalSafetensorsEditor key={selectedTemplate.id} value={selectedTemplate.additionalSafetensors ?? []} disabled={Boolean(downloading)} animate={selectedTemplate.mode === "animate"} onChange={(additionalSafetensors) => updateTemplate({ additionalSafetensors })} />- <TemplateLorasEditor value={selectedTemplate.loras ?? []} onChange={(loras) => updateTemplate({ loras })} />- <label className="generator-editor__advanced">- <input type="checkbox" checked={showAdvancedOptions} onChange={(event) => setShowAdvancedOptions(event.target.checked)} />- <span>Show advanced options</span>- </label>- </div>}+ </section>)}<LoraLibrary onAdd={() => setEditingLoraId(`lora-${crypto.randomUUID()}`)} onEdit={setEditingLoraId} /></>}</section>}</div>- {tab === "engine" && downloadState && <div className="weight-download-status" role="status">- <span>{downloadState.name ?? templateSettings.templates.find((template) => template.id === downloadState.templateId)?.name}: {downloadState.error ?? (downloadState.active ? `${downloadState.completed}/${downloadState.files} files · ${(downloadState.downloaded / 1024 ** 3).toFixed(2)} GB${downloadState.total ? ` / ${(downloadState.total / 1024 ** 3).toFixed(2)} GB` : ""}` : "Download complete")}</span>- {downloadState.active && <button type="button" className="secondary-button" onClick={() => void cancelWeightDownload().catch((reason) => setError(String(reason)))}>Cancel download</button>}- {downloadState.error && <button type="button" className="secondary-button" onClick={() => void retryWeightDownload()}>Retry download</button>}- </div>}- {tab === "engine" && editingTemplateId && <footer className="settings-view__foot">- {/* Clearing the paths is an engine action, so it is only offered- beside them. */}- <button className="secondary-button" disabled={Boolean(downloading)} onClick={clearAll}><RotateCcw size={16} /> Clear generator paths</button>- {templateNeedsDownload(selectedTemplate) && <button type="button" className="primary-button" disabled={!desktop || downloadState?.active} onClick={() => void downloadTemplateWeights(selectedTemplate.id)}><Download size={16} /> Download weights</button>}- </footer>}+ {tab === "engine" && downloadStatus}+{error && <div className="toast" role="alert"><strong>Couldn’t update generator settings</strong><span>{error}</span><button onClick={() => setError(null)}>Dismiss</button></div>}</div></main>+ {editingTemplateId && <GeneratorTemplateDialog onClose={() => setEditingTemplateId(null)} footer={generatorFooter}>{generatorEditor}</GeneratorTemplateDialog>}+ </>);}diff --git a/src/lib/referenceIconSettings.test.ts b/src/lib/referenceIconSettings.test.tsindex 127c8c8..655da55 100644--- a/src/lib/referenceIconSettings.test.ts+++ b/src/lib/referenceIconSettings.test.ts@@ -1,9 +1,20 @@// @vitest-environment jsdomimport { beforeEach, expect, it, vi } from "vitest";-import { loadReferenceIconAutomation, saveReferenceIconAutomation, subscribeReferenceIconAutomation } from "./referenceIconSettings";+import { loadReferenceIconAutomation, referenceIconGenerator, saveReferenceIconAutomation, saveReferenceIconGeneratorId, subscribeReferenceIconAutomation } from "./referenceIconSettings";+import { createGeneratorTemplate } from "./settings";beforeEach(() => localStorage.clear());+it("falls back to an available still generator when the icon choice disappears", () => {+ const available = createGeneratorTemplate("Available"), animate = { ...createGeneratorTemplate("Animate"), mode: "animate" as const };+ const pending = createGeneratorTemplate("Download");+ pending.paths.transformer = "https://example.com/weights.safetensors";+ const settings = { templates: [animate, pending, available], defaultTemplateId: animate.id };+ saveReferenceIconGeneratorId("removed");+ expect(referenceIconGenerator(settings)?.id).toBe(available.id);+ expect(referenceIconGenerator({ ...settings, templates: [animate, pending] })).toBeUndefined();+});+it("defaults to confirmation and ignores invalid stored choices", () => {expect(loadReferenceIconAutomation()).toBe("ask");localStorage.setItem("slopus.reference-icon-automation.v1", "unexpected");diff --git a/src/lib/referenceIconSettings.ts b/src/lib/referenceIconSettings.tsindex 39fb0ef..530281d 100644--- a/src/lib/referenceIconSettings.ts+++ b/src/lib/referenceIconSettings.ts@@ -1,3 +1,5 @@+import { loadGeneratorTemplateSettings, templateNeedsDownload, type GeneratorTemplateSettings } from "./settings";+export type ReferenceIconAutomation = "ask" | "enabled" | "disabled";const BUILTIN_KEY = "slopus.builtin-reference-icons.v1";@@ -29,8 +31,32 @@ export function builtinIconVisitAction(): "ask" | "generate" | "skip" {const STORAGE_KEY = "slopus.reference-icon-automation.v1";const CHANGE_EVENT = "slopus:reference-icon-automation-changed";+const GENERATOR_KEY = "slopus.reference-icon-generator.v1";+let generatorOverride: string | undefined;let sessionOverride: ReferenceIconAutomation | undefined;+export function loadReferenceIconGeneratorId(): string {+ if (generatorOverride !== undefined) return generatorOverride;+ try { return localStorage.getItem(GENERATOR_KEY) ?? ""; } catch { return ""; }+}++export function saveReferenceIconGeneratorId(id: string) {+ try { localStorage.setItem(GENERATOR_KEY, id); generatorOverride = undefined; }+ catch { generatorOverride = id; }+ window.dispatchEvent(new Event(CHANGE_EVENT));+}++export function availableReferenceIconGenerators(settings: GeneratorTemplateSettings) {+ return settings.templates.filter((template) => template.mode !== "animate" && !templateNeedsDownload(template));+}++export function referenceIconGenerator(settings = loadGeneratorTemplateSettings(), id = loadReferenceIconGeneratorId()) {+ const available = availableReferenceIconGenerators(settings);+ return available.find((template) => template.id === id)+ ?? available.find((template) => template.id === settings.defaultTemplateId)+ ?? available[0];+}+export function loadReferenceIconAutomation(): ReferenceIconAutomation {if (sessionOverride) return sessionOverride;try {@@ -53,7 +79,7 @@ export function saveReferenceIconAutomation(value: ReferenceIconAutomation) {export function subscribeReferenceIconAutomation(listener: () => void) {const onStorage = (event: StorageEvent) => {- if (event.key === STORAGE_KEY || event.key === null) listener();+ if (event.key === STORAGE_KEY || event.key === GENERATOR_KEY || event.key === null) listener();};window.addEventListener(CHANGE_EVENT, listener);window.addEventListener("storage", onStorage);diff --git a/src/lib/referenceIconWork.test.ts b/src/lib/referenceIconWork.test.tsindex 9276bd2..eb60388 100644--- a/src/lib/referenceIconWork.test.ts+++ b/src/lib/referenceIconWork.test.ts@@ -5,7 +5,9 @@ import { releaseRendered, saveGeneratedScene } from "./generatedVideo";import { createProjectConfig, parseProjectConfig, referenceImages, type ProjectRecord, type ProjectReference } from "./project";import { REFERENCE_PRESETS } from "./reference-presets";import { referenceIconPrompt } from "./referenceIcons";-import { loadReferenceIconAutomation, saveReferenceIconAutomation } from "./referenceIconSettings";+import { loadReferenceIconAutomation, saveReferenceIconAutomation, saveReferenceIconGeneratorId } from "./referenceIconSettings";+import { createGeneratorTemplate, loadGeneratorTemplateSettings, saveGeneratorTemplateSettings } from "./settings";+import { saveLoras } from "./loras";import { cancelSlopfabGeneration, enqueueSlopfabGeneration, resolveSlopfabPlan, saveReferenceIcon } from "./runtime";import { WorkQueue } from "./workQueue";@@ -72,6 +74,27 @@ it("renders a refmod icon without a description and rejects a result after its sexpect(session.getSnapshot().config.references[0].iconRelativePath).toContain("references/icons/");});+it("renders automatic icons with the chosen template without changing the video generator", async () => {+ const videoTemplate = createGeneratorTemplate("Video"), icons = createGeneratorTemplate("Icons");+ icons.paths.transformer = "D:/icons.safetensors";+ icons.defaultSteps = 12;+ icons.attention = "exact";+ icons.motionCache = true;+ saveLoras([{ id: "style", name: "Style", path: "D:/style.safetensors", multiplier: 0.9, stepOverride: 6 }]);+ icons.loras = [{ loraId: "style", enabled: true, strength: 1 }];+ saveGeneratorTemplateSettings({ templates: [videoTemplate, icons], defaultTemplateId: videoTemplate.id, catalogVersion: 9 });+ saveReferenceIconGeneratorId(icons.id);+ const { session } = setup([reference("hero")]);+ await vi.advanceTimersByTimeAsync(1001);+ const [request, runtime] = vi.mocked(enqueueSlopfabGeneration).mock.calls[0];+ expect(request).toMatchObject({ stillImage: true, steps: 6 });+ expect(runtime.providerSettings.slopfab.options).toMatchObject({ transformer: "D:/icons.safetensors", attention: "exact", motionCache: true, stepOverride: 6 });+ expect(JSON.parse(runtime.providerSettings.slopfab.options.loras as string)).toEqual([{ path: "D:/style.safetensors", strength: 0.9 }]);+ expect(loadGeneratorTemplateSettings().defaultTemplateId).toBe(videoTemplate.id);+ expect(session.getSnapshot().config.providerSettings).toEqual({});+ await finish(request.jobId);+});+it("waits for batch confirmation without blocking video generation", async () => {saveReferenceIconAutomation("ask");const { queue, session } = setup([reference("hero"), reference("place", "location")]);diff --git a/src/lib/referenceIconWork.ts b/src/lib/referenceIconWork.tsindex 90871a6..e9498f9 100644--- a/src/lib/referenceIconWork.ts+++ b/src/lib/referenceIconWork.ts@@ -5,9 +5,9 @@ import type { ProjectSession } from "./projectSession";import { referenceImages, type ProjectReference } from "./project";import { needsReferenceIcon, referenceIconPrompt, REFERENCE_ICON_RENDER_SIZE, REFERENCE_ICON_STEPS } from "./referenceIcons";import { cancelSlopfabGeneration, enqueueSlopfabGeneration, saveReferenceIcon } from "./runtime";-import { withEngineSettings } from "./settings";+import { engineProviderSetting, generationStepsWithLoras } from "./settings";import { activeReferenceRefmods, referenceRefmodInputs } from "./project";-import { loadReferenceIconAutomation, saveReferenceIconAutomation, subscribeReferenceIconAutomation } from "./referenceIconSettings";+import { loadReferenceIconAutomation, referenceIconGenerator, saveReferenceIconAutomation, subscribeReferenceIconAutomation } from "./referenceIconSettings";import type { WorkItem } from "./workQueue";import { hasPresetIcon, REFERENCE_PRESETS, REFERENCE_TYPES, type ReferencePreset } from "./reference-presets";import { saveBuiltinIcon } from "./builtinReferenceIcons";@@ -254,13 +254,21 @@ export class ReferenceIconWork {task.prompt = referenceIconPrompt(reference);task.refmodsSnapshot = JSON.stringify(activeReferenceRefmods(reference));task.name = reference.name;+ const template = referenceIconGenerator();+ if (!template) throw new Error("Choose an available text-prompt generator for reference icons in Settings.");+ const config = task.session.getSnapshot().config;+ const runtimeConfig = { ...config, providerSettings: { ...config.providerSettings,+ slopfab: engineProviderSetting(template.paths, config.providerSettings.slopfab, template.attention, template.loras ?? [], "prompt", template.additionalSafetensors ?? [], template.motionCache ?? false),+ } };+ const steps = generationStepsWithLoras(template.defaultSteps, runtimeConfig);+ if (this.item) { this.item = { ...this.item, settings: { ...this.item.settings, steps } }; this.publish(); }task.nativeId = `icon-${crypto.randomUUID()}`;const done = new Promise<void>((resolve) => { task.finish = resolve; });await enqueueSlopfabGeneration({jobId: task.nativeId, prompt: task.prompt, stillImage: true, frames: 1,- steps: REFERENCE_ICON_STEPS, seed: -1, canvasWidth: REFERENCE_ICON_RENDER_SIZE, canvasHeight: REFERENCE_ICON_RENDER_SIZE, referencePaths: [],+ steps, seed: -1, canvasWidth: REFERENCE_ICON_RENDER_SIZE, canvasHeight: REFERENCE_ICON_RENDER_SIZE, referencePaths: [],...(activeReferenceRefmods(reference).length ? { refmods: referenceRefmodInputs(task.session.record.folderPath, [reference]) } : {}),- }, withEngineSettings(task.session.getSnapshot().config), task.session.record.folderPath);+ }, runtimeConfig, task.session.record.folderPath);task.submitted = true;if (task.cancelled) await this.cancelNative(task);else if (task.yielded) await this.cancelForVideo(task);diff --git a/src/styles/shell.css b/src/styles/shell.cssindex c33db91..8b9260a 100644--- a/src/styles/shell.css+++ b/src/styles/shell.css@@ -215,6 +215,41 @@/* --- Generator templates ------------------------------------------------- */+.reference-icon-settings { margin-bottom: var(--space-5); }+.reference-icon-settings .generator-template-fields { grid-template-columns: minmax(0, 420px); }+.generator-dialog-overlay {+ position: fixed;+ inset: 0;+ z-index: 70;+ display: grid;+ place-items: center;+ padding: var(--space-5);+ background: var(--scrim);+}+.generator-dialog {+ width: min(1000px, 100%);+ max-height: calc(100dvh - var(--space-5) * 2);+ display: flex;+ flex-direction: column;+ min-height: 0;+ border: 1px solid var(--line-strong);+ border-radius: var(--radius-xl);+ background: var(--panel);+ box-shadow: var(--shadow);+ overflow: hidden;+}+.generator-dialog__head {+ display: flex;+ align-items: center;+ flex-shrink: 0;+ gap: var(--space-3);+ padding: var(--space-4);+ border-bottom: 1px solid var(--line);+}+.generator-dialog__head h2 { flex: 1; margin: 0; font-size: var(--text-lg); }+.generator-dialog__body { min-height: 0; overflow-y: auto; padding: var(--space-5); overscroll-behavior: contain; }+.generator-dialog > .weight-download-status { flex-shrink: 0; padding: var(--space-3) var(--space-5); }+.generator-templates {margin-bottom: var(--space-4);padding: var(--space-4);