Repository navigation
Conversation
This was referenced Nov 19, 2026
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.
A remote command can arrive minutes after it was sent. If someone gave a bolus or entered carbs on the phone in the meantime, the command can double the treatment. Today Loop only accepts a command for about a minute, which makes commands fail on a slow network.
With this change Loop refuses a remote bolus if insulin the sender could not have seen adds up to 20 % or more of the requested amount, and refuses carbs if any carb entry was added that the sender had not seen. The command is never changed: it runs as sent or is refused with a reason. LoopFollow sends the Nightscout id of the newest treatment it had, so Loop can tell what the sender had seen. Because of this, commands are now accepted for 12 minutes. The careportal keeps its 5 minutes. The same change is open for Trio in nightscout/Trio#1789.
Many people use the remote_window customization today to get a longer window. It reduces the bolus by every bolus from the last 10 minutes, also the ones the sender already saw, so the caregiver can get less insulin than they decided on. It also refuses carbs after any recent carb entry and has to be kept up to date with every Loop change. I look forward to retiring it.
Older LoopFollow versions keep working with this Loop. They send no Nightscout id and set a 5-minute expiration, so their commands are accepted for 5 minutes and only treatments dated after the send time count. A treatment added just before the command was sent, that LoopFollow had not fetched yet, is not caught. A new LoopFollow with an older Loop works as today, since older Loop ignores the new fields.
LoopCaregiver sends its commands through Nightscout, the same way as the careportal. Nightscout sets the send time and a 5-minute expiration, so LoopCaregiver keeps working without changes: its commands are accepted for 5 minutes and only treatments dated after the send time count. To get the full check, LoopCaregiver would need to send the newest Nightscout id it had, and Nightscout would need to pass it on to Loop. If there is interest, I'm happy to open PRs for that.
Tested on an iPhone with a simulated pump, LoopFollow on a second phone, real push notifications and a test Nightscout. All passed:
This branch builds the whole feature; the submodules point at the PR commits and need re-pinning once those are merged. PRs: LoopKit/LoopKit#704, LoopKit/NightscoutService#54 and LoopKit/NightscoutService#53, LoopKit/Loop#2692 and LoopKit/Loop#2691. LoopFollow: loopandlearn/LoopFollow#842.