screen-locker/stronglift_replacement/workout_app/test
Krzysztof kuhy Rudnicki 65380df425 Mirror the in-progress session so an app-data wipe can't lose your set
The active session (which set you are on, and the reps done so far) lived
only in app-private SQLite. An uninstall — or `pm clear`, which sounds
harmless and is not — wipes that, so a user standing mid-workout loses the
exact set and rep they were on. `backup.json` did not help: it mirrors only
COMPLETED history. This is not hypothetical; it happened, mid-workout, and
the state had to be re-entered by hand.

Persistence granularity was already right (saveActiveSession fires on every
set tap, untap, warmup and break change, storing `tapped` + `doneReps`).
Only the LOCATION was wrong, so this mirrors it the same way the sync token
already is:

- BackupService.exportActiveSession/readActiveSession keep
  /sdcard/WorkoutTracker/active_session.json; a null export clears it.
- StorageService.saveActiveSession mirrors on every write;
  loadActiveSession falls back to the mirror and re-seeds the table when it
  is empty — exactly the state after a wipe; clearActiveSession clears the
  mirror too, so a finished workout is never resurrected.
- Both reads are defensive: a truncated/non-object mirror (battery death
  mid-set) is ignored rather than bricking the resume.

Tested by simulating the wipe in the suite (resetForTesting + fresh init
with the mirror intact), not on a real device holding real data.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fv8ULVt3Q67GwCFbM7doHB
2026-07-17 09:57:54 +02:00
..
models Support multiple workouts per day; fix the dead sync; ban silent failures 2026-07-17 09:22:31 +02:00
screens Recover the sync token from backup when the stored one is rejected 2026-07-17 09:45:12 +02:00
services Mirror the in-progress session so an app-data wipe can't lose your set 2026-07-17 09:57:54 +02:00
widgets Add phone-workout GitHub sync via shared crdt_sync (Workstream C) 2026-07-11 00:06:59 +02:00
fake_audio_platform.dart Add phone-workout GitHub sync via shared crdt_sync (Workstream C) 2026-07-11 00:06:59 +02:00
fake_secure_storage.dart Add phone-workout GitHub sync via shared crdt_sync (Workstream C) 2026-07-11 00:06:59 +02:00
widget_test.dart Cover services + app bootstrap toward 100% flutter coverage 2026-07-13 13:27:18 +02:00