Fix #498: Implement consistent logout experience across VS Code windows#563
Closed
OyinloluB wants to merge 4 commits intocoder:mainfrom
Closed
Fix #498: Implement consistent logout experience across VS Code windows#563OyinloluB wants to merge 4 commits intocoder:mainfrom
OyinloluB wants to merge 4 commits intocoder:mainfrom
Conversation
Fixes coder#498 by implementing event-driven authentication synchronization. When a user logs out from one VS Code window, all other windows now immediately show a clear 'You've been logged out of Coder!' notification instead of confusing errors like 'Invalid argument uriOrString'. Uses ctx.secrets.onDidChange to detect session token changes and syncAuth() to update all windows consistently. - Add syncAuth() function to handle auth state changes - Listen for sessionToken changes via ctx.secrets.onDidChange - Update REST client, VS Code contexts, and workspace providers - Show consistent logout notifications across windows Tested: A/B validation confirms fix eliminates confusing user experience.
Add debug output to syncAuth function and event listener to help
Move syncAuth function and event listener to better location in code Cleaned up logs
Author
|
Hi @aslilac Connor asked me to tag you for review of this PR. This fix addresses Issue #498 by implementing event-driven authentication synchronization across VS Code windows. When a user logs out from one window, all other windows now receive consistent "You've been logged out of Coder!" notifications instead of confusing error messages. The solution uses I would be happy to address any feedback you have! Thanks for taking the time to review! |
Collaborator
|
Closing this in favor of #590 since it handles both login and logout consistency and we need some urgency to land it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Issue #498 reported inconsistent behavior when users are logged out of Coder:
Cause
Multiple VS Code windows share the same authentication storage, but when one window logs out, other windows aren't notified of the state change. This leads to:
Solution
Implemented event-driven authentication synchronization using VS Code's
ctx.secrets.onDidChangeAPI:syncAuth()updates REST client, VS Code contexts, and workspace providers when auth state changesImplementation
ctx.secrets.onDidChangefor immediate, event-driven updates (no polling)Commands.logout()restClient, VS Code contexts, and workspace providers consistentlyctx.subscriptionsfor extension disposalTesting
Result
Eliminates confusing "Invalid argument" errors
Provides consistent logout experience across all windows
Clear user messaging with actionable "Login" button
Immediate synchronization (no delays)
Fixes #498