Skip to content

Hide the native browser view behind any overlay that covers it - #3755

Closed
dillionverma wants to merge 1 commit into
get-bb:mainfrom
dillionverma:fix/browser-view-overlay-occlusion
Closed

dillionverma wants to merge 1 commit into
get-bb:mainfrom
dillionverma:fix/browser-view-overlay-occlusion

Conversation

@dillionverma

Copy link
Copy Markdown

Human comments

What was wrong

The embedded browser tab is an Electron WebContentsView, a native layer that always paints above the renderer DOM. The only thing that hid it was the shared-ui Dialog, which registers itself through useBrowserDimmingModal. Popovers, dropdown menus, the floating new-thread composer, plugin app overlays, and any other floating window never registered, so they rendered underneath the page whenever a browser tab was open in the secondary panel.

What changed

  • apps/app/src/components/secondary-panel/useBrowserViewOcclusion.ts (new): hit-tests the browser content area with document.elementsFromPoint on a 48px grid whenever the DOM changes (childList mutations immediately, attribute mutations and scroll/resize throttled, plus transition and animation end). If the topmost element at any sample is not the browser surface, the native view is hidden. This covers every overlay, including plugin ones, without per-component registration. Elements marked data-bb-browser-view-passthrough are looked through; the split-drag guard uses this so pane resizing keeps the live view.
  • BrowserTabContent combines this with the existing dimming-modal signal. When the view hides because something covers it, the hide request carries snapshot: true.
  • packages/desktop-contract/src/browser.ts: optional snapshot flag on the set-visible request. Renderer to main IPC only; no daemon wire change, so HOST_DAEMON_PROTOCOL_VERSION is untouched.
  • apps/desktop/src/desktop-browser-view.ts: a snapshot hide captures the page first (same cap and JPEG path as the resize snapshot), pushes it over the existing snapshot channel, then hides. Duplicate hide requests while a capture is in flight are ignored. Showing again clears the snapshot. A show that arrives before capture completes discards the snapshot.
  • browserViewVisibilityCoordinator.hide accepts { snapshot }.

Known limits: overlays with pointer-events: none are invisible to hit-testing, and overlays smaller than the grid spacing can slip through. Menus, dialogs, and floating windows are all well above that size.

How you verified

  • New tests: useBrowserViewOcclusion.test.tsx (hit-test semantics, passthrough, mount/unmount tracking, disabled state), BrowserTabContent.occlusion.test.tsx (view hides with snapshot: true when an overlay appears and shows again when it leaves), coordinator snapshot option, and three desktop-browser-view-manager cases (capture then hide, discard on early show, hide without snapshot on capture failure).
  • pnpm exec turbo run typecheck lint --filter=@bb/app --filter=@bb/desktop --filter=@bb/desktop-contract clean.
  • vitest run src/components/secondary-panel in @bb/app (394 tests) and test/desktop-browser-view-manager.test.ts in @bb/desktop pass.
  • Built and launched the desktop app from this branch via turbo run dev --filter=@bb/desktop; it starts cleanly. Manual overlay check still pending.

🤖 Generated with Claude Code

AGENT GENERATED

The embedded browser tab is an Electron WebContentsView, a native layer
that always paints above the renderer DOM. Only shared-ui Dialogs
registered as browser-dimming modals, so popovers, menus, the floating
composer, plugin overlays and other floating windows rendered underneath
the page.

BrowserTabContent now hit-tests its content area with elementsFromPoint
whenever the DOM changes and hides the native view when anything other
than the browser surface is on top. Hides caused by an overlay capture
a page snapshot first so the page stays visible under the overlay
instead of blanking. The split-drag guard opts out via a passthrough
attribute so pane resizing keeps the live view.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Thanks @dillionverma for the PR. This repo needs approval before a PR. Join the #contributors channel in Discord (https://discord.gg/kvBU6tJhcJ) and explain what you want to open a PR for and why. A maintainer then adds you to the allow list. This PR now closes on its own. Reopen it or open a new one after approval.

@github-actions github-actions Bot closed this Sep 16, 2026
@dillionverma
dillionverma deleted the fix/browser-view-overlay-occlusion branch September 16, 2026 00:44
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.

1 participant