From aca39f390e1a7fdacfcd8b0f262258f3403b330b Mon Sep 17 00:00:00 2001 From: Raghav Chari Date: Fri, 14 Aug 2026 23:44:22 +0000 Subject: [PATCH] fix(extension): make Google connector browser launch diagnosable and reliable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - server_manager: log BROWSER and VSCODE_IPC_HOOK_CLI at spawn so a 'browser doesn't launch' failure is immediately visible in the 'Amicode — opencode' output channel. The extension already inherits process.env (including BROWSER) into the opencode server, but without logging the failure was silent. - Companion fork fix (harmoniqs/opencode#fix/google-connector-browser-launch): McpBrowser now respects BROWSER (the VS Code helper that does code --openExternal via IPC) before falling back to xdg-open, and the Connections tab now wires onStartAuth for google/google-drive to POST /amicode/connections/auth and open the returned URL. Together they make the Google connector's 'Connect with browser' actually launch the browser in devcontainers and remote hosts. After the fork merges, bump the vendored opencode (opencode.lock.json) to pick up the fix. Fixes: No Google Workspace integration browser launch (issue #335 follow-up) --- packages/extension/src/server_manager.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/extension/src/server_manager.ts b/packages/extension/src/server_manager.ts index 3cd6760a..7f19f7c8 100644 --- a/packages/extension/src/server_manager.ts +++ b/packages/extension/src/server_manager.ts @@ -59,6 +59,14 @@ export class ServerManager { this._port = port; this.opts.channel.appendLine(`[server] spawning opencode serve --port=${port} (cwd=${this.opts.cwd})`); + // Browser wiring for Google connector (and any MCP OAuth): VS Code remote sets + // BROWSER to the helper that does `code --openExternal` via VSCODE_IPC_HOOK_CLI. + // The opencode McpBrowser now respects BROWSER first (fallback to xdg-open), + // but only if the server inherits it. Explicitly log what we propagate so a + // "browser doesn't launch" failure is diagnosable from the output channel. + const browserEnv = process.env.BROWSER ? `BROWSER=${process.env.BROWSER}` : "BROWSER=(unset)" + const ipcEnv = process.env.VSCODE_IPC_HOOK_CLI ? "VSCODE_IPC_HOOK_CLI=present" : "VSCODE_IPC_HOOK_CLI=(unset)" + this.opts.channel.appendLine(`[server] browser env: ${browserEnv}, ${ipcEnv}`) const child = cp.spawn(this.opts.binary, ["serve", "--port", String(port)], { cwd: this.opts.cwd, env: { ...process.env, ...this.opts.env },