Skip to content

Fix the Swift concurrency warnings in the app and tests - #19

Merged
mattonik merged 2 commits into
mainfrom
claude/eager-cerf-epu54h
Oct 2, 2026
Merged

mattonik merged 2 commits into
mainfrom
claude/eager-cerf-epu54h

Conversation

@mattonik

@mattonik mattonik commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

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

Where Warning Fix
MouseBridge.swift:56, Onboarding/ReadinessMonitor.swift:30 Main actor-isolated static property shared referenced from a nonisolated context hub: MouseEventHub = .shared was a default argument. Swift evaluates default arguments off the main actor, and MouseEventHub.shared is main-actor isolated. The parameter is now MouseEventHub? = nil, and the initializer, which is on the main actor, falls back to .shared.
BrowserViewController.swift:252, :255 Call to main actor-isolated didEnterBackground() / willEnterForeground() in a synchronous nonisolated context The NotificationCenter observers use queue: .main, so the calls are wrapped in MainActor.assumeIsolated. That's the pattern the app already uses for its other main-queue callbacks.

Tests

Where Warning Fix
RootViewControllerTests.swift:39 Converting non-Sendable function value to @MainActor @Sendable block may introduce data races The test polled by re-scheduling a local function with DispatchQueue.main.asyncAfter. It's now async and polls on the main actor with Task.sleep, keeping the same 5 s timeout.
ReadinessMonitorTests.swift:80 Mutation of captured var changes in concurrently-executing code The @Sendable withObservationTracking onChange closure counted into a captured var. It now counts through an OSAllocatedUnfairLock.

No behaviour change in the app. Callers that pass their own hub (ReadinessMonitorTests) work unchanged.

Checked

  • On the first commit, CI's full build log no longer had the four app warnings, which the previous main build listed. All 100 tests passed.
  • The test changes are checked by this PR's ios-tests run.

🤖 Generated with Claude Code

https://claude.ai/code/session_01W5tzx8GXgMz9DMzc5BF4ND

claude added 2 commits October 2, 2026 07:28
…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
@mattonik mattonik changed the title Fix main-actor warnings in MouseBridge, ReadinessMonitor and BrowserViewController Fix the Swift concurrency warnings in the app and tests Oct 2, 2026
@mattonik
mattonik merged commit d4ed549 into main Oct 2, 2026
2 checks passed
@mattonik
mattonik deleted the claude/eager-cerf-epu54h branch October 2, 2026 08:27
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.

2 participants