Skip to content

Present alert manager alerts in their own window - #2702

Open
ps2 wants to merge 1 commit into
next-devfrom
in-app-alerts-overlay-window
Open

ps2 wants to merge 1 commit into
next-devfrom
in-app-alerts-overlay-window

Conversation

@ps2

@ps2 ps2 commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

A glucose alarm presented over the bolus screen blocked the screen's own SwiftUI alerts. In-app modal alerts were presented on the app's topmost view controller, so when a new reading both crossed the high threshold and changed the recommendation, UIKit logged:

Attempt to present <SwiftUI.PlatformAlertController> on <UINavigationController> (from …BolusEntryView…) which is already presenting <UIAlertController>

"Bolus Recommendation Updated" was lost and activeAlert stayed set. presentAlert's activeAlert == nil guard then dropped every later alert on that bolus screen, including "Exceeds Maximum Bolus". Delivery was still refused, but with no explanation.

This presents the alert manager's in-app modal alerts (glucose and pump) from their own window at .alert level, so they no longer occupy the app's presentation chain. The window passes touches through when no alert is showing and hides once its alert is dismissed. Other presenters (delivery uncertainty, etc.) are unchanged.

Testing, simulator with CGM and pump simulators:

  • Repro: bolus screen open with a bolus entered, CGM moves to a constant 200 mg/dL (High Glucose on). Without this change it fails every time with the error above. With it, both alerts show, each is acknowledged, and a following over-max entry shows "Exceeds Maximum Bolus". 3 of 3 runs.
  • Same scenario at 170 (no alarm): unchanged.
  • Taps after acknowledging an alert, two in-app alerts at once, and an alert retracted while showing: unchanged.
  • Full UI test suite: no new failures.

Not tested: VoiceOver focus with both alerts up (the alert underneath is in the accessibility tree), and real hardware.

In-app modal alerts (glucose alarms, pump alerts) were presented on the
app's topmost view controller. A SwiftUI .alert from that screen then
failed with "already presenting", and on the bolus screen the stuck
activeAlert suppressed every later alert there, including Exceeds Maximum
Bolus. Presenting those alerts from an overlay window at alert level
leaves the app's presentation chain free; the window passes touches
through and hides when no alert is showing.
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