diff --git a/src/components/auth/LocalKeyGate.tsx b/src/components/auth/LocalKeyGate.tsx index 1e3b8a8..202e1a4 100644 --- a/src/components/auth/LocalKeyGate.tsx +++ b/src/components/auth/LocalKeyGate.tsx @@ -1,6 +1,7 @@ "use client"; import { useEffect, useMemo, useState } from 'react'; +import { createPortal } from 'react-dom'; import { isLocalMode } from '@/config/runtime'; import { apiKeyService } from '@/services/storage/apiKeys'; @@ -30,6 +31,11 @@ const buttonStyle: React.CSSProperties = { export function LocalKeyGate({ children }: LocalKeyGateProps) { const isLocal = useMemo(() => isLocalMode(), []); const [hasKeys, setHasKeys] = useState(() => (!isLocal) || apiKeyService.hasUserKeys()); + const [mounted, setMounted] = useState(false); + + useEffect(() => { + setMounted(true); + }, []); useEffect(() => { if (!isLocal) return; @@ -47,46 +53,47 @@ export function LocalKeyGate({ children }: LocalKeyGateProps) { } const openApiKeySettings = () => { - if (typeof window !== 'undefined') { - window.dispatchEvent(new CustomEvent('settings:open', { detail: { tab: 'apikeys' } })); - } + window.dispatchEvent(new CustomEvent('settings:open', { detail: { tab: 'apikeys' } })); }; + const popupContent = ( +
+ Local mode needs an OpenAI or Anthropic key. Add one under Settings → API Keys + to unlock the workspace. +
+- Local mode needs an OpenAI or Anthropic key. Add one under Settings → API Keys - to unlock the workspace. -
-