fix: recover the streamed reply after Android background/resume#493
Open
X-15 wants to merge 1 commit into
Open
fix: recover the streamed reply after Android background/resume#493X-15 wants to merge 1 commit into
X-15 wants to merge 1 commit into
Conversation
|
Reviews (1): Last reviewed commit: "fix: recover the streamed reply after An..." | Re-trigger Greptile |
6c3b8c8 to
b425402
Compare
On Android the OS suspends the isolate when the app is backgrounded and tears down the TCP connection, but socket.io never processes the disconnect. On resume the socket is often a zombie (connected == true but dead): nothing fires 'disconnect', nothing auto-reconnects, and the connectivity-edge force-reconnect never triggers because the network never actually went offline. Since OpenWebUI streams completions out-of-band over the socket and does not replay missed events, the in-flight reply is lost until a full app restart. Two parts: - socket_service: only a real background->foreground transition (paused/hidden/detached -> resumed) forces a fresh socket and emits a reconnect so streaming recovery polls the server for the missed completion. The transient `inactive` state (notification shade, app switcher, permission/system dialog) is treated as foreground so it no longer tears down a healthy socket on every shade peek. A re-entrancy guard prevents overlapping resume reconnects from orphaning sockets. - app_startup_providers: on resume, re-fetch the open conversation from the server (the source of truth) so a reply that finished in the background appears immediately, with a stale-write guard so a slow fetch cannot overwrite a conversation the user switched to in the meantime. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 Android, backgrounding the app suspends the Flutter isolate and the OS tears down the TCP connection, but
socket.ionever processes the disconnect. On resume the socket is frequently a zombie (connected == truebut dead):disconnect, so there is no auto-reconnect;Since OpenWebUI delivers chat completions out-of-band over the socket and does not replay missed events, a reply that finishes while the app is backgrounded is lost — the user sees nothing until a full app restart.
Fix
socket_service.dart— resume reconnectpaused/hidden/detached→resumed). The transientinactivestate (notification shade, app switcher, permission/system dialog, PiP) is treated as foreground, so a healthy socket is no longer torn down on every shade peek.app_startup_providers.dart— resume re-fetchNotes
🤖 Generated with Claude Code