fix(ui): refresh all rooms after PC suspension to catch missed updates #75
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
When a user's PC suspends and resumes, River UI may miss contract updates that arrived while the page was hidden or the machine was suspended. The user would open River expecting to see recent messages but find stale state until they took an action (like sending a message) that triggered a state refresh.
Root cause: The
PageBecameVisiblehandler (triggered by the browser's visibility change event) only calledProcessRoomswhich handles pending local changes but doesn't explicitly fetch the latest network state for all rooms.User impact: After PC wake from suspension, users see outdated chat messages and miss recent activity.
Approach
Add a new
RefreshAllRoomsmechanism that explicitly fetches current state for all subscribed rooms after wake:SynchronizerMessage::RefreshAllRooms- Message type to trigger refreshRoomSynchronizer::refresh_all_rooms()- Sends GET requests for all known room contractsPageBecameVisiblehandler - Now triggersRefreshAllRoomsinstead of justProcessRoomsThe GET requests fetch current contract state from the network, which is then merged with local state via the existing response handling, catching any updates missed during suspension.
Why this approach vs alternatives:
ProcessRoomsdirectly, but that would add overhead to every sync cycleTesting
cargo check -p river-uiandcargo test -p river-coreAdditional Changes
Also fixes a pre-existing compilation error in
example_data.rswhereConfiguration.namewas accessed directly instead of through the newConfiguration.display.namepath introduced in a recent refactor.[AI-assisted - Claude]