diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index e2040a474b..9eb4ed9e98 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -1003,6 +1003,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { ...apiConfiguration, apiProvider: clineProvider, clineApiKey: apiKey, + authToken: customToken, } if (this.cline) { diff --git a/src/services/auth/FirebaseAuthManager.ts b/src/services/auth/FirebaseAuthManager.ts index 58d37deefb..6d7e85359b 100644 --- a/src/services/auth/FirebaseAuthManager.ts +++ b/src/services/auth/FirebaseAuthManager.ts @@ -200,16 +200,22 @@ export class FirebaseAuthManager { } private async restoreSession() { - console.log("Attempting to restore session") + console.log("[restoreSession] Attempting to restore session") const provider = this.providerRef.deref() if (!provider) { - console.log("Provider reference lost during session restore") + console.log("[restoreSession] Provider reference lost during session restore") return } - // If no active session, try to sign in with stored custom token - const storedToken = await provider.getSecret("authToken") - if (storedToken) { + // Get the auth state from the provider's state, which is loaded when the webview launches + const { apiConfiguration } = await provider.getState() + const storedToken = apiConfiguration?.authToken + console.log("[restoreSession] Auth state from provider:", { + hasToken: !!storedToken, + hasClineApiKey: !!apiConfiguration?.clineApiKey, + }) + + if (storedToken && apiConfiguration?.clineApiKey) { console.log("Found stored custom token, attempting to restore session") try { await this.retryWithBackoff(async () => {