Keep active thread state consistent after browser resume#439
Open
ymichael wants to merge 1 commit into
Open
Conversation
ef88e15 to
6b35074
Compare
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.
Summary
Active Thread Bundle
The browser-resume path refreshes the currently observed thread IDs across:
This is intentionally scoped to active thread state. It does not duplicate PR #440's broader reconnect audit or its terminal/automation reconnect additions.
Root Cause
Before this PR, mobile sleep/resume depended on per-query React Query focus behavior unless the websocket produced a clean reconnect/open callback. Timeline could recover via focus/pageshow refetch, while queued messages, pending interactions, default options, and bootstrap-like neighboring state could remain stale because some of those queries explicitly opt out of focus refetch or use long/infinite stale times. Reconnect catch-up also covered timeline but missed conversation outline and bootstrap.
Before / After
Before: if the phone locked on a bad network and websocket events were missed without a clean reconnect notification, active thread surfaces could drift: timeline could show accepted/new rows while queue/pending/composer-adjacent state still reflected the pre-sleep snapshot.
After: browser resume invalidates the active thread bundle as one unit, independent of individual query focus settings. Websocket reconnect catch-up also covers timeline outline and bootstrap alongside the existing thread/queue/pending/prompt/default-option invalidations.
Verification
pnpm exec turbo run test --filter=@bb/app -- query-client.test.ts system-cache-effects.test.ts cache-owner-registry.test.tspnpm exec turbo run typecheck --filter=@bb/app