The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(webapp): state what the pop-out gives up without noopener
Adolanium498003444108
diff --git a/apps/desktop/src/lib/browser-window.test.ts b/apps/desktop/src/lib/browser-window.test.tsindex cc633d3f519..479ec211c24 100644--- a/apps/desktop/src/lib/browser-window.test.ts+++ b/apps/desktop/src/lib/browser-window.test.ts@@ -17,25 +17,33 @@ function target(): URL {return new URL('/?win=secondary#/session-1', window.location.origin)}+// The browser's side of window.open: `child` is null when the popup blocker stops the window, and a+// `noopener` or `noreferrer` open returns null even when the window opens (HTML window open steps).+function browserOpens(child: Window | null) {+ return vi.spyOn(window, 'open').mockImplementation((_url, _target, features) =>+ /noopener|noreferrer/.test(features ?? '') ? null : child+ )+}+describe('browser pop-out', () => {it('reports a blocked popup instead of success', async () => {- vi.spyOn(window, 'open').mockReturnValue(null)+ browserOpens(null)await expect(opener(false)(target())).rejects.toThrow(POPUP_BLOCKED)})- it('resolves when the browser returns a window and severs its opener', async () => {+ it('resolves when the browser opens the window and severs its opener', async () => {const child = { opener: window } as Window- const open = vi.spyOn(window, 'open').mockReturnValue(child)+ const open = browserOpens(child)const href = target().hrefawait expect(opener(false)(new URL(href))).resolves.toEqual({ ok: true })- expect(open).toHaveBeenCalledWith(href, '_blank')+ expect(open.mock.calls[0]?.[0]).toBe(href)expect(child.opener).toBeNull()})it('reports a blocked private-session popup without waiting for the handoff', async () => {- vi.spyOn(window, 'open').mockReturnValue(null)+ browserOpens(null)vi.stubGlobal('BroadcastChannel',class {diff --git a/apps/desktop/src/lib/browser-window.ts b/apps/desktop/src/lib/browser-window.tsindex a2f23fe44c1..661bc1ae107 100644--- a/apps/desktop/src/lib/browser-window.ts+++ b/apps/desktop/src/lib/browser-window.ts@@ -10,8 +10,12 @@ interface BrowserWindowOptions {const POPUP_BLOCKED = 'Webapp window did not open. Allow popups for this site and try again.'-// `noopener` makes a successful open return null (HTML window open step 18),-// so a blocked popup is indistinguishable. Sever opener on the handle instead.+// No `noopener`: with it, window.open returns null even when the window opens (HTML "window+// open steps"), so a blocked popup cannot be told from an open one. Severing `opener` on the+// handle keeps the window from reaching this one. The rest of what noopener prevented now+// happens: the browser copies this tab's sessionStorage into the window and sends this URL as a+// same-origin Referer. The only credential in that copy is the launch-link one, which the window+// ticket below hands over anyway.function openWebappWindow(href: string): Window | null {const opened = window.open(href, '_blank')@@ -22,7 +26,10 @@ function openWebappWindow(href: string): Window | null {return opened}-/** Open synchronously in the user gesture; never rely on an opener/storage copy. */+/**+ * Open synchronously in the user gesture. A launch-link tab's window signs in with a one-use ticket+ * and does not rely on the opener or on the sessionStorage copy.+ */export function createBrowserWindowOpener({ api, basePath, privateSession }: BrowserWindowOptions) {return (target: URL): Promise<{ ok: true }> => {if (!privateSession) {