fix(acp): prevent unnecessary credential cache clearing on re-authent… (#9410)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
Hirokazu Hata
2025-12-04 08:43:15 +09:00
committed by GitHub
parent 1e6243045e
commit 3da4fd5f7d

View File

@@ -113,8 +113,16 @@ export class GeminiAgent {
async authenticate({ methodId }: acp.AuthenticateRequest): Promise<void> {
const method = z.nativeEnum(AuthType).parse(methodId);
const selectedAuthType = this.settings.merged.security?.auth?.selectedType;
await clearCachedCredentialFile();
// Only clear credentials when switching to a different auth method
if (selectedAuthType && selectedAuthType !== method) {
await clearCachedCredentialFile();
}
// Refresh auth with the requested method
// This will reuse existing credentials if they're valid,
// or perform new authentication if needed
await this.config.refreshAuth(method);
this.settings.setValue(
SettingScope.User,