Skip to content

Backup: carry the preferences that hold the user's data; repair Drinks after a restore - #49

Merged
gabrielbr merged 1 commit into
mainfrom
ccr-67ccb970-dqwwqd
Oct 30, 2026
Merged

gabrielbr merged 1 commit into
mainfrom
ccr-67ccb970-dqwwqd

Conversation

@gabrielbr

Copy link
Copy Markdown
Owner

After moving to a new phone, drinks looked lost after a restore.

Cause. The drink entries were in the archive and were restored. But Drinks' on/off switch is a SharedPreferences value that defaults to off, and allowBackup is false. So on the new phone every drinks surface hid itself. The plan (weekly limit, dry days, standard-drink size), the start date and the AUDIT-C result were lost outright.

Audit of the archive.

  • Every Room table is carried except body_measurements and findings. Both are deliberate and documented: Health Connect re-imports the first, and the second is recomputed.
  • The gap was preferences only.

Fix

  • ArchivedSettings: an allowlist of preference files written into the archive (new settings field) and restored after the database. Manual export, auto backup and restore all use it. It carries:
    • drinks, all of it;
    • postpartum, the life stage (the EPDS answers stay excluded, per the existing rule);
    • mindful_sessions (breathing sessions);
    • step_calibration, minus the raw phone step counter;
    • activity_detection (detections already answered);
    • rest_mode.
      Device state stays out: ring pairing, Health Connect grants and watermarks, notification scheduling, algorithm and scoring versions.
  • DrinkPrefs.adoptRestoredHistory: drinks present but Drinks never switched on here (no start date) only happens after such a restore. It switches Drinks on, with its start on the first logged evening. It runs after every restore and on every app start, so a phone already restored recovers on update. A user who switched Drinks off keeps it off: switching off keeps the start date, so the condition doesn't match.
  • AGENTS.md records the rule for future preferences.

Archives from before this change have no settings and still restore. No UI change, so no design-file update.

CI green on 56a3af9. Not tried on a device.


Generated by Claude Code

…s after a restore

The archive carried drink entries, but Drinks' on/off switch is a
SharedPreferences value that defaults to off, and allowBackup is false,
so after moving phones every drinks surface hid itself and the history
looked lost. The plan, start date and AUDIT-C result were lost outright.

- ArchivedSettings: an allowlist of preference files written into the
  archive (new 'settings' field) and restored after the database:
  drinks, postpartum life stage (EPDS answers excluded, as before),
  breathing sessions, step calibration (not the raw counter), answered
  detections, Rest Mode. Manual export, auto backup and restore use it.
- DrinkPrefs.adoptRestoredHistory: drinks present but Drinks never
  switched on here only happens after such a restore; switch it on with
  its start on the first logged evening. Runs after every restore and
  once per app start, so phones already restored recover on update.
- AGENTS.md: the rule for future preferences.

Claude-Session: https://claude.ai/code/session_01P1t1aUqSUPd3whKXmgVm7w
@gabrielbr
gabrielbr merged commit bf6932f into main Oct 30, 2026
2 checks passed
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.

2 participants