feat(desktop): add embedded browser panel with WebContentsView#1671
Merged
benjaminshafii merged 1 commit intodevfrom May 6, 2026
Merged
feat(desktop): add embedded browser panel with WebContentsView#1671benjaminshafii merged 1 commit intodevfrom
benjaminshafii merged 1 commit intodevfrom
Conversation
Adds a built-in browser panel to the Electron desktop app, activated via a Globe icon in the session header. The browser uses WebContentsView for full process isolation with a sandboxed session partition. Main process (electron/main.mjs): - Create/show/hide/destroy a WebContentsView with sandbox=true - IPC handlers for navigate, back, forward, reload, setBounds, getState - Push navigation state changes to the renderer in real time - Clean up on window close Preload (preload.mjs): - Expose browser.* methods: show, hide, navigate, back, forward, reload, setBounds, getState, destroy, onStateChange Renderer (apps/app/): - New BrowserPanel component with URL bar, nav buttons, close button - Integrated into session-page.tsx as a right-side panel (520px) - Globe toggle icon in the session header (Electron-only) - ResizeObserver keeps WebContentsView bounds in sync with the panel - TypeScript types for the browser bridge in desktop.ts
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
benjaminshafii
added a commit
that referenced
this pull request
May 6, 2026
…ixed) Re-implements both features with fixes for the issues found in #1670/#1671: Fixes from PR1 (chrome-devtools-mcp bundling): - Use 'node' string literal instead of process.execPath in the IPC handler — process.execPath in Electron is the Electron binary, not node, so OpenCode couldn't spawn the command - Fix args filter to only carry --prefixed flags (not -y from npx) - Fix mcp.add fallback path to use resolved command from mcpEntryConfig instead of the original entry.command Fixes from PR2 (embedded browser panel): - Guard against zero-dimension bounds on first render — skip browser.show() until the panel has non-zero dimensions, let ResizeObserver trigger the actual show - Defensive try/catch in destroyBrowserView for already-destroyed webContents Verified: - resolveChromeDevtoolsMcpBin returns ['node', '<abs-path>'] (not ['Electron', '<path>']) - All 17 existing tests pass - Electron app starts and loads successfully - CDP targets visible at the remote debugging port
benjaminshafii
added a commit
that referenced
this pull request
May 6, 2026
…e-implement * Revert "feat(desktop): add embedded browser panel with WebContentsView (#1671)" This reverts commit 610ae1c. * Revert "feat(desktop): bundle chrome-devtools-mcp as dependency, eliminate npx requirement (#1670)" This reverts commit fe9881b. * feat(desktop): bundle chrome-devtools-mcp + embedded browser panel (fixed) Re-implements both features with fixes for the issues found in #1670/#1671: Fixes from PR1 (chrome-devtools-mcp bundling): - Use 'node' string literal instead of process.execPath in the IPC handler — process.execPath in Electron is the Electron binary, not node, so OpenCode couldn't spawn the command - Fix args filter to only carry --prefixed flags (not -y from npx) - Fix mcp.add fallback path to use resolved command from mcpEntryConfig instead of the original entry.command Fixes from PR2 (embedded browser panel): - Guard against zero-dimension bounds on first render — skip browser.show() until the panel has non-zero dimensions, let ResizeObserver trigger the actual show - Defensive try/catch in destroyBrowserView for already-destroyed webContents Verified: - resolveChromeDevtoolsMcpBin returns ['node', '<abs-path>'] (not ['Electron', '<path>']) - All 17 existing tests pass - Electron app starts and loads successfully - CDP targets visible at the remote debugging port * feat(desktop): auto-inject chrome-devtools MCP into opencode.json on engine start When the OpenCode engine starts in the Electron desktop app, ensureOpencodeConfig now automatically adds a chrome-devtools MCP entry to opencode.json if one doesn't already exist. The command uses the bundled chrome-devtools-mcp package (['node', '<abs-path>']) so no npm/npx is needed at runtime. This mirrors what Tauri's ensure_workspace_files() does in files.rs for the starter preset, making Control Chrome a zero-setup default for all Electron workspaces. * fix(desktop): seed chrome-devtools MCP at workspace creation time ensureOpencodeConfig in runtime.mjs only runs when the OpenCode engine starts, which happens asynchronously after the workspace is selected. New workspaces were left without a chrome-devtools entry because the engine hadn't started yet. Fix: call seedChromeDevtoolsMcp(folderPath) directly inside the workspaceCreate IPC handler so the config is written synchronously during workspace creation. The runtime.mjs ensureOpencodeConfig remains as a backup for workspaces created before this change. Verified: created a workspace via IPC, confirmed opencode.jsonc contains chrome-devtools with ['node', '<bundled-bin-path>']. * fix(desktop): migrate legacy npx/bare chrome-devtools commands to bundled node path Existing workspaces created by Tauri or older Electron versions have chrome-devtools MCP entries with npx-based or bare-binary commands like ['npx','-y','chrome-devtools-mcp@latest'] or ['chrome-devtools-mcp']. Both seedChromeDevtoolsMcp (main.mjs, runs at workspace creation) and ensureOpencodeConfig (runtime.mjs, runs at engine start) now detect these legacy commands and migrate them to the bundled ['node', path] command. User-customised commands (absolute paths, etc.) are preserved.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a built-in browser panel to the Electron desktop app. Users click the Globe icon in the session header to open a browser panel on the right side of the layout.
WebContentsView(the modern replacement forBrowserView) for full process isolationpersist:openwork-browser) -- separate cookies/storage from the main appResizeObserverkeeps the WebContentsView bounds in sync with the React panelArchitecture
The
WebContentsViewis a native Chromium view overlaid on top of the BrowserWindow. The React panel provides the toolbar (URL bar, nav buttons), and a transparent<div>placeholder where the native view renders. Bounds are synced viaResizeObserver+ window resize listener.Why this matters
This enables Chrome DevTools MCP to point at the embedded browser (
--browserUrl=http://127.0.0.1:<port>) so agents can automate a browser visible inside the app -- no external Chrome window needed. Users can watch what the agent is doing in real time.Test plan
bun test apps/app/tests/-- 0 failures)isElectronRuntime()gate)BrowserPanelcomponent shows a fallback message in non-Electron contextsFiles changed
apps/desktop/electron/main.mjsWebContentsViewbrowser management + IPC handlersapps/desktop/electron/preload.mjsbrowser.*methods via contextBridgeapps/app/src/app/lib/desktop.tsapps/app/src/react-app/domains/session/browser/browser-panel.tsxapps/app/src/react-app/domains/session/chat/session-page.tsxManual verification steps
pnpm dev:electronfromapps/desktop/