From 17200740a83099699d7e1bdbb9c782b646d65d38 Mon Sep 17 00:00:00 2001 From: Bee <68532117+abeatrix@users.noreply.github.com> Date: Fri, 11 Jul 2025 12:53:24 -0700 Subject: [PATCH] Trigger auth status update on secret storage change (#4837) * Trigger auth status update on secret storage change The auth status should be updated when the clineAccountId secret changes. This commit adds a listener to the secrets.onDidChange event and calls sendAuthStatusUpdate when the clineAccountId secret changes. This ensures that the auth status is always up-to-date. * restore * afgain --------- Co-authored-by: abeatrix --- src/extension.ts | 8 ++++++++ src/services/auth/AuthService.ts | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/extension.ts b/src/extension.ts index 894da3db..34c67f75 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -685,6 +685,14 @@ export async function activate(context: vscode.ExtensionContext) { }), ) + context.subscriptions.push( + context.secrets.onDidChange((event) => { + if (event.key === "clineAccountId") { + AuthService.getInstance(context)?.restoreAuthToken() + } + }), + ) + return createClineAPI(outputChannel, sidebarWebview.controller) } diff --git a/src/services/auth/AuthService.ts b/src/services/auth/AuthService.ts index 57d31834..efada377 100644 --- a/src/services/auth/AuthService.ts +++ b/src/services/auth/AuthService.ts @@ -100,6 +100,7 @@ export class AuthService { }) this._setProvider(authProviders.find((authProvider) => authProvider.name === providerName).name) + this._context = context } @@ -118,7 +119,7 @@ export class AuthService { } AuthService.instance = new AuthService(context, config || {}, authProvider) } - if (context) { + if (context !== undefined) { AuthService.instance.context = context } return AuthService.instance