From 3919bbf7080cae32a66bcb483237201f5db58195 Mon Sep 17 00:00:00 2001 From: Harivansh Rathi Date: Wed, 11 Mar 2026 03:38:50 -0400 Subject: [PATCH] xubuntu --- .../coding-agent/src/core/tools/browser.ts | 14 +++++++++ .../coding-agent/test/browser-tool.test.ts | 30 +++++++++++++++++++ 2 files changed, 44 insertions(+) diff --git a/packages/coding-agent/src/core/tools/browser.ts b/packages/coding-agent/src/core/tools/browser.ts index 838c2f2..cae7fb8 100644 --- a/packages/coding-agent/src/core/tools/browser.ts +++ b/packages/coding-agent/src/core/tools/browser.ts @@ -188,6 +188,7 @@ export interface BrowserToolOptions { stateDir?: string; agentDir?: string; headed?: boolean; + windowClass?: string; } interface BrowserCommandContext { @@ -287,6 +288,15 @@ function shouldLaunchHeaded(options?: BrowserToolOptions): boolean { return isTruthyEnv(process.env.COMPANION_AGENT_BROWSER_HEADED); } +function getBrowserWindowClass( + options?: BrowserToolOptions, +): string | undefined { + const rawValue = + options?.windowClass ?? process.env.COMPANION_BROWSER_WINDOW_CLASS; + const windowClass = rawValue?.trim(); + return windowClass ? windowClass : undefined; +} + function createBrowserCommandContext( profilePath: string, stateDir: string, @@ -356,6 +366,10 @@ function buildBrowserCommand( if (shouldLaunchHeaded(options)) { baseArgs.push("--headed"); } + const windowClass = getBrowserWindowClass(options); + if (windowClass) { + baseArgs.push("--args", `--class=${windowClass}`); + } switch (input.action) { case "open": { diff --git a/packages/coding-agent/test/browser-tool.test.ts b/packages/coding-agent/test/browser-tool.test.ts index c8b9005..16df03b 100644 --- a/packages/coding-agent/test/browser-tool.test.ts +++ b/packages/coding-agent/test/browser-tool.test.ts @@ -144,6 +144,36 @@ describe("browser tool", () => { ]); }); + it("passes a custom browser window class through to agent-browser", async () => { + const cwd = createTempDir("coding-agent-browser-window-class-"); + const profileDir = join(cwd, "profile"); + const stateDir = join(cwd, "states"); + const { calls, operations } = createMockBrowserOperations(); + + const browserTool = createBrowserTool(cwd, { + operations, + profileDir, + stateDir, + headed: true, + windowClass: "CompanionBrowser", + }); + + await browserTool.execute("browser-open-window-class", { + action: "open", + url: "https://example.com", + }); + + expect(calls[0]?.args).toEqual([ + "--profile", + profileDir, + "--headed", + "--args", + "--class=CompanionBrowser", + "open", + "https://example.com", + ]); + }); + it("uses interactive snapshots by default and returns snapshot text", async () => { const cwd = createTempDir("coding-agent-browser-snapshot-"); const profileDir = join(cwd, "profile");