Repository navigation
Conversation
When the browser tab is hidden on mobile (user switches to another app), the OS may suspend it to save memory. When the user returns, the tab shows stale state because events were missed while suspended. Add a visibilitychange listener that tracks when the tab was hidden. When it becomes visible again after >2 seconds, refetch the bootstrap data to ensure the UI reflects the latest server state. Fixes mobile state-loss bug where users had to manually reload the page after switching back from another app.
Contributor
|
This PR doesn't fully meet our contributing guidelines and PR template. What needs to be fixed:
Please edit this PR description to address the above within 2 hours, or it will be automatically closed. If you believe this was flagged incorrectly, please let a maintainer know. |
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Author
|
Closing - not ready for review yet, using for CI testing only |
Contributor
|
This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window. Feel free to open a new pull request that follows our guidelines. |
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
On mobile browsers (iOS Safari, Chrome Android), when a user switches from the browser to another app, the OS may suspend or freeze the browser tab to conserve memory. When the user returns to the browser:
This is particularly painful on mobile where tab switching is frequent and users expect apps to stay up-to-date when they return.
Root Cause
The web app maintains a persistent SSE connection to receive real-time updates. When the browser tab is backgrounded:
refetchOnWindowFocus: false(set inQueryProvider), so returning to the tab doesn't trigger any refreshesvisibilitychangehandlers only flush scroll positions or abort stale connections — none refresh dataHow to Reproduce
Solution
Track tab visibility in
ServerSyncContextand trigger a bootstrap refetch when returning from a long suspension.What Changed
File:
packages/app/src/context/server-sync.tsxInside the existing
onMount()hook that starts the SSE event listener, added:Why This Approach
server-sync.tsx, which already owns the bootstrap lifecyclebootstrap.refetch()which already handles refreshing global config, providers, path, and all directory data — no new fetch logic neededonCleanup()so the listener is removed when the component unmountsvoidso the refetch doesn't block other visibility change handlersWhy Not Other Approaches
Trade-offs
bootstrap.refetch()call after a long suspension. Acceptable given the user just returned to the app and expects fresh dataTesting
Manual test on mobile:
bootstrap.refetch()fires (can be confirmed in Network tab or by adding a console log)Desktop verification:
Checklist