fix(app): re-fetch visible session messages on foreground resume#1390
Open
jlixfeld wants to merge 1 commit into
Open
fix(app): re-fetch visible session messages on foreground resume#1390jlixfeld wants to merge 1 commit into
jlixfeld wants to merge 1 commit into
Conversation
A backgrounded mobile websocket can silently miss realtime new-message deliveries (the server does not push per-message). On foreground resume the app refreshed global/session-metadata state but never invalidated the currently-open conversation's messages, so the chat stayed stale until the user backed out to the session list and re-entered it. Extract the resume-resync sequence into a dependency-injected helper (resyncOnForeground) and add a per-session invalidation for the visible session via onSessionVisible. Unit-tested in isolation since Sync is an import-time singleton with heavy socket/storage deps. Refs slopus#1308 Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
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
Addresses the app-side half of #1308. When the mobile app is backgrounded/locked, iOS suspends the websocket. The server intentionally does not push a notification for every
new-message, so a suspended socket silently misses realtime message deliveries.On foreground resume, the
AppStateactivehandler refreshed global state and session metadata (sessionsSync) but never invalidated the currently-open conversation's messages. Result: the open chat stays stale until the user backs out to the session list and re-enters it (which firesonSessionVisible). Conversation titles update; the reply body doesn't appear.Fix
Extract the resume-resync sequence into a small dependency-injected helper (
resyncOnForeground) and add a per-session invalidation for the visible session viaonSessionVisible(currentViewingSessionId). Global-sync behavior is unchanged (same syncs, same order); the only new behavior is re-fetching the open session's messages on resume.Test
foregroundResync.test.tscovers the helper in isolation (the regression: resume re-fetches the visible session's messages; no-op when no chat is open). Unit-tested standalone becauseSyncis an import-time singleton with heavy socket/storage deps.Scope
Only the app-side foreground recovery. The server-side push-suppression problem in #1308 (session-scoped CLI sockets counting as active user surfaces) is not touched here.
🤖 Generated with Claude Code