fix: restore headed mode by using browser context factory
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
aa84278d36
commit
5b7a1e0452
@ -243,8 +243,8 @@ export class Context {
|
|||||||
// Create a new browser context with video recording enabled
|
// Create a new browser context with video recording enabled
|
||||||
result = await this._createVideoEnabledContext();
|
result = await this._createVideoEnabledContext();
|
||||||
} else {
|
} else {
|
||||||
// Use session-aware browser context factory
|
// Use the standard browser context factory
|
||||||
result = await this._createSessionIsolatedContext();
|
result = await this._browserContextFactory.createContext(this.clientVersion!);
|
||||||
}
|
}
|
||||||
const { browserContext } = result;
|
const { browserContext } = result;
|
||||||
await this._setupRequestInterception(browserContext);
|
await this._setupRequestInterception(browserContext);
|
||||||
@ -299,42 +299,6 @@ export class Context {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private async _createSessionIsolatedContext(): Promise<{ browserContext: playwright.BrowserContext, close: () => Promise<void> }> {
|
|
||||||
// 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) {
|
setVideoRecording(config: { dir: string; size?: { width: number; height: number } }, baseFilename: string) {
|
||||||
this._videoRecordingConfig = config;
|
this._videoRecordingConfig = config;
|
||||||
this._videoBaseFilename = baseFilename;
|
this._videoBaseFilename = baseFilename;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user