Repository navigation
profiles: remote profile switch from LoopFollow and editing saved profiles - #107
Conversation
Lets LoopFollow switch Loop to a profile saved with the profiles customization. Loop uploads the saved profiles to the Nightscout profile store, lists profile-switch in remoteCommands, and accepts an OTP-protected profile switch command whose fingerprint must match the saved profile it activates. Includes dev (also main) and next-dev patches and variants for remote_carb_edit and remote_window in either order.
profiles now includes the remote profile switch instead of a separate remote_profile customization. The profiles patches without it are archived as *_noremote, so workspaces that have them applied show an update. profiles, remote_carb_edit and remote_window get variants for each other in every order, on dev also together with basal_lock.
Saved profiles can be edited with the Therapy Settings editors without loading them; edits only change the profile file, and editing the active profile offers to load it. Loading a profile saves all four schedules in one settings change with the profile name already set, so stored and uploaded settings never mix two profiles, and the pump completion keeps the view model alive so a written basal schedule is always followed by the settings save.
… is outdated The basal schedule saved on load is the one returned by the pump manager, which carries that pump's time zone. Carb ratio and basal rates are now compared by their entries, like correction range and insulin sensitivity, so a profile is only reported as outdated when its values differ.
TestThis was tested in conjunction with LoopFollow PR 790: Switch Loop profiles from the Loop remote screen It is successful both on the Loop phone alone and in conjunction with the LoopFollow remote command as added by that LoopFollow PR. It does not work with the latest version of LoopWorkspace next-dev, commit 97b2cfc. |
Test✅ successful test on LoopWorkspace main, release v3.14.11. OverviewBecause many patches were touched, need to make sure they all work with LoopWorkspace main (not just that they apply without errors.)
Test all 4Use the Add in Order test below and build to make sure all 4 items work; then continue the test as each is removed
Test orderAdd in order: 13, 14, 16, 17 - make sure all apply and build is successful (✅)
After the removal, ensure clone is clean
|
marionbarker
left a comment
There was a problem hiding this comment.
Approved by test for LoopWorkspace main, v3.14.11
…ions The profile switch command is routed in RemoteDataServicesManager to its own handler in NightscoutService, which skips duplicates, checks expiration and OTP, activates the profile, sends the reply push and posts a note on errors, using the shared OTP secret and used-OTP list. profile-switch is added to remoteCommands at device status upload, next to the commands already listed there. On dev the Profiles screen opens from its own sheet state and the LoopKit project entries sit apart from basal_lock's. profiles, remote_carb_edit, remote_window and basal_lock now apply in any order without variants, so the combined variant patches are removed.
TestNow that the variants that depend on other customizations are removed, this should be much more stable. Test for next-dev will be in the next comment. Test Detailsmain branch, v3.14.11examine main branch for conflicts: ✅ no conflicts found ensure all 4 of the old variants apply and build ✅ all four apply successfully Check that remote profile adjustment works for this build in conjunction with loopandlearn/LoopFollow#790 (comment) ✅ on Loop phone, profile behavior is nominal
Test that remote profiles work from LoopFollow |
TestThis is a test for next-dev, commit 97b2cfc. Only the profiles customization is updated to work with next dev. Test Detailsnext-dev, commitexamine next-dev branch for conflicts: ✅ profiles does not conflict.
✅ successfully apply the customization Check that remote profile adjustment works for this next-dev build in conjunction with loopandlearn/LoopFollow#790 (comment) ✅ on Loop phone, profile behavior is nominal
Test that remote profiles work from LoopFollow I'm going to approve this as is. But I note 2 issues for a later PR, if we decide to make a change.
|
marionbarker
left a comment
There was a problem hiding this comment.
Approve by test.
Thanks for decoupling some customizations.
Adds remote profile switching to the profiles customization, so LoopFollow can switch Loop to a saved profile, and makes saved profiles editable without loading them.
Loop uploads every saved profile to the Nightscout profile store next to Default, re-uploads when a profile is saved, renamed or deleted, and lists profile-switch in loop.testingDetails.remoteCommands. The switch is an OTP-protected remote command that carries a fingerprint of the profile values the caregiver previewed. Loop checks it against the saved profile it is about to activate, then runs the same validation and load as the Profiles screen, so the basal schedule is written to the pump before the settings change. The result goes back through the return push, naming the profile, and a local notification; failures also post a Nightscout note. A pump error or a profile edited after upload leaves the settings unchanged and tells the caregiver why.
The profile switch does not go through the shared remote command code. RemoteDataServicesManager hands profile-switch pushes to a handler in NightscoutService that runs the same steps in the same order (duplicates, expiration, OTP with the shared secret and used-OTP list, action, reply push, note on error), and profile-switch is added to remoteCommands when the device status is uploaded, next to what other customizations list there. Together with keeping the LoopKit project entries and the Profiles sheet on dev apart from basal_lock's, this makes profiles independent of every other customization: profiles, remote_carb_edit, remote_window and basal_lock apply in any order without variant patches and give the same tree, and each can be removed on its own. With remote_window, profile switches keep the caregiver app's expiration and are not listed in the dev command history.
This changes dev_profiles (dev and main 3.14.11) and nextdev_profiles. The previous versions are archived as *_noremote, so workspaces that have them show an update, and dev_profiles_basal_lock is no longer needed. main380 and main382 are unchanged.
Saved profiles can now be edited from the profile detail screen without loading them. The detail screen uses the same tap-to-edit cards as Therapy Settings and opens the same editors, with their guardrail warnings, confirmations and authentication. The editors save to the profile file only; nothing reaches Loop's current settings or the pump until the profile is loaded, and editing the active profile offers to load it. The help texts and the Profile Outdated prompt were updated to match (its buttons are now Save Current Settings and Keep Saved Profile).
Loading a profile saves all four schedules in one settings change with the name set first, so Nightscout only gets complete profile documents, and the pump completion keeps the view model alive so a basal schedule written to the pump is always followed by the settings save.
LoopFollow side: loopandlearn/LoopFollow#790
To test: