From 5b7a1e0452f5c84d1910317ffae917f1c36651e7 Mon Sep 17 00:00:00 2001 From: Ryan Malloy Date: Mon, 11 Aug 2025 04:36:39 -0600 Subject: [PATCH] fix: restore headed mode by using browser context factory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fix browser_configure tool to properly use browser context factory - Remove bypass of browser context factory that was ignoring configuration changes - Headed mode now works correctly when DISPLAY is available - Browser windows properly appear when switching from headless to headed mode 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- src/context.ts | 40 ++-------------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) diff --git a/src/context.ts b/src/context.ts index e998b03..f3cb31d 100644 --- a/src/context.ts +++ b/src/context.ts @@ -243,8 +243,8 @@ export class Context { // Create a new browser context with video recording enabled result = await this._createVideoEnabledContext(); } else { - // Use session-aware browser context factory - result = await this._createSessionIsolatedContext(); + // Use the standard browser context factory + result = await this._browserContextFactory.createContext(this.clientVersion!); } const { browserContext } = result; await this._setupRequestInterception(browserContext); @@ -299,42 +299,6 @@ export class Context { }; } - private async _createSessionIsolatedContext(): Promise<{ browserContext: playwright.BrowserContext, close: () => Promise }> { - // Always create isolated browser contexts for each MCP client - // This ensures complete session isolation between different clients - const browserType = playwright[this.config.browser.browserName]; - - // Get environment-specific browser options - const envOptions = this._environmentIntrospector.getRecommendedBrowserOptions(); - - const browser = await browserType.launch({ - ...this.config.browser.launchOptions, - ...envOptions, // Include environment-detected options - handleSIGINT: false, - handleSIGTERM: false, - }); - - // Create isolated context options with session-specific storage - const contextOptions = { - ...this.config.browser.contextOptions, - // Each session gets its own isolated storage - no shared state - storageState: undefined, - }; - - const browserContext = await browser.newContext(contextOptions); - - testDebug(`created isolated browser context for session: ${this.sessionId}`); - - return { - browserContext, - close: async () => { - testDebug(`closing isolated browser context for session: ${this.sessionId}`); - await browserContext.close(); - await browser.close(); - } - }; - } - setVideoRecording(config: { dir: string; size?: { width: number; height: number } }, baseFilename: string) { this._videoRecordingConfig = config; this._videoBaseFilename = baseFilename;