Skip to content

Show insulin per day since a setup change - #2659

Merged
ps2 merged 2 commits into
next-devfrom
fix/setup-insulin-per-day
Nov 5, 2026
Merged

ps2 merged 2 commits into
next-devfrom
fix/setup-insulin-per-day

Conversation

@ps2

@ps2 ps2 commented Nov 4, 2026 •

Copy link
Copy Markdown
Collaborator

Current Setup always showed "–" for Insulin per Day since the change.

SetupComparison only counts insulin when the dose history reaches the end of the period (end <= history.end). The history ends when it was loaded. The comparison was then made with a fresh now() a moment later, so the "since change" period always ran past the history's end.

CurrentSetupViewModel now takes the time once in load(), before the data loads, and compares against that, also when another change is selected later.

New test testCurrentSetupShowsInsulinPerDaySinceTheChange runs the view model with a clock that moves on with every reading:

  • Without the fix, Insulin per Day is empty.
  • With it, Insulin per Day is 24 U/day.

The existing SetupComparison tests passed a fixed now, so they didn't catch this.

SetupComparisonTests pass, run on the Loop that LoopWorkspace next-dev pins (29928c1) with this commit on top. Loop's next-dev tip needs a G7SensorKit change the workspace doesn't have yet.

Before the change, from when the dose records start

The second commit stops "Before" being blank whenever the dose records start a few days into the 3 weeks before the change. The average now runs from when the records start, as long as that leaves at least 2 weeks. A note under the row says from when.

On a phone whose records start around Oct 5, a change on Oct 24 needs records from Oct 3, so "Before" was blank. It now shows about 19 days' average.

Two new tests:

  • Records starting 18 days before the change average over those 18 days and give their start date.
  • Records starting 10 days before the change still give nothing.

SetupComparisonTests (11) pass.

ps2 added 2 commits November 4, 2026 17:52
Current Setup always showed "–" for insulin per day since the change.
The comparison only counts insulin when the dose history reaches the end
of the period, and the history ends when it was loaded, but the
comparison was then made with a fresh now() a moment later, so the
period always ran past it.

The view model now takes the time once, before the data loads, and
compares against that.

New test: the view model, with a clock that moves on with every reading,
shows insulin per day since the change. It shows nothing without the
fix.
Insulin per day before a change was blank unless the dose records
covered all 3 weeks before it, so records starting a few days into the
window left it blank. It is now averaged from when the records start,
if that leaves at least 2 weeks, and a note says from when.
@ps2
ps2 merged commit fc3bd79 into next-dev Nov 5, 2026
ps2 added a commit to LoopKit/LoopWorkspace that referenced this pull request Nov 5, 2026
…t-swift (#571)

Loop: move the loop's types and cycle into LoopCore (LoopKit/Loop#2645),
restore the watch app's G7SensorKit framework reference (LoopKit/Loop#2652),
show the loop as open while a manual temp basal runs (LoopKit/Loop#2649),
show insulin per day since a setup change (LoopKit/Loop#2659).

LibreTransmitter: pair with libre2sim in the iOS Simulator
(LoopKit/LibreTransmitter#62, #64); Libre 2 BLE records stamped with
their correct age and smoothed over 5 minutes; incomplete BLE packets
dropped.

NightscoutService: space between the activity type and "Activity" in
override reasons (LoopKit/NightscoutService#46).

dexcom-share-client-swift: sort Share glucose before filterDateRange
(LoopKit/dexcom-share-client-swift#62).
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