Skip to content

fix(desktop): keep agent browsing out of the app window and on-screen - #2159

Merged
benjaminshafii merged 1 commit into
devfrom
fix/browser-takeover-and-blank
Jun 10, 2026
Merged

fix(desktop): keep agent browsing out of the app window and on-screen#2159
benjaminshafii merged 1 commit into
devfrom
fix/browser-takeover-and-blank

Conversation

@benjaminshafii

Copy link
Copy Markdown
Member

Summary

Fixes #2000 and #2015 — the remaining built-in-browser gaps at HEAD after the Puppeteer→CDP migration (#1707/#1861) and the post-0.14.0 fixes (#2020/#2022/#2079).

Root causes & changes (apps/desktop/electron/main.mjs)

#2000 — browser takes over the whole app window, no way back

The will-navigate guard added in #2079 routes blocked main-window navigations into a browser tab — but will-navigate never fires for CDP Page.navigate, which behaves like loadURL. The agent's opencode-chrome-devtools plugin defaults to the first page target when target_id is omitted, and when no browser tab exists yet that target is the OpenWork main window itself. Result: the workspace UI replaced wholesale by the website, with no close control (and no app menu on Windows).

→ Added a did-start-navigation guard on the main window that cancels disallowed external main-frame loads (webContents.stop()) and reroutes the URL into a built-in browser tab via the existing routeBlockedMainWindowNavigation.

#2015 — browser shows about:blank while navigation "succeeds"

Only the active tab's WebContentsView is attached to the window; background tabs stay alive but detached. Agent CDP navigation of a background tab returns full success (snapshots/screenshots work offscreen) while the visible active tab sits on about:blank.

→ Tab did-start-navigation now auto-selects the navigated tab so it becomes visible. data: loads (the internal CDP target-marker pages) no longer trigger the panel.

Tests run

  • pnpm --filter @openwork/desktop typecheck:electron — pass.
  • pnpm --filter @openwork/desktop check:electron — pass (bridge covers 50 renderer methods).
  • node --check apps/desktop/electron/main.mjs — pass.
  • I could not run a Windows desktop build in this environment. Reviewer repro:
    1. Fresh session, no browser tab open. Have the agent call browser_navigate without target_id (or prompt a browse task) → the app window must NOT be replaced; the site must open in the side-panel browser.
    2. Open two browser tabs; navigate the background tab via CDP → it should be brought on screen instead of leaving the active tab blank.

Two built-in browser gaps after the CDP-plugin migration:

#2000 - will-navigate never fires for CDP Page.navigate, so agent
automation that picked the wrong CDP target (the app window is the
first page target when no browser tab exists) replaced the entire
workspace UI with the website, with no way back. A did-start-navigation
guard on the main window now cancels disallowed external loads and
reroutes the URL into a built-in browser tab.

#2015 - only the active tab's WebContentsView is attached; agent CDP
navigation of a background tab 'succeeded' while the visible tab stayed
on about:blank. Tab navigations now auto-select the navigated tab so it
becomes visible. data: loads (internal CDP target-marker pages) no
longer surface the panel.

Fixes #2000, fixes #2015
@vercel

vercel Bot commented Jun 10, 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 10, 2026 9:19pm
openwork-den Ready Ready Preview, Comment Jun 10, 2026 9:19pm
openwork-den-worker-proxy Ready Ready Preview, Comment Jun 10, 2026 9:19pm
openwork-landing Ready Ready Preview, Comment, Open in v0 Jun 10, 2026 9:19pm

@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 1 file

Re-trigger cubic

@benjaminshafii
benjaminshafii merged commit 1d1de22 into dev Jun 10, 2026
11 checks passed
@benjaminshafii
benjaminshafii deleted the fix/browser-takeover-and-blank branch June 10, 2026 21:41
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.

[Bug]: Unable to exit from Browser

1 participant