Overview
Context: SettingsScreen has an auto-sync toggle that runs triggerSync() on a 5-minute Timer. The timer runs continuously regardless of whether the backend is reachable. There is no concept of "just reconnected" — the app doesn't know it was previously disconnected.
This issue adds a simple reconnect-triggered sync: when the app detects the backend has come back online after being unreachable, it triggers a sync immediately (rather than waiting up to 5 minutes for the timer).
What needs to be done
Goal
If the backend was unreachable and then comes back online, the next auto-sync timer tick detects the recovery, syncs immediately, and refreshes the notes list — so the user sees up-to-date content without having to tap "Sync now" manually.
Where to look
app/lib/services/app_state.dart — add _backendReachable, checkBackendHealth()
app/lib/screens/settings_screen.dart — _autoSyncTimer callback
app/lib/services/api_client.dart — ping() method already exists
Edge cases
- The auto-sync toggle is off: no timer runs, so no reconnect-triggered sync either (that's fine — manual sync button still works)
- The backend comes back but WebDAV sync is not configured: trigger
loadNotes() refresh but skip triggerSync()
Testing steps
Related to: #17, #22, #24, #26
Overview
Context:
SettingsScreenhas an auto-sync toggle that runstriggerSync()on a 5-minuteTimer. The timer runs continuously regardless of whether the backend is reachable. There is no concept of "just reconnected" — the app doesn't know it was previously disconnected.This issue adds a simple reconnect-triggered sync: when the app detects the backend has come back online after being unreachable, it triggers a sync immediately (rather than waiting up to 5 minutes for the timer).
What needs to be done
AppState, add a_backendReachableboolean (default:truewhen connected)AppState, add acheckBackendHealth()method that callsApiClient.ping()→GET /healthand updates_backendReachableAppState(anycatchblock), set_backendReachable = falseandnotifyListeners()SettingsScreen._autoSyncTimer), before triggering sync: if_backendReachablewasfalse, callcheckBackendHealth()first — if it passes, set_backendReachable = trueand immediately trigger syncloadNotebooks()andloadNotes()to refresh the UI with any remote changesGoal
If the backend was unreachable and then comes back online, the next auto-sync timer tick detects the recovery, syncs immediately, and refreshes the notes list — so the user sees up-to-date content without having to tap "Sync now" manually.
Where to look
app/lib/services/app_state.dart— add_backendReachable,checkBackendHealth()app/lib/screens/settings_screen.dart—_autoSyncTimercallbackapp/lib/services/api_client.dart—ping()method already existsEdge cases
loadNotes()refresh but skiptriggerSync()Testing steps
_backendReachabletransitions correctly fromfalse→trueby checking that the snackbar from Surface Sync Results in the Flutter UI (Not Just in the Settings Screen) #17 fires after reconnectRelated to: #17, #22, #24, #26