Content-Length: 273395 | pFad | http://github.com/coder/vscode-coder/pull/563

76 Fix #498: Implement consistent logout experience across VS Code windows by OyinloluB · Pull Request #563 · coder/vscode-coder · GitHub
Skip to content

Fix #498: Implement consistent logout experience across VS Code windows #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

OyinloluB
Copy link

Problem

Issue #498 reported inconsistent behavior when users are logged out of Coder:

  • Window A might show clear "please login" messages
  • Window B would show confusing errors like "Invalid argument 'uriOrString'"
  • Windows became unusable with no clear indication of what was wrong

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:

  • Inconsistent UI states across windows
  • Confusing error messages instead of clear logout notifications
  • Poor user experience

Solution

Implemented event-driven authentication synchronization using VS Code's ctx.secrets.onDidChange API:

  1. Authentication Sync Function: syncAuth() updates REST client, VS Code contexts, and workspace providers when auth state changes
  2. Event Listener: Detects session token changes across all windows
  3. Consistent Notifications: All windows show clear "You've been logged out of Coder!" messages
  4. UI State Sync: Sidebars and contexts update consistently across windows

Implementation

  • Uses ctx.secrets.onDidChange for immediate, event-driven updates (no polling)
  • Reuses existing logout notification patterns from Commands.logout()
  • Updates restClient, VS Code contexts, and workspace providers consistently
  • Proper cleanup via ctx.subscriptions for extension disposal

Testing

  • A/B Validation: Confirmed bug exists without fix, disappears with fix
  • Multi-window Testing: Tested logout sync across multiple Extension Development Host windows
  • User Experience: Verified clear notifications replace confusing errors
  • Debug Logs: Added logging to help reviewers verify fix during testing

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

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
@OyinloluB
Copy link
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 ctx.secrets.onDidChange to detect session token changes and synchronizes the authentication state across all windows immediately.

I would be happy to address any feedback you have!

Thanks for taking the time to review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve consistency in client-side logout experience
1 participant








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/coder/vscode-coder/pull/563

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy