Skip to content

Don't snooze high alarm when there is no IOB (#6348) - #8549

Open
IsraelAfangideh wants to merge 3 commits into
nightscout:devfrom
IsraelAfangideh:fix/bwp-snooze-without-iob-6348
Open

Don't snooze high alarm when there is no IOB (#6348)#8549
IsraelAfangideh wants to merge 3 commits into
nightscout:devfrom
IsraelAfangideh:fix/bwp-snooze-without-iob-6348

Conversation

@IsraelAfangideh

@IsraelAfangideh IsraelAfangideh commented Jun 28, 2026

Copy link
Copy Markdown

Fixes #6348.

Problem

The Bolus Wizard Preview plugin snoozes a high alarm when prop.bolusEstimate < snoozeBWP, treating a near-zero estimate as "there is enough insulin on board to cover the high". But bolusEstimate starts at 0 and stays 0 in a case that has nothing to do with IOB coverage:

  • the BG is above the alarm threshold (bgTargetTop) yet still below the profile high target, so neither the high nor the low branch of calc() runs.

With no insulin on board, bolusEstimate is then left at its initial 0, and a genuine high alarm gets silenced. This matches the report in #6348: a complete profile, a default ISF, and no insulin treatments. (The exact target_high from the report is not in the issue, so this is the most likely mechanism consistent with it rather than a certainty.)

Because the snooze is requested at URGENT level and notifications.snoozedBy() matches by level across the group, this can also suppress other urgent alarms for the snooze duration.

Note: the other path that leaves bolusEstimate at 0calc() returning early with errors (missing profile/IOB, stale data) — is already handled, since checkNotifications() returns early when prop.errors is non-empty before highSnoozedByIOB is ever called. So this change targets only the no-error, no-IOB case above.

Fix

Guard the snooze on prop.iob > 0, so a high alarm is only snoozed when there is actually insulin on board to cover it:

return high && prop.iob > 0 && prop.bolusEstimate < settings.snoozeBWP;

Legitimate enough-IOB snoozing is unchanged. No new dependencies.

Tests

Added to tests/boluswizardpreview.test.js:

Full suite green locally (1346 passing).

🤖 Generated with Claude Code

The Bolus Wizard Preview plugin snoozes a high alarm when its
`bolusEstimate` is below the snooze threshold, treating that as "enough
insulin on board to cover the high". But `bolusEstimate` is 0 in a case
that has nothing to do with IOB coverage: when the BG is above the alarm
threshold (`bgTargetTop`) yet still below the profile's high target, so
neither the high nor low branch of calc() runs. With no insulin on board
this leaves bolusEstimate at its initial 0 and a genuine high alarm is
silenced -- the scenario reported in nightscout#6348 (complete profile, no insulin
treatments). Because the snooze is requested at URGENT level and
snoozedBy() matches by level across the group, it can also suppress other
urgent alarms for the snooze duration.

Guard the snooze on `prop.iob > 0` so a high is only snoozed when there
is actually insulin on board to cover it. Legitimate "enough IOB"
snoozing is unchanged.

Adds regression tests for the reported scenario (BG below the profile
high target with no IOB) and for the unchanged enough-IOB snooze.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@IsraelAfangideh
IsraelAfangideh force-pushed the fix/bwp-snooze-without-iob-6348 branch from 364c712 to 2284d89 Compare June 29, 2026 02:02
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