Network state awareness: don't bounce to login when offline and distingush between Network Offline and Server Unavailable#89
Merged
Conversation
…pill Cold-launching with no connectivity used to bounce to the login screen because `AuthenticationService.restoreSession()` returned nil for both "no saved session" and "buildClient failed." Now those are distinguished via a new `RestoreOutcome` enum. When a saved session exists but the homeserver is unreachable, we keep the user logged in, flip `syncState` to `.offline` to surface the banner, and ask `SyncManager` to retry the full restore on the next reconnect. Network-shaped SDK errors are classified by typed pattern-match (`ClientBuildError.ServerUnreachable` / `WellKnownLookupFailed`, `ClientError.MatrixApi(.connectionFailed / .connectionTimeout)`) — no string sniffing. Runtime sync failures of those shapes drop to `.offline` instead of the terminal `.error` state and retry with truncated binary exponential backoff (Ethernet-style, randomized to avoid thundering-herd reconnects). The bottom-of-sidebar banner now disambiguates the two cases: "Network Offline" with the wifi-slash glyph when `NWPathMonitor` reports no path, and "Server Unreachable" with an `xserve` glyph plus a caution-triangle badge when the radio is up but the homeserver isn't responding. Note: this commit fixes the login-bounce regression but doesn't yet populate the timeline with cached messages during an offline cold- start — that requires the SDK client itself to build successfully offline, which is a separate change. Co-Authored-By: Claude Opus 4.7 <[email protected]>
subpop
approved these changes
May 9, 2026
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.
Summary
Addresses #87
Cold-launching with no connectivity used to bounce to the login screen because
AuthenticationService.restoreSession()returnednilfor both "no saved session" and "buildClient failed." This branch distinguishes the two and surfaces an offline state in the sidebar instead.RestoreOutcomeenum onAuthenticationService:.noSavedSession/.restored/.offlineWithSavedSession/.failed.syncStateto.offline, and askSyncManagerto retry the full restore on the next reconnect.NetworkErrorClassifier—ClientBuildError.{ServerUnreachable, WellKnownLookupFailed}andClientError.MatrixApi(.connectionFailed / .connectionTimeout). No string sniffing..offlineinstead of the terminal.errorstate and retry with truncated binary exponential backoff (Ethernet-style, base 1 s, cap 2⁶ slots, randomized to avoid thundering-herd reconnects).wifi.slashglyph whenNWPathMonitorreports no path.xserveglyph + caution-triangle badge when the radio is up but the homeserver isn't responding.Out of scope
This commit fixes the login-bounce regression but doesn't yet populate the timeline with cached messages during an offline cold-start — that requires the SDK client itself to build successfully without contacting the homeserver, which is its own investigation. For now the offline-restored state shows MainView with empty rooms until connectivity returns.
Test plan
🤖 Generated with Claude Code