Repository navigation
Commit 2fa9a05
fix(desktop): enforce single scope authority in observed-unread persistence
Pass 2 review blocked on three IMPORTANT findings — all resolved here.
Finding (a) — one scope authority, enforced everywhere:
- handleChannelMessage now fences latestByChannelRef on isScopeLoaded()
before mutating, guarding the path that was unfenced at 420-423.
- Catch-up .then() drops threadActivityScopeRef as its guard and uses
observedPersistence.isScopeLoaded() instead — one authority, not two.
- removeChannel/clearAll reject when scopeLoadedRef.current !== currentScope;
non-empty props alone are no longer sufficient.
Finding (b) — removeChannel never cancel-without-replacement:
- removeChannel deletes the channel from both in-memory refs and then calls
scheduleObservedUnreadWrite with the current full map. The previous path
(cancel + edit persisted bucket) would lose unsaved sibling-channel events
on the next reload. The updated removeChannel test seeds both channel-1 and
channel-2, removes channel-1 before the debounce fires, flushes via
pagehide, and asserts channel-2 survives.
Finding (c) — real scope-transition tests:
- isScopeLoaded test now drives a real prop transition (re-render with new
pubkey) instead of manually back-dating scopeLoadedRef.current.
- Added stale-removeChannel scope-fence test: captures removeChannel under
scope A, switches to scope B via re-render, calls stale callback, asserts
B's bucket is untouched.
- Fixed two pre-existing biome useOptionalChain findings in A→B late-timer
test (storedAT?.has / storedBT2?.has).
Co-authored-by: Will Pfleger <[email protected]>
Signed-off-by: Will Pfleger <[email protected]>1 parent 13d5de1 commit 2fa9a05
3 files changed
Lines changed: 534 additions & 53 deletions
File tree
- desktop/src/features/channels
0 commit comments