From 9500435f2031ffbb6e13b6fc4eb59d99784374a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bj=C3=B6rkert?= Date: Fri, 3 Jul 2026 19:24:47 +0200 Subject: [PATCH] Upload bolus origin for user-initiated boluses Resolve the origin the app recorded for a bolus (via LoopKit's BolusOriginStore, keyed by the dose's syncIdentifier) and upload it as bolusOrigin, with a readable note so it shows in the Nightscout UI. Automatic boluses are unaffected. --- NightscoutServiceKit/Extensions/DoseEntry.swift | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/NightscoutServiceKit/Extensions/DoseEntry.swift b/NightscoutServiceKit/Extensions/DoseEntry.swift index c7bea8c..f8e43c8 100644 --- a/NightscoutServiceKit/Extensions/DoseEntry.swift +++ b/NightscoutServiceKit/Extensions/DoseEntry.swift @@ -18,6 +18,11 @@ extension DoseEntry { case .basal: return nil case .bolus: + // Non-automatic boluses may carry a finer origin (remote/watch/manual/shortcut), recorded by the + // app against the dose's syncIdentifier. Automatic boluses are already distinguished by `automatic`. + // `notes` carries the human-readable label so it shows in the Nightscout UI; `bolusOrigin` is the + // stable machine token. + let origin = syncIdentifier.flatMap { BolusOriginStore.shared.origin(forSyncIdentifier: $0) } return BolusNightscoutTreatment( timestamp: startDate, enteredBy: source, @@ -27,9 +32,11 @@ extension DoseEntry { unabsorbed: 0, // The pump's reported IOB isn't relevant, nor stored duration: duration, automatic: automatic ?? false, + notes: origin?.displayName, /* id: objectId, */ /// Specifying _id only works when doing a put (modify); all dose uploads are currently posting so they can be either create or update syncIdentifier: syncIdentifier, - insulinType: insulinType?.brandName + insulinType: insulinType?.brandName, + bolusOrigin: origin?.rawValue ) case .resume: return nil