Use globalEnvironment$ on environment selector#20495
Conversation
|
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE Reviewed a one-line change in No findings. Code Review DetailsNo issues found. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #20495 +/- ##
==========================================
- Coverage 47.11% 47.11% -0.01%
==========================================
Files 3950 3951 +1
Lines 119726 119732 +6
Branches 18348 18349 +1
==========================================
+ Hits 56408 56410 +2
- Misses 59081 59086 +5
+ Partials 4237 4236 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
JaredSnider-Bitwarden
left a comment
There was a problem hiding this comment.
This makes perfect sense to me. Thank you for the in depth explanation. As this is an unflagged change, please talk to QA about testing on the feature or in main. Also, please ask for testing on both desktop and the extension as both use this shared component (web has its own, older implementation).



🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-30715
📔 Objective
We currently subscribe to the
environment$observable on theEnvironmentSelector.The
environment$makes decisions based on whether the user is logged in or not, which may result in race conditions on logout, when the application is transitioning from an authenticated to unauthenticated state.This added complexity is not necessary on the
EnvironmentSelector, as by definition when you're selecting an environment to log into, you're not logged in, and therefore user-scoped state is not in play. TheEnvironmentSelectorshould only care about the "global" (non-user-scoped) environment.The screenshot below shows that login and logout work as expected, and the environment does change correctly. The issue this is trying to reproduce does not occur consistently on any environment, and only on environments that use MDM for setting the environment.
📓 Note that follow-up work will be done to deprecate
environment$and replace with anaccountEnvironment$that is explicitly scoped to the logged-in user. This will be done separately and by the Platform team. This is tracked in https://bitwarden.atlassian.net/browse/PM-36480.📸 Screenshots
Screen.Recording.2026-05-04.at.1.29.27.PM.mov