Skip to content

Bump LoopKit, Loop, NightscoutKit, NightscoutService, LoopOnboarding and TidepoolService for therapy profiles - #583

Open
bjorkert wants to merge 4 commits into
LoopKit:next-devfrom
bjorkert:therapy-profiles
Open

bjorkert wants to merge 4 commits into
LoopKit:next-devfrom
bjorkert:therapy-profiles

Conversation

@bjorkert

@bjorkert bjorkert commented Nov 11, 2026 •

Copy link
Copy Markdown

Therapy profiles are named sets of the four therapy schedules (correction range, carb ratios, basal rates and insulin sensitivities) that the user can switch between. They are stored in StoredSettings together with the name of the active profile, so every settings record says which profiles existed and which one was in use. Default always exists and onboarding is unchanged. Editing therapy settings edits the active profile, and the editors say which profile that is. The status screen shows the active profile.

A switch validates the profile against the guardrails and the pump, writes the basal schedule to the pump and then stores the schedules and the active name in one settings change. If the pump write fails nothing changes, and a switch is refused while delivery is suspended. A profile can also be switched to automatically at a weekly start time. That switch is the same validated switch: it waits for a running bolus, retries while delivery is suspended, alerts after 30 minutes and tells the user when it has run.

NightscoutService uploads every profile in one profile document with the active one as defaultProfile, and records each switch as a Profile Switch treatment. TidepoolService sends the profiles as named pump settings schedules. Onboarding can restore all profiles from Nightscout, including a document written by Trio.

Remote switch, save and delete of profiles, and replacing the scheduled starts, are new remote actions with OTP and a required expiration. A save or delete carries a fingerprint of the profile the caregiver saw, so an outdated copy is refused. The active profile and Default can never be deleted. LoopFollow uses these (loopandlearn/LoopFollow#833).

User stories: school days versus weekends, training days, the days before a period, and a sick-day set.

Tested in the simulator and on an iPhone XS Max with Omnipod DASH (a water-filled pod, not on a body), with LoopFollow on a second phone over real APNs. Not tested with other pumps or in daily use.

This branch builds the whole feature; the submodules and the NightscoutKit pin point at the PR commits and need re-pinning once those are merged. PRs: NightscoutKit LoopKit/NightscoutKit#7, LoopKit LoopKit/LoopKit#698, Loop LoopKit/Loop#2680, NightscoutService LoopKit/NightscoutService#48 (and LoopKit/NightscoutService#47 for dev), LoopOnboarding LoopKit/LoopOnboarding#41, TidepoolService LoopKit/TidepoolService#50.

Screenshots and recordings from the simulator with invented data.

01-profile-list
Profiles with scheduled switches
02-profile-detail-weekend
Profile detail
03-profile-detail-actions
Activate, rename, delete
04-switch-confirmation
Switch confirmation
05-create-profile-name
New profile
06-delete-confirmation
Delete confirmation
07-validation-duplicate-name
Name validation
08-status-active-profile-row
Status screen: active profile
08b-status-row-with-schedule
Status row with next scheduled start
09-therapy-settings-banner-weekend
Therapy Settings editing a profile
10-scheduled-switches-list
Scheduled switches
11-scheduled-switch-start-editor
Start editor
12-refused-while-suspended
Refused while suspended
13-remote-command-notification
Remote command notification

Create a profile, switch to it, edit it with the banner

V3-loop-create-switch-edit.mp4

@bjorkert

bjorkert commented Nov 12, 2026 •

Copy link
Copy Markdown
Author

Testing so far, for reviewers.

On real phones. Loop ran on an iPhone XS Max with an Omnipod DASH pod. The pod was filled with water and lay on the table, not on a body. LoopFollow ran on a second iPhone, over real APNs, against a test Nightscout.

  • Creating a profile and switching to it. The pod gets the new basal schedule, and the status screen shows the profile.
  • Editing the active profile. The banner names the profile, and the new basal reaches the pod.
  • A switch is refused while the pod is suspended, and the pod stays suspended.
  • A scheduled start runs on the next loop cycle, with one "Scheduled" Profile Switch in Nightscout.
  • A scheduled start while the pod is suspended retries and alerts after 30 minutes. It switches once delivery resumes.
  • A scheduled start during a 1 U bolus waits until the bolus is done, and the bolus is delivered in full.
  • A paused start does not run, and resuming it does not catch up.
  • A start missed while Loop was not running runs on the next launch.
  • From LoopFollow:
    • switch, create, edit of the active profile, rename and delete;
    • deleting the active profile or Default is refused;
    • the scheduled-start editor (add, pause, resume, delete);
    • a conflict after a change on the phone, and a missing profile.
    • Loop shows a notification for each remote command.
  • Downgrade to plain next-dev with the pod running. The active profile's values stay in use and the pod's schedule is unchanged; the other profiles are gone.
  • Upgrade from Loop dev with the Profile Save & Load customization. The values in use become Default, and the customization's profiles are not carried over.
  • Switching the glucose unit between mg/dL and mmol/L (Health app). Profiles keep their values and no Profile Switch is recorded. An edit sent from LoopFollow before the switch is applied correctly.
  • A remote save keeps every glucose value that comes back unchanged exactly as stored. This was checked with LoopFollow changing only the carb ratio, and then only the high bound.
  • Each schedule editor opened from a profile's detail closes after Save and after Cancel, in both units.

In the simulator.

  • Unit tests in LoopKit, Loop, NightscoutService and TidepoolService. They include the review fixes: an active profile that can't be read is stored again from the live settings and Default keeps its values, and TherapySettings decodes profiles lossily.
  • End to end against a mock Nightscout and against Nightscout 15.0.9:
    • upload of all profiles and Profile Switch treatments;
    • restore during onboarding, including a document written by Trio.
  • Upgrade and downgrade between next-dev and dev.

Not tested yet: other pumps (Medtronic, Dana, Medtrum), and use over several days.

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