AI media harness for planning, generating, and editing locally
TypeScript
Rebuild Settings as a Fluent page with cards, sub-page editor and LoRA dialog
Bitti71c1018e43d8
diff --git a/src/components/AdditionalSafetensorsEditor.tsx b/src/components/AdditionalSafetensorsEditor.tsxindex 756a526..4a10bb6 100644--- a/src/components/AdditionalSafetensorsEditor.tsx+++ b/src/components/AdditionalSafetensorsEditor.tsx@@ -1,42 +1,50 @@import { useState } from "react";-import { Plus, Trash2 } from "lucide-react";+import { FileBox, Plus, Trash2 } from "lucide-react";import { isDownloadUrl, type AdditionalSafetensor } from "../lib/settings";+import { ComboBox, InfoBar, SettingsCard, SettingsExpander, SettingsGroup, SettingsRow } from "./ui";+/* Extra .safetensors files that download with a generator. Each file is an+ expander (name + download state in the header, its fields inside); the+ last card adds one by URL. */export function AdditionalSafetensorsEditor({ value, disabled, animate, onChange }: {value: AdditionalSafetensor[]; disabled: boolean; animate: boolean; onChange: (files: AdditionalSafetensor[]) => void;}) {const [url, setUrl] = useState("");const [error, setError] = useState<string | null>(null);const update = (id: string, patch: Partial<AdditionalSafetensor>) => onChange(value.map((file) => file.id === id ? { ...file, ...patch } : file));- return <details className="weight-sources" open={animate || undefined}>- <summary>Additional safetensors ({value.length})</summary>- <p>These files download with this generator into your weights folder.</p>- {value.map((file, index) => <div className="weight-source" key={`${file.id}-${file.url}`}>- <label>Name<input aria-label={`Additional safetensor ${index + 1} name`} value={file.name} disabled={disabled}- onChange={(event) => update(file.id, { name: event.target.value })} /></label>- <label>Download URL<input aria-label={`Additional safetensor ${index + 1} URL`} defaultValue={file.url} disabled={disabled} onBlur={(event) => {- const url = event.target.value.trim();- if (!isDownloadUrl(url)) { setError("Enter an HTTP or HTTPS download URL."); return; }- setError(null);- if (url !== file.url) update(file.id, { url, downloadedPath: undefined });- }} /></label>- {animate && <label>Use<select aria-label={`Additional safetensor ${index + 1} use`} value={file.role ?? ""} disabled={disabled} onChange={(event) => {- const role = event.target.value === "promptEmbedding" ? "promptEmbedding" : undefined;- onChange(value.map((entry) => entry.id === file.id ? { ...entry, role } : role ? { ...entry, role: undefined } : entry));- }}><option value="">Additional file</option><option value="promptEmbedding">Animate conditioning</option></select></label>}- <span title={file.downloadedPath}>{file.downloadedPath ? "Downloaded" : "Download required"}</span>- <button type="button" className="icon-button" disabled={disabled} aria-label={`Remove additional safetensor ${index + 1}`}- onClick={() => onChange(value.filter((entry) => entry.id !== file.id))}><Trash2 size={15} /></button>- </div>)}- <div className="weight-source-add">- <input aria-label="Add additional safetensor URL" value={url} disabled={disabled} placeholder="https://…"+ return <SettingsGroup heading={`Additional safetensors (${value.length})`} className="additional-safetensors">+ {value.map((file, index) => <SettingsExpander key={`${file.id}-${file.url}`} icon={<FileBox size={20} />} header={file.name || "Additional safetensor"}+ description={<span data-tooltip={file.downloadedPath}>{file.downloadedPath ? "Downloaded" : "Download required"}</span>} defaultExpanded={!file.downloadedPath}+ control={<button type="button" className="icon-button" disabled={disabled} aria-label={`Remove additional safetensor ${index + 1}`} data-tooltip="Remove"+ onClick={() => onChange(value.filter((entry) => entry.id !== file.id))}><Trash2 size={16} /></button>}>+ <SettingsRow header="Name">+ <input className="settings-field" aria-label={`Additional safetensor ${index + 1} name`} value={file.name} disabled={disabled}+ onChange={(event) => update(file.id, { name: event.target.value })} />+ </SettingsRow>+ <SettingsRow header="Download URL">+ <input className="settings-field" aria-label={`Additional safetensor ${index + 1} URL`} defaultValue={file.url} disabled={disabled} spellCheck={false} onBlur={(event) => {+ const next = event.target.value.trim();+ if (!isDownloadUrl(next)) { setError("Enter an HTTP or HTTPS download URL."); return; }+ setError(null);+ if (next !== file.url) update(file.id, { url: next, downloadedPath: undefined });+ }} />+ </SettingsRow>+ {animate && <SettingsRow header="Use">+ <ComboBox aria-label={`Additional safetensor ${index + 1} use`} value={file.role ?? ""} disabled={disabled} onChange={(next) => {+ const role = next === "promptEmbedding" ? "promptEmbedding" : undefined;+ onChange(value.map((entry) => entry.id === file.id ? { ...entry, role } : role ? { ...entry, role: undefined } : entry));+ }} options={[{ value: "", label: "Additional file" }, { value: "promptEmbedding", label: "Animate conditioning" }]} />+ </SettingsRow>}+ </SettingsExpander>)}+ <SettingsCard icon={<Plus size={20} />} header="Add a file" description="Downloads with this generator into your weights folder">+ <input className="settings-field" aria-label="Add additional safetensor URL" value={url} disabled={disabled} placeholder="https://…" spellCheck={false}onChange={(event) => setUrl(event.target.value)} /><button type="button" className="secondary-button" disabled={disabled || !isDownloadUrl(url) || value.some((file) => file.url === url.trim())} onClick={() => {onChange([...value, { id: crypto.randomUUID(), name: url.trim().split("/").pop()?.split("?")[0] || "Additional safetensor", url: url.trim(),...(animate && !value.some((file) => file.role === "promptEmbedding") ? { role: "promptEmbedding" } : {}) }]);setUrl("");- }}><Plus size={15} /> Add file</button>- </div>- {error && <p role="alert">{error}</p>}- </details>;+ }}>Add file</button>+ </SettingsCard>+ {error && <InfoBar severity="error" message={error} onClose={() => setError(null)} />}+ </SettingsGroup>;}diff --git a/src/components/LoraSettings.tsx b/src/components/LoraSettings.tsxindex ee83780..6dd5ea1 100644--- a/src/components/LoraSettings.tsx+++ b/src/components/LoraSettings.tsx@@ -1,12 +1,13 @@-import { ArrowDown, ArrowUp, Download, FolderSearch, Layers, LoaderCircle, Plus, Trash2, Wrench } from "lucide-react";+import { ArrowDown, ArrowUp, Download, Layers, LoaderCircle, Plus, Trash2, Wrench } from "lucide-react";import "../styles/loras.css";import { useEffect, useRef, useState, useSyncExternalStore } from "react";import { highestLoraStepOverride, isLoraStepOverride, loadLoras, saveLoras, subscribeLoras, type Lora, type TemplateLora } from "../lib/loras";-import { SettingsEditorDialog } from "./SettingsEditorDialog";import { MAX_GENERATION_STEPS } from "../lib/project";import { isTauri } from "../lib/persistence";import { chooseEnginePath } from "../lib/runtime";import { downloadLora, getWeightDownloadState, prepareLora, refreshDownloadedLoras, removeLora, subscribeWeightDownloads, weightDownloadProgress } from "../lib/weightDownloads";+import { Checkbox, ComboBox, ContentDialog, InfoBar, ProgressBar, SettingsCard, SettingsGroup, ToggleSwitch } from "./ui";+import { OpenableCard } from "./OpenableCard";function useLoras() {const [loras, setLoras] = useState(loadLoras);@@ -26,20 +27,29 @@ export function LoraLibrary({ onAdd, onEdit }: { onAdd: () => void; onEdit: (id:const timer = window.setInterval(refresh, 5000);return () => { window.removeEventListener("focus", refresh); window.clearInterval(timer); };}, []);- return <section className="generator-templates" aria-labelledby="loras-heading">- <header><div><h2 id="loras-heading">LoRAs</h2><p>Download adapters or add local files, then activate them in a generator template.</p></div>- <button className="secondary-button" type="button" onClick={onAdd}><Plus size={16} /> Add Lora</button></header>- <div className="generator-template-list" role="list" aria-label="LoRAs">- {loras.map((lora) => <div className="generator-template-item lora-library-item" role="listitem" key={lora.id}>- {download?.active && download.loraId === lora.id && download.phase !== "preparing" && <span className="generator-template-item__progress" role="progressbar" aria-label={`Downloading ${lora.name}`} aria-valuemin={0} aria-valuemax={100} aria-valuenow={Math.floor(weightDownloadProgress(download))} style={{ width: `${weightDownloadProgress(download)}%` }} />}- <button type="button" className="generator-template-item__open" aria-label={`Edit ${lora.name} LoRA`} onClick={() => onEdit(lora.id)}><Layers size={16} /><b>{lora.name}</b><small title={lora.path}>{download?.active && download.loraId === lora.id ? download.phase === "preparing" ? "Preparing…" : `Downloading · ${Math.floor(weightDownloadProgress(download))}%` : lora.needsPreparation ? "Needs preparation" : lora.path ? "Available" : "Not downloaded"}</small></button>- {lora.path ? <button className="icon-button" type="button" disabled={!desktop || download?.active} aria-label={`Prepare LoRA ${lora.name}`} title="Prepare missing timestep grid" onClick={() => { setError(null); void prepareLora(lora).catch((reason) => setError(String(reason))); }}>{download?.active && download.loraId === lora.id && download.phase === "preparing" ? <LoaderCircle size={15} className="spin" /> : <Wrench size={15} />}</button> : <span />}- {lora.url && !lora.path ? <button className="icon-button" type="button" disabled={!desktop || download?.active} aria-label={`Download LoRA ${lora.name}`} onClick={() => void downloadLora(lora.id)}><Download size={15} /></button>- : <button className="icon-button" type="button" disabled={Boolean(download?.active)} aria-label={`Remove LoRA ${lora.name}`} onClick={() => void removeLora(lora.id).catch((reason) => setError(String(reason)))}><Trash2 size={15} /></button>}- </div>)}+ return <SettingsGroup heading="LoRAs">+ <SettingsCard icon={<Plus size={20} />} header="Add a LoRA" description="Download adapters or add local files, then turn them on in a generator">+ <button className="secondary-button" type="button" onClick={onAdd}>Add LoRA</button>+ </SettingsCard>+ <div className="settings-card-list" role="list" aria-label="LoRAs">+ {loras.map((lora) => {+ const active = download?.active && download.loraId === lora.id;+ const preparing = active && download?.phase === "preparing";+ const percent = download ? Math.floor(weightDownloadProgress(download)) : 0;+ return <OpenableCard key={lora.id} icon={<Layers size={20} />} header={lora.name} openLabel={`Edit ${lora.name} LoRA`} onOpen={() => onEdit(lora.id)}+ description={<span data-tooltip={lora.path || undefined}>{active ? preparing ? "Preparing…" : `Downloading · ${percent}%` : lora.needsPreparation ? "Needs preparation" : lora.path ? "Available" : "Not downloaded"}</span>}+ progress={active && !preparing && <ProgressBar className="settings-progress" value={weightDownloadProgress(download!)} aria-label={`Downloading ${lora.name}`} />}+ actions={<>+ {lora.path && <button className="icon-button" type="button" disabled={!desktop || download?.active} aria-label={`Prepare LoRA ${lora.name}`} data-tooltip="Prepare missing timestep grid"+ onClick={() => { setError(null); void prepareLora(lora).catch((reason) => setError(String(reason))); }}>{preparing ? <LoaderCircle size={16} className="spin" /> : <Wrench size={16} />}</button>}+ {lora.url && !lora.path+ ? <button className="icon-button" type="button" disabled={!desktop || download?.active} aria-label={`Download LoRA ${lora.name}`} data-tooltip="Download" onClick={() => void downloadLora(lora.id)}><Download size={16} /></button>+ : <button className="icon-button" type="button" disabled={Boolean(download?.active)} aria-label={`Remove LoRA ${lora.name}`} data-tooltip="Remove" onClick={() => void removeLora(lora.id).catch((reason) => setError(String(reason)))}><Trash2 size={16} /></button>}+ </>} />;+ })}</div>- {error && <p role="alert">{error}</p>}- </section>;+ {error && <InfoBar severity="error" message={error} onClose={() => setError(null)} />}+ </SettingsGroup>;}export function LoraEditor({ loraId, onDone }: { loraId: string; onDone: () => void }) {@@ -62,8 +72,9 @@ export function LoraEditor({ loraId, onDone }: { loraId: string; onDone: () => vif (!name.trim()) setName(picked.split(/[\\/]/).pop()!.replace(/\.safetensors$/i, ""));} catch (reason) { setError(String(reason)); }};+ const invalid = !name.trim() || (!path.trim() && !existing?.url) || (override && !isLoraStepOverride(Number(steps)));const save = async () => {- if (!name.trim() || (!path.trim() && !existing?.url) || (override && !isLoraStepOverride(Number(steps)))) return;+ if (invalid) return;if (path.trim() && (!/^(?:[a-z]:[\\/]|\\\\|\/)/i.test(path.trim()) || path.includes("\0"))) {setError("Choose a local LoRA file using its absolute path."); return;}@@ -80,20 +91,21 @@ export function LoraEditor({ loraId, onDone }: { loraId: string; onDone: () => v} catch (reason) { setError(String(reason)); }finally { setSaving(false); }};- return <SettingsEditorDialog title={existing ? "Edit Lora" : "Add Lora"} headingId="lora-editor-heading" initialFocusLabel="LoRA name" closeLabel="Close LoRA settings" onClose={onDone}>+ return <ContentDialog title={existing ? "Edit LoRA" : "Add LoRA"} className="lora-dialog" width={560}+ primaryText={saving ? "Preparing LoRA…" : existing ? "Save" : "Add"} onPrimary={() => void save()} primaryDisabled={saving || Boolean(download?.active) || invalid}+ closeText="Cancel" onClose={onDone} defaultButton="primary" disableEscape={saving}><fieldset className="lora-manual" disabled={saving}><label>Name<input aria-label="LoRA name" value={name} onChange={(event) => setName(event.target.value)} /></label>- <label>Local file<div className="settings-path__row"><input aria-label="LoRA path" value={path} onChange={(event) => setPath(event.target.value)} placeholder="Absolute path to a .safetensors file" />- <button className="secondary-button" type="button" disabled={!isTauri()} onClick={() => void browse()}><FolderSearch size={16} /> Browse</button></div></label>- <label className="lora-toggle"><input type="checkbox" checked={override} onChange={(event) => setOverride(event.target.checked)} /> Override step count</label>+ <label>Local file<span className="lora-manual__path"><input aria-label="LoRA path" value={path} spellCheck={false} onChange={(event) => setPath(event.target.value)} placeholder="Absolute path to a .safetensors file" />+ <button className="secondary-button" type="button" disabled={!isTauri()} onClick={() => void browse()}>Browse…</button></span></label>+ <Checkbox aria-label="Override step count" checked={override} onChange={setOverride} label="Override step count"+ description="The highest override among active LoRAs replaces the scene's step count." />{override && <label>Step count<input aria-label="LoRA step override" type="number" min={2} max={MAX_GENERATION_STEPS} step={1} value={steps} onChange={(event) => setSteps(event.target.value)} /></label>}- <p>The highest override among active LoRAs replaces the scene's step count. Without an override, the scene's steps are used.</p>- <label className="lora-toggle"><input type="checkbox" checked={allowDownload} onChange={(event) => setAllowDownload(event.target.checked)} /> Download missing timestep grid</label>- <p>Newly selected files are prepared in place before use. Preparation may embed a timestep grid in the adapter.</p>- <button className="primary-button" type="button" disabled={Boolean(download?.active) || !name.trim() || (!path.trim() && !existing?.url) || (override && !isLoraStepOverride(Number(steps)))} onClick={() => void save()}>{saving ? "Preparing LoRA…" : existing ? "Save Lora" : "Add Lora"}</button>- {error && <p role="alert">{error}</p>}+ <Checkbox aria-label="Download missing timestep grid" checked={allowDownload} onChange={setAllowDownload} label="Download missing timestep grid"+ description="New files are prepared in place before use, which may embed a timestep grid." />+ {error && <InfoBar severity="error" message={error} />}</fieldset>- </SettingsEditorDialog>;+ </ContentDialog>;}export function TemplateLorasEditor({ value, onChange }: { value: TemplateLora[]; onChange: (value: TemplateLora[]) => void }) {@@ -108,26 +120,25 @@ export function TemplateLorasEditor({ value, onChange }: { value: TemplateLora[][next[index], next[index + delta]] = [next[index + delta], next[index]];onChange(next);};- return <section className="template-loras" aria-labelledby="template-loras-heading">- <h3 id="template-loras-heading">LoRAs <small>{active.length} active</small></h3>- <p>Enable adapters, set their strength, and arrange their order. A strength of 0 disables the adapter.</p>- <p>Missing active LoRAs with download links are downloaded with the generator.</p>+ return <SettingsGroup heading={<>LoRAs <span className="settings-group__count">{active.length} active</span></>} className="template-loras">{value.map((entry, index) => {const lora = library.find(({ id }) => id === entry.loraId);const name = lora?.name ?? "Missing LoRA";- return <div className="template-lora-row" key={entry.loraId}>- <span>{index + 1}.</span>- <label className="lora-toggle"><input type="checkbox" checked={entry.enabled} aria-label={`Enable ${name}`} onChange={(event) => update(index, { enabled: event.target.checked })} /> {name}{!lora?.path && (lora?.url ? " (download required)" : " (file unavailable)")}</label>- <label>Strength<input type="number" step="0.1" aria-label={`${name} strength`} value={entry.strength} onChange={(event) => { const strength = Number(event.target.value); if (event.target.value && Number.isFinite(strength)) update(index, { strength }); }} /></label>- <button className="icon-button" type="button" aria-label={`Move ${name} up`} disabled={index === 0} onClick={() => move(index, -1)}><ArrowUp size={15} /></button>- <button className="icon-button" type="button" aria-label={`Move ${name} down`} disabled={index === value.length - 1} onClick={() => move(index, 1)}><ArrowDown size={15} /></button>- <button className="icon-button" type="button" aria-label={`Deactivate and remove ${name}`} onClick={() => onChange(value.filter((_, i) => i !== index))}><Trash2 size={15} /></button>- </div>;+ return <SettingsCard key={entry.loraId} className="template-lora" icon={<Layers size={20} />} header={`${index + 1}. ${name}`}+ description={!lora?.path ? (lora?.url ? "Download required" : "File unavailable") : undefined}>+ <label className="template-lora__strength">Strength<input className="settings-field settings-field--number" type="number" step="0.1" aria-label={`${name} strength`} value={entry.strength}+ onChange={(event) => { const strength = Number(event.target.value); if (event.target.value && Number.isFinite(strength)) update(index, { strength }); }} /></label>+ <button className="icon-button" type="button" aria-label={`Move ${name} up`} data-tooltip="Move up" disabled={index === 0} onClick={() => move(index, -1)}><ArrowUp size={16} /></button>+ <button className="icon-button" type="button" aria-label={`Move ${name} down`} data-tooltip="Move down" disabled={index === value.length - 1} onClick={() => move(index, 1)}><ArrowDown size={16} /></button>+ <button className="icon-button" type="button" aria-label={`Deactivate and remove ${name}`} data-tooltip="Remove" onClick={() => onChange(value.filter((_, i) => i !== index))}><Trash2 size={16} /></button>+ <ToggleSwitch checked={entry.enabled} aria-label={`Enable ${name}`} onChange={(enabled) => update(index, { enabled })} />+ </SettingsCard>;})}- <select aria-label="Add LoRA to generator" value="" disabled={!available.length} onChange={(event) => { if (event.target.value) onChange([...value, { loraId: event.target.value, enabled: true, strength: 1 }]); }}>- <option value="">{available.length ? "Add an available LoRA…" : "Download or add a LoRA in Generators settings"}</option>- {available.map((lora) => <option value={lora.id} key={lora.id}>{lora.name}</option>)}- </select>- {stepOverride !== undefined && <p>Active LoRAs override the scene's step count to {stepOverride}, the highest selected override.</p>}- </section>;+ <SettingsCard icon={<Plus size={20} />} header="Add a LoRA" description="A strength of 0 turns an adapter off. Missing active LoRAs download with the generator.">+ <ComboBox aria-label="Add LoRA to generator" value="" disabled={!available.length} placeholder={available.length ? "Choose a LoRA" : "None available"}+ onChange={(loraId) => { if (loraId) onChange([...value, { loraId, enabled: true, strength: 1 }]); }}+ options={available.map((lora) => ({ value: lora.id, label: lora.name }))} />+ </SettingsCard>+ {stepOverride !== undefined && <InfoBar severity="informational" message={`Active LoRAs set the scene's step count to ${stepOverride}, the highest selected override.`} />}+ </SettingsGroup>;}diff --git a/src/components/OpenableCard.tsx b/src/components/OpenableCard.tsxnew file mode 100644index 0000000..a152614--- /dev/null+++ b/src/components/OpenableCard.tsx@@ -0,0 +1,25 @@+import { ChevronRight } from "lucide-react";+import type { ReactNode } from "react";++/* A settings card that opens something (a generator, a LoRA) AND carries its+ own buttons. A button cannot hold buttons, so the open action is a+ transparent button laid under the card, the way the SettingsExpander header+ is built; the trailing controls sit above it and take their own presses. */+export function OpenableCard({ icon, header, description, progress, openLabel, onOpen, actions, className, openRef }: {+ icon: ReactNode; header: ReactNode; description?: ReactNode; progress?: ReactNode; openLabel: string; onOpen: () => void;+ actions?: ReactNode; className?: string; openRef?: string;+}) {+ return <div className={`ui-settings-card settings-open-card${className ? ` ${className}` : ""}`} role="listitem">+ <button type="button" className="settings-open-card__open" aria-label={openLabel} data-open-ref={openRef} onClick={onOpen} />+ <span className="ui-settings-card__icon" aria-hidden="true">{icon}</span>+ <span className="ui-settings-card__text">+ <span className="ui-settings-card__header">{header}</span>+ {description && <span className="ui-settings-card__description">{description}</span>}+ {progress}+ </span>+ <span className="ui-settings-card__control settings-open-card__control">+ {actions}+ <ChevronRight size={16} aria-hidden="true" className="ui-settings-card__glyph" />+ </span>+ </div>;+}diff --git a/src/components/SettingsEditorDialog.tsx b/src/components/SettingsEditorDialog.tsxdeleted file mode 100644index e6740d7..0000000--- a/src/components/SettingsEditorDialog.tsx+++ /dev/null@@ -1,33 +0,0 @@-import { ArrowLeft, X } from "lucide-react";-import { useEffect, useRef, type ReactNode } from "react";--export function SettingsEditorDialog({ children, footer, title, headingId, initialFocusLabel, closeLabel, onClose }: {- children: ReactNode; footer?: ReactNode; title: string; headingId: string;- initialFocusLabel: string; closeLabel: string; onClose: () => void;-}) {- const dialog = useRef<HTMLDivElement>(null);- useEffect(() => {- const opener = document.activeElement as HTMLElement | null;- dialog.current?.querySelector<HTMLInputElement>(`[aria-label="${initialFocusLabel}"]`)?.focus();- return () => { requestAnimationFrame(() => { if (opener?.isConnected) opener.focus(); }); };- }, [initialFocusLabel]);- 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={headingId}>- <header className="generator-dialog__head">- <button type="button" className="icon-button icon-button--strong" onClick={onClose} aria-label="Generators" title="Back to generators"><ArrowLeft size={18} /></button>- <h2 id={headingId}>{title}</h2>- <button type="button" className="icon-button" aria-label={closeLabel} onClick={onClose}><X size={18} /></button>- </header>- <div className="generator-dialog__body">{children}</div>- {footer}- </div>- </div>;-}diff --git a/src/components/SettingsView.downloads.test.tsx b/src/components/SettingsView.downloads.test.tsxindex cac0226..8cda651 100644--- a/src/components/SettingsView.downloads.test.tsx+++ b/src/components/SettingsView.downloads.test.tsx@@ -14,6 +14,11 @@ import { loadLoras, saveLoras, TAOMATE_LORA, TURBO_LORA } from "../lib/loras";vi.mock("@tauri-apps/api/core", () => ({ invoke: vi.fn() }));vi.mock("@tauri-apps/api/event", () => ({ listen: vi.fn(async () => () => undefined) }));const files = new Set<string>();+const pick = (name: string, option: string) => {+ fireEvent.click(screen.getByRole("combobox", { name }));+ fireEvent.click(screen.getByRole("option", { name: option }));+};+const card = (openLabel: string) => screen.getByRole("button", { name: openLabel }).closest(".settings-open-card") as HTMLElement;it("keeps a failed local import editable and supports local-only preparation", async () => {const normal = vi.mocked(invoke).getMockImplementation()!;@@ -22,17 +27,17 @@ it("keeps a failed local import editable and supports local-only preparation", areturn normal(command, args);});render(<SettingsView onClose={() => undefined} />);- fireEvent.click(screen.getByRole("button", { name: "Add Lora" }));+ fireEvent.click(screen.getByRole("button", { name: "Add LoRA" }));fireEvent.change(screen.getByLabelText("LoRA name"), { target: { value: "Offline style" } });fireEvent.change(screen.getByLabelText("LoRA path"), { target: { value: "D:/style.safetensors" } });fireEvent.click(screen.getByLabelText("Download missing timestep grid"));- fireEvent.click(screen.getByRole("button", { name: "Add Lora" }));+ fireEvent.click(screen.getByRole("button", { name: "Add" }));expect(await screen.findByRole("alert")).toHaveTextContent("Local companion grid missing");expect(loadLoras().find(({ name }) => name === "Offline style")).toBeUndefined();expect(invoke).toHaveBeenCalledWith("prepare_lora", { path: "D:/style.safetensors", allowDownload: false });expect(screen.getByLabelText("LoRA name")).toHaveValue("Offline style");vi.mocked(invoke).mockImplementation(normal);- fireEvent.click(screen.getByRole("button", { name: "Add Lora" }));+ fireEvent.click(screen.getByRole("button", { name: "Add" }));await screen.findByRole("button", { name: "Prepare LoRA Offline style" });expect(loadLoras().find(({ name }) => name === "Offline style")?.path).toBe("D:/style.safetensors");});@@ -81,8 +86,8 @@ it("adds and downloads an additional safetensor from a generator's settings", asfireEvent.click(screen.getByRole("button", { name: "Download weights" }));await waitFor(() => expect(getWeightDownloadState()).toMatchObject({ templateId: "default", active: false, completed: 1, error: null }));expect(loadGeneratorTemplateSettings().templates[0].additionalSafetensors![0].downloadedPath).toBe("C:/Slopus/weights/extra.safetensors");- fireEvent.change(screen.getByLabelText("Generator mode"), { target: { value: "animate" } });- fireEvent.change(screen.getByLabelText("Additional safetensor 1 use"), { target: { value: "promptEmbedding" } });+ pick("Generator mode", "Animate (reference video)");+ pick("Additional safetensor 1 use", "Animate conditioning");await waitFor(() => expect(invoke).toHaveBeenCalledWith("slopfab_status", expect.objectContaining({ settings: {slopfab: expect.objectContaining({ options: expect.objectContaining({ generationMode: "animate", promptEmbedding: "C:/Slopus/weights/extra.safetensors" }) }),} })));@@ -98,10 +103,10 @@ it("discovers Singularity's existing weights on opening Settings and downloads orender(<SettingsView onClose={() => undefined} />);await waitFor(() => expect(loadGeneratorTemplateSettings().templates.find(({ id }) => id === "minimax-h3-singularity")?.paths.transformer).toMatch(/^D:\/Projects\/weights\//));expect(screen.getByRole("button", { name: "Download generator Singularity" })).toBeEnabled();- expect(screen.getByRole("button", { name: "Edit Singularity generator" })).toHaveTextContent("Needs Turbo LoRA");+ expect(card("Edit Singularity generator")).toHaveTextContent("Needs Turbo LoRA");expect(invoke).not.toHaveBeenCalledWith("download_weight", expect.anything());fireEvent.click(screen.getByRole("button", { name: "Download generator Singularity" }));- expect(await screen.findByRole("radio", { name: "Use Singularity as the default generator" })).toBeEnabled();+ expect(await screen.findByRole("button", { name: "Set Singularity as default" })).toBeEnabled();expect(vi.mocked(invoke).mock.calls.filter(([command]) => command === "download_weight")).toEqual([["download_weight", { requestId: expect.any(String), url: TURBO_LORA.url }],]);@@ -132,8 +137,9 @@ it("shows discovered model files as Found even when an active LoRA is missing",it("selects an undownloaded LoRA in a generator and downloads it from that generator", async () => {render(<SettingsView onClose={() => undefined} />);fireEvent.click(screen.getByRole("button", { name: "Edit Default generator" }));+ fireEvent.click(screen.getByRole("combobox", { name: "Add LoRA to generator" }));expect(screen.getByRole("option", { name: "Turbo" })).toBeInTheDocument();- fireEvent.change(screen.getByLabelText("Add LoRA to generator"), { target: { value: TURBO_LORA.id } });+ fireEvent.click(screen.getByRole("option", { name: "Turbo" }));expect(screen.getByLabelText("Enable Turbo")).toBeChecked();expect(screen.getByText(/step count to 4/)).toBeInTheDocument();fireEvent.click(screen.getByRole("button", { name: "Download weights" }));@@ -141,26 +147,28 @@ it("selects an undownloaded LoRA in a generator and downloads it from that generexpect(loadLoras().find(({ id }) => id === TURBO_LORA.id)?.path).not.toBe("");expect(screen.queryByRole("button", { name: "Download weights" })).not.toBeInTheDocument();fireEvent.click(screen.getByRole("button", { name: "Generators" }));- expect(screen.getByRole("radio", { name: "Use Default as the default generator" })).toBeEnabled();+ expect(within(screen.getByRole("list", { name: "Generators" })).getByText("Default")).toBeInTheDocument();+ expect(card("Edit Default generator")).toHaveTextContent("Used by default");fireEvent.click(screen.getByRole("button", { name: "Remove LoRA Turbo" }));expect(await screen.findByRole("button", { name: "Download generator Default" })).toBeEnabled();- expect(screen.queryByRole("radio", { name: "Use Default as the default generator" })).not.toBeInTheDocument();+ expect(within(screen.getByRole("list", { name: "Available to download" })).getByText("Default")).toBeInTheDocument();+ expect(card("Edit Default generator")).not.toHaveTextContent("Used by default");});it("downloads TaoMate and persists manual adapters, activation, strength and order per template", async () => {const settings = render(<SettingsView onClose={() => undefined} />);fireEvent.click(screen.getByRole("button", { name: "Download LoRA TaoMate 3-Step" }));await waitFor(() => expect(loadLoras()[0].path).not.toBe(""));- fireEvent.click(screen.getByRole("button", { name: "Add Lora" }));+ fireEvent.click(screen.getByRole("button", { name: "Add LoRA" }));expect(screen.queryByRole("button", { name: "New generator" })).not.toBeInTheDocument();- expect(screen.getByRole("heading", { name: "Add Lora" })).toBeInTheDocument();- expect(screen.getByRole("dialog", { name: "Add Lora" })).toBeInTheDocument();+ expect(screen.getByRole("heading", { name: "Add LoRA" })).toBeInTheDocument();+ expect(screen.getByRole("dialog", { name: "Add LoRA" })).toBeInTheDocument();fireEvent.change(screen.getByLabelText("LoRA name"), { target: { value: "My style" } });fireEvent.change(screen.getByLabelText("LoRA path"), { target: { value: "D:/models/style.safetensors" } });expect(screen.queryByLabelText("LoRA multiplier")).not.toBeInTheDocument();fireEvent.click(screen.getByLabelText("Override step count"));fireEvent.change(screen.getByLabelText("LoRA step override"), { target: { value: "8" } });- fireEvent.click(screen.getByRole("button", { name: "Add Lora" }));+ fireEvent.click(screen.getByRole("button", { name: "Add" }));await waitFor(() => expect(loadLoras().find(({ name }) => name === "My style")).toBeDefined());expect(invoke).toHaveBeenCalledWith("prepare_lora", { path: "D:/models/style.safetensors", allowDownload: true });const manual = loadLoras().find(({ name }) => name === "My style")!;@@ -169,12 +177,12 @@ it("downloads TaoMate and persists manual adapters, activation, strength and ordexpect(screen.queryByRole("dialog")).not.toBeInTheDocument();fireEvent.click(screen.getByRole("button", { name: "Edit My style LoRA" }));expect(screen.getByLabelText("LoRA step override")).toHaveValue(8);- expect(screen.getByRole("dialog", { name: "Edit Lora" })).toBeInTheDocument();+ expect(screen.getByRole("dialog", { name: "Edit LoRA" })).toBeInTheDocument();expect(screen.queryByLabelText("LoRA multiplier")).not.toBeInTheDocument();- fireEvent.click(screen.getByRole("button", { name: "Generators" }));+ fireEvent.click(screen.getByRole("button", { name: "Cancel" }));fireEvent.click(screen.getByRole("button", { name: "Edit Default generator" }));- fireEvent.change(screen.getByLabelText("Add LoRA to generator"), { target: { value: TAOMATE_LORA.id } });- fireEvent.change(screen.getByLabelText("Add LoRA to generator"), { target: { value: manual.id } });+ pick("Add LoRA to generator", TAOMATE_LORA.name);+ pick("Add LoRA to generator", manual.name);fireEvent.change(screen.getByLabelText("My style strength"), { target: { value: "-0.5" } });fireEvent.click(screen.getByRole("button", { name: "Move My style up" }));fireEvent.click(screen.getByLabelText("Enable TaoMate 3-Step"));@@ -211,7 +219,7 @@ it("keeps a LoRA download alive outside Settings, shows progress and cancels thrsettings.unmount();render(<WorkQueuePanel queue={new WorkQueue()} items={[]} onClose={() => undefined} />);act(() => progress({ payload: { requestId, downloaded: 50, total: 100 } }));- expect(screen.getByRole("progressbar", { name: "TaoMate 3-Step download progress" })).toHaveAttribute("value", "50");+ expect(screen.getByRole("progressbar", { name: "TaoMate 3-Step download progress" })).toHaveAttribute("aria-valuenow", "50");fireEvent.click(screen.getByRole("button", { name: "Cancel TaoMate 3-Step download" }));await waitFor(() => expect(getWeightDownloadState()).toMatchObject({ active: false, error: "Download cancelled." }));expect(loadLoras()[0].path).toBe("");@@ -236,22 +244,23 @@ it("keeps downloading with Settings closed and restores progress in the templateawait waitFor(() => expect(pending).toHaveLength(1));act(() => progress({ payload: { requestId: pending[0].requestId, downloaded: 50, total: 100 } }));const fill = screen.getByRole("progressbar", { name: "Downloading First/Last Frame weights" });- expect(fill.closest(".generator-template-item")).not.toBeNull();- expect(within(screen.getByRole("list", { name: "Download" })).getByRole("progressbar")).toBe(fill);+ expect(fill.closest(".settings-open-card")).toHaveTextContent("Downloading · 12%");+ expect(within(screen.getByRole("list", { name: "Available to download" })).getByRole("progressbar")).toBe(fill);expect(within(screen.getByRole("list", { name: "Generators" })).queryByText("First/Last Frame")).toBeNull();- expect(fill).toHaveStyle({ width: "12.5%" });- fireEvent.click(screen.getByRole("button", { name: "Close settings" }));+ expect(fill).toHaveAttribute("aria-valuenow", "13");+ expect(fill.querySelector(".ui-progress__fill")).toHaveStyle({ width: "12.5%" });+ fireEvent.click(screen.getByRole("button", { name: "Back" }));await act(async () => pending[0].finish());await waitFor(() => expect(pending).toHaveLength(2));act(() => progress({ payload: { requestId: pending[1].requestId, downloaded: 50, total: 100 } }));const queue = new WorkQueue(async (record) => record);const panel = render(<WorkQueuePanel queue={queue} items={[]} onClose={() => panel.unmount()} />);expect(screen.getByRole("region", { name: "Weight downloads" })).toHaveTextContent("First/Last Frame");- expect(screen.getByRole("progressbar", { name: "First/Last Frame download progress" })).toHaveAttribute("value", "37.5");+ expect(screen.getByRole("progressbar", { name: "First/Last Frame download progress" })).toHaveAttribute("aria-valuenow", "38");expect(screen.queryByText("No work yet")).toBeNull();- fireEvent.click(screen.getByRole("button", { name: "Close work queue" }));+ panel.unmount();const reopened = render(<SettingsView onClose={() => reopened.unmount()} />);- expect(screen.getByRole("progressbar", { name: "Downloading First/Last Frame weights" })).toHaveStyle({ width: "37.5%" });+ expect(screen.getByRole("progressbar", { name: "Downloading First/Last Frame weights" }).querySelector(".ui-progress__fill")).toHaveStyle({ width: "37.5%" });reopened.unmount();for (let index = 1; index < 4; index++) {await waitFor(() => expect(pending.length).toBe(index + 1));@@ -266,24 +275,24 @@ it("keeps downloading with Settings closed and restores progress in the templateit("downloads the sample, enables its default choice, and removes only weights to restore the download action", async () => {render(<SettingsView onClose={() => undefined} />);- const radio = () => screen.getByRole("radio", { name: "Use First/Last Frame as the default generator" });+ const makeDefault = () => screen.getByRole("button", { name: "Set First/Last Frame as default" });expect(within(screen.getByRole("list", { name: "Generators" })).getByText("Default")).toBeInTheDocument();- expect(within(screen.getByRole("list", { name: "Download" })).getByText("First/Last Frame")).toBeInTheDocument();- expect(within(screen.getByRole("list", { name: "Download" })).queryByRole("radio")).toBeNull();+ expect(within(screen.getByRole("list", { name: "Available to download" })).getByText("First/Last Frame")).toBeInTheDocument();+ expect(within(screen.getByRole("list", { name: "Available to download" })).queryByRole("button", { name: /as default/ })).toBeNull();expect(screen.queryByRole("button", { name: "Remove generator First/Last Frame" })).toBeNull();fireEvent.click(screen.getByRole("button", { name: "Download generator First/Last Frame" }));- const remove = await screen.findByRole("button", { name: "Remove downloaded weights for First/Last Frame" });+ const remove = await screen.findByRole("button", { name: "Remove downloaded weights for First/Last Frame" }, { timeout: 5000 });expect(within(screen.getByRole("list", { name: "Generators" })).getByText("First/Last Frame")).toBeInTheDocument();- expect(within(screen.getByRole("list", { name: "Download" })).queryByText("First/Last Frame")).toBeNull();- expect(within(screen.getByRole("list", { name: "Download" })).getByText("References")).toBeInTheDocument();- expect(radio()).toBeEnabled();- fireEvent.click(radio());+ expect(within(screen.getByRole("list", { name: "Available to download" })).queryByText("First/Last Frame")).toBeNull();+ expect(within(screen.getByRole("list", { name: "Available to download" })).getByText("References")).toBeInTheDocument();+ expect(makeDefault()).toBeEnabled();+ fireEvent.click(makeDefault());await waitFor(() => expect(loadGeneratorTemplateSettings().defaultTemplateId).toBe("minimax-h3-original"));fireEvent.click(remove);expect(await screen.findByRole("button", { name: "Download generator First/Last Frame" })).toBeEnabled();- expect(within(screen.getByRole("list", { name: "Download" })).getByText("First/Last Frame")).toBeInTheDocument();+ expect(within(screen.getByRole("list", { name: "Available to download" })).getByText("First/Last Frame")).toBeInTheDocument();expect(within(screen.getByRole("list", { name: "Generators" })).queryByText("First/Last Frame")).toBeNull();- expect(within(screen.getByRole("list", { name: "Download" })).queryByRole("radio")).toBeNull();+ expect(within(screen.getByRole("list", { name: "Available to download" })).queryByRole("button", { name: /as default/ })).toBeNull();expect(files.size).toBe(0);expect(loadGeneratorTemplateSettings().templates.find((template) => template.id === "minimax-h3-original")?.paths.transformer).toMatch(/^https:/);});@@ -291,7 +300,7 @@ it("downloads the sample, enables its default choice, and removes only weights tit("restores a deleted downloaded file when Settings regains focus", async () => {render(<SettingsView onClose={() => undefined} />);fireEvent.click(screen.getByRole("button", { name: "Download generator First/Last Frame" }));- await screen.findByRole("button", { name: "Remove downloaded weights for First/Last Frame" });+ await screen.findByRole("button", { name: "Remove downloaded weights for First/Last Frame" }, { timeout: 5000 });files.clear();fireEvent.focus(window);expect(await screen.findByRole("button", { name: "Download generator First/Last Frame" })).toBeEnabled();@@ -300,15 +309,16 @@ it("restores a deleted downloaded file when Settings regains focus", async () =>it("stores multiple variants and their GPU and VRAM criteria in the editor", async () => {render(<SettingsView onClose={() => undefined} />);fireEvent.click(screen.getByRole("button", { name: "Edit First/Last Frame generator" }));- const advanced = screen.getByRole("checkbox", { name: "Show advanced options" });+ const advanced = screen.getByRole("switch", { name: "Show advanced options" });expect(advanced).not.toBeChecked();expect(screen.queryByText(/Download variants/)).toBeNull();- expect(advanced.closest(".generator-editor")?.lastElementChild).toBe(advanced.closest("label"));+ const groups = document.querySelectorAll(".settings-page > .ui-settings-group");+ expect(groups[groups.length - 1]).toBe(advanced.closest(".ui-settings-group"));fireEvent.click(advanced);- const weight = screen.getByLabelText("Transformer weights").closest(".settings-path")!;- const details = weight.querySelector("details")!;- fireEvent.click(within(weight as HTMLElement).getByText("Download variants (2)"));- details.open = true;+ const weight = screen.getByRole("group", { name: "Transformer weights" }).closest(".settings-path") as HTMLElement;+ const variants = within(weight).getByRole("button", { name: /^Download variants \(2\)/ });+ fireEvent.click(variants);+ expect(variants).toHaveAttribute("aria-expanded", "true");fireEvent.change(screen.getByLabelText("Add Transformer weights download URL"), { target: { value: "https://example.com/larger.safetensors" } });fireEvent.click(within(weight as HTMLElement).getByRole("button", { name: "Add URL" }));const gpu = screen.getByLabelText("Transformer weights variant 3 GPU model");@@ -322,6 +332,6 @@ it("stores multiple variants and their GPU and VRAM criteria in the editor", asyexpect(screen.getByLabelText("Transformer weights variant 3 GPU model")).toHaveValue("RTX 5090");fireEvent.click(screen.getByRole("button", { name: "Generators" }));fireEvent.click(screen.getByRole("button", { name: "Edit Default generator" }));- expect(screen.getByRole("checkbox", { name: "Show advanced options" })).not.toBeChecked();+ expect(screen.getByRole("switch", { name: "Show advanced options" })).not.toBeChecked();expect(screen.queryByText(/Download variants/)).toBeNull();});diff --git a/src/components/SettingsView.test.tsx b/src/components/SettingsView.test.tsxindex 59de86c..61676bf 100644--- a/src/components/SettingsView.test.tsx+++ b/src/components/SettingsView.test.tsx@@ -3,7 +3,7 @@import { cleanup, fireEvent, render, screen, waitFor, within } from "@testing-library/react";import { invoke } from "@tauri-apps/api/core";import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";-import { SettingsView } from "./SettingsView";+import { middleEllipsis, SettingsView } from "./SettingsView";import { createGeneratorTemplate, loadGeneratorTemplateSettings, saveGeneratorTemplateSettings } from "../lib/settings";import { loadReferenceIconGeneratorId } from "../lib/referenceIconSettings";import { loadLoras } from "../lib/loras";@@ -21,58 +21,90 @@ afterEach(() => {});const open = () => render(<SettingsView onClose={() => undefined} />);-const tab = (name: string) => screen.getByRole("tab", { name: new RegExp(`^${name}`) });+const tab = (name: string) => within(screen.getByRole("navigation", { name: "Settings sections" })).getByRole("button", { name: new RegExp(`^${name}`) });const editDefaultGenerator = () => fireEvent.click(screen.getByRole("button", { name: "Edit Default generator" }));+const combo = (name: string) => screen.getByRole("combobox", { name });+const pick = (name: string, option: string) => { fireEvent.click(combo(name)); fireEvent.click(screen.getByRole("option", { name: option })); };+const optionsOf = (name: string) => {+ fireEvent.click(combo(name));+ const labels = screen.getAllByRole("option").map((option) => option.textContent);+ fireEvent.keyDown(combo(name), { key: "Escape" });+ return labels;+};+const toggle = (name: string) => screen.getByRole("switch", { name });+const enterPath = (label: string, value: string) => {+ fireEvent.click(screen.getByRole("button", { name: `More options for ${label}` }));+ fireEvent.click(screen.getByRole("menuitem", { name: "Enter path or URL…" }));+ const input = screen.getByRole("textbox", { name: label });+ fireEvent.change(input, { target: { value } });+ fireEvent.blur(input);+};describe("the settings page", () => {- it("opens a focused page with vertical navigation and a Back action", () => {+ it("opens a focused page with a navigation pane and a Back action", () => {const onClose = vi.fn();render(<SettingsView onClose={onClose} />);expect(document.activeElement).toBe(screen.getByRole("main", { name: "Settings" }));expect(screen.queryByRole("dialog")).toBeNull();- expect(screen.getByRole("tablist").getAttribute("aria-orientation")).toBe("vertical");- fireEvent.click(screen.getByRole("button", { name: "Close settings" }));+ expect(screen.getByRole("heading", { level: 1, name: "Generator" })).toBeTruthy();+ expect(tab("Generator").getAttribute("aria-current")).toBe("page");+ fireEvent.click(screen.getByRole("button", { name: "Back" }));expect(onClose).toHaveBeenCalledOnce();});++ it("closes on Escape from the top level", () => {+ const onClose = vi.fn();+ render(<SettingsView onClose={onClose} />);+ fireEvent.keyDown(screen.getByRole("main", { name: "Settings" }), { key: "Escape" });+ expect(onClose).toHaveBeenCalledOnce();+ });++ it("middle-ellipsises long paths and keeps the file name", () => {+ expect(middleEllipsis("C:\\short.safetensors")).toBe("C:\\short.safetensors");+ const long = `D:\\${"folder\\".repeat(20)}model.safetensors`;+ const shown = middleEllipsis(long);+ expect(shown.length).toBe(64);+ expect(shown).toMatch(/^D:\\folder.*….*model\.safetensors$/);+ });});describe("the settings screen", () => {it("remembers MotionCache per generator and disables it in Animate mode", () => {const view = open();editDefaultGenerator();- const toggle = () => screen.getByRole("checkbox", { name: "Enable MotionCache" }) as HTMLInputElement;- expect(toggle().checked).toBe(false);- fireEvent.click(toggle());+ const motion = () => toggle("Enable MotionCache");+ expect(motion().getAttribute("aria-checked")).toBe("false");+ fireEvent.click(motion());expect(loadGeneratorTemplateSettings().templates.find(({ id }) => id === "default")?.motionCache).toBe(true);- fireEvent.change(screen.getByLabelText("Generator mode"), { target: { value: "animate" } });- expect(toggle().checked).toBe(false);- expect(toggle().disabled).toBe(true);- fireEvent.change(screen.getByLabelText("Generator mode"), { target: { value: "prompt" } });- expect(toggle().checked).toBe(true);+ pick("Generator mode", "Animate (reference video)");+ expect(motion().getAttribute("aria-checked")).toBe("false");+ expect((motion() as HTMLButtonElement).disabled).toBe(true);+ pick("Generator mode", "Text prompt");+ expect(motion().getAttribute("aria-checked")).toBe("true");fireEvent.click(screen.getByRole("button", { name: "Generators" }));fireEvent.click(screen.getByRole("button", { name: "New generator" }));- expect(toggle().checked).toBe(false);+ expect(motion().getAttribute("aria-checked")).toBe("false");view.unmount();open();editDefaultGenerator();- expect(toggle().checked).toBe(true);- fireEvent.click(toggle());+ expect(motion().getAttribute("aria-checked")).toBe("true");+ fireEvent.click(motion());expect(loadGeneratorTemplateSettings().templates.find(({ id }) => id === "default")?.motionCache).toBe(false);});it("defaults to Sage and remembers each generator's attention", () => {const view = open();editDefaultGenerator();- expect((screen.getByLabelText("Generator attention") as HTMLSelectElement).value).toBe("sage2");- expect(within(screen.getByLabelText("Generator attention")).getAllByRole("option").map((option) => option.textContent)).toEqual(["Exact attention", "Flash attention", "Sage attention"]);- fireEvent.change(screen.getByLabelText("Generator attention"), { target: { value: "flash2" } });+ expect(combo("Generator attention").getAttribute("data-value")).toBe("sage2");+ expect(optionsOf("Generator attention")).toEqual(["Exact attention", "Flash attention", "Sage attention"]);+ pick("Generator attention", "Flash attention");fireEvent.click(screen.getByRole("button", { name: "Generators" }));fireEvent.click(screen.getByRole("button", { name: "New generator" }));- expect((screen.getByLabelText("Generator attention") as HTMLSelectElement).value).toBe("sage2");+ expect(combo("Generator attention").getAttribute("data-value")).toBe("sage2");view.unmount();open();editDefaultGenerator();- expect((screen.getByLabelText("Generator attention") as HTMLSelectElement).value).toBe("flash2");+ expect(combo("Generator attention").getAttribute("data-value")).toBe("flash2");});it("switches NVIDIA between CUDA and Vulkan and keeps both choices after switching", async () => {@@ -84,20 +116,20 @@ describe("the settings screen", () => {} : null);const view = open();fireEvent.click(tab("Diagnostics"));- const backend = () => screen.getByLabelText("GPU backend") as HTMLSelectElement;+ const backend = () => combo("GPU backend") as HTMLButtonElement;await waitFor(() => expect(backend().disabled).toBe(false));- expect(backend().value).toBe("cuda");- fireEvent.change(backend(), { target: { value: "vulkan" } });+ expect(backend().getAttribute("data-value")).toBe("cuda");+ expect(optionsOf("GPU backend")).toEqual(["CUDA", "Vulkan"]);+ pick("GPU backend", "Vulkan");await waitFor(() => expect(backend().disabled).toBe(false));- expect(backend().value).toBe("vulkan");- expect(within(backend()).getAllByRole("option")).toHaveLength(2);+ expect(backend().getAttribute("data-value")).toBe("vulkan");view.unmount();open();fireEvent.click(tab("Diagnostics"));await waitFor(() => expect(backend().disabled).toBe(false));- expect(backend().value).toBe("vulkan");- fireEvent.change(backend(), { target: { value: "cuda" } });- await waitFor(() => expect(backend().value).toBe("cuda"));+ expect(backend().getAttribute("data-value")).toBe("vulkan");+ pick("GPU backend", "CUDA");+ await waitFor(() => expect(backend().getAttribute("data-value")).toBe("cuda"));expect(localStorage.getItem("slopus.inference-backend.v1")).toBe("cuda");});@@ -108,55 +140,63 @@ describe("the settings screen", () => {open();fireEvent.click(tab("Diagnostics"));await waitFor(() => expect(invoke).toHaveBeenCalledWith("slopfab_status", expect.anything()));- const backend = screen.getByLabelText("GPU backend") as HTMLSelectElement;+ const backend = combo("GPU backend") as HTMLButtonElement;expect(backend.disabled).toBe(true);- expect(backend.value).toBe("vulkan");- expect(within(backend).getAllByRole("option")).toHaveLength(1);+ expect(backend.getAttribute("data-value")).toBe("vulkan");+ expect(backend.textContent).toBe("Vulkan");});it("keeps the popup's saved icon choice without exposing confirmation in settings", () => {localStorage.setItem("slopus.reference-icon-automation.v1", "enabled");const view = open();- const automatic = () => screen.getByRole("checkbox", { name: "Automatic reference icon generation" }) as HTMLInputElement;- expect(automatic().checked).toBe(true);- expect(screen.queryByRole("checkbox", { name: "Ask before automatic icon generation" })).toBeNull();+ const automatic = () => toggle("Automatic reference icon generation");+ expect(automatic().getAttribute("aria-checked")).toBe("true");+ expect(screen.queryByRole("switch", { name: "Ask before automatic icon generation" })).toBeNull();view.unmount();open();- expect(automatic().checked).toBe(true);+ expect(automatic().getAttribute("aria-checked")).toBe("true");expect(localStorage.getItem("slopus.reference-icon-automation.v1")).toBe("enabled");fireEvent.click(automatic());- expect(automatic().checked).toBe(false);+ expect(automatic().getAttribute("aria-checked")).toBe("false");expect(localStorage.getItem("slopus.reference-icon-automation.v1")).toBe("disabled");fireEvent.click(automatic());- expect(automatic().checked).toBe(true);+ expect(automatic().getAttribute("aria-checked")).toBe("true");expect(localStorage.getItem("slopus.reference-icon-automation.v1")).toBe("ask");});it("keeps debug options off by default and remembers the Diagnostics choice", () => {const view = open();fireEvent.click(tab("Diagnostics"));- const toggle = screen.getByRole("checkbox", { name: "Enable debug options" }) as HTMLInputElement;- expect(toggle.checked).toBe(false);- fireEvent.click(toggle);+ expect(toggle("Enable debug options").getAttribute("aria-checked")).toBe("false");+ fireEvent.click(toggle("Enable debug options"));view.unmount();open();fireEvent.click(tab("Diagnostics"));- const restored = screen.getByRole("checkbox", { name: "Enable debug options" }) as HTMLInputElement;- expect(restored.checked).toBe(true);- fireEvent.click(restored);- expect(restored.checked).toBe(false);+ expect(toggle("Enable debug options").getAttribute("aria-checked")).toBe("true");+ fireEvent.click(toggle("Enable debug options"));+ expect(toggle("Enable debug options").getAttribute("aria-checked")).toBe("false");+ });++ it("picks the app theme from one combo box and saves it", () => {+ open();+ fireEvent.click(tab("Appearance"));+ expect(screen.getByRole("heading", { level: 1, name: "Appearance" })).toBeTruthy();+ expect(combo("App theme").textContent).toBe("Use system setting");+ expect(optionsOf("App theme")).toEqual(["Use system setting", "Light", "Dark"]);+ pick("App theme", "Light");+ expect(localStorage.getItem("slopus.theme.v1")).toBe("light");+ expect(combo("App theme").textContent).toBe("Light");});it("opens on the engine, because that is what has to be set before anything renders", async () => {open();- expect(tab("Generator").getAttribute("aria-selected")).toBe("true");+ expect(tab("Generator").getAttribute("aria-current")).toBe("page");expect(screen.getByRole("heading", { name: "Generators" })).toBeTruthy();- expect(screen.queryByLabelText(/Transformer weights/)).toBeNull();+ expect(screen.queryByRole("group", { name: "Transformer weights" })).toBeNull();editDefaultGenerator();- expect(screen.getByLabelText("Transformer weights")).toBeTruthy();- // The other tab's contents are not merely hidden, they are not rendered:- // a settings screen that draws both panels is the tall screen tabs replaced.- expect(screen.queryByLabelText("Appearance")).toBeNull();+ expect(screen.getByRole("group", { name: "Transformer weights" })).toBeTruthy();+ // The other sections are not merely hidden, they are not rendered.+ expect(screen.queryByRole("combobox", { name: "App theme" })).toBeNull();await waitFor(() => expect(screen.getByRole("status").textContent).toContain("Browser preview"));});@@ -176,58 +216,73 @@ describe("the settings screen", () => {expect(screen.getByText("Platform")).toBeTruthy();});- it("swaps panels when a tab is chosen, and follows the arrow keys", () => {+ it("swaps sections from the navigation pane, and follows the arrow keys", () => {open();- expect(screen.getAllByRole("tab").map((item) => item.textContent?.replace(/\d+$/, ""))).toEqual([+ const items = within(screen.getByRole("navigation", { name: "Settings sections" })).getAllByRole("button").filter((item) => item.id.startsWith("settings-tab-"));+ expect(items.map((item) => item.textContent?.replace(/\d+$/, ""))).toEqual(["Generator", "Agents", "Appearance", "Diagnostics", "Updates",]);fireEvent.click(tab("Appearance"));- expect(screen.getByRole("radiogroup", { name: "Appearance" })).toBeTruthy();- expect(screen.queryByLabelText(/Transformer weights/)).toBeNull();- // Each panel is named by the tab that opened it, so a screen reader lands- // somewhere that says what it is.- expect(screen.getByRole("tabpanel").getAttribute("aria-labelledby")).toBe("settings-tab-appearance");+ expect(combo("App theme")).toBeTruthy();+ expect(screen.queryByRole("group", { name: "Transformer weights" })).toBeNull();+ expect(screen.getByRole("heading", { level: 1 }).textContent).toBe("Appearance");fireEvent.keyDown(tab("Appearance"), { key: "ArrowDown" });- expect(tab("Diagnostics").getAttribute("aria-selected")).toBe("true");+ expect(tab("Diagnostics").getAttribute("aria-current")).toBe("page");fireEvent.keyDown(tab("Diagnostics"), { key: "ArrowUp" });- expect(tab("Appearance").getAttribute("aria-selected")).toBe("true");+ expect(tab("Appearance").getAttribute("aria-current")).toBe("page");fireEvent.keyDown(tab("Appearance"), { key: "Home" });expect(document.activeElement).toBe(tab("Generator"));fireEvent.keyDown(tab("Generator"), { key: "End" });expect(document.activeElement).toBe(tab("Updates"));});- it("counts the paths still to set on the engine tab, from either tab", () => {+ it("counts the paths still to set on the Generator item, from any section", () => {open();// Four of the five fields are required and none is set yet.expect(within(tab("Generator")).getByText("4")).toBeTruthy();+ expect(tab("Generator").getAttribute("aria-label")).toBe("Generator, 4 model paths to set");fireEvent.click(tab("Appearance"));- // Still legible from the other side: what is unfinished is the reason the- // screen was opened, and hiding it behind a tab would bury it.expect(within(tab("Generator")).getByText("4")).toBeTruthy();});- it("keeps the settings header short", () => {+ it("keeps the settings copy short", () => {const { container } = open();- for (const gone of ["belongs to this computer", "stays behind when", "needs the model files", "ships with the app"]) {+ for (const gone of ["belongs to this computer", "stays behind when", "needs the model files", "ships with the app", "Match this computer", "whatever this computer"]) {expect(container.textContent, gone).not.toContain(gone);}expect(screen.queryByText("This computer")).toBeNull();- expect(screen.getByRole("heading", { name: "Settings" })).toBeTruthy();editDefaultGenerator();expect(screen.queryByText("Reads your prompt so the transformer can act on it.")).toBeNull();expect(screen.queryByText("Set its name, generation steps, attention, and model locations on this computer.")).toBeNull();});- it("puts the optional tokenizer setting last", () => {+ it("puts the optional tokenizer setting last, marked (optional) in plain text", () => {const { container } = open();editDefaultGenerator();- const labels = Array.from(container.querySelectorAll(".settings-path label b")).map((label) => label.textContent);- expect(labels.at(-1)).toContain("Tokenizer");+ const labels = Array.from(container.querySelectorAll(".settings-path .ui-settings-card__header")).map((label) => label.textContent);+ expect(labels.at(-1)).toBe("Tokenizer (optional)");+ });++ it("shows paths in cards and edits them through the More menu", () => {+ open();+ editDefaultGenerator();+ const card = screen.getByRole("group", { name: "Transformer weights" });+ expect(card.textContent).toContain("Not set");+ expect(within(card).getByRole("button", { name: "Browse for Transformer weights" })).toBeTruthy();+ const long = "D:\\Models\\a-very-long-folder-name\\another-nested-folder\\wan2.2\\transformer-weights.safetensors";+ enterPath("Transformer weights", long);+ expect(loadGeneratorTemplateSettings().templates.find(({ id }) => id === "default")?.paths.transformer).toBe(long);+ const shown = card.querySelector(".settings-path__value")!;+ expect(shown.textContent).toContain("…");+ expect(shown.textContent).toMatch(/transformer-weights\.safetensors$/);+ expect(shown.getAttribute("data-tooltip")).toBe(long);+ fireEvent.click(screen.getByRole("button", { name: "More options for Transformer weights" }));+ fireEvent.click(screen.getByRole("menuitem", { name: "Clear" }));+ expect(loadGeneratorTemplateSettings().templates.find(({ id }) => id === "default")?.paths.transformer).toBe("");});- it("offers Clear generator paths only on the generator editor page", () => {+ it("offers Clear generator paths only on the generator sub-page", () => {open();expect(screen.queryByRole("button", { name: /Clear generator paths/ })).toBeNull();editDefaultGenerator();@@ -238,45 +293,46 @@ describe("the settings screen", () => {expect(screen.queryByRole("button", { name: /Clear generator paths/ })).toBeNull();});- 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();+ it("edits generators on a sub-page with a breadcrumb and returns on Escape or Back", async () => {+ const onClose = vi.fn();+ render(<SettingsView onClose={onClose} />);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.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.keyDown(dialog, { key: "Escape" });expect(screen.queryByRole("dialog")).toBeNull();- expect(screen.getByRole("tab", { name: "Appearance" })).toBeTruthy();- await waitFor(() => expect(document.activeElement).toBe(opener));- fireEvent.click(tab("Appearance"));- expect(screen.getByRole("radiogroup", { name: "Appearance" })).toBeTruthy();- fireEvent.click(tab("Generator"));+ const breadcrumb = screen.getByRole("navigation", { name: "Breadcrumb" });+ expect(breadcrumb.textContent).toBe("GeneratorsDefault");+ expect(document.activeElement).toBe(screen.getByRole("heading", { level: 1, name: "Default" }));+ // The navigation pane stays usable while a sub-page is open.+ expect(tab("Appearance")).toBeTruthy();+ for (const group of ["General", "Performance", "Model files", /^Additional safetensors/, /^LoRAs/]) {+ expect(screen.getByRole("heading", { name: group })).toBeTruthy();+ }++ fireEvent.keyDown(screen.getByLabelText("Generator name"), { key: "Escape" });+ expect(screen.queryByRole("navigation", { name: "Breadcrumb" })).toBeNull();+ expect(onClose).not.toHaveBeenCalled();+ await waitFor(() => expect(document.activeElement).toBe(screen.getByRole("button", { name: "Edit Default generator" })));++ fireEvent.click(screen.getByRole("button", { name: "Edit Default generator" }));+ fireEvent.click(screen.getByRole("button", { name: "Back" }));expect(screen.queryByLabelText("Generator name")).toBeNull();+ expect(onClose).not.toHaveBeenCalled();+ fireEvent.click(screen.getByRole("button", { name: "Back" }));+ expect(onClose).toHaveBeenCalledOnce();});- it("edits LoRAs in a focused popup and discards unsaved changes on close", async () => {+ it("edits LoRAs in a content dialog and discards unsaved changes on Cancel or Escape", async () => {const onClose = vi.fn();render(<SettingsView onClose={onClose} />);const opener = screen.getByRole("button", { name: "Edit TaoMate 3-Step LoRA" });opener.focus(); fireEvent.click(opener);- const dialog = screen.getByRole("dialog", { name: "Edit Lora" });+ const dialog = screen.getByRole("dialog", { name: "Edit LoRA" });const name = within(dialog).getByLabelText("LoRA name");expect(document.activeElement).toBe(name);- expect(screen.queryByRole("tab", { name: "Appearance" })).toBeNull();+ // The page behind is hidden from assistive technology while it is open.+ expect(screen.queryByRole("main", { name: "Settings" })).toBeNull();expect(within(dialog).queryByLabelText("LoRA multiplier")).toBeNull();- const first = within(dialog).getByRole("button", { name: "Generators" });- const last = within(dialog).getByRole("button", { name: "Save Lora" });- last.focus(); fireEvent.keyDown(last, { key: "Tab" });- expect(document.activeElement).toBe(first);- fireEvent.keyDown(first, { key: "Tab", shiftKey: true });- expect(document.activeElement).toBe(last);+ expect(within(dialog).getByRole("button", { name: "Save" })).toBeTruthy();fireEvent.change(name, { target: { value: "Unsaved name" } });fireEvent.keyDown(name, { key: "Escape" });expect(screen.queryByRole("dialog")).toBeNull();@@ -284,7 +340,7 @@ describe("the settings screen", () => {expect(loadLoras()[0].name).toBe("TaoMate 3-Step");await waitFor(() => expect(document.activeElement).toBe(opener));fireEvent.click(opener);- fireEvent.click(screen.getByRole("button", { name: "Close LoRA settings" }));+ fireEvent.click(screen.getByRole("button", { name: "Cancel" }));expect(screen.queryByRole("dialog")).toBeNull();});@@ -293,47 +349,51 @@ describe("the settings screen", () => {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);+ expect(combo("Reference icon generator").getAttribute("data-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 } });+ pick("Reference icon generator", "Icons");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);+ expect(combo("Reference icon generator").getAttribute("data-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();+ expect(screen.queryByRole("group", { name: "Transformer weights" })).toBeNull();const nextGeneratorName = `Generator ${loadGeneratorTemplateSettings().templates.length + 1}`;fireEvent.click(screen.getByRole("button", { name: "New generator" }));expect((screen.getByLabelText("Generator name") as HTMLInputElement).value).toBe(nextGeneratorName);+ expect(document.activeElement).toBe(screen.getByLabelText("Generator name"));expect((screen.getByLabelText("Generator default steps") as HTMLInputElement).value).toBe("20");fireEvent.change(screen.getByLabelText("Generator name"), { target: { value: "Fast draft" } });fireEvent.change(screen.getByLabelText("Generator default steps"), { target: { value: "12" } });- fireEvent.change(screen.getByLabelText("Transformer weights"), { target: { value: "D:\\Models\\draft.safetensors" } });+ expect(screen.getByRole("heading", { level: 1, name: "Fast draft" })).toBeTruthy();+ enterPath("Transformer weights", "D:\\Models\\draft.safetensors");fireEvent.click(screen.getByRole("button", { name: "Generators" }));- expect(screen.queryByLabelText(/Transformer weights/)).toBeNull();- fireEvent.click(screen.getByRole("radio", { name: "Use Fast draft as the default generator" }));+ expect(screen.queryByRole("group", { name: "Transformer weights" })).toBeNull();+ fireEvent.click(screen.getByRole("button", { name: "Set Fast draft as default" }));const stored = JSON.parse(localStorage.getItem("slopus.generator-templates.v1") ?? "null");const selected = stored.templates.find((template: { id: string }) => template.id === stored.defaultTemplateId);expect(selected).toMatchObject({ name: "Fast draft", defaultSteps: 12, paths: { transformer: "D:\\Models\\draft.safetensors" } });+ expect(screen.queryByRole("button", { name: "Set Fast draft as default" })).toBeNull();+ expect(screen.getByRole("button", { name: "Set Default as default" })).toBeTruthy();});- it("puts each generator's radio first without a visible Default label", () => {+ it("marks the default generator in its card description instead of a radio", () => {open();- const radio = screen.getByRole("radio", { name: "Use Default as the default generator" });- const row = radio.closest(".generator-template-item");- expect(row?.firstElementChild).toBe(radio.closest("label"));- expect(radio.closest("label")?.textContent).toBe("");+ expect(screen.queryByRole("radio")).toBeNull();+ const card = screen.getByRole("button", { name: "Edit Default generator" }).closest(".settings-open-card") as HTMLElement;+ expect(card.textContent).toContain("Used by default");+ expect(within(card).queryByRole("button", { name: /as default/ })).toBeNull();});- it("offers only a button to reveal the log without fetching log details", async () => {+ it("offers only a row to reveal the log without fetching log details", async () => {Object.defineProperty(window, "__TAURI_INTERNALS__", { configurable: true, value: {} });const info = {path: "C:\\Users\\Editor\\AppData\\Local\\Slopus\\logs\\slopus.log",@@ -358,14 +418,17 @@ describe("the settings screen", () => {it("configures OpenRouter and local OpenAI-compatible models without requiring a local API key", () => {open();fireEvent.click(tab("Agents"));+ const provider = (name: string) => screen.getByRole("button", { name }).closest(".ui-settings-expander") as HTMLElement;- const openrouter = screen.getByRole("heading", { name: "OpenRouter" }).closest("section")!;+ const openrouter = provider("OpenRouter");+ fireEvent.click(screen.getByRole("button", { name: "OpenRouter" }));+ expect(screen.getByRole("button", { name: "OpenRouter" }).getAttribute("aria-expanded")).toBe("true");expect((within(openrouter).getByLabelText("OpenRouter endpoint") as HTMLInputElement).value).toBe("https://openrouter.ai/api/v1");fireEvent.change(within(openrouter).getByLabelText("OpenRouter API key"), { target: { value: "sk-or-test" } });fireEvent.change(within(openrouter).getByLabelText("OpenRouter model"), { target: { value: "openai/gpt-test" } });expect(openrouter.textContent).toContain("Configured");- const local = screen.getByRole("heading", { name: "Local OpenAI-compatible" }).closest("section")!;+ const local = provider("Local OpenAI-compatible");fireEvent.change(within(local).getByLabelText("Local OpenAI-compatible endpoint"), { target: { value: "http://localhost:1234/v1" } });fireEvent.change(within(local).getByLabelText("Local OpenAI-compatible model"), { target: { value: "local-model" } });expect(local.textContent).toContain("Configured");diff --git a/src/components/SettingsView.tsx b/src/components/SettingsView.tsxindex 1fb533c..7aaebf2 100644--- a/src/components/SettingsView.tsx+++ b/src/components/SettingsView.tsx@@ -1,14 +1,17 @@-import { SettingsEditorDialog } from "./SettingsEditorDialog";import { AdditionalSafetensorsEditor } from "./AdditionalSafetensorsEditor";-import { AlertCircle, ArrowLeft, Check, 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";+import {+ Activity, AlertCircle, ArrowLeft, Bot, Check, ChevronRight, Cpu, Download, FileBox, FileText, Folder, Gauge, Image, ListOrdered,+ LoaderCircle, MoreHorizontal, Palette, Plus, RefreshCw, RotateCcw, Settings2, Sparkles, SquarePen, Trash2, Video, Zap,+} from "lucide-react";+import { useCallback, useEffect, useRef, useState, useSyncExternalStore, type KeyboardEvent, type ReactNode } from "react";import { revealDiagnosticLog } from "../lib/diagnostics";import { isTauri } from "../lib/persistence";import { WeightSourcesEditor } from "./WeightSourcesEditor";import { LoraEditor, LoraLibrary, TemplateLorasEditor } from "./LoraSettings";+import { OpenableCard } from "./OpenableCard";import { downloadableTemplateLoras } from "../lib/loras";import { retryWeightDownload } from "../lib/weightDownloads";-import { cancelWeightDownload, downloadTemplateWeights, getWeightDownloadState, refreshDownloadedWeights, removeTemplateWeights, subscribeWeightDownloads, updateWeightPath, weightDownloadProgress } from "../lib/weightDownloads";+import { cancelWeightDownload, downloadTemplateWeights, getWeightDownloadState, refreshDownloadedWeights, removeTemplateWeights, subscribeWeightDownloads, updateWeightPath, weightDownloadProgress, type DownloadState } from "../lib/weightDownloads";import { chooseEnginePath, getAgentModels, getEngineStatus, type ModelStatus, type SlopfabStatus } from "../lib/runtime";import {EMPTY_ENGINE_SETTINGS, generatorPathFields,@@ -23,10 +26,11 @@ import {} from "../lib/settings";import { MAX_GENERATION_STEPS } from "../lib/project";import { availableReferenceIconGenerators, loadReferenceIconAutomation, loadReferenceIconGeneratorId, referenceIconGenerator, saveReferenceIconAutomation, saveReferenceIconGeneratorId, subscribeReferenceIconAutomation } from "../lib/referenceIconSettings";+import { applyTheme, loadTheme, saveTheme, type ThemeChoice } from "../lib/theme";import {- applyTheme, loadTheme, saveTheme, systemTheme, watchSystemTheme,- type ResolvedTheme, type ThemeChoice,-} from "../lib/theme";+ ComboBox, ContextMenu, InfoBadge, InfoBar, NavItem, NavPane, ProgressBar, SettingsCard, SettingsExpander, SettingsGroup, SettingsRow,+ TextField, ToggleSwitch, type InfoBarSeverity,+} from "./ui";type PathState = "unset" | "checking" | "found" | "missing" | "download";@@ -46,10 +50,18 @@ const stateLabel: Record<PathState, string> = {unset: "Not set",checking: "Checking…",found: "Found",- missing: "Not found on disk",+ missing: "Not found",download: "Download required",};+/* Paths are long and the file name is the part that tells them apart, so the+ middle goes, not the end (Explorer does the same in narrow columns). */+export function middleEllipsis(text: string, max = 64): string {+ if (text.length <= max) return text;+ const tail = Math.ceil(max * 0.6);+ return `${text.slice(0, max - tail - 1)}…${text.slice(-tail)}`;+}+function templateSummary(template: GeneratorTemplate): string {const loras = downloadableTemplateLoras(template.loras);const pendingModels = generatorPathFields(template).some(({ id }) => isDownloadUrl(template.paths[id])@@ -57,91 +69,77 @@ function templateSummary(template: GeneratorTemplate): string {return `${template.defaultSteps} steps${loras.length && !pendingModels ? ` · Needs ${loras.map(({ name }) => name).join(", ")} LoRA${loras.length > 1 ? "s" : ""}` : ""}`;}-/* The system option has to say what the computer is currently set to, or- "Match this computer" is a promise the user cannot check. */-const themeOptions: { id: ThemeChoice; label: string; icon: typeof Sun; detail: (system: ResolvedTheme) => string }[] = [- {- id: "system",- label: "Match this computer",- icon: Monitor,- detail: (system) => `Currently ${system}. Follows along when you change it.`,- },- { id: "light", label: "Light", icon: Sun, detail: () => "Always light, whatever this computer is set to." },- { id: "dark", label: "Dark", icon: Moon, detail: () => "Always dark, whatever this computer is set to." },-];+const hasDownloadedWeights = (template: GeneratorTemplate) =>+ Object.values(template.sources ?? {}).some((sources) => sources.length > 0) || Boolean(template.additionalSafetensors?.length);++/* --- Shared pieces ---------------------------------------------------------- */++/* The one line that says what the weight downloader is doing, with its+ Cancel / Retry. It sits at the top of the page it concerns. */+function DownloadStatus({ state, templateName, onError }: { state: DownloadState; templateName?: string; onError: (message: string) => void }) {+ const text = state.error ?? (state.active+ ? state.phase === "preparing" ? "Preparing LoRA…"+ : `${state.completed}/${state.files} files · ${(state.downloaded / 1024 ** 3).toFixed(2)} GB${state.total ? ` / ${(state.total / 1024 ** 3).toFixed(2)} GB` : ""}`+ : state.preparePath ? "LoRA prepared" : "Download complete");+ return <div className="ui-settings-card settings-download-status" role="status">+ <span className="ui-settings-card__icon" aria-hidden="true">{state.error ? <AlertCircle size={20} /> : state.active ? <Download size={20} /> : <Check size={20} />}</span>+ <span className="ui-settings-card__text">+ <span className="ui-settings-card__header">{state.name ?? templateName}</span>+ <span className="ui-settings-card__description">{text}</span>+ </span>+ <span className="ui-settings-card__control">+ {state.active && state.phase !== "preparing" && <button type="button" className="secondary-button" onClick={() => void cancelWeightDownload().catch((reason) => onError(String(reason)))}>Cancel download</button>}+ {state.error && <button type="button" className="secondary-button" onClick={() => void retryWeightDownload()}>{state.phase === "preparing" ? "Retry preparation" : "Retry download"}</button>}+ </span>+ </div>;+}++/* --- Generator page: reference icons ------------------------------------------ */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>- );+ return <SettingsGroup heading="Reference icons">+ <SettingsCard icon={<Sparkles size={20} />} header="Automatic reference icon generation">+ <ToggleSwitch checked={automation !== "disabled"} aria-label="Automatic reference icon generation" onChange={(on) => saveReferenceIconAutomation(on ? "ask" : "disabled")} />+ </SettingsCard>+ <SettingsCard icon={<Image size={20} />} header="Reference icon generator">+ <ComboBox aria-label="Reference icon generator" disabled={!available.length} value={selected?.id ?? ""} placeholder="No available generators"+ onChange={saveReferenceIconGeneratorId} options={available.map((template) => ({ value: template.id, label: template.name }))} />+ </SettingsCard>+ </SettingsGroup>;}-function AppearanceSetting() {- const [choice, setChoice] = useState<ThemeChoice>(loadTheme);- const [system, setSystem] = useState<ResolvedTheme>(systemTheme);+/* --- Appearance ------------------------------------------------------------------- */- /* The app repaints itself through prefers-color-scheme; this listener only- keeps the "Currently dark/light" line honest while the screen is open. */- useEffect(() => watchSystemTheme(setSystem), []);+const themeOptions: { value: ThemeChoice; label: string }[] = [+ { value: "system", label: "Use system setting" },+ { value: "light", label: "Light" },+ { value: "dark", label: "Dark" },+];+function AppearanceSetting() {+ const [choice, setChoice] = useState<ThemeChoice>(loadTheme);const pick = (next: ThemeChoice) => {setChoice(next);saveTheme(next);applyTheme(next);};-- return (- /* Named here rather than by a heading: the tab above IS the heading now,- and a group pointed at an element that no longer exists announces- nothing at all. */- <div className="theme-choice" role="radiogroup" aria-label="Appearance">- {themeOptions.map((option) => {- const Icon = option.icon;- const selected = choice === option.id;- return (- <label- key={option.id}- className={`theme-choice__option${selected ? " theme-choice__option--selected" : ""}`}- >- <input- type="radio"- name="slopus-theme"- value={option.id}- checked={selected}- onChange={() => pick(option.id)}- />- <Icon size={18} aria-hidden="true" />- <b>{option.label}</b>- <small>{option.detail(system)}</small>- </label>- );- })}- </div>- );+ return <SettingsCard icon={<Palette size={20} />} header="App theme" description="Select which app theme to display">+ <ComboBox aria-label="App theme" value={choice} onChange={pick} options={themeOptions} />+ </SettingsCard>;}-const endpointProviders: { id: EndpointProviderId; label: string; detail: string; endpointPlaceholder: string; keyRequired: boolean }[] = [+/* --- Agents ------------------------------------------------------------------------ */++const endpointProviders: { id: EndpointProviderId; label: string; detail: string; icon: ReactNode; endpointPlaceholder: string; keyRequired: boolean }[] = [{id: "openrouter",label: "OpenRouter",detail: "Use models from openrouter.ai through its OpenAI-compatible API.",+ icon: <Bot size={20} />,endpointPlaceholder: "https://openrouter.ai/api/v1",keyRequired: true,},@@ -149,6 +147,7 @@ const endpointProviders: { id: EndpointProviderId; label: string; detail: stringid: "local",label: "Local OpenAI-compatible",detail: "Use a server on this computer or network that implements /models and /chat/completions.",+ icon: <Cpu size={20} />,endpointPlaceholder: "http://localhost:1234/v1",keyRequired: false,},@@ -174,7 +173,7 @@ function PromptLlmSetting({ desktop }: { desktop: boolean }) {try {const found = await getAgentModels(id, settings[id]);setModels((current) => ({ ...current, [id]: found }));- if (found.length === 0) setErrors((current) => ({ ...current, [id]: "The endpoint returned no models. You can still enter a model ID manually." }));+ if (found.length === 0) setErrors((current) => ({ ...current, [id]: "The endpoint returned no models. You can still enter a model ID." }));} catch (reason) {setErrors((current) => ({ ...current, [id]: reason instanceof Error ? reason.message : String(reason) }));} finally {@@ -182,43 +181,35 @@ function PromptLlmSetting({ desktop }: { desktop: boolean }) {}};- return <div className="llm-settings">- <p className="llm-settings__intro">Configured providers appear in Slop’s agent list. Endpoints and API keys stay on this computer and are never saved in a project.</p>+ return <SettingsGroup heading="Providers">+ <p className="settings-caption">Configured providers appear in Slop’s agent list. Endpoints and API keys stay on this computer.</p>{endpointProviders.map((provider) => {const value = settings[provider.id];const configured = isEndpointProviderConfigured(provider.id, value);const listId = `llm-models-${provider.id}`;- return <section className={`llm-provider${configured ? " llm-provider--configured" : ""}`} key={provider.id} aria-labelledby={`llm-${provider.id}-heading`}>- <header>- <div><h2 id={`llm-${provider.id}-heading`}>{provider.label}</h2><p>{provider.detail}</p></div>- <span>{configured ? <><Check size={14} /> Configured</> : "Not configured"}</span>- </header>- <div className="llm-provider__fields">- <label>- <span>Endpoint</span>- <input aria-label={`${provider.label} endpoint`} value={value.endpoint} spellCheck={false} placeholder={provider.endpointPlaceholder} onChange={(event) => update(provider.id, "endpoint", event.target.value)} />- </label>- <label>- <span>API key{!provider.keyRequired && <em>Optional</em>}</span>- <input type="password" aria-label={`${provider.label} API key`} value={value.apiKey} autoComplete="off" spellCheck={false} placeholder={provider.keyRequired ? "Required" : "Leave blank if the server does not require one"} onChange={(event) => update(provider.id, "apiKey", event.target.value)} />- </label>- <label className="llm-provider__model">- <span>Model</span>- <div>- <input list={listId} aria-label={`${provider.label} model`} value={value.model} spellCheck={false} placeholder="Select or enter a model ID" onChange={(event) => update(provider.id, "model", event.target.value)} />- <datalist id={listId}>{models[provider.id].map((model) => <option value={model} key={model} />)}</datalist>- <button type="button" className="secondary-button" disabled={!desktop || !value.endpoint.trim() || loading === provider.id} onClick={() => void discover(provider.id)} title={desktop ? "Load models from this endpoint" : "Model discovery is available in the desktop app"}>- {loading === provider.id ? <LoaderCircle className="spin" size={15} /> : <RefreshCw size={15} />} Load models- </button>- </div>- </label>- </div>- {errors[provider.id] && <p className="llm-provider__error" role="alert">{errors[provider.id]}</p>}- </section>;+ return <SettingsExpander key={provider.id} className="llm-provider" icon={provider.icon} header={provider.label} description={provider.detail}+ control={<span className="llm-provider__status">{configured ? <><Check size={14} aria-hidden="true" /> Configured</> : "Not configured"}</span>}>+ <SettingsRow header="Endpoint">+ <TextField className="settings-field" aria-label={`${provider.label} endpoint`} value={value.endpoint} spellCheck={false} placeholder={provider.endpointPlaceholder} onChange={(next) => update(provider.id, "endpoint", next)} />+ </SettingsRow>+ <SettingsRow header="API key" description={provider.keyRequired ? undefined : "Optional"}>+ <TextField className="settings-field" type="password" aria-label={`${provider.label} API key`} value={value.apiKey} autoComplete="off" spellCheck={false} placeholder={provider.keyRequired ? "Required" : "Leave blank if not required"} onChange={(next) => update(provider.id, "apiKey", next)} />+ </SettingsRow>+ <SettingsRow header="Model">+ <TextField className="settings-field" list={listId} aria-label={`${provider.label} model`} value={value.model} spellCheck={false} placeholder="Select or enter a model ID" onChange={(next) => update(provider.id, "model", next)} />+ <datalist id={listId}>{models[provider.id].map((model) => <option value={model} key={model} />)}</datalist>+ <button type="button" className="secondary-button" disabled={!desktop || !value.endpoint.trim() || loading === provider.id} onClick={() => void discover(provider.id)} data-tooltip={desktop ? "Load models from this endpoint" : "Model discovery is available in the desktop app"}>+ {loading === provider.id ? <LoaderCircle className="spin" size={16} /> : <RefreshCw size={16} />} Load models+ </button>+ </SettingsRow>+ {errors[provider.id] && <div className="settings-expander-message"><InfoBar severity="error" message={errors[provider.id]} /></div>}+ </SettingsExpander>;})}- </div>;+ </SettingsGroup>;}+/* --- Diagnostics ------------------------------------------------------------------- */+function DiagnosticsSetting({ desktop, status, onBackendChange }: { desktop: boolean; status: SlopfabStatus | null; onBackendChange: () => void }) {const [backend, setBackend] = useState(loadInferenceBackend);const cudaAvailable = status?.cudaAvailable === true;@@ -238,75 +229,81 @@ function DiagnosticsSetting({ desktop, status, onBackendChange }: { desktop: boo}};- return <>- <div className="generator-template-fields diagnostics-backend">- <label>- <span>GPU backend</span>- <select aria-label="GPU backend" value={cudaAvailable ? backend : "vulkan"} disabled={!desktop || !cudaAvailable} onChange={(event) => {- const next = event.target.value as InferenceBackend;- saveInferenceBackend(next);- setBackend(next);- onBackendChange();- }}>- {cudaAvailable && <option value="cuda">CUDA</option>}- <option value="vulkan">Vulkan</option>- </select>- </label>- </div>- <label className="diagnostics-debug-option">- <input type="checkbox" checked={debugEnabled} onChange={(event) => saveDebugOptionsEnabled(event.target.checked)} aria-labelledby="debug-options-label" aria-describedby="debug-options-description" />- <span><b id="debug-options-label">Enable debug options</b><small id="debug-options-description">Show Debug Prompt in scene settings and the image inspector, and Debug Icon Prompt in reference details.</small></span>- </label>- <button type="button" className="secondary-button" disabled={!desktop || opening} onClick={() => void reveal()} title={error ?? undefined}>- {opening ? <LoaderCircle className="spin" size={16} /> : <FolderOpen size={16} />} Show log file- </button>- </>;+ return <SettingsGroup heading="Diagnostics">+ <SettingsCard icon={<Cpu size={20} />} header="GPU backend">+ <ComboBox aria-label="GPU backend" value={cudaAvailable ? backend : "vulkan"} disabled={!desktop || !cudaAvailable} onChange={(value) => {+ const next = value as InferenceBackend;+ saveInferenceBackend(next);+ setBackend(next);+ onBackendChange();+ }} options={[...(cudaAvailable ? [{ value: "cuda", label: "CUDA" }] : []), { value: "vulkan", label: "Vulkan" }]} />+ </SettingsCard>+ <SettingsCard icon={<Settings2 size={20} />} header="Enable debug options" description="Show Debug Prompt in scene settings and the image inspector, and Debug Icon Prompt in reference details">+ <ToggleSwitch checked={debugEnabled} aria-label="Enable debug options" onChange={saveDebugOptionsEnabled} />+ </SettingsCard>+ <SettingsCard icon={opening ? <LoaderCircle className="spin" size={20} /> : <FileText size={20} />} header="Show log file" actionIcon="external" disabled={!desktop || opening} onClick={() => void reveal()} />+ {error && <InfoBar severity="error" title="Couldn’t show the log file" message={error} onClose={() => setError(null)} />}+ </SettingsGroup>;}-/* The settings page keeps its section navigation behind the generator popup. */+/* --- The page ------------------------------------------------------------------------ */+const TABS = [- { id: "engine", label: "Generator" },- { id: "llms", label: "Agents" },- { id: "appearance", label: "Appearance" },- { id: "diagnostics", label: "Diagnostics" },- { id: "updates", label: "Updates" },+ { id: "engine", label: "Generator", icon: Video },+ { id: "llms", label: "Agents", icon: Bot },+ { id: "appearance", label: "Appearance", icon: Palette },+ { id: "diagnostics", label: "Diagnostics", icon: Activity },+ { id: "updates", label: "Updates", icon: RefreshCw },] as const;type TabId = (typeof TABS)[number]["id"];+const engineSeverity = (status: SlopfabStatus | null, desktop: boolean): InfoBarSeverity => {+ if (!desktop || !status || status.state === "demo") return "informational";+ if (status.state === "ready") return "success";+ if (status.state === "runtimeMissing") return "error";+ return "warning";+};++/* Settings is a page of the app window, below the title bar the shell draws:+ a 280px navigation pane with Back at its top, and a content column that+ reads like Windows Settings — a 28px title (a breadcrumb on sub-pages) over+ groups of one-setting-per-row cards. */export function SettingsView({ onClose, updates, initialTab = "engine" }: { onClose: () => void; updates?: ReactNode; initialTab?: TabId }) {/* The engine first: this screen exists because those paths have to be set- before anything can be rendered, and its status line answers "is Slopus- ready?" without a click. */+ before anything can be rendered. */const [tab, setTab] = useState<TabId>(initialTab);const page = useRef<HTMLElement>(null);const body = useRef<HTMLDivElement>(null);+ const subpageHeading = useRef<HTMLHeadingElement>(null);+ const nameField = useRef<HTMLInputElement>(null);+ const returnFocus = useRef<string | null>(null);+ const focusName = useRef(false);useEffect(() => { page.current?.focus(); }, []);const [templateSettings, setTemplateSettings] = useState<GeneratorTemplateSettings>(() => loadGeneratorTemplateSettings());const 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 [editingPath, setEditingPath] = useState<EnginePathId | null>(null);+ const [pathMenu, setPathMenu] = useState<{ field: EnginePathField; anchor: HTMLElement } | null>(null);const [status, setStatus] = useState<SlopfabStatus | null>(null);const probeRevision = useRef(0);const [error, setError] = useState<string | null>(null);const desktop = isTauri();const defaultTemplate = defaultGeneratorTemplate(templateSettings);- const selectedTemplate = templateSettings.templates.find((template) => template.id === editingTemplateId)- ?? defaultTemplate;+ const editingTemplate = templateSettings.templates.find((template) => template.id === editingTemplateId);+ const selectedTemplate = editingTemplate ?? defaultTemplate;const settings = selectedTemplate.paths;const downloadedPathsKey = JSON.stringify(Object.values(selectedTemplate.sources ?? {}).flatMap((sources) => sources.map(({ downloadedPath }) => downloadedPath)));const downloading = downloadState?.active && downloadState.templateId === selectedTemplate.id;const generatorSections = [{ id: "generators", title: "Generators", templates: templateSettings.templates.filter((template) => !templateNeedsDownload(template)) },- { id: "downloadable-generators", title: "Download", templates: templateSettings.templates.filter(templateNeedsDownload) },+ { id: "downloadable-generators", title: "Available to download", templates: templateSettings.templates.filter(templateNeedsDownload) },];- useEffect(() => setShowAdvancedOptions(false), [editingTemplateId]);+ useEffect(() => { setShowAdvancedOptions(false); setEditingPath(null); setPathMenu(null); }, [editingTemplateId]);useEffect(() => subscribeGeneratorTemplates(() => setTemplateSettings(loadGeneratorTemplateSettings())), []);useEffect(() => {@@ -357,7 +354,23 @@ export function SettingsView({ onClose, updates, initialTab = "engine" }: { onClsetTemplateSettings(next);};- useEffect(() => { if (body.current) body.current.scrollTop = 0; }, [tab, editingTemplateId, editingLoraId]);+ /* A new page opens at its top; a sub-page takes focus on its title (or on+ the name of a generator that was just created), and going back returns+ focus to the card that opened it. */+ useEffect(() => { if (body.current) body.current.scrollTop = 0; }, [tab, editingTemplateId]);+ useEffect(() => {+ if (editingTemplateId) {+ if (focusName.current) { focusName.current = false; nameField.current?.focus(); nameField.current?.select(); }+ else subpageHeading.current?.focus();+ return;+ }+ const ref = returnFocus.current;+ returnFocus.current = null;+ if (ref) [...(body.current?.querySelectorAll<HTMLElement>("[data-open-ref]") ?? [])].find((element) => element.dataset.openRef === ref)?.focus();+ }, [editingTemplateId]);++ const openTemplate = (id: string) => { returnFocus.current = `template:${id}`; setEditingTemplateId(id); };+ const leaveTemplate = () => setEditingTemplateId(null);const browse = async (field: EnginePathField) => {setError(null);@@ -403,12 +416,14 @@ export function SettingsView({ onClose, updates, initialTab = "engine" }: { onClsaveGeneratorTemplateSettings(next);return next;});+ focusName.current = true;+ returnFocus.current = `template:${created.id}`;setEditingTemplateId(created.id);};const removeTemplate = (id: string) => {const template = templateSettings.templates.find((template) => template.id === id);- if (template && (Object.values(template.sources ?? {}).some((sources) => sources.length > 0) || Boolean(template.additionalSafetensors?.length))) {+ if (template && hasDownloadedWeights(template)) {void removeTemplateWeights(id).catch((reason) => setError(String(reason)));return;}@@ -437,234 +452,210 @@ export function SettingsView({ onClose, updates, initialTab = "engine" }: { onClsetEditingTemplateId(null);setEditingLoraId(null);};+ const back = () => { if (editingTemplateId) leaveTemplate(); else onClose(); };++ const downloadStatus = downloadState && <DownloadStatus state={downloadState} onError={setError}+ templateName={templateSettings.templates.find((template) => template.id === downloadState.templateId)?.name} />;++ const pathCard = (field: EnginePathField) => {+ const value = settings[field.id];+ const state = pathState(field, value, status);+ const fieldDownload = downloading && downloadState?.field === field.id ? downloadState : null;+ const filePercent = fieldDownload?.total ? Math.floor(100 * fieldDownload.downloaded / fieldDownload.total) : undefined;+ const editing = editingPath === field.id;+ const description = editing+ ? <input+ id={`engine-${field.id}`}+ className="settings-path__input"+ aria-label={field.label}+ value={value}+ spellCheck={false}+ autoFocus+ placeholder={field.directory ? "Folder on this computer or download URL" : "Local path or download URL"}+ onChange={(event) => update(field.id, event.target.value)}+ onBlur={() => { probe(settings); setEditingPath(null); }}+ onKeyDown={(event) => {+ if (event.key !== "Enter" && event.key !== "Escape") return;+ event.preventDefault();+ event.currentTarget.blur();+ }}+ />+ : fieldDownload+ ? <>{filePercent === undefined ? "Downloading…" : `Downloading · ${filePercent}%`}<ProgressBar className="settings-progress" value={filePercent} aria-label={`Downloading ${field.label}`} /></>+ : value.trim() ? <span className="settings-path__value" data-tooltip={value}>{middleEllipsis(value)}</span> : "Not set";+ return <div className={`settings-path settings-path--${state}`} key={field.id}>+ <SettingsCard+ icon={field.directory ? <Folder size={20} /> : <FileBox size={20} />}+ header={<>{field.label}{!field.required && <span className="settings-path__optional"> (optional)</span>}</>}+ description={description}+ >+ {state !== "unset" && <span className="settings-path__state" data-tooltip={state === "found" ? "Found" : undefined}>+ {state === "found" ? <Check size={16} aria-hidden="true" /> : state === "missing" ? <AlertCircle size={16} aria-hidden="true" /> : null}+ <span className={state === "found" ? "sr-only" : undefined}>{stateLabel[state]}</span>+ </span>}+ <button type="button" className="secondary-button" onClick={() => void browse(field)} disabled={!desktop || Boolean(downloading)}+ aria-label={`Browse for ${field.label}`} data-tooltip={desktop ? undefined : "Browsing for files is available in the desktop app"}>+ Browse…+ </button>+ <button type="button" className="icon-button" aria-label={`More options for ${field.label}`} data-tooltip="More options" aria-haspopup="menu"+ disabled={Boolean(downloading)} onClick={(event) => setPathMenu({ field, anchor: event.currentTarget })}>+ <MoreHorizontal size={16} />+ </button>+ </SettingsCard>+ {showAdvancedOptions && <WeightSourcesEditor label={field.label} sources={selectedTemplate.sources?.[field.id] ?? []} disabled={Boolean(downloading)} onChange={(sources) => updateSources(field.id, sources)} />}+ </div>;+ };++ const generatorEditor = editingTemplate && <>+ <div className="settings-page__actions">+ {templateNeedsDownload(selectedTemplate) && <button type="button" className="primary-button" disabled={!desktop || downloadState?.active} onClick={() => void downloadTemplateWeights(selectedTemplate.id)}><Download size={16} /> Download weights</button>}+ <button type="button" className="secondary-button" disabled={Boolean(downloading)} onClick={clearAll}><RotateCcw size={16} /> Clear generator paths</button>+ </div>+ {downloadStatus}+ <InfoBar severity={engineSeverity(status, desktop)} title={engineHeadline(status, desktop)} message={<>+ {engineDetail(status, desktop, missing.length)}+ {status?.platform && <span className="settings-status__platform"> <b>Platform</b> <span>{status.platform}</span></span>}+ </>} />++ <SettingsGroup heading="General">+ <SettingsCard icon={<SquarePen size={20} />} header="Name">+ <input ref={nameField} className="settings-field" aria-label="Generator name" value={selectedTemplate.name} onChange={(event) => updateTemplate({ name: event.target.value })} onBlur={() => { if (!selectedTemplate.name.trim()) updateTemplate({ name: "Untitled generator" }); }} />+ </SettingsCard>+ <SettingsCard icon={<Video size={20} />} header="Mode">+ <ComboBox aria-label="Generator mode" value={selectedTemplate.mode ?? "prompt"} onChange={(value) => updateTemplate({ mode: value === "animate" ? "animate" : "prompt" })}+ options={[{ value: "prompt", label: "Text prompt" }, { value: "animate", label: "Animate (reference video)" }]} />+ </SettingsCard>+ <SettingsCard icon={<ListOrdered size={20} />} header="Default steps" description={`2 to ${MAX_GENERATION_STEPS}`}>+ <input className="settings-field settings-field--number" 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 });+ }} />+ </SettingsCard>+ </SettingsGroup>++ <SettingsGroup heading="Performance">+ <SettingsCard icon={<Gauge size={20} />} header="Attention">+ <ComboBox aria-label="Generator attention" value={selectedTemplate.attention} onChange={(value) => updateTemplate({ attention: value as AttentionMode })}+ options={[{ value: "exact", label: "Exact attention" }, { value: "flash2", label: "Flash attention" }, { value: "sage2", label: "Sage attention" }]} />+ </SettingsCard>+ <SettingsCard icon={<Zap size={20} />} header="Enable MotionCache" description={<span id="motion-cache-help">{selectedTemplate.mode === "animate" ? "Unavailable in Animate mode" : "Reuses similar denoising results to reduce computation. May affect detail and motion."}</span>}>+ <ToggleSwitch aria-label="Enable MotionCache" aria-describedby="motion-cache-help"+ checked={selectedTemplate.mode !== "animate" && Boolean(selectedTemplate.motionCache)} disabled={selectedTemplate.mode === "animate"}+ onChange={(on) => updateTemplate({ motionCache: on })} />+ </SettingsCard>+ </SettingsGroup>++ <SettingsGroup heading="Model files">+ {generatorPathFields(selectedTemplate).map(pathCard)}+ </SettingsGroup>++ <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 })} />++ <SettingsGroup heading="Advanced" className="generator-editor__advanced">+ <SettingsCard icon={<Settings2 size={20} />} header="Show advanced options" description="Per-GPU download sources for each model file">+ <ToggleSwitch aria-label="Show advanced options" checked={showAdvancedOptions} onChange={setShowAdvancedOptions} />+ </SettingsCard>+ </SettingsGroup>+ {pathMenu && <ContextMenu aria-label={`${pathMenu.field.label} options`} position={{ anchor: pathMenu.anchor, placement: "bottom-end" }} onClose={() => setPathMenu(null)} items={[+ { id: "enter", label: "Enter path or URL…", onSelect: () => setEditingPath(pathMenu.field.id) },+ { id: "clear", label: "Clear", disabled: !settings[pathMenu.field.id], onSelect: () => { update(pathMenu.field.id, ""); probe({ ...settings, [pathMenu.field.id]: "" }); } },+ ]} />}+ </>;++ const generatorList = <>+ {downloadStatus}+ <ReferenceIconSetting templates={templateSettings} />+ {generatorSections.filter((section) => section.id === "generators" || section.templates.length > 0).map((section) => <SettingsGroup key={section.id} heading={section.title}>+ {section.id === "generators" && <SettingsCard icon={<Plus size={20} />} header="Add a generator" description="Choose the generator used by default, or open one to edit its model setup">+ <button type="button" className="secondary-button" onClick={addTemplate}>New generator</button>+ </SettingsCard>}+ <div className="settings-card-list" role="list" aria-label={section.title}>+ {section.templates.map((template) => {+ const needsDownload = templateNeedsDownload(template);+ const isDefault = template.id === templateSettings.defaultTemplateId;+ const active = downloadState?.active && downloadState.templateId === template.id;+ const weights = hasDownloadedWeights(template);+ return <OpenableCard key={template.id} icon={<Video size={20} />} header={template.name} openRef={`template:${template.id}`}+ openLabel={`Edit ${template.name} generator`} onOpen={() => openTemplate(template.id)}+ description={active ? downloadState?.phase === "preparing" ? "Preparing LoRA…" : `Downloading · ${Math.floor(downloadPercent)}%`+ : `${!needsDownload && isDefault ? "Used by default · " : ""}${templateSummary(template)}`}+ progress={active && downloadState?.phase !== "preparing" && <ProgressBar className="settings-progress" value={downloadPercent} aria-label={`Downloading ${template.name} weights`} />}+ actions={needsDownload+ ? <button type="button" className="icon-button" disabled={!desktop || downloadState?.active} onClick={() => void downloadTemplateWeights(template.id)} aria-label={`Download generator ${template.name}`} data-tooltip={`Download ${template.name} weights`}>+ {active ? <LoaderCircle size={16} className="spin" /> : <Download size={16} />}+ </button>+ : <>+ {!isDefault && <button type="button" className="secondary-button" onClick={() => makeDefault(template.id)} aria-label={`Set ${template.name} as default`}>Set as default</button>}+ <button type="button" className="icon-button" disabled={Boolean(downloadState?.active) || (weights ? !desktop : templateSettings.templates.length === 1)} onClick={() => removeTemplate(template.id)}+ aria-label={weights ? `Remove downloaded weights for ${template.name}` : `Remove generator ${template.name}`}+ data-tooltip={weights ? "Remove weights and keep the template" : "Remove generator"}><Trash2 size={16} /></button>+ </>} />;+ })}+ </div>+ </SettingsGroup>)}+ <LoraLibrary onAdd={() => setEditingLoraId(`lora-${crypto.randomUUID()}`)} onEdit={setEditingLoraId} />+ </>;- 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.phase === "preparing" ? "Preparing LoRA…" : `${downloadState.completed}/${downloadState.files} files · ${(downloadState.downloaded / 1024 ** 3).toFixed(2)} GB${downloadState.total ? ` / ${(downloadState.total / 1024 ** 3).toFixed(2)} GB` : ""}` : downloadState.preparePath ? "LoRA prepared" : "Download complete")}</span>- {downloadState.active && downloadState.phase !== "preparing" && <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()}>{downloadState.phase === "preparing" ? "Retry preparation" : "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></>;+ const current = TABS.find((item) => item.id === tab)!;return (<>- <main aria-hidden={editingTemplateId || editingLoraId ? true : undefined} className="settings-view" ref={page} tabIndex={-1} aria-labelledby="settings-heading" onKeyDown={(event) => {+ <main aria-hidden={editingLoraId ? true : undefined} className="settings-view" ref={page} tabIndex={-1} aria-label="Settings" onKeyDown={(event: KeyboardEvent<HTMLElement>) => {// The mounted editor must not receive shortcuts while Settings has focus.event.stopPropagation();- if (event.key === "Escape" && !event.defaultPrevented) onClose();+ if (event.key !== "Escape" || event.defaultPrevented) return;+ back();}}>- <header className="settings-view__head">- <button type="button" className="icon-button icon-button--strong" onClick={onClose} aria-label="Close settings" title="Back"><ArrowLeft size={18} /></button>- <h1 id="settings-heading">Settings</h1>- </header>-- <aside className="settings-sidebar" aria-label="Settings navigation">- <div className="settings-tabs" role="tablist" aria-label="Settings sections" aria-orientation="vertical">- {TABS.map((item, index) => (- <button- key={item.id}- id={`settings-tab-${item.id}`}- role="tab"- type="button"- aria-selected={tab === item.id}- aria-controls={`settings-panel-${item.id}`}- tabIndex={tab === item.id ? 0 : -1}- className={tab === item.id ? "active" : ""}- onClick={() => selectTab(item.id)}- onKeyDown={(event) => {- if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;- event.preventDefault();- const next = TABS[event.key === "Home" ? 0 : event.key === "End" ? TABS.length - 1- : (index + (event.key === "ArrowDown" ? 1 : TABS.length - 1)) % TABS.length];- selectTab(next.id);- document.getElementById(`settings-tab-${next.id}`)?.focus();- }}- >- {item.label}- {/* What is wrong stays visible from the other tab: a count here- is the whole reason someone opens this screen. */}- {item.id === "engine" && missing.length > 0 && <em title={`${missing.length} model ${missing.length === 1 ? "path" : "paths"} still to set`}>{missing.length}</em>}- </button>- ))}- </div>- </aside>-- <div className="settings-view__content">- <div className="settings-view__body" ref={body}>- {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>}- {tab === "llms" && <section- className="settings-section"- id="settings-panel-llms"- role="tabpanel"- aria-labelledby="settings-tab-llms"- >- <PromptLlmSetting desktop={desktop} />- </section>}-- {tab === "appearance" && <section- className="settings-section"- id="settings-panel-appearance"- role="tabpanel"- aria-labelledby="settings-tab-appearance"- >- <AppearanceSetting />- </section>}-- {tab === "diagnostics" && <section- className="settings-section"- id="settings-panel-diagnostics"- role="tabpanel"- aria-labelledby="settings-tab-diagnostics"- >- <DiagnosticsSetting desktop={desktop} status={status} onBackendChange={() => probe(settings)} />- </section>}-- {tab === "engine" && <section- className="settings-section"- id="settings-panel-engine"- role="tabpanel"- aria-labelledby="settings-tab-engine"- >- <ReferenceIconSetting templates={templateSettings} />- {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>- {section.id === "generators" && <p>Choose the generator used by default, or open one to edit its model setup.</p>}- </div>- {section.id === "generators" && <button type="button" className="secondary-button" onClick={addTemplate}><Plus size={16} /> New generator</button>}- </header>- <div className="generator-template-list" role="list" aria-label={section.title}>- {section.templates.map((template) => (- <div className={`generator-template-item${templateNeedsDownload(template) ? " generator-template-item--download" : template.id === templateSettings.defaultTemplateId ? " generator-template-item--selected" : ""}`} role="listitem" key={template.id}>- {downloadState?.active && downloadState.templateId === template.id && downloadState.phase !== "preparing" && <span- className="generator-template-item__progress"- role="progressbar"- aria-label={`Downloading ${template.name} weights`}- aria-valuemin={0}- aria-valuemax={100}- aria-valuenow={Math.floor(downloadPercent)}- aria-valuetext={`${downloadState.completed} of ${downloadState.files} files complete${downloadState.total ? `; current file ${Math.floor(100 * downloadState.downloaded / downloadState.total)}%` : "; downloading"}`}- style={{ width: `${downloadPercent}%` }}- />}- {!templateNeedsDownload(template) && <label className="generator-template-item__default" title="Use this generator for generation by default">- <input type="radio" name="default-generator-template" checked={template.id === templateSettings.defaultTemplateId} onChange={() => makeDefault(template.id)} aria-label={`Use ${template.name} as the default generator`} />- </label>}- <button type="button" className="generator-template-item__open" onClick={() => setEditingTemplateId(template.id)} aria-label={`Edit ${template.name} generator`}>- <Video size={16} aria-hidden="true" />- <b>{template.name}</b><small>{downloadState?.active && downloadState.templateId === template.id ? downloadState.phase === "preparing" ? "Preparing LoRA…" : `Downloading · ${Math.floor(downloadPercent)}%` : templateSummary(template)}</small>- </button>- {templateNeedsDownload(template)- ? <button type="button" className="icon-button" disabled={!desktop || downloadState?.active} onClick={() => void downloadTemplateWeights(template.id)} aria-label={`Download generator ${template.name}`} title={`Download ${template.name} weights`}>- {downloadState?.active && downloadState.templateId === template.id ? <LoaderCircle size={15} className="spin" /> : <Download size={15} />}- </button>- : <button type="button" className="icon-button" disabled={Boolean(downloadState?.active) || ((Object.values(template.sources ?? {}).some((sources) => sources.length) || Boolean(template.additionalSafetensors?.length)) ? !desktop : templateSettings.templates.length === 1)} onClick={() => removeTemplate(template.id)} aria-label={(Object.values(template.sources ?? {}).some((sources) => sources.length) || Boolean(template.additionalSafetensors?.length)) ? `Remove downloaded weights for ${template.name}` : `Remove generator ${template.name}`} title={(Object.values(template.sources ?? {}).some((sources) => sources.length) || Boolean(template.additionalSafetensors?.length)) ? `Remove ${template.name} weights and keep the template` : `Remove ${template.name}`}><Trash2 size={15} /></button>}- </div>- ))}- </div>- </section>)}<LoraLibrary onAdd={() => setEditingLoraId(`lora-${crypto.randomUUID()}`)} onEdit={setEditingLoraId} />- </section>}+ <NavPane aria-label="Settings sections" className="settings-nav" header={+ <button type="button" className="icon-button settings-nav__back" onClick={back} aria-label="Back" data-tooltip="Back"><ArrowLeft size={16} /></button>+ }>+ {TABS.map((item, index) => {+ const Icon = item.icon;+ const count = item.id === "engine" ? missing.length : 0;+ return <NavItem+ key={item.id}+ id={`settings-tab-${item.id}`}+ icon={<Icon size={16} />}+ label={item.label}+ selected={tab === item.id}+ badge={count > 0 ? count : undefined}+ badgeSeverity="caution"+ aria-label={count > 0 ? `${item.label}, ${count} model ${count === 1 ? "path" : "paths"} to set` : undefined}+ data-tooltip={count > 0 ? `${count} model ${count === 1 ? "path" : "paths"} still to set` : undefined}+ onClick={() => selectTab(item.id)}+ onKeyDown={(event) => {+ if (!["ArrowDown", "ArrowUp", "Home", "End"].includes(event.key)) return;+ event.preventDefault();+ const next = TABS[event.key === "Home" ? 0 : event.key === "End" ? TABS.length - 1+ : (index + (event.key === "ArrowDown" ? 1 : TABS.length - 1)) % TABS.length];+ selectTab(next.id);+ document.getElementById(`settings-tab-${next.id}`)?.focus();+ }}+ />;+ })}+ </NavPane>++ <div className="settings-view__body" ref={body}>+ <div className="settings-page" id={`settings-panel-${tab}`} aria-labelledby={editingTemplate ? "settings-subpage-heading" : "settings-page-heading"}>+ {editingTemplate+ ? <nav className="settings-breadcrumb" aria-label="Breadcrumb">+ <button type="button" className="settings-breadcrumb__link" onClick={leaveTemplate}>Generators</button>+ <ChevronRight size={20} aria-hidden="true" className="settings-breadcrumb__separator" />+ <h1 id="settings-subpage-heading" ref={subpageHeading} tabIndex={-1} aria-current="page">{editingTemplate.name || "Untitled generator"}</h1>+ </nav>+ : <h1 id="settings-page-heading" className="settings-page__title">{current.label}</h1>}++ {error && <InfoBar severity="error" title="Couldn’t update generator settings" message={error} onClose={() => setError(null)} closeLabel="Dismiss" />}++ {tab === "engine" && (editingTemplate ? generatorEditor : generatorList)}+ {tab === "llms" && <PromptLlmSetting desktop={desktop} />}+ {tab === "appearance" && <AppearanceSetting />}+ {tab === "diagnostics" && <DiagnosticsSetting desktop={desktop} status={status} onBackendChange={() => probe(settings)} />}+ {tab === "updates" && (updates ?? <p className="settings-caption">Updates are available in the desktop app.</p>)}</div>-- {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 && <SettingsEditorDialog title="Edit generator" headingId="generator-editor-heading" initialFocusLabel="Generator name" closeLabel="Close generator settings" onClose={() => setEditingTemplateId(null)} footer={generatorFooter}>{generatorEditor}</SettingsEditorDialog>}{editingLoraId && <LoraEditor key={editingLoraId} loraId={editingLoraId} onDone={() => setEditingLoraId(null)} />}</>);@@ -672,21 +663,21 @@ export function SettingsView({ onClose, updates, initialTab = "engine" }: { onClconst engineHeadline = (status: SlopfabStatus | null, desktop: boolean) => {if (!desktop) return "Browser preview";- if (!status) return "Checking this computer…";+ if (!status) return "Checking…";switch (status.state) {- case "ready": return "Engine ready";+ case "ready": return "Ready";case "modelsMissing": return "Model files missing";- case "runtimeMissing": return "Engine missing from this install";+ case "runtimeMissing": return "Engine missing";case "incompatible": return "Engine version not supported";case "demo": return "Browser preview";}};const engineDetail = (status: SlopfabStatus | null, desktop: boolean, missing: number) => {- if (!desktop) return "Paths are saved here, but only the desktop app can check them or render with them.";- if (!status) return "Looking for the engine and the model files.";- if (status.state === "runtimeMissing") return `${status.detail} slopfab.dll should sit next to Slopus.exe.`;- if (status.state === "ready") return "Everything Slopus needs to render a shot is in place.";- if (missing > 0) return `${status.detail} ${missing === 1 ? "One path" : `${missing} paths`} still need setting below.`;+ if (!desktop) return "Only the desktop app can check paths and render.";+ if (!status) return "Looking for the engine and model files.";+ if (status.state === "runtimeMissing") return `${status.detail} slopfab.dll should be next to Slopus.exe.`;+ if (status.state === "ready") return "All required model files found.";+ if (missing > 0) return `${status.detail} ${missing === 1 ? "1 path" : `${missing} paths`} still to set.`;return status.detail;};diff --git a/src/components/WeightSourcesEditor.tsx b/src/components/WeightSourcesEditor.tsxindex 91d5f34..236d946 100644--- a/src/components/WeightSourcesEditor.tsx+++ b/src/components/WeightSourcesEditor.tsx@@ -1,6 +1,7 @@import { useState } from "react";import { Plus, Trash2 } from "lucide-react";import { isDownloadUrl, type WeightSource } from "../lib/settings";+import { Expander, InfoBar } from "./ui";export function WeightSourcesEditor({ label, sources, disabled, onChange }: {label: string; sources: WeightSource[]; disabled: boolean; onChange: (sources: WeightSource[]) => void;@@ -8,9 +9,9 @@ export function WeightSourcesEditor({ label, sources, disabled, onChange }: {const [url, setUrl] = useState("");const [error, setError] = useState<string | null>(null);const update = (index: number, patch: Partial<WeightSource>) => onChange(sources.map((source, i) => i === index ? { ...source, ...patch } : source));- return <details className="weight-sources">- <summary>Download variants{sources.length > 0 ? ` (${sources.length})` : ""}</summary>- <p>GPU model matches part of the device name, such as “RTX 5090”. Leave it blank for any GPU. Among matches, the highest minimum VRAM that fits is selected.</p>+ return <Expander className="weight-sources" header={`Download variants${sources.length > 0 ? ` (${sources.length})` : ""}`}+ description="Among matching GPUs, the highest minimum VRAM that fits is used">+ <p className="settings-caption">GPU model matches part of the device name, such as “RTX 5090”. Leave it blank for any GPU.</p>{sources.map((source, index) => <div className="weight-source" key={`${index}-${source.url}`}><label>Download URL<input aria-label={`${label} variant ${index + 1} URL`} defaultValue={source.url} disabled={disabled} onBlur={(event) => {const value = event.target.value.trim();@@ -20,14 +21,14 @@ export function WeightSourcesEditor({ label, sources, disabled, onChange }: {}} /></label><label>GPU model<input aria-label={`${label} variant ${index + 1} GPU model`} defaultValue={source.gpuModel} placeholder="Any GPU" disabled={disabled} onBlur={(event) => update(index, { gpuModel: event.target.value })} /></label><label>Minimum VRAM (GB)<input aria-label={`${label} variant ${index + 1} minimum VRAM`} type="number" min={0} step={1} value={source.minVramGb} disabled={disabled} onChange={(event) => update(index, { minVramGb: Math.max(0, Number(event.target.value) || 0) })} /></label>- <button type="button" className="icon-button" disabled={disabled} onClick={() => onChange(sources.filter((_, i) => i !== index))} aria-label={`Remove ${label} variant ${index + 1}`}><Trash2 size={15} /></button>+ <button type="button" className="icon-button" disabled={disabled} onClick={() => onChange(sources.filter((_, i) => i !== index))} aria-label={`Remove ${label} variant ${index + 1}`} data-tooltip="Remove variant"><Trash2 size={16} /></button></div>)}<div className="weight-source-add"><input aria-label={`Add ${label} download URL`} value={url} disabled={disabled} placeholder="https://…" onChange={(event) => setUrl(event.target.value)} /><button type="button" className="secondary-button" disabled={disabled || !isDownloadUrl(url) || sources.some((source) => source.url === url.trim())} onClick={() => {onChange([...sources, { url: url.trim(), gpuModel: "", minVramGb: 0 }]); setUrl("");- }}><Plus size={15} /> Add URL</button>+ }}><Plus size={16} /> Add URL</button></div>- {error && <p role="alert">{error}</p>}- </details>;+ {error && <InfoBar severity="error" message={error} onClose={() => setError(null)} />}+ </Expander>;}diff --git a/src/styles/loras.css b/src/styles/loras.cssindex 8ce9968..9c974c3 100644--- a/src/styles/loras.css+++ b/src/styles/loras.css@@ -1,16 +1,31 @@-.generator-template-item.lora-library-item { grid-template-columns: minmax(0, 1fr) var(--control-sm) var(--control-sm); }-.lora-manual { min-width: 0; padding: 0; border: 0; }-.lora-manual, .template-loras { display: grid; gap: var(--space-3); margin-top: var(--space-4); }-.lora-manual > label { display: grid; gap: var(--space-2); }-.lora-manual input:not([type="checkbox"]), .template-loras select, .template-loras input[type="number"] {- min-width: 0; min-height: var(--field-height); padding: var(--space-2) var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-sm);- color: inherit; background: var(--panel); font: inherit;+/* LoRA editor (a ContentDialog) and the generator's LoRA cards. The library+ and the per-generator list are SettingsGroups of cards (settings.css). */++.lora-manual {+ min-width: 0;+ display: grid;+ gap: var(--space-4);+ margin: 0;+ padding: 0;+ border: 0;+}++.lora-manual > label {+ display: grid;+ gap: var(--space-2);+}++.lora-manual__path {+ display: flex;+ gap: var(--space-2);+}++.lora-manual__path input { flex: 1; min-width: 0; }++.template-lora__strength {+ display: inline-flex;+ align-items: center;+ gap: var(--space-2);+ color: var(--text-secondary);+ font-size: var(--text-xs);}-.lora-manual .lora-toggle, .lora-toggle { display: flex; align-items: center; gap: var(--space-2); }-.lora-manual p, .template-loras p { margin: 0; color: var(--text-muted); font-size: var(--text-sm); }-.template-loras h3 { margin: 0; }-.template-loras h3 small { margin-left: var(--space-2); font-weight: normal; font-size: var(--text-sm); }-.template-lora-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }-.template-lora-row .lora-toggle { flex: 1; min-width: 140px; }-.template-lora-row > label:not(.lora-toggle) { display: grid; gap: var(--space-1); font-size: var(--text-2xs); }-.template-lora-row input[type="number"] { width: 78px; }diff --git a/src/styles/settings.css b/src/styles/settings.cssindex 9a60460..678af8d 100644--- a/src/styles/settings.css+++ b/src/styles/settings.css@@ -1,819 +1,310 @@/* ============================================================================- settings.css — the settings surface and its sections. Split out of shell.css.+ settings.css — the Settings page. Split out of shell.css.++ Settings is a page of the app window, drawn under the shell's title bar,+ not an overlay: a 280px navigation pane (Back at its top) and a scrolling+ content column that is at most 1000px wide, left-aligned, with 56px side+ padding — the Windows 11 Settings layout. Nothing here paints --bg: under+ Mica that is transparent, and the page lets the backdrop show through. The+ rows themselves are the shared SettingsGroup / SettingsCard /+ SettingsExpander from ui.css; this file only lays out the page and the few+ things those cards hold.========================================================================== */-/* --- Settings page --------------------------------------------------------- */-.settings-view {- position: fixed;- z-index: 60;- inset: 0;- height: 100vh;- height: 100dvh;- min-width: 0;- display: grid;- grid-template-columns: clamp(160px, 19vw, 250px) minmax(0, 1fr);- grid-template-rows: auto minmax(0, 1fr);- overflow: hidden;- background: var(--panel);-}+/* --- Page frame ----------------------------------------------------------- */-.settings-view__content {+.settings-view {+ flex: 1;+ width: 100%;+ height: 100%;min-width: 0;min-height: 0;- display: flex;- flex-direction: column;+ display: grid;+ grid-template-columns: 280px minmax(0, 1fr);overflow: hidden;+ outline: none;}-.settings-view__body {- flex: 1;- min-height: 0;- overflow: auto;- overscroll-behavior: contain;- padding: var(--space-6) clamp(16px, 3vw, 48px);+.settings-nav {+ padding: var(--space-1) var(--space-1) var(--space-4);}-.settings-view__body > .generator-editor__back {- margin-bottom: var(--space-4);+/* Back sits alone above the items, where Windows Settings puts it. */+.settings-nav__back {+ margin: 0 0 var(--space-2) var(--space-1);}-.settings-sidebar {+.settings-view__body {+ min-width: 0;min-height: 0;overflow-y: auto;- padding: var(--space-4) var(--space-3);- border-right: 1px solid var(--line);- background: var(--wash-1);-}--.settings-view__head {- grid-column: 1 / -1;- display: flex;- align-items: center;- gap: var(--space-4);- padding: var(--space-4) var(--space-5);- border-bottom: 1px solid var(--line);-}--.settings-view__head h1 {- margin: 0;- font-size: var(--text-2xl);- font-weight: var(--weight-semibold);- line-height: var(--leading-tight);+ overscroll-behavior: contain;}-/* --- Sidebar tabs ---------------------------------------------------------- */--.settings-tabs {+.settings-page {+ max-width: calc(1000px + 2 * 56px);display: flex;flex-direction: column;- gap: var(--space-1);-}--.settings-tabs button {- position: relative;- display: flex;- align-items: center;gap: var(--space-2);- min-height: var(--control-lg);- padding: var(--space-3);- border: 0;- border-radius: var(--radius-sm);- text-align: left;- color: var(--text-muted);- background: none;- font-size: var(--text-base);- font-weight: var(--weight-medium);- line-height: var(--leading-snug);+ padding: var(--space-2) 56px var(--space-8);}-.settings-tabs button:hover {- color: var(--text-secondary);- background: var(--wash-1);-}--.settings-tabs button.active {- color: var(--text-primary);- background: var(--accent-soft);-}--.settings-tabs button.active::after {- content: "";- position: absolute;- left: 0;- top: var(--space-2);- bottom: var(--space-2);- width: 2px;- border-radius: 2px;- background: var(--accent-bright);-}--/* How many paths still need setting, readable from the other tab. */-.settings-tabs button em {- margin-left: auto;- min-width: 18px;- padding: 0 var(--space-1);- border-radius: var(--radius-xs);- color: var(--text-primary);- border: 1px solid var(--warning-line);- background: var(--warning-soft);- font: var(--weight-semibold) var(--text-2xs) / 18px var(--font-mono);- font-style: normal;- text-align: center;+/* Groups are 4px-stacked cards; between groups, the heading's own space. */+.settings-page > .ui-settings-group,+.settings-page > .settings-download-status + .ui-settings-group,+.settings-page > .ui-infobar + .ui-settings-group {+ margin-top: var(--space-5);}-/* --- Generator templates ------------------------------------------------- */--.reference-icon-settings {- display: flex;- align-items: center;- flex-wrap: wrap;- gap: var(--space-4);- margin-bottom: var(--space-5);- padding: var(--space-4) var(--space-5);- border: 1px solid var(--line);- border-radius: var(--radius-lg);- background: var(--wash-1);-}-.reference-icon-option {- flex: 1 1 260px;- display: flex;- align-items: center;- gap: var(--space-3);-}-.reference-icon-settings .generator-template-fields {- flex: 0 1 320px;- min-width: 0;- width: 100%;- grid-template-columns: minmax(0, 1fr);- margin: 0;-}-.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(--stroke-surface);- border-radius: var(--radius-xl);- background: var(--dialog-bg);- 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);- border: 1px solid var(--line);- border-radius: var(--radius-lg);- background: var(--wash-1);+.settings-page > .ui-settings-group:first-of-type {+ margin-top: var(--space-3);}-.generator-templates > header {- display: flex;- align-items: flex-start;- justify-content: space-between;- gap: var(--space-4);-}+/* --- Title and breadcrumb -------------------------------------------------+ The title is the section name at 28/36; a sub-page shows the trail+ instead, its ancestors in secondary text and clickable. */-.generator-templates h2 {+.settings-page__title,+.settings-breadcrumb h1 {margin: 0;- color: var(--text-primary);- font-size: var(--text-lg);-}--.generator-templates header p {- margin: var(--space-1) 0 0;- color: var(--text-muted);- font-size: var(--text-sm);-}--.generator-template-list {- display: grid;- gap: var(--space-2);- margin-top: var(--space-4);-}--.generator-template-item {- position: relative;- isolation: isolate;- overflow: hidden;- display: grid;- grid-template-columns: var(--control-sm) minmax(0, 1fr) var(--control-sm);- align-items: center;- gap: var(--space-2);- padding: var(--space-1);- border: 1px solid var(--line);- border-radius: var(--radius-sm);- background: var(--field-bg);-}--.generator-template-item--download {- grid-template-columns: minmax(0, 1fr) var(--control-sm);-}--.generator-template-item__progress {- position: absolute;- inset: 0 auto 0 0;- z-index: -1;- background: var(--accent-bright);- opacity: 0.22;- pointer-events: none;- transition: width 0.2s linear;-}--@media (prefers-reduced-motion: reduce) {- .generator-template-item__progress { transition: none; }+ font-family: var(--font-display);+ font-size: var(--text-2xl);+ font-weight: var(--weight-semibold);+ line-height: 36px;+ outline: none;}-.generator-template-item--selected {- border-color: var(--accent-line-strong);- background: var(--accent-soft);+.settings-page__title {+ padding: var(--space-3) 0 var(--space-4);}-.generator-template-item__open {+.settings-breadcrumb {min-width: 0;display: flex;- align-items: baseline;+ align-items: center;gap: var(--space-2);- padding: var(--space-2);- border: 0;- color: var(--text-primary);- background: transparent;- text-align: left;+ padding: var(--space-3) 0 var(--space-4);}-.generator-template-item__open b {+.settings-breadcrumb h1 {min-width: 0;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;}-.generator-template-item__open > svg {- flex-shrink: 0;- align-self: center;- color: var(--text-muted);-}--.generator-template-item__open small,-.generator-template-item > label {- color: var(--text-muted);- font-size: var(--text-xs);-}--.generator-template-item__default {- display: flex;- align-items: center;- justify-content: center;- width: var(--control-sm);- height: var(--control-sm);-}--.generator-template-fields {- display: grid;- grid-template-columns: minmax(0, 1fr) 160px;- gap: var(--space-3);- margin-top: var(--space-3);-}--.generator-template-fields label {- display: grid;- gap: var(--space-1);- color: var(--text-muted);- font-size: var(--text-xs);-}--.generator-template-fields input,-.generator-template-fields select {- min-width: 0;- width: 100%;- height: var(--field-height);- padding: 0 var(--space-3);- border: 1px solid var(--line-strong);+.settings-breadcrumb__link {+ flex: none;+ padding: 0 var(--space-1);+ border: 0;border-radius: var(--radius-sm);- color: var(--text-primary);- background: var(--field-bg);- font-size: var(--text-sm);-}--.generator-editor__head {- margin-bottom: var(--space-4);-}--.generator-editor__advanced {- display: flex;- align-items: center;- gap: var(--space-2);- margin-top: var(--space-3);color: var(--text-secondary);- font-size: var(--text-sm);-}--.diagnostics-backend {- grid-template-columns: 180px minmax(0, 1fr);- align-items: center;- margin: 0 0 var(--space-4);-}--.generator-editor__head h2 {- margin: 0;- color: var(--text-primary);- font-size: var(--text-lg);-}--.generator-editor__back {- padding-inline: var(--space-2);-}--.generator-editor .generator-template-fields {- margin: 0 0 var(--space-4);-}--.settings-status {- padding: var(--space-4);- border: 1px solid var(--line);- border-radius: var(--radius-lg);- background: var(--wash-1);-}--.settings-status span {- display: flex;- align-items: center;- gap: var(--space-2);- color: var(--text-primary);- font-size: var(--text-base);- font-weight: var(--weight-semibold);- line-height: var(--leading-snug);+ background: transparent;+ font: var(--weight-semibold) var(--text-2xl) / 36px var(--font-display);+ transition: var(--transition-control);}-.settings-status i {- width: 9px;- height: 9px;- flex: 0 0 auto;- border-radius: 50%;- background: var(--text-faint);-}+.settings-breadcrumb__link:hover { color: var(--text-primary); }+.settings-breadcrumb__link:active { color: var(--text-muted); }-.settings-status p {- margin: var(--space-2) 0 0;- color: var(--text-muted);- font-size: var(--text-sm);- line-height: var(--leading-normal);+.settings-breadcrumb__separator {+ flex: none;+ color: var(--text-secondary);}-.settings-status__platform {+/* The editor's page commands, under the title like Windows' "Add device". */+.settings-page__actions {display: flex;- align-items: baseline;+ flex-wrap: wrap;gap: var(--space-2);- margin-top: var(--space-3);- color: var(--text-muted);- font-size: var(--text-sm);+ margin-bottom: var(--space-2);}-.settings-status__platform b {- color: var(--text-primary);+.settings-caption {+ margin: 0 0 var(--space-2);+ color: var(--text-secondary);font-size: var(--text-xs);+ line-height: var(--leading-snug);}-.settings-status--ready {- border-color: var(--success-line);- background: var(--success-soft);-}--.settings-status--ready i {- background: var(--success);-}--.settings-status--modelsMissing i,-.settings-status--incompatible i {- background: var(--warning);-}--.settings-status--runtimeMissing i {- background: var(--danger);-}--/* A section is a whole tab panel now, so it opens at the top of the body- rather than a heading's distance below the one before it. */-.settings-section {- margin: 0;-}--.settings-section .settings-status {- margin-bottom: var(--space-2);-}--/* --- Diagnostics ---------------------------------------------------------- */--.diagnostics-debug-option {- display: flex;- align-items: center;- gap: var(--space-3);- margin-bottom: var(--space-4);- padding: var(--space-4) var(--space-5);- border: 1px solid var(--line);- border-radius: var(--radius-lg);- background: var(--wash-1);+.settings-group__count {+ margin-left: var(--space-2);+ color: var(--text-secondary);+ font-weight: var(--weight-regular);}-.diagnostics-debug-option input,-.reference-icon-option input {- margin: 0;- accent-color: var(--accent);-}+/* --- Controls inside cards --------------------------------------------------+ Text boxes are 280–320px in the UI font (paths and keys are not code);+ numbers are short. */-.diagnostics-debug-option b,-.reference-icon-option b {- color: var(--text-primary);- font-size: var(--text-sm);+.settings-field {+ width: 300px;+ max-width: 100%;}-.diagnostics-debug-option small,-.reference-icon-option small {- display: block;- margin-top: var(--space-1);- color: var(--text-muted);- font-size: var(--text-sm);+input.settings-field--number,+.settings-field--number {+ width: 96px;}-/* --- Appearance -------------------------------------------------------------- Three options, always all three visible: "system" is a real choice, not the- absence of one, and a two-state toggle cannot say so. */--.theme-choice {+.settings-card-list {display: grid;- grid-template-columns: repeat(3, minmax(0, 1fr));- gap: var(--space-3);+ gap: var(--space-1);}-.theme-choice__option {- min-height: var(--control-lg);- display: grid;- grid-template-columns: auto minmax(0, 1fr);- align-items: center;- gap: var(--space-1) var(--space-3);- padding: var(--space-4);- border: 1px solid var(--line-strong);- border-radius: var(--radius-lg);- color: var(--text-muted);- background: var(--wash-1);- transition: var(--transition-control);+/* A card that opens something and carries its own buttons. The open button+ covers the card beneath everything; text lets presses through to it and+ the trailing controls take their own. */+.settings-open-card {+ position: relative;}-/* The radio still exists and still takes focus — it is only invisible, so the- arrow keys, the label click and the screen reader all keep working. The ring- is drawn on the card, which is what reads as the control. */-.theme-choice__option input {+.settings-open-card__open {position: absolute;- width: 1px;- height: 1px;- opacity: 0;- pointer-events: none;-}--.theme-choice__option:has(input:focus-visible) {- outline: var(--focus-ring-width) solid var(--focus-outer);- outline-offset: 1px;- box-shadow: 0 0 0 1px var(--focus-inner);-}--.theme-choice__option > svg {- grid-row: 1;- flex: 0 0 auto;+ inset: 0;+ z-index: 0;+ padding: 0;+ border: 0;+ border-radius: inherit;+ background: transparent;+ transition: var(--transition-control);}-.theme-choice__option b {- grid-row: 1;- color: var(--text-primary);- font-size: var(--text-base);- font-weight: var(--weight-semibold);- line-height: var(--leading-snug);-}+.settings-open-card__open:hover { background: var(--card-hover); }+.settings-open-card__open:active { background: var(--card-pressed); }-.theme-choice__option small {- grid-column: 2;- grid-row: 2;- font-size: var(--text-xs);- line-height: var(--leading-normal);+.settings-open-card > :not(.settings-open-card__open) {+ position: relative;+ z-index: 1;+ pointer-events: none;}-.theme-choice__option:hover {- border-color: var(--line-hover);- color: var(--text-secondary);- background: var(--wash-2);+.settings-open-card__control > :not(.ui-settings-card__glyph) {+ pointer-events: auto;}-.theme-choice__option--selected,-.theme-choice__option--selected:hover {- border-color: var(--accent);- color: var(--text-secondary);- background: var(--accent-soft);+/* Download progress: a 3px bar under the row's description, never a tint+ behind the row. */+.settings-progress {+ width: min(320px, 100%);+ margin-top: var(--space-2);}-.theme-choice__option--selected > svg {+.settings-download-status .ui-settings-card__icon {color: var(--accent-bright);}-/* --- Prompt LLMs ----------------------------------------------------------- */--.llm-settings__intro {- margin: 0 0 var(--space-4);- color: var(--text-muted);- font-size: var(--text-sm);- line-height: var(--leading-normal);+.settings-view .spin {+ animation: spin 0.9s linear infinite;}-.llm-provider {- padding: var(--space-4);- border: 1px solid var(--line-strong);- border-radius: var(--radius-lg);- background: var(--wash-1);-}+/* --- Engine status (an InfoBar on the generator page) -------------------- */-.llm-provider + .llm-provider {- margin-top: var(--space-4);+.settings-status__platform b {+ font-weight: var(--weight-semibold);}-.llm-provider--configured {- border-color: var(--success-line);+/* --- Model paths ------------------------------------------------------------+ One card per path: the label ("(optional)" in secondary text), the path+ middle-ellipsised in 12px UI type, then state, Browse… and "…" (raw path+ or URL entry, Clear). */++.settings-path {+ display: grid;+ gap: var(--space-1);}-.llm-provider > header {- display: flex;- align-items: flex-start;- justify-content: space-between;- gap: var(--space-4);- margin-bottom: var(--space-4);+.settings-path__optional {+ color: var(--text-secondary);}-.llm-provider h2 {- margin: 0;- color: var(--text-primary);- font-size: var(--text-lg);- line-height: var(--leading-snug);+.settings-path__value {+ display: block;+ overflow: hidden;+ text-overflow: ellipsis;+ white-space: nowrap;}-.llm-provider header p {- margin: var(--space-1) 0 0;- color: var(--text-muted);- font-size: var(--text-xs);- line-height: var(--leading-normal);+.settings-path__input {+ width: 100%;+ margin-top: var(--space-1);}-.llm-provider header > span {+.settings-path__state {display: inline-flex;align-items: center;gap: var(--space-1);- flex: 0 0 auto;- color: var(--text-faint);+ color: var(--text-secondary);font-size: var(--text-xs);+ white-space: nowrap;}-.llm-provider--configured header > span {- color: var(--success);+.settings-path--found .settings-path__state { color: var(--success); }+.settings-path--missing .settings-path__state { color: var(--danger); }++/* Download variants: an Expander indented under the path it belongs to. */+.weight-sources {+ margin-left: calc(2 * var(--space-4) + 20px);}-.llm-provider__fields {+.weight-source {display: grid;- grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);- gap: var(--space-3);+ grid-template-columns: minmax(0, 1fr) 140px 130px auto;+ align-items: end;+ gap: var(--space-2);+ margin: var(--space-3) 0;}-.llm-provider__fields label {+.weight-source label {min-width: 0;-}--.llm-provider__fields label > span {- display: flex;- align-items: center;- gap: var(--space-2);- margin-bottom: var(--space-2);+ display: grid;+ gap: var(--space-1);color: var(--text-secondary);font-size: var(--text-xs);- font-weight: var(--weight-semibold);}-.llm-provider__fields label em {- color: var(--text-faint);- font-size: var(--text-2xs);- font-style: normal;- font-weight: var(--weight-regular);-}--.llm-provider__fields input {+.weight-source input,+.weight-source-add input {width: 100%;min-width: 0;- height: var(--field-height);- 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: var(--weight-regular) var(--text-sm) / 1 var(--font-mono);-}--.llm-provider__model {- grid-column: 1 / -1;-}--.llm-provider__model > div {- display: flex;- gap: var(--space-2);-}--.llm-provider__model input {- flex: 1 1 auto;-}--.llm-provider__model button {- flex: 0 0 auto;-}--.llm-provider__model .spin {- animation: spin 0.8s linear infinite;-}--.llm-provider__error {- margin: var(--space-3) 0 0;- color: var(--danger);- font-size: var(--text-xs);- line-height: var(--leading-normal);-}--/* Keep the path on a full-width row so long filenames and URLs remain readable. */-.settings-path {- display: grid;- grid-template-columns: minmax(0, 1fr);- align-items: start;- gap: var(--space-2);- padding: var(--space-3) 0;- border-top: 1px solid var(--line);-}--.settings-path label {- display: block;-}--.settings-path label b {- display: flex;- align-items: center;- gap: var(--space-2);- color: var(--text-primary);- font-size: var(--text-base);- font-weight: var(--weight-semibold);- line-height: var(--leading-snug);-}--/* "Optional" is a qualifier on the label, not a status — keep it quiet. */-.settings-path label b em {- padding: var(--space-1) var(--space-2);- border: 1px solid var(--line);- border-radius: var(--radius-xs);- color: var(--text-faint);- font: var(--weight-medium) var(--text-2xs) / 1 var(--font-mono);- font-style: normal;}-.settings-path__row {+.weight-source-add {display: flex;- flex-wrap: wrap;- align-items: center;gap: var(--space-2);+ margin-top: var(--space-2);}-.settings-path__row input {- flex: 1 1 auto;- min-width: 0;- height: var(--field-height);- 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: var(--weight-regular) var(--text-sm) / 1 var(--font-mono);-}--.weight-sources { min-width: 0; font-size: var(--text-sm); color: var(--text-muted); }-.weight-sources p { margin: var(--space-2) 0; }-.weight-source { display: grid; grid-template-columns: minmax(0, 1fr) 135px 125px auto; gap: var(--space-2); align-items: end; margin: var(--space-3) 0; }-.weight-source label { min-width: 0; font-size: var(--text-xs); }-.weight-source input, .weight-source-add input { width: 100%; min-width: 0; height: var(--field-height); padding: 0 var(--space-2); color: var(--text-primary); background: var(--field-bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); }-.weight-source-add { display: flex; gap: var(--space-2); margin-top: var(--space-2); }.weight-source-add input { flex: 1; }-.weight-download-status { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); padding: var(--space-3) 0; color: var(--text-secondary); font-size: var(--text-sm); }-.weight-download-status span { flex: 1 1 100%; }-.settings-view__content > .weight-download-status {- flex-shrink: 0;- padding: var(--space-3) clamp(16px, 3vw, 48px);- border-top: 1px solid var(--line);-}-.settings-path__row .secondary-button {- flex: 0 0 auto;-}+/* --- Agents -------------------------------------------------------------- */-.settings-path__state {- flex-basis: 100%;+.llm-provider__status {display: inline-flex;align-items: center;gap: var(--space-1);- color: var(--text-faint);- font-size: var(--text-xs);- line-height: var(--leading-snug);-}--.settings-path--found .settings-path__state {- color: var(--success);-}--.settings-path--missing .settings-path__state {- color: var(--danger);-}--.settings-path--missing .settings-path__row input {- border-color: var(--danger-line-strong);+ color: var(--text-secondary);+ font-size: var(--text-base);+ white-space: nowrap;}-.settings-view__foot {- flex-shrink: 0;- padding: var(--space-4) clamp(16px, 3vw, 48px);- display: flex;- align-items: center;- justify-content: space-between;- gap: var(--space-4);- border-top: 1px solid var(--line);+.llm-provider .ui-settings-row .ui-settings-card__control {+ flex-wrap: wrap;+ justify-content: flex-end;+ gap: var(--space-2);}-.settings-view__foot span {- color: var(--text-faint);- font-size: var(--text-xs);- line-height: var(--leading-snug);+.settings-expander-message {+ padding: var(--space-2) var(--space-4);}-/* --- Responsive ------------------------------------------------------------ */--@media (max-width: 650px) {- .settings-view {- grid-template-columns: 124px minmax(0, 1fr);- }-- .settings-sidebar { padding: var(--space-3) var(--space-1); }- .settings-tabs button { padding: var(--space-2); font-size: var(--text-sm); }- .settings-view__body { padding: var(--space-4) var(--space-3); }-- .settings-path {- grid-template-columns: minmax(0, 1fr);- gap: var(--space-2);- }-- .generator-template-fields {- grid-template-columns: minmax(0, 1fr);- }-- .settings-path__row {- flex-direction: column;- align-items: stretch;- }-- .settings-view__foot {- flex-direction: column;- align-items: flex-start;- }-- .theme-choice {- grid-template-columns: 1fr;- }-- .llm-provider__fields {- grid-template-columns: 1fr;- }-- .llm-provider__model {- grid-column: auto;- }-- .llm-provider__model > div {- flex-direction: column;- }+/* --- Narrower windows -------------------------------------------------------+ The window's minimum is 900px; below 1100px the pane and the gutters give+ the cards the room. */+@media (max-width: 1100px) {+ .settings-view { grid-template-columns: 240px minmax(0, 1fr); }+ .settings-page { padding-inline: var(--space-6); }+ .settings-field { width: 240px; }+ .weight-source { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }}