Repository navigation
Fix browser URL bar stealing focus on tab switch - #4623
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR moves blank-state logic from WebView inspection to the BrowserPanel model, adds a ChangesOmnibar blank-state detection consolidation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 16 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (16 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…l-bar-focus-steal
Greptile SummaryFixes a focus-steal bug where switching to a tab with a deferred/restored URL caused the URL bar to grab focus because the panel was misclassified as a new-tab page.
Confidence Score: 5/5Safe to merge — the change is small, localized to new-tab detection and omnibar autofocus, backed by a targeted regression test, and leaves no unsafe intermediate state representable. All three callsites of No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Tab Switch / Panel Focus] --> B{shouldRenderWebView?}
B -- Yes --> C[Live WebView active]
C --> D{isWebViewLoading?}
D -- Yes --> E[Skip autofocus — navigation in progress]
D -- No --> F{preferredURLStringForOmnibar == nil?}
F -- No --> G[Skip autofocus — real URL present]
F -- Yes --> H[Autofocus URL bar — true new tab]
B -- No --> I{preferredURLStringForOmnibar == nil?}
I -- Yes --> J[isShowingNewTabPage = true, webViewLifecycleState = .newTab, Autofocus URL bar, Show import overlay]
I -- No --> K[isShowingNewTabPage = false, webViewLifecycleState = .deferredURL, Do NOT autofocus]
Reviews (2): Last reviewed commit: "fix: classify deferred browser URLs expl..." | Re-trigger Greptile |
Fixes #4616.
Summary
Regression coverage
Local verification
Need help on this PR? Tag
@codesmithwith what you need. Autofix is disabled.Note
Medium Risk
Medium risk because it changes browser panel lifecycle state and blank/new-tab detection used to drive focus and empty-state UI, which could affect navigation and tab UX across multiple code paths.
Overview
Prevents the URL bar from stealing focus during tab switches by refining what counts as a real blank/new-tab state when a
WKWebViewhasn’t been attached yet.The panel now distinguishes
.deferredURL(a known/restored URL with deferred rendering) from.newTab, andBrowserPanelViewswitches autofocus and empty-state overlay checks to use the model’spreferredURLStringForOmnibar()/panel.isShowingNewTabPagerather thanabout:blank/WebView URL state.Adds regression tests ensuring deferred initial URLs are not treated as new tabs and that lifecycle state reflects
.deferredURLuntil rendering begins.Reviewed by Cursor Bugbot for commit 3b7be1b. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by cubic
Fixes #4616. Stops the URL bar from stealing focus on tab switch by treating deferred/restored URLs as real content and introducing a
deferredURLlifecycle state.deferredURL, not new tabs.about:blank/WebView URL checks with a model-based blank check and usedisShowingNewTabPagefor the empty-state overlay; autofocus now skips when content isn’t truly blank so pages keep focus.Written for commit 3b7be1b. Summary will update on new commits. Review in cubic
Summary by CodeRabbit
Bug Fixes
Tests