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
This commit is contained in:
Roo Code 2026-01-18 09:02:39 +00:00
parent 802b40a790
commit 6fbe59efcf

View file

@ -34,6 +34,8 @@ const WelcomeViewProvider = () => {
uriScheme,
cloudIsAuthenticated,
cloudAuthSkipModel,
openAiCodexIsAuthenticated,
claudeCodeIsAuthenticated,
} = useExtensionState()
const { t } = useAppTranslation()
const [errorMessage, setErrorMessage] = useState<string | undefined>(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) {