Skip to content

Add settings import with JSON backup export - #82

Open
Sjoerd-Bo3 wants to merge 4 commits into
Build-Experimentfrom
claude/settings-import-akd28q
Open

Add settings import with JSON backup export#82
Sjoerd-Bo3 wants to merge 4 commits into
Build-Experimentfrom
claude/settings-import-akd28q

Conversation

@Sjoerd-Bo3

Copy link
Copy Markdown
Owner

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.

Claude-Session: https://claude.ai/code/session_01Y9XRFomNerbiR4p6D8T7hh

claude and others added 4 commits August 22, 2026 10:22
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
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