Skip to content

Tag bolus origin and show it in Nightscout#1252

Open
bjorkert wants to merge 7 commits into
nightscout:devfrom
bjorkert:feature/bolus-origin
Open

Tag bolus origin and show it in Nightscout#1252
bjorkert wants to merge 7 commits into
nightscout:devfrom
bjorkert:feature/bolus-origin

Conversation

@bjorkert

@bjorkert bjorkert commented Jul 1, 2026

Copy link
Copy Markdown
Member

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.

bjorkert added 2 commits July 1, 2026 11:50
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 added 3 commits July 1, 2026 15:11
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.
bjorkert and others added 2 commits July 1, 2026 20:24
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.
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