Skip to content

Keep active thread state consistent after browser resume#439

Open
ymichael wants to merge 1 commit into
mainfrom
bb/investigate-queued-messages-refresh-after-phone-thr_4wdjts4x3k
Open

Keep active thread state consistent after browser resume#439
ymichael wants to merge 1 commit into
mainfrom
bb/investigate-queued-messages-refresh-after-phone-thr_4wdjts4x3k

Conversation

@ymichael

@ymichael ymichael commented Jun 28, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add an active-thread lifecycle cache owner that invalidates the active thread bundle after real browser suspend/resume signals.
  • Wire pagehide/hidden visibility to mark suspend and cancel active fetches; wire pageshow, visible visibilitychange, and focus to one deduped active-thread catch-up.
  • Extend websocket reconnect catch-up to include thread conversation outline and thread detail bootstrap, matching the active thread bundle.

Active Thread Bundle

The browser-resume path refreshes the currently observed thread IDs across:

  • thread detail
  • thread detail bootstrap
  • thread default execution options
  • queued messages
  • prompt history
  • pending interactions
  • timeline
  • conversation outline

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.ts
  • pnpm exec turbo run typecheck --filter=@bb/app

@ymichael ymichael force-pushed the bb/investigate-queued-messages-refresh-after-phone-thr_4wdjts4x3k branch from ef88e15 to 6b35074 Compare June 29, 2026 02:20
@ymichael ymichael changed the title Fix queued message refresh on mobile resume Keep active thread state consistent after browser resume Jun 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant