Skip to content

Keep Offline Mode pings when a radio drop ends the drive - #40

Merged
MrAlders0n merged 1 commit into
devfrom
fix/offline-save-on-ble-drop
Oct 19, 2026
Merged

MrAlders0n merged 1 commit into
devfrom
fix/offline-save-on-ble-drop

Conversation

@MrAlders0n

@MrAlders0n MrAlders0n commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two gaps let an Offline Mode drive appear in Session History with no offline file to upload. They came up while looking into MeshMapper/MeshMapper_Project#605 ("Data not uploading": a drive in History, nothing on the map, nothing in offline records).

These may not be what hit that reporter. The app also saves an offline snapshot whenever it is backgrounded or the screen locks, so both gaps only lose pings if the app dies (a crash, for example) before that snapshot runs. We still need the reporter's History card (date, time, mode name) to say which way their drive went.

What changed

  • A radio drop that ends the drive now saves the offline pings.
    • When a reconnect gives up, _fullDisconnectCleanupImpl stored the Session History entry and cleared the queue but never called _saveOfflineSession(). The pings stayed only in memory, which every app launch clears.
    • It now saves them before clearing the queue, the same way the Disconnect button already does.
    • The connection is already gone on that path, so the save falls back to the remembered radio config (_lastRadioConfig) and device name (_displayDeviceName). Without that, the file would lack the device and radio details its upload uses.
  • The 60 s auto-save now runs for the whole Offline Mode stint.
    • _saveOfflineSession() used to stop it, and only toggling Offline Mode restarted it. After the first stop, disconnect or failed switch to online, every later connect or mode start ran without an auto-save.
    • It now stops only when Offline Mode is turned off, or when the switch back to online succeeds.
  • DEVELOPMENT.md, Offline Mode: a note on when pings are written to the file.

Testing

  • flutter analyze: no issues.
  • flutter test: all passed (2536, 1 skipped).
  • No unit test covers this. AppStateProvider is never constructed in tests, and the change lives in its teardown wiring.
  • Device check owed, on Android:
    • Offline Mode, Passive, then switch the radio off and keep the app on screen until the reconnect gives up. The log should show [APP] Saved offline session with N pings straight after the cleanup, and the drive should already be in Settings > Data without leaving the app. Leaving the app first would hide the bug, because the background snapshot saves the pings anyway.
    • Offline Mode, run, stop, then start again for more than a minute. The log should show [OFFLINE] Updated session lines during the second run.

The cleanup after an abandoned reconnect stored the Session History entry but never wrote the offline pings, so a drive could sit in History with no offline file. It now saves them the way Disconnect does, using the remembered radio config and device name since the connection is already gone.

A save also stopped the 60 s auto-save, and only toggling Offline Mode restarted it, so every later connect or mode start in the same Offline Mode stint ran without one. The auto-save now runs until Offline Mode is turned off.
@MrAlders0n
MrAlders0n merged commit 0308a31 into dev Oct 19, 2026
1 of 2 checks passed
@MrAlders0n
MrAlders0n deleted the fix/offline-save-on-ble-drop branch October 19, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant