AI media harness for planning, generating, and editing locally
TypeScript
Simplify settings controls
Bitti102472fb7de4
diff --git a/src/components/SettingsView.test.tsx b/src/components/SettingsView.test.tsxindex 4d3c205..7e51ad0 100644--- a/src/components/SettingsView.test.tsx+++ b/src/components/SettingsView.test.tsx@@ -83,29 +83,29 @@ describe("the settings screen", () => {vi.mocked(invoke).mockResolvedValue({ state: "ready", dllPath: "slopfab.dll", version: "1.4.0", platform: "Vulkan", cudaAvailable: false, detail: "Ready.", models: [] });open();fireEvent.click(tab("Diagnostics"));- await screen.findByText(/AMD and Intel GPUs use Vulkan/);+ await waitFor(() => expect(invoke).toHaveBeenCalledWith("slopfab_status", expect.anything()));const backend = screen.getByLabelText("GPU backend") as HTMLSelectElement;expect(backend.disabled).toBe(true);expect(backend.value).toBe("vulkan");expect(within(backend).getAllByRole("option")).toHaveLength(1);});- it("remembers automatic reference icon generation and confirmation preferences", () => {+ 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;- const confirmation = () => screen.getByRole("checkbox", { name: "Ask before automatic icon generation" }) as HTMLInputElement;expect(automatic().checked).toBe(true);- expect(confirmation().checked).toBe(true);- fireEvent.click(confirmation());- expect(confirmation().checked).toBe(false);+ expect(screen.queryByRole("checkbox", { name: "Ask before automatic icon generation" })).toBeNull();view.unmount();open();- expect(confirmation().checked).toBe(false);+ expect(automatic().checked).toBe(true);+ expect(localStorage.getItem("slopus.reference-icon-automation.v1")).toBe("enabled");fireEvent.click(automatic());expect(automatic().checked).toBe(false);- expect(screen.queryByRole("checkbox", { name: "Ask before automatic icon generation" })).toBeNull();+ expect(localStorage.getItem("slopus.reference-icon-automation.v1")).toBe("disabled");fireEvent.click(automatic());- expect(confirmation().checked).toBe(true);+ expect(automatic().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", () => {@@ -248,7 +248,7 @@ describe("the settings screen", () => {expect(radio.closest("label")?.textContent).toBe("");});- it("shows where diagnostic logs live and can reveal the current file", async () => {+ it("offers only a button 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\\com.slopus.desktop\\logs\\slopus.log",@@ -262,8 +262,10 @@ describe("the settings screen", () => {open();fireEvent.click(tab("Diagnostics"));- expect(await screen.findByText(info.path)).toBeTruthy();- expect(screen.getByText(/Prompt text and credentials are not recorded/)).toBeTruthy();+ expect(screen.queryByText(info.path)).toBeNull();+ expect(screen.queryByRole("heading", { name: "Application log" })).toBeNull();+ expect(screen.queryByText(/Prompt text and credentials are not recorded/)).toBeNull();+ expect(vi.mocked(invoke).mock.calls.map(([command]) => command)).not.toContain("diagnostic_log_info");fireEvent.click(screen.getByRole("button", { name: "Show log file" }));await waitFor(() => expect(vi.mocked(invoke).mock.calls.map(([command]) => command)).toContain("reveal_diagnostic_log"));});diff --git a/src/components/SettingsView.tsx b/src/components/SettingsView.tsxindex a6be5fb..bc79f11 100644--- a/src/components/SettingsView.tsx+++ b/src/components/SettingsView.tsx@@ -1,6 +1,6 @@-import { AlertCircle, Check, ChevronLeft, FileText, FolderOpen, FolderSearch, LoaderCircle, Monitor, Moon, Plus, RefreshCw, RotateCcw, Sun, Trash2, X } from "lucide-react";+import { AlertCircle, Check, ChevronLeft, FolderOpen, FolderSearch, LoaderCircle, Monitor, Moon, Plus, RefreshCw, RotateCcw, Sun, Trash2, X } from "lucide-react";import { useCallback, useEffect, useRef, useState, useSyncExternalStore, type ReactNode } from "react";-import { getDiagnosticLogInfo, revealDiagnosticLog, type DiagnosticLogInfo } from "../lib/diagnostics";+import { revealDiagnosticLog } from "../lib/diagnostics";import { isTauri } from "../lib/persistence";import { chooseEnginePath, getAgentModels, getEngineStatus, type ModelStatus, type SlopfabStatus } from "../lib/runtime";import {@@ -55,16 +55,12 @@ const themeOptions: { id: ThemeChoice; label: string; icon: typeof Sun; detail:function ReferenceIconSetting() {const automation = useSyncExternalStore(subscribeReferenceIconAutomation, loadReferenceIconAutomation);- return <>+ return (<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" aria-describedby="automatic-reference-icons-description" />- <span><b id="automatic-reference-icons-label">Automatic reference icon generation</b><small id="automatic-reference-icons-description">Generate icons for references without artwork. Turning this off skips waiting automatic icons; an icon already rendering can finish. Manual generation stays available.</small></span>+ <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>- {automation !== "disabled" && <label className="reference-icon-option">- <input type="checkbox" checked={automation === "ask"} onChange={(event) => saveReferenceIconAutomation(event.target.checked ? "ask" : "enabled")} />- <span><b>Ask before automatic icon generation</b></span>- </label>}- </>;+ );}function AppearanceSetting() {@@ -197,21 +193,14 @@ function DiagnosticsSetting({ desktop, status, onBackendChange }: { desktop: booconst [backend, setBackend] = useState(loadInferenceBackend);const cudaAvailable = status?.cudaAvailable === true;const debugEnabled = useSyncExternalStore(subscribeDebugOptions, loadDebugOptionsEnabled);- const [info, setInfo] = useState<DiagnosticLogInfo | null>(null);const [opening, setOpening] = useState(false);const [error, setError] = useState<string | null>(null);- useEffect(() => {- if (!desktop) return;- void getDiagnosticLogInfo().then(setInfo).catch((reason) => setError(reason instanceof Error ? reason.message : String(reason)));- }, [desktop]);-const reveal = async () => {setOpening(true);setError(null);try {- const next = await revealDiagnosticLog();- if (next) setInfo(next);+ await revealDiagnosticLog();} catch (reason) {setError(reason instanceof Error ? reason.message : String(reason));} finally {@@ -233,26 +222,14 @@ function DiagnosticsSetting({ desktop, status, onBackendChange }: { desktop: boo<option value="vulkan">Vulkan</option></select></label>- <p>{!desktop ? "Available in the desktop app." : !status ? "Checking GPU backends…" : cudaAvailable ? "Choose CUDA or Vulkan for your NVIDIA GPU. Applies to new generations." : "AMD and Intel GPUs use Vulkan. CUDA requires a compatible NVIDIA GPU and CUDA runtime."}</p></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 Debug Icon Prompt in reference details.</small></span></label>- <div className="diagnostics-setting">- <div className="diagnostics-setting__icon"><FileText size={22} aria-hidden="true" /></div>- <div>- <h2>Application log</h2>- <p>Slopus records startup, runtime checks, generation stages, encoding, file writes, and unexpected errors in a readable text log. The file rotates at 5 MB and keeps one previous file.</p>- <p>Prompt text and credentials are not recorded. Sensitive fields are redacted again when each record is written.</p>- <code title={info?.path}>{desktop ? info?.path ?? "Locating the log…" : "Available in the desktop app"}</code>- {info?.previousPath && <small>A previous rotated log is stored beside this file.</small>}- <button type="button" className="secondary-button" disabled={!desktop || opening} onClick={() => void reveal()}>- {opening ? <LoaderCircle className="spin" size={16} /> : <FolderOpen size={16} />} Show log file- </button>- {error && <p className="diagnostics-setting__error" role="alert">{error}</p>}- </div>- </div>+ <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></>;}diff --git a/src/styles/shell.css b/src/styles/shell.cssindex df3f784..ada1764 100644--- a/src/styles/shell.css+++ b/src/styles/shell.css@@ -342,11 +342,6 @@margin: 0 0 var(--space-4);}-.diagnostics-backend p {- color: var(--text-muted);- font-size: var(--text-sm);-}-.generator-editor__head h2 {margin: 0;color: var(--text-primary);@@ -480,63 +475,6 @@font-size: var(--text-sm);}-.diagnostics-setting {- display: grid;- grid-template-columns: auto minmax(0, 1fr);- gap: var(--space-4);- padding: var(--space-5);- border: 1px solid var(--line);- border-radius: var(--radius-lg);- background: var(--wash-1);-}--.diagnostics-setting__icon {- width: var(--control-lg);- height: var(--control-lg);- display: grid;- place-items: center;- border-radius: var(--radius-md);- color: var(--accent-bright);- background: var(--accent-soft);-}--.diagnostics-setting h2 {- margin: 0;- color: var(--text-primary);- font-size: var(--text-lg);-}--.diagnostics-setting p {- margin: var(--space-2) 0 0;- color: var(--text-muted);- font-size: var(--text-sm);- line-height: var(--leading-normal);-}--.diagnostics-setting code {- display: block;- margin: var(--space-4) 0 var(--space-3);- padding: var(--space-3);- overflow: hidden;- border: 1px solid var(--line-solid);- border-radius: var(--radius-sm);- color: var(--text-secondary);- background: var(--field-bg);- font-size: var(--text-xs);- text-overflow: ellipsis;- white-space: nowrap;-}--.diagnostics-setting small {- display: block;- margin: calc(-1 * var(--space-2)) 0 var(--space-3);- color: var(--text-faint);-}--.diagnostics-setting__error {- color: var(--danger) !important;-}-/* --- Appearance -------------------------------------------------------------Three options, always all three visible: "system" is a real choice, not theabsence of one, and a two-state toggle cannot say so. */