From 3c6c919feab8b6fb522c396e141a63ee25765aa3 Mon Sep 17 00:00:00 2001 From: Brace Sproul Date: Wed, 6 Aug 2025 10:26:13 -0700 Subject: [PATCH] fix: early return if no api key is provided (#686) * fix: early return if no api key is provided * cr --- apps/web/src/components/v2/terminal-input.tsx | 1 + apps/web/src/features/settings-page/api-keys.tsx | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/apps/web/src/components/v2/terminal-input.tsx b/apps/web/src/components/v2/terminal-input.tsx index b5ef154b..c41f1a0c 100644 --- a/apps/web/src/components/v2/terminal-input.tsx +++ b/apps/web/src/components/v2/terminal-input.tsx @@ -109,6 +109,7 @@ export function TerminalInput({ MISSING_API_KEYS_TOAST_CONTENT, MISSING_API_KEYS_TOAST_OPTIONS, ); + return; } setLoading(true); diff --git a/apps/web/src/features/settings-page/api-keys.tsx b/apps/web/src/features/settings-page/api-keys.tsx index bd81431c..94937ee7 100644 --- a/apps/web/src/features/settings-page/api-keys.tsx +++ b/apps/web/src/features/settings-page/api-keys.tsx @@ -53,6 +53,14 @@ const API_KEY_DEFINITIONS = { // ], }; +const shouldAutofocus = (apiKeyId: string, hasValue: boolean): boolean => { + if (apiKeyId === "anthropicApiKey") { + return !hasValue; + } + + return false; +}; + export function APIKeysTab() { const { getConfig, updateConfig } = useConfigStore(); const config = getConfig(DEFAULT_CONFIG_KEY); @@ -186,6 +194,7 @@ export function APIKeysTab() { } placeholder={`Enter your ${apiKey.name} API key`} className="font-mono text-sm" + autoFocus={shouldAutofocus(apiKey.id, !!apiKey.value)} />