Compare commits

...

2 Commits

Author SHA1 Message Date
abeatrix 6f07dcd53b changeset 2025-07-16 23:51:14 -07:00
abeatrix 3abc882dde Handle auth state changes in all extension windows
Addresses an issue where authentication state changes (login/logout) were not being properly propagated across all extension windows.

The `onDidChange` event handler for `clineAccountId` secret now checks if the secret was added/updated (login) or removed (logout).

- If the secret exists, `restoreRefreshTokenAndRetrieveAuthInfo` is called to restore auth info (login from another window).
- If the secret is removed, `handleDeauth` is called to handle logout for all windows.

This ensures that all extension windows are kept in sync with the current authentication state.
2025-07-16 23:48:10 -07:00
2 changed files with 16 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": patch
---
Handle auth state changes in all extension windows
+11 -2
View File
@@ -691,9 +691,18 @@ export async function activate(context: vscode.ExtensionContext) {
)
context.subscriptions.push(
context.secrets.onDidChange((event) => {
context.secrets.onDidChange(async (event) => {
if (event.key === "clineAccountId") {
AuthService.getInstance(context)?.restoreRefreshTokenAndRetrieveAuthInfo()
// Check if the secret was removed (logout) or added/updated (login)
const secretValue = await context.secrets.get("clineAccountId")
const authService = AuthService.getInstance(context)
if (secretValue) {
// Secret was added or updated - restore auth info (login from another window)
authService?.restoreRefreshTokenAndRetrieveAuthInfo()
} else {
// Secret was removed - handle logout for all windows
authService?.handleDeauth()
}
}
}),
)