fix(session): keep feature-flag-derived state across logout - #1162
Merged
Conversation
SessionState.isTippingEnabled (and vibrateOnScan / showNetworkOffline) are fed only by featureFlagController.observe(flag) — hot StateFlows that dedup and re-emit only on a value change. On logout, stateHolder.reset() blanket- reset SessionState() to defaults, forcing these to false. The observer never re-pushes its unchanged value, so the field stayed stuck at the default even though the underlying flag was still enabled. Result: log out with tipping on, log into another account, and the beta flag is still on but the scanner Tips tab is gone — SessionState desynced from the flag. reset() now clears only account-scoped state and preserves the device-scoped, feature-flag-derived fields, letting observe(flag) remain their single source of truth. Account/token/settings-derived fields still reset; their sources re-emit on account switch and self-heal.
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
Log out of an account with the Tipping beta flag on, log into another account, and you end up in a contradictory state: the beta flag is still on, but the scanner Tips tab is gone — and stays gone.
Root cause
SessionState.isTippingEnabled(andvibrateOnScan/showNetworkOffline) are fed only byfeatureFlagController.observe(flag)— hotStateFlows that dedup and re-emit only on a value change.On logout (
AuthState.LoggedOutinRealSessionController),stateHolder.reset()did a blanket_state.value = SessionState(), forcingisTippingEnabled = false. Because the observer's value was unchanged (the beta-flags store is device-level and shared across accounts, sotipping_enabledstaystrue), it never re-pushed to repopulate the field.isTippingEnabledwas stuck at the reset default, so the scanner hid the Tips tab even though the flag was still enabled — a permanent desync until the flag value actually changed.Fix
SessionStateHolder.reset()now clears only account-scoped state and preserves the device-scoped, feature-flag-derived fields (isTippingEnabled,vibrateOnScan,showNetworkOffline), lettingobserve(flag)remain their single source of truth:falseand the field follows.Either way
SessionStatecan no longer desync from the flag. Account/token/settings-derived fields (isPhoneNumberSendEnabled,hasGiveableBalance,autoStartCamera, …) still reset — their sources re-emit on account switch and self-heal.Tests
SessionStateHolderTest: split the oldresettest intoreset clears account-scoped state, and addedreset preserves device-scoped feature-flag state. All passing.Note
Distinct root cause from #1157 (that fixes the persisted nav-bar order lacking
Tips). This one fixes session state desyncing from the flag on logout. The two together cover both ways the Tips tab could fail to appear.