Skip to content

Fix crash in HomeRootView by injecting the existing SettingsSearchHighlight instance - #1483

Open
premnirmal wants to merge 1 commit into
nightscout:devfrom
premnirmal:nightscout-cgm-crash
Open

Fix crash in HomeRootView by injecting the existing SettingsSearchHighlight instance#1483
premnirmal wants to merge 1 commit into
nightscout:devfrom
premnirmal:nightscout-cgm-crash

Conversation

@premnirmal

@premnirmal premnirmal commented Sep 8, 2026

Copy link
Copy Markdown

NightscoutUploadView and NightscoutFetchView require a SettingsSearchHighlight environment object that is missing when Nightscout configuration is opened from the Home-screen CGM sheet.

Cause of the crash is 5cb78b6 which added .settingsHighlightScroll() to these two views.

  • Both destinations apply .settingsHighlightScroll()
  • That modifier unconditionally reads  @Environment(SettingsSearchHighlight.self)
  • The object is injected only into the Settings tab’s NavigationStack
  • The Home-screen CGM sheet is outside that subtree, so navigating to Upload or Fetch causes SwiftUI’s fatal “no observable object of type SettingsSearchHighlight found” failure
  • Settings to Services to Nightscout works because that route inherits the required environment object

So we can inject the existing settings-highlight environment into the Home CGM sheet so the Nightscout child routes inherit it, without changing the working Settings navigation path.

PR fixes the crash in HomeRootView.swift by injecting the existing SettingsSearchHighlight instance into the Home-screen CGM configuration sheet. Nightscout’s Upload and Fetch views now inherit their required environment dependency.

Fixes #1480

Test steps:

  1. Enable nightscout as a CGM (you may need to delete your existing CGM and set up nightscout as the CGM)
  2. Click on your CGM and configure nightscout, then go to 'Fetch' or 'Upload' and verify the subscreens open without crashing

…ngsSearchHighlight instance into the Home-screen CGM configuration sheet. Nightscout’s Upload and Fetch views now inherit their required environment dependency.
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