Add settings import with JSON backup export - #82
Open
Sjoerd-Bo3 wants to merge 4 commits into
Open
Conversation
Export now writes a machine-readable, schema-versioned JSON backup (SettingsBackup) alongside the existing CSV report, shared together via one share sheet. Credentials (Nightscout URL/secret, remote control secret) and pump/CGM pairing state are included only behind separate opt-in toggles, and the filename gains a _sensitive suffix when either is on. New Settings > Trio Backup > Import Settings flow reads the JSON: - file picker -> validation -> change overview (per category, per setting: current vs imported, unit-aware) -> destructive confirmation -> guardrail-clamped apply -> results with warnings - guardrails resolve from PickerSettingsProvider (single source of truth); basal rates snap to pump-supported rates - therapy schedules validate (positive values, mg/dL sanity, 30-minute grid, first entry at midnight) and sync to the pump before persisting - presets import with a conflict strategy (replace same-named default); running presets are never touched - closed loop mode and bolus increment are never imported - optional pump/CGM pairing restore for phone migration, behind an extra confirmation Onboarding gains a Trio Backup step that prefills all onboarding editors from a backup file (user still reviews every screen) and applies the remaining categories when onboarding completes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9XRFomNerbiR4p6D8T7hh
- SettingsBackupCodableTests: encode/decode round trip, partial and future-schema backups, strict schemaVersion rejection, manager-state base64 plist round trip - SettingsImportApplierTests: mapping totality (every TrioSettings/ Preferences field mapped or explicitly excluded - fails when a new field ships uncategorized), exclusions, guardrail clamping with warnings, category filtering, diff/apply parity, therapy validation and normalization, pump-rate snapping, preset conflict strategies - SettingsImportPresetTests: all conflict strategies against in-memory Core Data, running-preset protection, override attribute fidelity - SettingsBackupE2ETests: full backup -> JSON -> decode -> merge -> real FileStorage/SettingsManager/Core Data -> read-back equality, plus partial-category isolation - Remove dead SettingsExportTests.swift (was never in the test target and referenced since-moved types) - Register the new test files in the TrioTests target Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9XRFomNerbiR4p6D8T7hh
Swift cannot synthesize Equatable in an extension outside the type's declaring file, so the therapy container/entry types and PumpSettings get explicit == implementations. Surfaced by the first real (Xcode Cloud) build of this feature on Build-Experiment. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y9XRFomNerbiR4p6D8T7hh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Export now writes a machine-readable, schema-versioned JSON backup (SettingsBackup) alongside the existing CSV report, shared together via one share sheet. Credentials (Nightscout URL/secret, remote control secret) and pump/CGM pairing state are included only behind separate opt-in toggles, and the filename gains a _sensitive suffix when either is on.
New Settings > Trio Backup > Import Settings flow reads the JSON:
Onboarding gains a Trio Backup step that prefills all onboarding editors from a backup file (user still reviews every screen) and applies the remaining categories when onboarding completes.
Claude-Session: https://claude.ai/code/session_01Y9XRFomNerbiR4p6D8T7hh