Skip to content

fix: dismiss stuck browser address bar autocomplete on webview click - #5769

Merged
AmethystLiang merged 2 commits into
stablyai:mainfrom
tmchow:tmchow/persistent-webview-toolbar-removal
Jun 19, 2026
Merged

AmethystLiang merged 2 commits into
stablyai:mainfrom
tmchow:tmchow/persistent-webview-toolbar-removal

Conversation

@tmchow

@tmchow tmchow commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Clicking the loaded page in a browser tab could leave the address bar history dropdown stuck under the toolbar, with no way to dismiss it except refocusing the address bar and pressing Escape. The dropdown now closes when you click into the page, switch away from Orca, or press Escape.

Electron <webview> guests run in a separate process, so clicks inside the page never reach the renderer's outside-click handlers that Radix popovers rely on. The fix listens for focus entering the webview guest, window blur, and Escape — matching the pattern already used by the browser import hint popover — and wires a backup dismiss path from BrowserPane when the webview element receives focus.

Demo

Before

CleanShot.2026-06-18.at.22.18.57.mp4

After

CleanShot.2026-06-18.at.22.19.38.mp4

Test plan

  • Open a browser tab, focus the address bar to show history suggestions, then click the page — dropdown should close
  • Press Escape while suggestions are open — dropdown should close and restore the typed query
  • pnpm exec vitest run --config config/vitest.config.ts src/renderer/src/components/browser-pane/BrowserAddressBar.test.tsx

Compound Engineering
Composer 2.5 Fast


Open in Stage

Electron webview guests never dispatch outside pointer events to the
renderer, so the address bar history dropdown could stay open after
clicking the page. Close it on guest focus, window blur, and Escape.

Co-authored-by: Cursor <[email protected]>
@ghost

ghost commented Jun 19, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 3 individual chapters for you:

Title
1 Expose suggestion dismissal in BrowserAddressBar
2 Wire address bar dismissal to BrowserPane webview
3 Verify address bar dismissal behavior
Open in Stage

Chapters generated by Stage for commit 9dbe979 on Jun 19, 2026 5:57am UTC.

@coderabbitai

coderabbitai Bot commented Jun 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 151844c3-8d30-45a8-9667-24eb8f9623f5

📥 Commits

Reviewing files that changed from the base of the PR and between 2895328 and 9dbe979.

📒 Files selected for processing (1)
  • src/renderer/src/components/browser-pane/BrowserAddressBar.test.tsx

📝 Walkthrough

Walkthrough

BrowserAddressBar is updated to accept an optional dismissSuggestionsRef prop. Internally, the cancel/dismiss logic is consolidated into a single dismissSuggestions callback that restores the typed query and closes the popover. Three global event listeners are added: window.blur, a capturing document.focusin that fires when focus moves to a WEBVIEW element, and window.keydown for Escape (with preventDefault and stopImmediatePropagation). A separate effect keeps dismissSuggestionsRef.current synchronized with the latest callback.

In BrowserPagePane, a dismissAddressBarSuggestionsRef is created, a helper function wraps it, and the webview 'focus' event listener is registered to invoke it (with cleanup on teardown). The ref is passed to BrowserAddressBar via the new prop. New tests validate that dispatching blur, Escape keydown, and focusin on a webview element all dismiss the active autocomplete preview.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is missing several required sections from the template: Screenshots, Testing checklist items (lint, typecheck, test, build status), AI Review Report, and Security Audit sections are not provided. Complete the PR description by adding the missing template sections: provide screenshots or confirm no visual change, check off testing steps, include AI review findings, and provide a security audit summary.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main fix: dismissing the stuck browser address bar autocomplete when the webview is clicked.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (3)
src/renderer/src/components/browser-pane/BrowserAddressBar.tsx (1)

17-17: ⚡ Quick win

Prefer the React 19 RefObject type for this mutable ref prop.

React 19 makes refs mutable through RefObject, and the provided React 19 docs call out the mutable-ref type changes. Typing this public prop as MutableRefObject risks drifting from the installed React 19 types.

♻️ Proposed ref type update
-  dismissSuggestionsRef?: React.MutableRefObject<(() => void) | null>
+  dismissSuggestionsRef?: React.RefObject<(() => void) | null>
src/renderer/src/components/browser-pane/BrowserPane.tsx (1)

3507-3509: ⚡ Quick win

Add a short “why” comment to the webview-focus bridge.

This listener is driven by Electron guest-process focus semantics, which are not obvious from focus alone.

📝 Proposed comment
+    // Why: focus inside the guest process never reaches Radix outside-click
+    // handlers, so bridge the webview focus event back to the address bar.
     const dismissAddressBarSuggestions = (): void => {
       dismissAddressBarSuggestionsRef.current?.()
     }

As per coding guidelines, “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”

Also applies to: 3745-3745

Source: Coding guidelines

src/renderer/src/components/browser-pane/BrowserAddressBar.test.tsx (1)

171-179: ⚡ Quick win

Assert the dropdown actually closes.

The regression is the stuck suggestions popover; this test currently verifies value restoration but would miss a regression where the listbox remains mounted.

✅ Proposed assertion
     await act(async () => {
       webview.dispatchEvent(new FocusEvent('focusin', { bubbles: true }))
     })
 
+    expect(document.querySelector('`#browser-history-listbox`')).toBeNull()
     expect(container.querySelector('[data-current-address-value="true"]')?.textContent).toBe(
       'local'
     )

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: d9e85d5d-a5cb-4b28-8439-d27bd98bad57

📥 Commits

Reviewing files that changed from the base of the PR and between f19390a and 2895328.

📒 Files selected for processing (3)
  • src/renderer/src/components/browser-pane/BrowserAddressBar.test.tsx
  • src/renderer/src/components/browser-pane/BrowserAddressBar.tsx
  • src/renderer/src/components/browser-pane/BrowserPane.tsx

@AmethystLiang AmethystLiang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, this fixes the webview focus boundary cleanly.

I added regression coverage for the remaining claimed dismiss paths:

  • window blur restores the typed query and closes suggestions
  • Escape through the native window listener restores the typed query and closes suggestions

Verified with targeted tests, full typecheck/lint, and Electron validation of the real browser pane: suggestions open from history, clicking the webview focuses the guest and removes the popover.

@AmethystLiang
AmethystLiang merged commit 76317d6 into stablyai:main Jun 19, 2026
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#5769)

* fix: dismiss stuck browser address bar autocomplete on webview click

Electron webview guests never dispatch outside pointer events to the
renderer, so the address bar history dropdown could stay open after
clicking the page. Close it on guest focus, window blur, and Escape.

Co-authored-by: Cursor <[email protected]>

* test: cover browser address bar dismiss paths

---------

Co-authored-by: Cursor <[email protected]>
Co-authored-by: Jinjing <[email protected]>
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