#3424: Use structured concurrency instead of Task.detached in GatewayDiscoveryModel
app: macos
size: XS
Cluster:
Fix Microsoft Teams Plugin Issues
This replaces Task.detached with Task in GatewayDiscoveryModel.
Since this class is @MainActor, structured tasks correctly inherit actor context and cancellation. No functional behavior changes intended this improves concurrency safety and follows Swift best practices.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates `GatewayDiscoveryModel` (a `@MainActor` observable model) to use structured concurrency by replacing `Task.detached` with `Task` for background work related to wide-area fallback discovery and local identity refresh. The intent is to ensure actor context and cancellation propagation behave consistently with Swift best practices, while keeping the discovery logic and UI updates (`MainActor.run`) unchanged.
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk.
- The change is small and localized (swapping `Task.detached` for `Task` in three call sites) and preserves existing logic and MainActor handoffs; no new API surface or behavior changes were introduced in the diff.
- No files require special attention
<!-- greptile_other_comments_section -->
<sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#22454: fix(macos): add re-subscribe loop to gateway stream subscribers
by mandofever78 · 2026-02-21
69.9%
#10034: Don't crash gateway on transient unhandled fetch failures
by gigq · 2026-02-06
69.0%
#4462: fix: prevent gateway crash when all auth profiles are in cooldown
by garnetlyx · 2026-01-30
68.0%
#19504: fix(gateway): avoid stale running status from Windows Scheduled Task
by Fologan · 2026-02-17
67.9%
#12168: feat: integrate Mission Control dashboard into Control UI
by riftagent-git · 2026-02-08
67.6%
#8260: fix(macOS): gateway readiness detection + reversible Configure later
by xksteven · 2026-02-03
67.5%
#8713: feat: gateway memory monitor, install linger, docs and failover
by quratus · 2026-02-04
67.3%
#17835: Fix misleading gateway stop hints for standalone listeners
by ConnorCallison · 2026-02-16
66.6%
#7382: fix: remove config.schema from agent gateway tool
by kakuteki · 2026-02-02
66.5%
#19088: fix(gateway): allow startup with unset mode and fix pairing for local…
by mdanassaif · 2026-02-17
66.5%