From 6fbe59efcf8074ba4589eb392152e69c76be4027 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Sun, 18 Jan 2026 09:02:39 +0000 Subject: [PATCH] fix: auto-save config when OAuth completes for openai-codex/claude-code providers When using OAuth-based providers (openai-codex or claude-code) in the welcome screen, the user would select the provider, sign in via OAuth, but then clicking "Finish" would not dismiss the welcome screen. Root cause: After OAuth completes, postStateToWebview() overwrites the local apiConfiguration with the backend state, which does not have the apiProvider set yet (since the user had not clicked Finish to save it). Solution: Add useEffect hooks that detect when OAuth completes for these providers and automatically save the configuration, following the existing pattern for the Roo provider authentication flow. Fixes #10819 --- .../welcome/WelcomeViewProvider.tsx | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/webview-ui/src/components/welcome/WelcomeViewProvider.tsx b/webview-ui/src/components/welcome/WelcomeViewProvider.tsx index c44114b895d..4cdf68b18f5 100644 --- a/webview-ui/src/components/welcome/WelcomeViewProvider.tsx +++ b/webview-ui/src/components/welcome/WelcomeViewProvider.tsx @@ -34,6 +34,8 @@ const WelcomeViewProvider = () => { uriScheme, cloudIsAuthenticated, cloudAuthSkipModel, + openAiCodexIsAuthenticated, + claudeCodeIsAuthenticated, } = useExtensionState() const { t } = useAppTranslation() const [errorMessage, setErrorMessage] = useState(undefined) @@ -73,6 +75,48 @@ const WelcomeViewProvider = () => { } }, [cloudIsAuthenticated, authInProgress, currentApiConfigName, cloudAuthSkipModel]) + // When OAuth completes for openai-codex or claude-code while on the custom provider screen, + // automatically save the configuration so the welcome screen dismisses. + // This is needed because postStateToWebview() after OAuth completion can overwrite the local + // apiConfiguration, losing the apiProvider selection before the user clicks "Finish". + useEffect(() => { + if ( + selectedProvider === "custom" && + apiConfiguration?.apiProvider === "openai-codex" && + openAiCodexIsAuthenticated + ) { + // Save the openai-codex configuration + const config: ProviderSettings = { + ...apiConfiguration, + apiProvider: "openai-codex", + } + vscode.postMessage({ + type: "upsertApiConfiguration", + text: currentApiConfigName, + apiConfiguration: config, + }) + } + }, [selectedProvider, apiConfiguration, openAiCodexIsAuthenticated, currentApiConfigName]) + + useEffect(() => { + if ( + selectedProvider === "custom" && + apiConfiguration?.apiProvider === "claude-code" && + claudeCodeIsAuthenticated + ) { + // Save the claude-code configuration + const config: ProviderSettings = { + ...apiConfiguration, + apiProvider: "claude-code", + } + vscode.postMessage({ + type: "upsertApiConfiguration", + text: currentApiConfigName, + apiConfiguration: config, + }) + } + }, [selectedProvider, apiConfiguration, claudeCodeIsAuthenticated, currentApiConfigName]) + // Focus the manual URL input when it becomes visible useEffect(() => { if (showManualEntry && manualUrlInputRef.current) {