← Back to PRs

#3424: Use structured concurrency instead of Task.detached in GatewayDiscoveryModel

by abhijeet117 open 2026-01-28 15:38 View on GitHub →
app: macos size: XS
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