Skip to content

fix(browser): open new tabs on Google, auto-open pane, fix view centering - #2020

Merged
benjaminshafii merged 1 commit into
devfrom
fix/browser-panel-default-url-centering
Jun 1, 2026
Merged

fix(browser): open new tabs on Google, auto-open pane, fix view centering#2020
benjaminshafii merged 1 commit into
devfrom
fix/browser-panel-default-url-centering

Conversation

@benjaminshafii

Copy link
Copy Markdown
Member

Problem

Three issues reported with the embedded browser/artifact panel:

  1. New browser pages opened blank. A new tab loaded about:blank — the user wanted a real site (Google).
  2. Forced to click +. Opening the browser pane (Globe rail button) showed an empty panel; you had to manually click + to get a tab.
  3. Browser view not well centered. The native WebContentsView was mis-positioned within its panel.

Root cause

1/2. New-tab default was hardcoded to about:blank, and openBrowserRailPane only toggled the panel open without ever creating a tab.

  1. computeBounds multiplied the measured rect by window.__OPENWORK_ZOOM_FACTOR__. But WebContentsView.setBounds expects device-independent pixels relative to the window content area — exactly the space getBoundingClientRect() already reports (renderer zoom is already baked into the layout it measures). The extra multiply applied zoom twice, pushing the native view down-and-right and oversizing it (a no-op at the default zoom of 1, but broken for font-zoom users). Independent rounding of x/width also left a possible 1px seam.

Fix

  • apps/desktop/electron/main.mjs: add BROWSER_NEW_TAB_URL = "https://www.google.com" and use it for user-initiated createTab (the + button / opening the pane). The agent's programmatic path still uses about:blank via BROWSER_DEFAULT_URL.
  • apps/app/.../chat/session-page.tsx: openBrowserRailPane auto-creates a browser tab when opening the pane and none exists, so the Globe button lands you on Google instead of an empty panel.
  • apps/app/.../panel/utils.ts: drop the spurious * zoom in computeBounds (and getNativeMenuPoint); derive width/height from rounded edges to avoid a 1px seam. Correct at zoom=1 (identical numbers) and fixed for zoom≠1.

Testing

pnpm --filter @openwork/app typecheck → exit 0.

Verified live in the running Electron app via CDP (after restarting the desktop dev process so the main.mjs change took effect):

Screenshot of the working panel (tab "Google", URL bar https://www.google.com/, nav chrome, content region aligned to the panel):

Screenshot captured locally during verification at /tmp/browser-screenshot-1780340865758.png — reviewer can reproduce by launching the dev app and clicking the Globe rail button.

Reproduce

  1. pnpm dev
  2. Open a session, click the Globe icon in the right rail.
  3. Observe: a tab opens automatically on https://www.google.com, and the browser view fills the panel cleanly (no offset).

Notes

  • The __OPENWORK_ZOOM_FACTOR__ global is still set by font-zoom.ts and kept in the type decl; left untouched to keep the diff minimal.

…ring

Three fixes to the embedded browser panel:

- New tabs (the "+" button and opening the browser pane) now load
  https://www.google.com instead of about:blank. The agent's programmatic
  path keeps about:blank via BROWSER_DEFAULT_URL.
- Opening the browser rail pane auto-creates a browser tab when none
  exists, so users land on a usable page instead of an empty panel that
  forced a manual "+" click.
- computeBounds no longer multiplies by __OPENWORK_ZOOM_FACTOR__.
  WebContentsView.setBounds expects content-area DIP, which is the same
  space getBoundingClientRect() already reports; the extra multiply pushed
  the native view off-panel at zoom != 1. Width/height are now derived from
  rounded edges to avoid a 1px seam. getNativeMenuPoint gets the same fix.
@vercel

vercel Bot commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openwork-app Ready Ready Preview, Comment Jun 1, 2026 7:13pm
openwork-den Ready Ready Preview, Comment Jun 1, 2026 7:13pm
openwork-den-worker-proxy Ready Ready Preview, Comment Jun 1, 2026 7:13pm
openwork-landing Ready Ready Preview, Comment, Open in v0 Jun 1, 2026 7:13pm

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 3 files

Re-trigger cubic

@benjaminshafii
benjaminshafii merged commit b215f73 into dev Jun 1, 2026
11 checks passed
benjaminshafii added a commit that referenced this pull request Jun 1, 2026
PR #2020 removed the `* zoom` factor from computeBounds on the incorrect
assumption that getBoundingClientRect() already reflects the page zoom in
the native coordinate space. It does not.

The renderer applies zoom via Electron's webContents.setZoomFactor, which
scales the page so getBoundingClientRect()/innerWidth report CSS pixels
DIVIDED by the zoom factor (verified live: at zoom 1.5 a 1180 DIP window
measures innerWidth 786). WebContentsView.setBounds, however, expects
window device-independent pixels — a fixed 1180-wide content area that
does not change with zoom. So renderer rects must be multiplied back by
the zoom factor to map into the native space.

Restore the multiplication (keeping the rounded-edge width/height that
avoids a 1px seam). At zoom = 1 the result is identical to before.

Verified live via CDP at zoom 1.0 and 1.5: the native view's left/right
edges and top exactly match the panel chrome (leftAligned/rightAligned
true, chrome-bottom-to-view-top gap 0), and bounds auto-resync on zoom
change.
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