This commit is contained in:
2025-12-01 19:28:49 +01:00
parent 98a09a3f2b
commit 086fdc1ea1
8 changed files with 406 additions and 86 deletions

View File

@@ -90,8 +90,23 @@ export class PlaywrightBrowserSession {
async connect(forceHeaded: boolean = false): Promise<{ success: boolean; error?: string }> {
if (this.connected && this.page) {
this.log('debug', 'Already connected, reusing existing connection');
return { success: true };
const shouldReuse =
!forceHeaded ||
this.actualBrowserMode === 'headed';
if (shouldReuse) {
this.log('debug', 'Already connected, reusing existing connection', {
browserMode: this.actualBrowserMode,
forcedHeaded: forceHeaded,
});
return { success: true };
}
this.log('info', 'Existing browser connection is headless, reopening in headed mode for login', {
browserMode: this.actualBrowserMode,
forcedHeaded: forceHeaded,
});
await this.closeBrowserContext();
}
if (this.isConnecting) {