From ddf4e2fba3d96e8381465921b342b74e40ccff77 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Sat, 31 Oct 2026 00:52:22 -0700 Subject: [PATCH 1/2] fix(desktop): keep sign-in popups working in the agent browser - Adopt window.open('') / about:blank popups as tabs that keep window.opener (MSAL-style sign-in and payment flows got null) - Read an adopted popup's session from its contents, not its URL - Refuse a form POST into a new tab rather than resending it as a GET; forward the referrer on reissued links - Closing a popup returns to its opener unless the user switched tabs since (Chrome's rule) - mailto: links in the app window open the mail client, with attach/extra headers refused --- apps/desktop/e2e/browser-tools.spec.ts | 168 +++++++++++++++++- .../src/main/browser-agent/session.test.ts | 2 +- .../desktop/src/main/browser-agent/session.ts | 76 +++++--- apps/desktop/src/main/navigation.test.ts | 31 ++++ apps/desktop/src/main/navigation.ts | 65 ++++++- 5 files changed, 305 insertions(+), 37 deletions(-) diff --git a/apps/desktop/e2e/browser-tools.spec.ts b/apps/desktop/e2e/browser-tools.spec.ts index 3b573ad9df3..92e5e18d429 100644 --- a/apps/desktop/e2e/browser-tools.spec.ts +++ b/apps/desktop/e2e/browser-tools.spec.ts @@ -1,5 +1,5 @@ import { mkdtempSync } from 'node:fs' -import { createServer, type Server } from 'node:http' +import { createServer, type IncomingMessage, type Server } from 'node:http' import { tmpdir } from 'node:os' import { join } from 'node:path' import { fileURLToPath } from 'node:url' @@ -62,6 +62,36 @@ const CAPABILITIES_FIXTURE = `Capabilities fixture const POPUP_FIXTURE = `Authorize fixture ` +/** Sign-in and payment popup patterns: blank-then-navigate, and form posts into a new tab. */ +const popupsFixture = ( + appOrigin: string, + popupOrigin: string +) => `Popups fixture +
+
+` + +async function readBody(request: IncomingMessage): Promise { + let body = '' + for await (const chunk of request) body += chunk.toString() + return body +} + +const echoPage = (method: string | undefined, body: string) => + `${method} ${body}` + const UPLOAD_TARGET_FIXTURE = `Upload target fixture