Overview
Context: Once the Flutter app connects to the backend on startup, it assumes the connection stays alive forever. There is no check when the user switches away from the app and returns. If the Python backend was restarted or the machine went to sleep in the meantime, the next API call fails unexpectedly.
This issue adds a lightweight health check whenever the app resumes from background.
What needs to be done
Goal
When the user comes back to the app after switching away, the app silently checks that the backend is still running and refreshes the notes list if needed — so the user always sees current data.
Where to look
app/lib/screens/home_screen.dart — add WidgetsBindingObserver here
app/lib/services/app_state.dart — loadNotes(), add _lastRefreshed timestamp
app/lib/services/api_client.dart — ping() method
Implementation hint
class _HomeScreenState extends State<HomeScreen> with WidgetsBindingObserver {
@override
void initState() {
super.initState();
WidgetsBinding.instance.addObserver(this);
}
@override
void dispose() {
WidgetsBinding.instance.removeObserver(this);
super.dispose();
}
@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
// run health check + optional refresh
}
}
}
Testing steps
Notes
This is a good first issue. It's a small, self-contained change in home_screen.dart that uses a standard Flutter lifecycle API. The full offline/reconnect logic is tracked in #22 and #23.
Related to: #22, #23, #26
Overview
Context: Once the Flutter app connects to the backend on startup, it assumes the connection stays alive forever. There is no check when the user switches away from the app and returns. If the Python backend was restarted or the machine went to sleep in the meantime, the next API call fails unexpectedly.
This issue adds a lightweight health check whenever the app resumes from background.
What needs to be done
HomeScreen(ormain.dart), add aWidgetsBindingObserverand overridedidChangeAppLifecycleState()AppLifecycleState.resumedis triggered, callAppState.checkBackendHealth()(to be added as part of Trigger a Sync Automatically When the App Reconnects to the Backend #23, or add it here first as a simpleping()call)AppState.loadNotes()to pull fresh dataGoal
When the user comes back to the app after switching away, the app silently checks that the backend is still running and refreshes the notes list if needed — so the user always sees current data.
Where to look
app/lib/screens/home_screen.dart— addWidgetsBindingObserverhereapp/lib/services/app_state.dart—loadNotes(), add_lastRefreshedtimestampapp/lib/services/api_client.dart—ping()methodImplementation hint
Testing steps
Notes
Related to: #22, #23, #26