From 3da4fd5f7dc685577ac81f445062e495e9423014 Mon Sep 17 00:00:00 2001 From: Hirokazu Hata Date: Thu, 4 Dec 2025 08:43:15 +0900 Subject: [PATCH] =?UTF-8?q?fix(acp):=20prevent=20unnecessary=20credential?= =?UTF-8?q?=20cache=20clearing=20on=20re-authent=E2=80=A6=20(#9410)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Tommaso Sciortino --- packages/cli/src/zed-integration/zedIntegration.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/zed-integration/zedIntegration.ts b/packages/cli/src/zed-integration/zedIntegration.ts index c95402c7b8..cd0cb4789a 100644 --- a/packages/cli/src/zed-integration/zedIntegration.ts +++ b/packages/cli/src/zed-integration/zedIntegration.ts @@ -113,8 +113,16 @@ export class GeminiAgent { async authenticate({ methodId }: acp.AuthenticateRequest): Promise { 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,