From 4b9ab69b9bb75bccaf3670147d8afb5fcdbc2281 Mon Sep 17 00:00:00 2001 From: Haze <709547807@qq.com> Date: Fri, 6 Feb 2026 03:27:32 +0800 Subject: [PATCH] fix(setup): auto-redirect to setup when no API keys are configured If setup was previously completed but no provider API keys were saved (due to the legacy bug where validation didn't persist keys), the app now detects this on startup and redirects to the setup wizard so the user can re-enter their key with the fixed save flow. --- src/App.tsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/App.tsx b/src/App.tsx index f8998d752..962e20bc6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -29,9 +29,29 @@ function App() { }, [initGateway]); // Redirect to setup wizard if not complete + // Also check if provider keys exist - if setup was "completed" but + // no keys were saved (legacy bug), re-run setup useEffect(() => { if (!setupComplete && !location.pathname.startsWith('/setup')) { navigate('/setup'); + return; + } + + // Check if we have any saved providers with keys + if (setupComplete && !location.pathname.startsWith('/setup')) { + window.electron.ipcRenderer.invoke('provider:list') + .then((providers: unknown) => { + const list = providers as Array<{ hasKey: boolean }>; + const hasAnyKey = Array.isArray(list) && list.some(p => p.hasKey); + if (!hasAnyKey) { + // No API keys configured - re-run setup + console.log('No provider API keys found, redirecting to setup'); + navigate('/setup'); + } + }) + .catch(() => { + // Ignore errors + }); } }, [setupComplete, location.pathname, navigate]);