Skip to content

Conversation

@tomerqodo
Copy link

@tomerqodo tomerqodo commented Jan 21, 2026

Benchmark PR from qodo-benchmark#208


Note

Modernizes concurrency annotations by stripping @Sendable from @MainActor closures/completions throughout BrowserKit, Client, and tests, and aligning call sites and protocols.

  • Adjusts many APIs (UI/WebKit delegates, menu actions, auth, downloads, search engines, history, passwords, tab/web view helpers) to use @MainActor-only closures; updates mocks accordingly
  • Updates ensureMainThread helpers; generic variant now returns T? and only returns a value when already on the main thread
  • Drops @Sendable from Reducer typealias; updates WKEngineWebView.evaluateJavaScript completion type
  • Makes WebServer non-final; minor cleanup in DispatchQueueInterface.ensureMainThread
  • Tweaks MainThreadThrottler.throttle implementation order (sets timestamp before gating)

Written by Cursor Bugbot for commit 38810ec. Configure here.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

guard threshold <= 0 || lastExecutionTime.timeIntervalSinceNow < -threshold else { return }
func throttle(completion: @escaping @MainActor () -> Void) {
lastExecutionTime = Date()
guard threshold <= 0 || lastExecutionTime.timeIntervalSinceNow < -threshold else { return }
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throttler never executes completions due to reordered logic

High Severity

The reordering of statements in throttle completely breaks the throttler. Setting lastExecutionTime = Date() before the guard check means lastExecutionTime.timeIntervalSinceNow is always approximately 0. The condition 0 < -threshold is always false for positive thresholds, so the guard always fails and completions are never executed. The original logic set lastExecutionTime only after the guard passed.

Fix in Cursor Fix in Web

ensureMainThread {
completionHandler(.performDefaultHandling, nil)
}
completionHandler(.performDefaultHandling, nil)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent threading for completion handler in handleServerTrust

Medium Severity

The ensureMainThread wrapper was removed from one completionHandler call but kept on the other. Now completionHandler(.performDefaultHandling, nil) is called directly from within dispatchQueue.async, meaning it executes on a background thread, while completionHandler(.useCredential, credential) is still wrapped with ensureMainThread. This inconsistency could cause threading issues with the WebKit callback.

Fix in Cursor Fix in Web

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.

3 participants