Tag bolus origin and show it in Nightscout#1252
Open
bjorkert wants to merge 7 commits into
Open
Conversation
Record where each user-initiated bolus came from (remote command, Apple Watch, manual UI, Siri shortcut) by passing an opaque reference through the pump and resolving it back to an origin when the delivered dose is reported. The origin is written to the pump event note and uploaded as the Nightscout treatment note, so these boluses are no longer indistinguishable from one another. SMB is left untagged as it is already labelled via its event type. Point the LoopKit and OmnipodKit submodules at the forks carrying the bolusReference plumbing.
Switch the bolus reference to a UUID end-to-end, and upload the origin as two Nightscout fields: the existing human-readable note plus a new machine-readable bolusOrigin (smb/remote/watch/manual/shortcut) stored on BolusStored, so the typed value stays stable if the note is localized later. SMB is derived from the dose; user origins are resolved from the echoed reference. Bump the LoopKit and OmnipodKit submodules to the matching UUID commits.
bjorkert
requested review from
AndreasStokholm,
MikePlante1,
Sjoerd-Bo3,
bjornoleh,
dnzxy,
kingst,
marionbarker,
marv-out and
t1dude
as code owners
July 1, 2026 11:55
This was referenced Jul 1, 2026
Drop Trio's own bolus origin store and its dependency injection in favour of the shared store in LoopKit, so Trio and Loop use the same implementation. The BolusOrigin enum stays app-side (Trio has smb and shortcut cases that Loop does not); only the store mechanism is shared. Trio resolves the origin directly by reference at store time, so no syncIdentifier promotion is needed. Bump the LoopKit submodule to the commit adding the store.
Delete Trio's app-level BolusOrigin in favour of the shared one in LoopKit, and drop the .smb origin — an SMB is already conveyed by isSMB and the SMB event type, so bolusOrigin now only carries the finer user origins. Bump the LoopKit submodule to the commit adding the shared enum.
Build/test against LoopKit/LoopKit#594 directly (the change is being landed upstream rather than in loopandlearn/LoopKit). Trio builds cleanly against pure upstream LoopKit. Do not merge before repointing this submodule back at a loopandlearn/LoopKit commit that carries the change.
This was referenced Jul 1, 2026
Move to loopandlearn/OmnipodKit dev (loopandlearn/OmnipodKit#102) so Loop and Trio build against the same OmnipodKit commit. Trio builds cleanly against it. Do not merge before repointing this submodule back at a merged loopandlearn/OmnipodKit commit.
Callers now hand APSManager a BolusOrigin and the manager mints the correlation reference once the command actually goes to the pump, so early returns cannot leave orphaned mappings behind. Consume the origin mapping only after the Core Data save succeeds, so a failed save keeps it resolvable when the pump re-delivers the events. Point LoopKit at the hardened store (public test init, logging) and rewrite the store tests against temporary files, covering promotion, persistence, expiry and a corrupt file.
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.
Tags remote, watch, manual and shortcut boluses with their origin using the LoopKit bolusReference, and shows it in Nightscout as a plain note plus a machine-readable bolusOrigin field. SMB is left as is since it already shows as SMB.
Needs LoopKit/LoopKit#594 and loopandlearn/OmnipodKit#102.
While building/testing, the LoopKit and OmnipodKit submodules point at bjorkert branches (the #594 and #102 branches). Repoint them at merged loopandlearn commits before merging.
The Loop side uses the same shared kit changes: LoopKit/Loop#2455, LoopKit/NightscoutKit#3, LoopKit/NightscoutService#27.