Skip to content

Keep last known device status values for 15 minutes - #780

Open
MtlPhil wants to merge 14 commits into
loopandlearn:devfrom
achkars-org:fix/device-status-grace-period-15min
Open

MtlPhil wants to merge 14 commits into
loopandlearn:devfrom
achkars-org:fix/device-status-grace-period-15min

Conversation

@MtlPhil

@MtlPhil MtlPhil commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What this fixes

Nightscout device status responses sometimes omit fields that were present in the previous response. When that happens the info rows go blank for that refresh, so IOB, COB and the batteries flicker or disappear between updates even though the data is only a few minutes old.

Changes

For up to 15 minutes after a field was last received, the info table now shows the last known value instead of going blank. After that the row goes blank as before. 15 minutes matches the existing not-looping threshold.

Fields covered: IOB, COB, TDD, autosens, pump battery and uploader battery.

  • Each field is timed from the wall-clock time it was last received (lastIOBTime, lastCOBTime, lastTddTime, lastAutosensTime, lastPumpBatteryTime, lastUploaderRecordTime), so the grace period does not depend on the APS type, the pump clock or CGM timing, and one field arriving does not keep another one alive. The Loop and OpenAPS parsers both set them.
  • The Live Activity follows the same grace period as the info rows. It shows the last known IOB, COB, TDD, autosens and battery values while they are fresh, and nothing after 15 minutes. Before, it kept the last value indefinitely. DeviceStatusGrace holds the 15 minute period and the freshness check for both.
  • InsulinMetric and CarbMetric get direct-value initialisers so a display value can be rebuilt from a stored double.

Not included

  • Pump reservoir. It is already handled by PumpReservoirResolver, which carries a reading across gaps for 30 minutes, so this PR leaves it alone.
  • Recommended bolus. It also feeds the recommended bolus alarm, the Live Activity and the remote bolus screens, so a carried-over value would not be display only. It still clears when the field is missing.

Notes

  • The info rows and the Live Activity are the only things that change. Alarms, the calendar event text and the remote bolus screens use latestIOB, latestCOB and the observable battery values exactly as before.
  • Behavior change for the Live Activity: IOB, COB, TDD, autosens and the batteries now disappear 15 minutes after they stop being received, instead of staying on screen with the last value.

claude and others added 14 commits May 26, 2026 13:50
Always branch off dev, never main.
Also unignore CLAUDE.md in .gitignore so instructions persist.

https://claude.ai/code/session_016VQatqaNuHQ2zupY8DtZmj
CLAUDE.md is kept in .gitignore so it never appears in upstream PRs,
but the hook recreates it on every fresh remote web session so
project instructions (always branch off dev, never main) persist.

https://claude.ai/code/session_016VQatqaNuHQ2zupY8DtZmj
Corrects the CLAUDE.md instructions the hook writes on every remote
session: replaces the reference to a nonexistent SwiftLint config with
the actual SwiftFormat command and rules CI enforces, plus a fallback
checklist for sessions without a Swift toolchain.
Corrects the stale SwiftLint reference (this repo has no SwiftLint
config) and adds an explicit lint pass before pushing a cherry-picked
upstream PR branch, so 'ready' branches land already lint-clean.
Use GITHUB_RUN_NUMBER as the build number so TestFlight and the
GitHub Actions run stay in sync. Fall back to latest TestFlight
build + 1 when the run number is missing or not higher.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
When IOB, COB, TDD, autosens, pump battery or uploader battery is absent
from a device status response, show the last known value for up to
15 minutes before going blank, consistent with the existing not-looping
threshold.

Each field records when it was last received, so a field missing from a
record that keeps arriving still expires. The grace period does not
depend on the APS type, the pump clock or CGM timing.

The Live Activity reads the same times, so it shows the last known value
for 15 minutes and then nothing, like the info rows. Before it kept the
last IOB, COB, TDD, autosens and battery values indefinitely.

Add direct-value initialisers to InsulinMetric and CarbMetric so the
display value can be rebuilt from a stored double.

The pump reservoir is left to PumpReservoirResolver, and the
recommended bolus is not carried over, since other screens use it.
@MtlPhil
MtlPhil force-pushed the fix/device-status-grace-period-15min branch from 7f4d41a to a914fe8 Compare October 15, 2026 02:52
@MtlPhil
MtlPhil marked this pull request as ready for review October 15, 2026 02:59
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.

2 participants