Repository navigation
Wave-3 (partial): fix cross-account leak + dead warning indicator + stale hierarchy - #8
Merged
Merged
Conversation
logout() cleared only the bearer token, but every repository + HierarchyStore + favorites/default-household prefs are @singleton, so an account switch on the same process rendered User A's households/products/ missing-items/favorites to User B (loadFromCache repopulates from stale caches before the network returns). Add clear() to each cache (default no-op on the interface so test fakes are unaffected), HierarchyStore (reset + cancel in-flight job), and FavoritesStore; centralize in a SessionCleaner called on logout AND at the start of each new sign-in (covers the reactive-401 path too). In-memory/prefs only. Tests added.
Home + drawer rendered the needs-attention warning purely from state.locationWarnings, populated only by a composed ProductsPane, so a missing mandatory item on a non-visible shelf showed no warning until the user opened that location and swiped to the shelf — the at-a-glance rollup silently showed 'all good'. HierarchyStore now computes locationWarnings in loadFromCache + buildFromNetwork by grouping the missingItems it already builds by locationId, and refresh takes the server-computed map as truth. Tests added.
Household mutations updated only the HouseholdRepository cache + their own UI state, so the drawer/home/dashboard (driven by the @singleton HierarchyStore) stayed stale until a manual refresh or relaunch. Inject HierarchyStore into HouseholdsViewModel + JoinHouseholdViewModel and call refresh() after a successful create/join/leave. Tests assert the store reflects the mutation via a shared TestHierarchy helper.
spdotdev
added a commit
that referenced
this pull request
Jul 18, 2026
- HierarchyStore.refresh(): rethrow CancellationException before the fold. A superseded refresh painted a stale 'failed to load' over the newer load, and a load cancelled by clear() on logout could write the PREVIOUS account's hierarchy back after the wipe — the one shared store was missing the CE guard every ViewModel already has. - DrawerViewModel: same CE guards on the list/confirm/undo delete pipeline; a session reset mid-flight no longer surfaces a spurious 'failed to delete' snackbar to the next signed-in account. - LiveUpdates/PusherRealtimeGateway: every arrival at CONNECTED (including the client's internal auto-reconnects) now triggers a silent refresh — events broadcast while backgrounded or during a network blip were lost and data stayed stale until a manual pull. A refused /broadcasting/auth was swallowed (Unit) and killed live updates for the process lifetime; it now logs and retries with a freshly-read token after a 5s pause. - Products/ProductDetail: the Undo snackbar is suppressed for plain Members — product delete is open to any member but restore is restructure-gated server-side, so their Undo tap was a guaranteed 403 mislabelled 'already restored' (the web gates its Undo flash the same way, GAP-7 #8). Tests: reconnect-refresh + auth-retry cases added to LiveUpdatesTest.
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.
Third-wave fixes from a fresh 3-agent audit of the twice-hardened MVP. Loop stopped by request after X1–X5; see
inventory-docs/GAP-ANALYSIS-3.md.HierarchyStore+ favorites/default-household prefs are@Singletonand survived logout, so an account switch rendered User A's households/products/missing-items/favorites to User B (loadFromCacherepopulates from stale caches before the network returns). Addedclear()to each cache (default no-op on the interface so test fakes are unaffected) + aSessionCleanercalled on logout and at each new sign-in (covers the reactive-401 path too).ProductsPanepopulated it, so a missing item on a non-visible shelf showed nothing until the user swiped to it.HierarchyStorenow computeslocationWarningsauthoritatively from server data inloadFromCache+buildFromNetwork.HierarchyStore→ stale drawer/home/dashboard. Both VMs nowrefresh()after a successful mutation.New pure-JVM tests:
SessionCleanerTest,HierarchyStore.clear()/warning computation, household-mutation refresh. Gated by compile +testDebugUnitTest.