Repository navigation
Watch bolus: review fixes for the recommendation handling and compact buttons - #6
Conversation
…low only untouched amounts while on top, clear an expired starting recommendation, and let compact buttons wrap A loop cycle without a recommendation no longer counts as 0 U. The Presets button appears once the recommendation is old enough to be listed there, and meal Quick-Picks are centered like the other buttons.
MtlPhil
left a comment
There was a problem hiding this comment.
Thanks Jonas, this looks good to me.
One thing I noticed while going through it. It isn't caused by this PR, and I'd like your read on it.
A failed Loop cycle makes the old recommendation look fresh
The phone only reads recommendedBolus when the cycle didn't fail. Both DeviceStatusLoop and DeviceStatusOpenAPS set it inside the failureReason == nil branch. So on a failed cycle, deviceRecBolus keeps the previous value.
For Loop, though, the recommendation's time is alertLastLoopTime (WatchStateBuilder.swift). That comes from pump.clock on every upload (DeviceStatus.swift), failed cycles included. So after a failed cycle, the watch gets the old recommendation stamped with the new time. It treats that as "same amount, newer cycle" and restarts the age, so the 5- and 12-minute limits start over even though nothing was recalculated. The Loop bolus screen on the phone shows "Calculated 0 minutes ago" for the same reason.
Trio looks fine here, because enactedOrSuggested is also only updated when the cycle didn't fail.
Does that match what you'd expect from Loop's uploads? If it does, I think the recommendation's time should come from the last successful cycle rather than the pump clock, or a failed cycle should clear the recommendation. That would be a separate PR, not a reason to hold this one.
Follow-up to loopandlearn#792. A fresh recommendation that arrives after the bolus screen opened with nothing filled in is offered with a tap, the same way as a higher one. Newer recommendations are followed only while the amount is untouched by hand and the amount screen is on top, so nothing changes underneath the confirmation. A loop cycle without a recommendation is treated as having none, not as 0 U. A starting recommendation older than 12 minutes is cleared at Continue with a Recommendation Expired alert, matching the cut-off on the phone and in Presets. The Presets button refreshes so it shows up once the recommendation passes 5 minutes. CompactButtonStyle allows two centered lines, so longer meal Quick-Pick titles fit, and the Quick-Pick rows are centered like Time and Log.