The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(window): force-show fallback + top-level ErrorBoundary so a window always appears (surfingbird1010)
purpled004e715812c
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex 4a959b92..f429d25a 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -236,6 +236,33 @@ fn main() {let _ = window.set_shadow(false);}+ // ─── Bug D (surfingbird1010): force-show fallback ───+ // The window starts hidden (visible:false in tauri.conf.json) and is+ // normally revealed by the frontend's invoke('show_window') once React+ // mounts (App.tsx). If the WebView never loads, or a render/hydration+ // throw happens before that effect runs (corrupt persisted state,+ // GPU/WebView2 fault), the window would stay hidden forever and the app+ // looks like it "runs with no window". Reveal it unconditionally after a+ // timeout so the user always gets a window. The frontend's earlier+ // show_window is idempotent, so a healthy launch sees no double-show /+ // flicker. 10 s is comfortably longer than a normal cold React mount+ // (~1-2 s) yet short enough not to feel broken on a slow i7/8 GB box.+ {+ let handle = app.handle().clone();+ std::thread::spawn(move || {+ std::thread::sleep(std::time::Duration::from_secs(10));+ if let Some(window) = handle.get_webview_window("main") {+ // Treat "unknown" as hidden → show (a redundant show on an+ // already-visible window is a harmless no-op).+ if !window.is_visible().unwrap_or(false) {+ println!("[Window] Force-show fallback fired (frontend never called show_window)");+ let _ = window.show();+ let _ = window.set_focus();+ }+ }+ });+ }+// ─── System Tray ───let show = MenuItem::with_id(app, "show", "Show", true, None::<&str>)?;let quit = MenuItem::with_id(app, "quit", "Quit", true, None::<&str>)?;diff --git a/src/components/ui/ErrorBoundary.tsx b/src/components/ui/ErrorBoundary.tsxindex cfed90ad..d7357601 100644--- a/src/components/ui/ErrorBoundary.tsx+++ b/src/components/ui/ErrorBoundary.tsx@@ -1,10 +1,18 @@import { Component, type ReactNode } from 'react'import { AlertCircle, RefreshCw } from 'lucide-react'import { log } from '../../lib/logger'+import { forceShowWindow, resetSettingsAndReload } from '../../lib/fatal-error'interface Props {children: ReactNodefallbackClassName?: string+ /**+ * Top-level boundary over the whole app (used in main.tsx): on a render throw+ * it force-shows the initially-hidden Tauri window (so the fallback is seen at+ * all — Bug D) and renders a full-screen, actionable recovery UI (reload /+ * reset settings) instead of the small inline card.+ */+ root?: boolean}interface State {@@ -21,6 +29,9 @@ export class ErrorBoundary extends Component<Props, State> {componentDidCatch(error: Error, info: React.ErrorInfo) {log.error('ErrorBoundary caught', { error, componentStack: info.componentStack })+ // Bug D: a render throw above App.tsx's show_window effect would leave the+ // Tauri window hidden forever — force it visible so this UI is actually seen.+ if (this.props.root) forceShowWindow()}handleReset = () => {@@ -29,6 +40,43 @@ export class ErrorBoundary extends Component<Props, State> {render() {if (this.state.hasError) {+ // Bug D: full-screen, actionable recovery UI for the top-level boundary.+ // Inline styles (not Tailwind) so it renders even if a CSS/build problem+ // is part of the failure. Reload retries; Reset clears settings/state+ // (keeps chats & knowledge) — covers a poisoned persisted store.+ if (this.props.root) {+ const overlay: React.CSSProperties = {+ position: 'fixed', inset: 0, display: 'flex', flexDirection: 'column',+ alignItems: 'center', justifyContent: 'center', gap: 14,+ background: '#171717', color: '#e5e5e5', padding: 24, textAlign: 'center',+ fontFamily: 'system-ui, -apple-system, sans-serif',+ }+ const btn: React.CSSProperties = {+ cursor: 'pointer', borderRadius: 8, padding: '8px 16px', fontSize: 13,+ border: '1px solid rgba(255,255,255,0.15)', background: 'rgba(255,255,255,0.06)',+ color: '#e5e5e5',+ }+ return (+ <div style={overlay}>+ <AlertCircle size={28} color="#f87171" />+ <div style={{ fontSize: 18, fontWeight: 600 }}>Locally Uncensored hit a problem</div>+ <div style={{+ fontSize: 12, color: '#9ca3af', maxWidth: 560, maxHeight: 160, overflow: 'auto',+ whiteSpace: 'pre-wrap', wordBreak: 'break-word', textAlign: 'left',+ background: 'rgba(0,0,0,0.3)', padding: 10, borderRadius: 8,+ }}>+ {this.state.error?.message || 'Unknown error'}+ </div>+ <div style={{ display: 'flex', gap: 12, marginTop: 6 }}>+ <button style={btn} onClick={() => window.location.reload()}>Reload</button>+ <button style={btn} onClick={resetSettingsAndReload}>Reset settings & reload</button>+ </div>+ <div style={{ fontSize: 11, color: '#6b7280', maxWidth: 520 }}>+ Reset clears app settings (providers, preferences) but keeps your chats & knowledge.+ </div>+ </div>+ )+ }return (<div className={this.props.fallbackClassName || 'flex flex-col items-center justify-center p-6 gap-3'}><AlertCircle size={24} className="text-red-400" />diff --git a/src/lib/fatal-error.ts b/src/lib/fatal-error.tsnew file mode 100644index 00000000..ba0f644b--- /dev/null+++ b/src/lib/fatal-error.ts@@ -0,0 +1,93 @@+/**+ * Boot-failure recovery helpers (Bug D — surfingbird1010 "app runs, no window").+ *+ * A throw while a persisted store hydrates from corrupt data fires at+ * module-import time — before the React ErrorBoundary can mount. With the window+ * starting hidden (visible:false), that left the app launched-but-invisible.+ * `mountFatalError` renders a minimal, plain-DOM recovery screen that cannot+ * itself throw and force-shows the hidden Tauri window. The Rust force-show+ * timeout is the ultimate net; this is the fast, actionable path.+ */++/**+ * zustand-persist keys holding SETTINGS / transient state — safe to reset.+ * Deliberately EXCLUDES user DATA so a reset never destroys content:+ * chat-conversations (chats) · rag-store (knowledge) ·+ * locally-uncensored-memory (curated memory/brain).+ */+export const SETTINGS_STORAGE_KEYS = [+ 'chat-settings',+ 'lu-providers',+ 'locally-uncensored-voice',+ 'chat-models',+ 'create-store',+ 'locally-uncensored-codex',+ 'locally-uncensored-mcp-servers',+ 'locally-uncensored-permissions',+ 'locally-uncensored-agent',+ 'locally-uncensored-agent-mode',+ 'locally-uncensored-agent-workflows',+ 'locally-uncensored-model-health',+ 'workflow-store',+ 'lu-update-checker-v2',+ 'lu-benchmark-store',+ 'lu_cloud_teaser',+ 'lu_image_tool_noti',+]++/** Force the (initially hidden) Tauri window visible so recovery UI is seen. */+export function forceShowWindow(): void {+ try {+ const w = window as unknown as { __TAURI_INTERNALS__?: unknown }+ if (typeof window !== 'undefined' && w.__TAURI_INTERNALS__) {+ import('@tauri-apps/api/core')+ .then(({ invoke }) => invoke('show_window').catch(() => {}))+ .catch(() => {})+ }+ } catch { /* ignore — best effort */ }+}++/** Clear settings/state keys (keeps chats/knowledge/memory) and reload. */+export function resetSettingsAndReload(): void {+ try {+ for (const k of SETTINGS_STORAGE_KEYS) {+ try { localStorage.removeItem(k) } catch { /* ignore one bad key */ }+ }+ } finally {+ window.location.reload()+ }+}++function escapeHtml(s: string): string {+ return s.replace(/[&<>"']/g, (c) =>+ ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c] as string),+ )+}++/** Plain-DOM fatal-error screen for a boot throw the ErrorBoundary can't catch. */+export function mountFatalError(rootEl: HTMLElement, err: unknown): void {+ forceShowWindow()+ // eslint-disable-next-line no-console+ try { console.error('[LU] fatal boot error', err) } catch { /* ignore */ }+ const message = err instanceof Error ? err.stack || err.message : String(err)+ const btn =+ 'cursor:pointer;border-radius:8px;padding:8px 16px;font-size:13px;' ++ 'border:1px solid rgba(255,255,255,0.15);background:rgba(255,255,255,0.06);color:#e5e5e5'+ rootEl.innerHTML =+ '<div style="position:fixed;inset:0;display:flex;flex-direction:column;align-items:center;' ++ 'justify-content:center;gap:14px;background:#171717;color:#e5e5e5;' ++ 'font-family:system-ui,-apple-system,sans-serif;padding:24px;text-align:center">' ++ '<div style="font-size:18px;font-weight:600">Locally Uncensored couldn’t start</div>' ++ '<div style="font-size:12px;color:#9ca3af;max-width:560px;max-height:160px;overflow:auto;' ++ 'white-space:pre-wrap;word-break:break-word;text-align:left;background:rgba(0,0,0,0.3);' ++ 'padding:10px;border-radius:8px">' + escapeHtml(message) + '</div>' ++ '<div style="display:flex;gap:12px;margin-top:6px">' ++ '<button id="lu-fatal-reload" style="' + btn + '">Reload</button>' ++ '<button id="lu-fatal-reset" style="' + btn + '">Reset settings & reload</button>' ++ '</div>' ++ '<div style="font-size:11px;color:#6b7280;max-width:520px">Reset clears app settings ' ++ '(providers, preferences) but keeps your chats & knowledge.</div>' ++ '</div>'+ document.getElementById('lu-fatal-reload')?.addEventListener('click', () => window.location.reload())+ document.getElementById('lu-fatal-reset')?.addEventListener('click', resetSettingsAndReload)+}diff --git a/src/main.tsx b/src/main.tsxindex bef5202a..03107c86 100644--- a/src/main.tsx+++ b/src/main.tsx@@ -1,10 +1,29 @@+import './index.css'import { StrictMode } from 'react'import { createRoot } from 'react-dom/client'-import './index.css'-import App from './App.tsx'+import { mountFatalError } from './lib/fatal-error'++const rootEl = document.getElementById('root')!++// Bug D (surfingbird1010): a throw while a persisted store hydrates from corrupt+// data (D1 corrupt chat-settings / D2 migrate throw / D5 locked IndexedDB) fires+// at module-import time — before the React ErrorBoundary can mount. With the+// window starting hidden, that left the app launched-but-invisible. Load the app+// via dynamic import inside a catch so any boot throw renders an actionable+// recovery screen (which also force-shows the window) instead of a blank page.+// The Rust force-show timeout (main.rs setup) is the ultimate net.+async function boot() {+ const [{ default: App }, { ErrorBoundary }] = await Promise.all([+ import('./App.tsx'),+ import('./components/ui/ErrorBoundary'),+ ])+ createRoot(rootEl).render(+ <StrictMode>+ <ErrorBoundary root>+ <App />+ </ErrorBoundary>+ </StrictMode>,+ )+}-createRoot(document.getElementById('root')!).render(- <StrictMode>- <App />- </StrictMode>,-)+void boot().catch((err) => mountFatalError(rootEl, err))