diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index a54dc97986..159d9835f3 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -37,6 +37,7 @@ https://github.com/KumarVariable/vscode-extension-sidebar-html/blob/master/src/c type SecretKey = | "apiKey" + | "clineApiKey" | "openRouterApiKey" | "awsAccessKey" | "awsSecretKey" @@ -836,13 +837,18 @@ export class ClineProvider implements vscode.WebviewViewProvider { return true } - async handleAuthCallback(token: string) { + async handleAuthCallback(token: string, apiKey: string) { try { // First sign in with Firebase to trigger auth state change await this.authManager.signInWithCustomToken(token) // Then store the token securely await this.storeSecret("authToken", token) + await this.storeSecret("clineApiKey", apiKey) + + const clineProvider: ApiProvider = "cline" + await this.updateGlobalState("apiProvider", clineProvider) + await this.postStateToWebview() vscode.window.showInformationMessage("Successfully logged in to Cline") } catch (error) { diff --git a/src/extension.ts b/src/extension.ts index 1faee0133b..a644409b12 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -158,10 +158,12 @@ export function activate(context: vscode.ExtensionContext) { case "/auth": { const token = query.get("token") const state = query.get("state") + const apiKey = query.get("apiKey") console.log("Auth callback received:", { token: token, state: state, + apiKey: apiKey, }) // Validate state parameter @@ -170,8 +172,8 @@ export function activate(context: vscode.ExtensionContext) { return } - if (token) { - await visibleProvider.handleAuthCallback(token) + if (token && apiKey) { + await visibleProvider.handleAuthCallback(token, apiKey) } break } diff --git a/src/shared/api.ts b/src/shared/api.ts index 81eb1d5897..d660b1bda0 100644 --- a/src/shared/api.ts +++ b/src/shared/api.ts @@ -11,10 +11,12 @@ export type ApiProvider = | "deepseek" | "mistral" | "vscode-lm" + | "cline" export interface ApiHandlerOptions { apiModelId?: string apiKey?: string // anthropic + clineApiKey?: string anthropicBaseUrl?: string openRouterApiKey?: string openRouterModelId?: string diff --git a/webview-ui/src/context/ExtensionStateContext.tsx b/webview-ui/src/context/ExtensionStateContext.tsx index 59e03f3fb3..59f277b11b 100644 --- a/webview-ui/src/context/ExtensionStateContext.tsx +++ b/webview-ui/src/context/ExtensionStateContext.tsx @@ -70,9 +70,10 @@ export const ExtensionStateContextProvider: React.FC<{ config.deepSeekApiKey, config.mistralApiKey, config.vsCodeLmModelSelector, + config.clineApiKey, ].some((key) => key !== undefined) : false - setShowWelcome(!hasKey && !message.state!.isLoggedIn) + setShowWelcome(!hasKey) setDidHydrateState(true) break }