From fe81ca49db49725ac06f4dc16aa53751e42b3c36 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Sat, 5 Sep 2026 13:16:25 -0700 Subject: [PATCH] fix(browser): silence popup notices for links opened in Orca tabs Links that open in new Orca tabs are immediately visible to the user and don't warrant a toast notification. Only external popup opens now show notifications, reducing unnecessary clutter while still alerting the user to unexpected external window opens. --- ...entHostedBrowserPagePane.popup-notices.test.tsx | 14 +++----------- .../browser-client-hosted-popup-notices.ts | 12 ++++++------ .../browser-pane/navigate/browser-notices.test.ts | 2 +- .../browser-pane/navigate/browser-notices.ts | 4 ++-- .../navigate/use-browser-page-resource-notices.ts | 5 ++++- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/renderer/src/components/browser-pane/ClientHostedBrowserPagePane.popup-notices.test.tsx b/src/renderer/src/components/browser-pane/ClientHostedBrowserPagePane.popup-notices.test.tsx index 779c33a751a..80762dcb87f 100644 --- a/src/renderer/src/components/browser-pane/ClientHostedBrowserPagePane.popup-notices.test.tsx +++ b/src/renderer/src/components/browser-pane/ClientHostedBrowserPagePane.popup-notices.test.tsx @@ -99,21 +99,13 @@ describe('ClientHostedBrowserPagePane popup notices', () => { expect(new Set(ids).size).toBe(1) }) - // Why: the local pane reports all three outcomes; only "blocked" reaching this pane left a page - // that silently opened somewhere else looking like it did nothing. - it('reports where a popup Orca did open actually went', () => { + it('silences in-Orca opens but reports external opens', () => { renderPane() emitPopup({ action: 'opened-in-orca' }) + expect(toastMocks.message).not.toHaveBeenCalled() emitPopup({ action: 'opened-external' }) - - expect(toastMocks.message).toHaveBeenNthCalledWith( - 1, - 'https://accounts.example.com opened a new page in Orca.', - { id: 'browser-popup:page-a:opened-in-orca:https://accounts.example.com' } - ) - expect(toastMocks.message).toHaveBeenNthCalledWith( - 2, + expect(toastMocks.message).toHaveBeenCalledExactlyOnceWith( 'https://accounts.example.com opened a new window in your default browser.', { id: 'browser-popup:page-a:opened-external:https://accounts.example.com' } ) diff --git a/src/renderer/src/components/browser-pane/browser-client-hosted-popup-notices.ts b/src/renderer/src/components/browser-pane/browser-client-hosted-popup-notices.ts index 1894cae892f..510bbeec03e 100644 --- a/src/renderer/src/components/browser-pane/browser-client-hosted-popup-notices.ts +++ b/src/renderer/src/components/browser-pane/browser-client-hosted-popup-notices.ts @@ -2,18 +2,18 @@ import { useEffect } from 'react' import { toast } from 'sonner' import { formatPopupNotice } from './navigate/browser-notices' -/** - * A client-hosted page's popups are gesture-gated and capped, and every outcome — blocked, opened - * in an Orca tab, or handed to the default browser — leaves no other trace on this pane. One quiet - * toast per page and origin says what happened, without spamming a site that retries. - */ +// Deduplicate blocked and external-popup notices per page and origin. export function useBrowserClientHostedPopupNotices(browserPageId: string): void { useEffect(() => { return window.api.browser.onPopup((event) => { if (event.browserPageId !== browserPageId) { return } - toast.message(formatPopupNotice(event), { + const notice = formatPopupNotice(event) + if (!notice) { + return + } + toast.message(notice, { id: `browser-popup:${browserPageId}:${event.action}:${event.origin}` }) }) diff --git a/src/renderer/src/components/browser-pane/navigate/browser-notices.test.ts b/src/renderer/src/components/browser-pane/navigate/browser-notices.test.ts index f812d5fe02f..b54b70055d1 100644 --- a/src/renderer/src/components/browser-pane/navigate/browser-notices.test.ts +++ b/src/renderer/src/components/browser-pane/navigate/browser-notices.test.ts @@ -83,7 +83,7 @@ describe('browser notice formatting', () => { origin: 'https://example.com', action: 'opened-in-orca' }) - ).toBe('https://example.com opened a new page in Orca.') + ).toBeNull() expect( formatPopupNotice({ diff --git a/src/renderer/src/components/browser-pane/navigate/browser-notices.ts b/src/renderer/src/components/browser-pane/navigate/browser-notices.ts index ca5e6aa209a..445e92d278a 100644 --- a/src/renderer/src/components/browser-pane/navigate/browser-notices.ts +++ b/src/renderer/src/components/browser-pane/navigate/browser-notices.ts @@ -64,10 +64,10 @@ export function formatPermissionNotice(event: BrowserPermissionDeniedEvent): str return `${target} asked for ${humanizePermission(event.permission)}, and Orca denied it.` } -export function formatPopupNotice(event: BrowserPopupEvent): string { +export function formatPopupNotice(event: BrowserPopupEvent): string | null { const target = event.origin === 'unknown' ? 'A site' : event.origin if (event.action === 'opened-in-orca') { - return `${target} opened a new page in Orca.` + return null } if (event.action === 'opened-external') { return `${target} opened a new window in your default browser.` diff --git a/src/renderer/src/components/browser-pane/navigate/use-browser-page-resource-notices.ts b/src/renderer/src/components/browser-pane/navigate/use-browser-page-resource-notices.ts index e3be43f4aac..9fad1200742 100644 --- a/src/renderer/src/components/browser-pane/navigate/use-browser-page-resource-notices.ts +++ b/src/renderer/src/components/browser-pane/navigate/use-browser-page-resource-notices.ts @@ -50,7 +50,10 @@ export function useBrowserPageResourceNotices(browserTabId: string): { if (event.browserPageId !== browserTabId) { return } - setResourceNotice(formatPopupNotice(event)) + const notice = formatPopupNotice(event) + if (notice) { + setResourceNotice(notice) + } }) }, [browserTabId])