Fix omnibar arrow key focus races

Merged
AU
6mo ago
+1044-85

Summary

  • adds regression coverage for stale omnibar field-editor ownership and transient WebView first-responder arrow routing
  • restores live omnibar field fallback lookup for stale/nil window ownership cases
  • prevents browser arrow forwarding from treating the omnibar field editor as web content, and restores the logically focused omnibar before dispatching arrows

Fixes #4141

Testing

  • Not run locally, per repo policy; CI is the validation path.

[!NOTE]
Medium Risk
Touches AppKit first-responder tracking and keyboard event routing for the browser omnibar, which is easy to regress and can affect typing/navigation behavior across windows and panels.

Overview
Fixes browser omnibar arrow-key race conditions by resolving the focused panel from the current omnibar responder/intent (not just stale tracked state) and by making omnibar selection repeat state panel-specific.

Adds a BrowserOmnibarNativeFieldRegistry and browserOmnibarField(panelId:in:) fallback lookup to reliably find the live omnibar field/field-editor even when AppKit leaves stale responder chains, and updates arrow-key forwarding to route plain arrows through keyDown for omnibar responders (including restoring omnibar focus before forwarding).

Refactors address-bar tracking preservation into shouldPreserveBrowserAddressBarTrackingDuringWebViewFocus with pointer-initiated WebView focus signals (propagated via .browserDidBecomeFirstResponderWebView userInfo), and adds regression tests covering stale field-editor ownership, transient first-responder states, and arrow routing.

Reviewed by Cursor Bugbot for commit 0dd9e94f19348b67f2a47d4387d7649041a203c3. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features

    • Registry and lookup support for live omnibar fields and improved omnibar focus resolution
    • First-responder notifications now include pointer-initiated info for focus transitions
  • Bug Fixes

    • Improved preservation/clearing of address-bar tracking across webview focus changes (pointer-initiated, suppression, live omnibar)
    • More reliable arrow-key routing that restores and forwards keys to the omnibar when appropriate
  • Tests

    • Added tests for tracking policy, omnibar lookup/resolution, and key-event routing

Review Change Stack