bug(browser): preview WebContentsView renders in the wrong position
Bug
The browser preview panel (ao preview <url> / the in-app browser view) renders its native WebContentsView in the wrong position — misaligned relative to where the app's placeholder UI expects it to sit. Reporter will attach a screenshot to this issue.
Reporter's environment: Debian Linux, triggered via ao preview. Not yet confirmed whether this is Linux-specific or reproduces on other platforms too — see caveat below.
How positioning works (traced, not guessed)
- Main process creates the view via
createBrowserViewHost()and adds it as a child view (frontend/src/main/browser-view-host.ts:137-163), starting at an off-screen sentinel bounds. - Positioning is entirely renderer-driven over IPC — there is no bounds computation in the main process.
useBrowserView(frontend/src/renderer/hooks/useBrowserView.ts) reads a placeholder<div>'sgetBoundingClientRect()(useBrowserView.ts:59-71), intersects it with the enclosing[data-panel]column's rect, and sends the result viawindow.ao.browser.setBounds({ viewId, rect, visible })(useBrowserView.ts:120). - The main process's
browser:setBoundshandler (browser-view-host.ts:235) clamps the incoming rect's width/height againstmainWindow.getContentBounds()(clampBoundsToWindow,browser-view-host.ts:115-135) — note it does not re-derivex/yfrom the window, it only shrinks the rect to fit — then applies it directly viaview.setBounds(bounds). - Re-measurement is triggered only by renderer-side signals: a
ResizeObserveron the slot node and its panel-column ancestor, a windowresize/scrolllistener, and a ~280ms "settle" re-measure after URL/active-tab changes (useBrowserView.ts:147-175, 211-222).
Suspected fragility (not a confirmed root cause, and not confirmed to be platform-specific)
There is no main-process window move/resize listener. mainWindow.on(...) in frontend/src/main.ts:233 only handles "closed" — nothing re-syncs the view's bounds when the OS-level window itself moves, resizes, maximizes, or changes monitor/scale-factor. All re-sync depends entirely on the renderer's ResizeObserver/window.resize events firing correctly.
I checked for platform-specific branches (process.platform, DPI/scale-factor handling) in the positioning path (browser-view-host.ts, useBrowserView.ts) and found none — the code is platform-agnostic by design. So this isn't a case of AO special-casing (or mishandling) Linux specifically. It's an open question whether the missing resize/move listener above, or a DPI/fractional-scaling coordinate mismatch, behaves differently across window managers/compositors (X11, Wayland, macOS, Windows) in a way that would make this manifest only on some platforms — that hasn't been confirmed either way yet.
Git history shows prior positioning/clipping fixes to this component (0b4c2090, acd811dc, b39a4795) but none mention Linux/X11/Wayland/DPI specifically, so this looks like a genuinely new observation rather than a regression of a known platform-specific fix.
Screenshots
Repro (to be confirmed/expanded by reporter)
- On Debian Linux, run
ao preview <url>inside a session. - Observe the browser view rendering offset from its expected panel position (screenshot to follow).
- Worth checking during triage: does resizing/moving/maximizing the app window change the offset? Does it differ between X11 and Wayland, or with fractional display scaling on vs off? Does it reproduce on macOS/Windows?
Next steps
Needs reproduction (on the reporter's Debian machine, and ideally on macOS/Windows for comparison) to determine whether this is platform-specific at all, and if so whether the main-process resize/move gap above is the cause, or a DPI/fractional-scaling issue at the Electron/Chromium compositor level (outside AO's own code).
Thanks for contributing to Agent Orchestrator.
This issue is being picked up by the current external contributor on-call pair:
- @neversettle17-101
- @somewherelostt
If someone is already working on this, please continue as usual. The on-call pair is added for visibility, tracking, and support, not to take over the work. If you need help with review, direction, reproduction, or next steps, please tag @neversettle17-101 and @somewherelostt here. You can also join the AO Discord if you want faster context, want to ask questions live, or just want to follow what the community is building.
You are also welcome to join the AO Discord community.
We do daily Discord calls at 10 PM IST, except Saturday.
Join the session here: https://discord.gg/H6ZDcUXmq
Come by if you want to see what is being built, ask questions, or just hang around with the community.
@Vaibhaav-Tiwari This was closed as completed on Aug 27, but I can't find a PR or commit that addressed it — what shipped for this? I still see the preview render at stale bounds after an OS-level window move/resize; if that's still a bug I'm happy to revive #3898.
Follow-up: answered my own question by tracing the code. Current main positions the native view window-relative (setBounds clamps to the window content bounds, so an OS-level move carries the view along), and resize/animation staleness is covered by #5719 (layout revisions + boundsApplied ack + settle re-measure). Retracting the question above — closing my two stale PRs (#3898, #3903) as covered.