diff --git a/src/providers/ClaudeDevProvider.ts b/src/providers/ClaudeDevProvider.ts index e102eb6..c2f3ebb 100644 --- a/src/providers/ClaudeDevProvider.ts +++ b/src/providers/ClaudeDevProvider.ts @@ -425,7 +425,7 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider { async getState() { const [ - apiProvider, + storedApiProvider, apiModelId, apiKey, openRouterApiKey, @@ -447,9 +447,24 @@ export class ClaudeDevProvider implements vscode.WebviewViewProvider { this.getGlobalState("lastShownAnnouncementId") as Promise, this.getGlobalState("customInstructions") as Promise, ]) + + let apiProvider: ApiProvider + if (storedApiProvider) { + apiProvider = storedApiProvider + } else { + // Either new user or legacy user that doesn't have the apiProvider stored in state + // (If they're using OpenRouter or Bedrock, then apiProvider state will exist) + if (apiKey) { + apiProvider = "anthropic" + } else { + // New users should default to openrouter + apiProvider = "openrouter" + } + } + return { apiConfiguration: { - apiProvider: apiProvider || "anthropic", // for legacy users that were using Anthropic by default + apiProvider, apiModelId, apiKey, openRouterApiKey, diff --git a/webview-ui/src/components/WelcomeView.tsx b/webview-ui/src/components/WelcomeView.tsx index e6852ea..2b91f2e 100644 --- a/webview-ui/src/components/WelcomeView.tsx +++ b/webview-ui/src/components/WelcomeView.tsx @@ -1,10 +1,9 @@ -import { ApiConfiguration } from "../../../src/shared/api" import { VSCodeButton, VSCodeLink } from "@vscode/webview-ui-toolkit/react" import React, { useEffect, useState } from "react" +import { ApiConfiguration } from "../../../src/shared/api" import { validateApiConfiguration } from "../utils/validate" import { vscode } from "../utils/vscode" import ApiOptions from "./ApiOptions" -import { useEffectOnce } from "react-use" interface WelcomeViewProps { apiConfiguration?: ApiConfiguration @@ -24,13 +23,6 @@ const WelcomeView: React.FC = ({ apiConfiguration, setApiConfi setApiErrorMessage(validateApiConfiguration(apiConfiguration)) }, [apiConfiguration]) - useEffectOnce(() => { - setApiConfiguration((prevConfig) => ({ - ...prevConfig, - apiProvider: "openrouter", - })) - }) - return (

Hi, I'm Claude Dev