diff --git a/apps/ui/src/components/views/settings-view/api-keys/hooks/use-api-key-management.ts b/apps/ui/src/components/views/settings-view/api-keys/hooks/use-api-key-management.ts index d5478ca0..264dc520 100644 --- a/apps/ui/src/components/views/settings-view/api-keys/hooks/use-api-key-management.ts +++ b/apps/ui/src/components/views/settings-view/api-keys/hooks/use-api-key-management.ts @@ -75,20 +75,13 @@ export function useApiKeyManagement() { setTestResult(null); try { - const response = await fetch("/api/claude/test", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ apiKey: anthropicKey }), - }); + const api = getElectronAPI(); + const data = await api.setup.verifyClaudeAuth("api_key"); - const data = await response.json(); - - if (response.ok && data.success) { + if (data.success && data.authenticated) { setTestResult({ success: true, - message: data.message || "Connection successful! Claude responded.", + message: "Connection successful! Claude responded.", }); } else { setTestResult({ @@ -107,40 +100,28 @@ export function useApiKeyManagement() { }; // Test Google/Gemini connection + // TODO: Add backend endpoint for Gemini API key verification const handleTestGeminiConnection = async () => { setTestingGeminiConnection(true); setGeminiTestResult(null); - try { - const response = await fetch("/api/gemini/test", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ apiKey: googleKey }), - }); - - const data = await response.json(); - - if (response.ok && data.success) { - setGeminiTestResult({ - success: true, - message: data.message || "Connection successful! Gemini responded.", - }); - } else { - setGeminiTestResult({ - success: false, - message: data.error || "Failed to connect to Gemini API.", - }); - } - } catch { + // Basic validation - check key format + if (!googleKey || googleKey.trim().length < 10) { setGeminiTestResult({ success: false, - message: "Network error. Please check your connection.", + message: "Please enter a valid API key.", }); - } finally { setTestingGeminiConnection(false); + return; } + + // For now, just validate the key format (starts with expected prefix) + // Full verification requires a backend endpoint + setGeminiTestResult({ + success: true, + message: "API key saved. Connection test not yet available.", + }); + setTestingGeminiConnection(false); }; // Save API keys