fix: skip sync when the OS reports disconnected - #5694
Open
haydenholligan wants to merge 2 commits into
Open
haydenholligan wants to merge 2 commits into
haydenholligan wants to merge 2 commits into
Conversation
Initialize Qt's native network information backend and use definite offline status to skip automatic collection and media sync. Manual collection sync shows the existing offline message immediately. Allow requests when network status is unknown or a custom sync server is configured. Keep the existing background status calculation so locally pending changes continue to update the sync indicator while offline. Cover offline callbacks, manual sync, reconnection, unsupported reachability, custom servers, media sync, and pending local status updates in Qt tests. Validation: just test-py and just check. The pending-status regression tests fail with the removed guard and pass without it. A prior physical Wi-Fi-off A/B test reproduced a 45-second stock wait and an immediate offline response from the patched manual handler using disposable profiles.
This branch has not been deployed
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.
Linked issue (required)
Closes #5693
Summary / motivation (required)
Prevent an intermittent long sync wait after losing connectivity. Use Qt's cached native network status to skip collection and media sync when the OS reports Disconnected. Manual Sync shows Anki's existing translated warning dialog; automatic startup/shutdown sync skips silently.
Steps to reproduce (required, use N/A if not applicable)
This is conditional: our first request after disconnection took 45–51 seconds, while cold-start and later offline attempts could fail immediately.
How to test (required)
Checklist (minimum)
./ninja checkor an equivalent relevant check locally.Details
just test-pypassed before rebasing;just checkpassed again after rebasing onto main. The check used Anki's local contributor-email allowlist.Before / after behavior (optional)
Before: attempts sync while offline; failure can be immediate or delayed.
After: definite offline status prevents the request and gives immediate manual feedback.
Risk / compatibility / migration (optional)
Native reachability is advisory and may be inaccurate. Unknown/unavailable status and custom sync servers retain normal behavior. Background sync-status checks remain unchanged. This does not shorten timeouts while reported online, cancel an in-flight sync, or force collection sync on reconnection.
UI evidence (required for visual changes; otherwise N/A)
Stock waited 45.8 seconds; the patched handler returned in 0.4 seconds with the standard warning dialog and no sync request. Recorded from real app frames on the release-based revision before rebase; both patches were unchanged by rebase. GIF playback is 4x; captions show measured real timings. This demonstrates the intermittent delay after an online request followed by disconnection, not every offline attempt.
Scope