Repository navigation
Show how long the current setup has been unchanged, and its last change - #2618
Merged
Merged
Conversation
Settings gets a Current Setup row under Statistics, e.g. "5 days · Last change: Carb Ratios". It opens a screen with the time since the last change, its date, what changed, and a note that about 2 weeks with the same setup is a good amount of time to see a change in outcomes. The last change is found in the stored settings history by comparing consecutive records: basal rates, insulin sensitivities, carb ratios, correction range, pre-meal range, glucose safety limit, delivery limits, insulin type and model, and dosing strategy. Schedules are compared by their values, not their time zone. Changes within an hour of the latest are reported together. Presets, closed loop, alerts, devices and the glucose unit don't count. With no change in the history, the setup is unchanged since at least the oldest record. Turning an algorithm experiment on or off records the time and which one. An experiment that was already on before this build counts from the first launch that sees it, as a lower bound.
The stored insulin type comes from the pump's status, which has none while the pump is being replaced or hasn't loaded yet, so the history flips between a type and none. Carry the last known type across those gaps and only count a change from one type to another.
Collaborator
Author
|
Added c0a7651: the stored insulin type comes from the pump's status, which has none while the pump is being replaced or hasn't loaded, so the history flipped between a type and none and showed up as "Insulin Type" changes. The last known type is now carried across those gaps, and only a change from one type to another counts. Found by decoding a simulator's settings history. |
The Current Setup screen now opens with a summary, e.g. "It's been 5 days since your last setup change: Carb Ratios. Compared with the 2 weeks before it, time in range rose from 68% to 79%, and time below 70 mg/dL stayed about the same at 5.6%." Below it are time-in-range bars for both periods, before and after values for time in range, time below 70, average glucose and insulin per day, and the median glucose by time of day before (dashed) and since (solid) the change. The before period is the 14 days before the change, cut short at the change before it so it covers one setup. It's left out with less than a day or less than 70% CGM data. Results start a day after the change, and while the setup has run under 2 weeks the summary says the numbers can still change a lot. Insulin per day is shown only where the dose records cover the period.
This was referenced Oct 27, 2026
…story Experiment changes now come from the experiments recorded on each dosing decision instead of a date saved when a switch is flipped. That covers changes made before this build, back to the builds that started recording experiments, so an experiment that's on no longer counts from the first launch as "at least". It also uses the experiments actually in effect, so Glucose Based Partial Application turns off with automatic bolus. SetupHistory lists every change from both sources, oldest first, grouping changes within an hour, each with the date of the change before it. The experiment transitions read from dosing decisions are cached, so each decision is read once. Needs LoopKit/LoopKit#669.
Merges feature/current-setup (#2618), whose SetupHistory replaces this branch's single latest change. The Current Setup screen gets a Setup History list: every change, newest first, with its date, how long that setup ran, what changed and its time in range. Tapping one compares that setup, from its change to the next one, with the period before it. The latest is selected at first. Glucose and insulin are read once for the whole history, so switching is instant.
Compare outcomes since the last setup change with the period before it
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.
Settings gets a Current Setup row under Statistics showing how long the setup has been unchanged and what the last change was, e.g. "5 days · Last change: Carb Ratios". It opens a screen with the time since the last change, its date, what changed, and a note that about 2 weeks with the same setup is a good amount of time to see a change in outcomes.
This is the first step toward comparing your results before and after a change, and later toward sharing that data with the developers. Both of those build on this date.
What counts as a change
The last change is found in the settings history Loop already stores (90 days), by comparing consecutive records:
Not counted: running a preset, turning closed loop on or off, alerts and notifications, devices, the glucose unit and the time zone.
Details:
Experiments
Experiment changes come from the experiments recorded on each dosing decision, which builds since LoopKit/LoopWorkspace#534 store. That covers changes made before this build, and it uses the experiments actually in effect, so Glucose Based Partial Application turns off with automatic bolus. Decisions from older builds, which recorded nothing, are skipped. The experiment transitions are cached in UserDefaults, so each decision is read once. The 2-week note also appears on the Algorithm Experiments screen.
SetupHistorylists every change from both sources, oldest first, each with the date of the change before it. The Current Setup row uses the latest; #2619 uses the rest.Needs LoopKit/LoopKit#669 (
getDosingDecisions(start:end:as:)).Testing
SetupChangeTests: change detection, grouping, ignored fields, units, the pump's missing insulin type, experiment changes from dosing decisions, grouping with settings changes, and the cache reading each decision once. All pass.LoopWorkspacescheme and checked in the simulator: turning Guard + Runway off updated the row to "1 minute · Last change: Guard + Runway turned off".