Skip to content

Investigate and Document: What Happens When the Backend Goes Down Mid-Session #22

@TheZupZup

Description

@TheZupZup

Overview

Context: The Flutter app has no local storage — all note data lives in the Python backend's SQLite database. The Flutter app only holds notes in memory (in AppState._notes). There is currently no offline mode.

Before building a proper offline cache (a large task), this issue is about understanding and documenting the current failure modes when the backend becomes unreachable mid-session, and fixing the most dangerous ones.

What needs to be done

Audit (do this first)

  • Kill the Python backend while the Flutter app is open with notes loaded
  • Try each action and document what happens: editing a note, creating a note, deleting a note, tapping sync, navigating between notebooks
  • Note which actions crash the app, which fail silently, and which show an error

Fix the worst failure modes

  • Any API call that throws an unhandled exception and crashes the app → wrap in try/catch in AppState and show a SnackBar instead
  • Auto-save in NoteEditorScreen should catch HTTP errors and show "Save failed — backend unreachable" in the save status indicator (already has a "Saved" / "Saving..." indicator — add a red "Save failed" state)
  • If loadNotes() or loadNotebooks() fails, keep the last successfully loaded data in memory rather than clearing the list

Document the findings

  • Add a comment block in app_state.dart summarising which operations are safe when offline and which are not — this will guide whoever implements true offline caching in the future

Goal

No action the user can take in the app while the backend is down causes a crash or an unhandled exception. All failures are caught and shown as user-readable error messages. The data already loaded in memory remains visible.

Where to look

  • app/lib/services/app_state.dart — all API calls, error handling
  • app/lib/screens/note_editor_screen.dart — auto-save debounce and status indicator
  • app/lib/services/api_client.dart — HTTP calls that can throw

Notes

True offline editing (local SQLite cache in Flutter) is a much larger project and is NOT part of this issue. This issue is purely about graceful degradation.

Related to: #12, #24, #26 | Parent: #17

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions