Skip to content

Add dismissable top banner for Nightscout, Dexcom, and heartbeat issues#696

Open
bjorkert wants to merge 2 commits into
devfrom
top-info-banner
Open

Add dismissable top banner for Nightscout, Dexcom, and heartbeat issues#696
bjorkert wants to merge 2 commits into
devfrom
top-info-banner

Conversation

@bjorkert

@bjorkert bjorkert commented Jul 8, 2026

Copy link
Copy Markdown
Member

Summary

Failed BG downloads are currently only visible in the log viewer, and a failed Dexcom Share login silently falls back to Nightscout — a user with a bad token, mistyped URL, or wrong Dexcom credentials sees no data with no explanation.

This adds a dismissable banner above the tab view. It is visible on every tab and pushes the content down (up to 3 lines) rather than overlaying it.

What it does

  • Nightscout failures: after a failed BG fetch, a rate-limited probe of status.json classifies the cause, so the banner can say why — "The token is invalid.", "A token is required.", "The site was not found.", "A network error occurred." — reusing the same NightscoutError messages the settings screen shows. If the server is reachable but the data fetch still failed, a softer warning says so.
  • Dexcom Share failures: ShareError login codes are mapped to friendly text (account not found, incorrect username or password, too many failed attempts). Matching is by substring so both the legacy SSO_Authenticate… codes and the current AccountPasswordInvalid are covered. When Nightscout is configured as backup, the previously silent fallback is now surfaced as a warning ("… Using Nightscout as backup.") while data keeps flowing.
  • Frequent heartbeat dropouts: when the Bluetooth heartbeat becomes regularly delayed — 5 or more beats arriving later than 1.5× the expected interval within the last hour, a typical symptom of a dying transmitter battery — a warning suggests checking the transmitter/RileyLink/pod battery or Bluetooth range. A single late beat never triggers it; gaps large enough to indicate out-of-range, Bluetooth off, or a suspended app reset the count instead of adding to it. The warning clears after a clean hour, or immediately on device disconnect/switch.
  • Clearing: a banner disappears automatically when its source recovers (next successful fetch, clean heartbeat window) or when that source is deconfigured (URL/credentials removed, device disconnected).
  • Dismissal: tapping ✕ hides the banner. The same error stays hidden for 30 minutes (then re-appears if still occurring); a different error shows immediately. Repeated failing retries reuse the same message, so the banner doesn't re-animate every 10–60 s cycle.
  • Severity: when multiple sources have problems, the more severe message wins (error > warning > info); dismissing it reveals the next one.

The banner system is generic (BannerManager.report/clear with a custom source), so other important notices can use it later.

Also fixed

NightscoutUtils.verifyURLAndToken classified transport errors backwards: DNS/connection failures were reported as siteNotFound and everything else as networkError. It now distinguishes them by URLError code, which also improves the status label in Nightscout settings.

Failed BG downloads were only visible in the log viewer, and a failed
Dexcom Share login silently fell back to Nightscout. Users with a bad
token, mistyped URL, or wrong Dexcom credentials saw no data with no
explanation.

Add a banner above the tab view (visible on every tab, pushes content
down) that surfaces these failures with a clear cause:

- Nightscout fetch failures trigger a rate-limited status.json probe
  to classify the error (invalid token, token required, site not
  found, no network) using the existing NightscoutError messages.
- Dexcom Share errors are mapped to friendly text (account not found,
  incorrect username or password, too many attempts), including the
  current AccountPasswordInvalid code alongside the legacy SSO_ ones.
  The previously silent Nightscout fallback is now shown as a warning.
- Banners clear automatically on a successful fetch or when the
  source is deconfigured. Dismissing a banner suppresses that exact
  error for 30 minutes; a different error shows immediately.
- Repeated failing retries reuse the same message so the banner does
  not re-animate every cycle.

Also fix verifyURLAndToken transport-error classification, which
reported DNS/connection failures as siteNotFound and everything else
as networkError; it now distinguishes them by URLError code, which
also improves the settings status label.
@bjorkert bjorkert changed the title Add dismissable top banner for Nightscout and Dexcom errors Add dismissable top banner for Nightscout, Dexcom, and heartbeat issues Jul 8, 2026
@bjorkert

bjorkert commented Jul 8, 2026

Copy link
Copy Markdown
Member Author
image

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