Repository navigation
Fix the Swift concurrency warnings in the app and tests - #19
Merged
Merged
Conversation
…iewController - MouseBridge and ReadinessMonitor took 'hub: MouseEventHub = .shared'. Default arguments are evaluated off the main actor, and .shared is main-actor isolated (an error in Swift 6 mode). The parameter is now optional and falls back to .shared inside the initializer. - BrowserViewController's background and foreground observers called the main-actor BackgroundSessionKeeper from NotificationCenter closures. They run on .main, so the calls are wrapped in MainActor.assumeIsolated, as the other main-queue callbacks in the app already are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W5tzx8GXgMz9DMzc5BF4ND
- RootViewControllerTests polled by re-scheduling a local function with DispatchQueue.main.asyncAfter, which converts a non-Sendable function to a @mainactor @sendable block. The test is now async and polls on the main actor with Task.sleep, keeping the 5 s timeout. - ReadinessMonitorTests counted changes in a var captured by the @sendable withObservationTracking onChange closure (an error in Swift 6 mode). It now counts through an OSAllocatedUnfairLock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01W5tzx8GXgMz9DMzc5BF4ND
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the six Swift concurrency warnings in the build: four in the app and two in the tests. Three of them become errors in the Swift 6 language mode.
App
MouseBridge.swift:56,Onboarding/ReadinessMonitor.swift:30sharedreferenced from a nonisolated contexthub: MouseEventHub = .sharedwas a default argument. Swift evaluates default arguments off the main actor, andMouseEventHub.sharedis main-actor isolated. The parameter is nowMouseEventHub? = nil, and the initializer, which is on the main actor, falls back to.shared.BrowserViewController.swift:252,:255didEnterBackground()/willEnterForeground()in a synchronous nonisolated contextNotificationCenterobservers usequeue: .main, so the calls are wrapped inMainActor.assumeIsolated. That's the pattern the app already uses for its other main-queue callbacks.Tests
RootViewControllerTests.swift:39@MainActor @Sendableblock may introduce data racesDispatchQueue.main.asyncAfter. It's nowasyncand polls on the main actor withTask.sleep, keeping the same 5 s timeout.ReadinessMonitorTests.swift:80changesin concurrently-executing code@SendablewithObservationTrackingonChangeclosure counted into a capturedvar. It now counts through anOSAllocatedUnfairLock.No behaviour change in the app. Callers that pass their own hub (
ReadinessMonitorTests) work unchanged.Checked
mainbuild listed. All 100 tests passed.ios-testsrun.🤖 Generated with Claude Code
https://claude.ai/code/session_01W5tzx8GXgMz9DMzc5BF4ND