From 4a50a5e0884c6e4747720600a5fb7fde8bd891e8 Mon Sep 17 00:00:00 2001 From: Taylor Ho Date: Sun, 23 Aug 2026 20:40:07 -0700 Subject: [PATCH] fix(desktop): reserve deep links for main window Co-authored-by: Rizz <302abe414ca6e3134763d2539bfcf145aea2a63fe5f8455204ed602fd40cf381@buzz.block.builderlab.xyz> Signed-off-by: Taylor Ho --- desktop/src/app/App.tsx | 13 +++++++++---- desktop/src/app/companionWindow.test.mjs | 13 ++++++++++++- desktop/src/app/companionWindow.ts | 7 +++++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/desktop/src/app/App.tsx b/desktop/src/app/App.tsx index bfaf2ba200..a52f86b5c3 100644 --- a/desktop/src/app/App.tsx +++ b/desktop/src/app/App.tsx @@ -23,7 +23,10 @@ import { CommunityThemeController } from "@/shared/theme/CommunityThemeControlle import { useReloadShortcut } from "@/app/useReloadShortcut"; import { useCloseWindowShortcut } from "@/app/useCloseWindowShortcut"; import { KnownAgentPubkeysProvider } from "@/features/agents/useKnownAgentPubkeys"; -import { huddleWindowChannelId } from "@/features/huddle/lib/huddleWindow"; +import { + acceptsNativeDeepLinks, + currentCompanionWindowKind, +} from "@/app/companionWindow"; import { useAppOnboardingState } from "@/features/onboarding/hooks"; import { useMachineOnboardingState } from "@/features/onboarding/machineOnboarding"; import { @@ -712,10 +715,12 @@ function MachineBootstrap({ sharedIdentity }: { sharedIdentity: boolean }) { [activeCommunity, communityOnboarding.start], ); - // Community links are app-global work. A Huddle companion loads the same + // Community links are app-global work. Companion windows load the same // React tree, but must never race the main window for the native pending-link - // queue or replace its dedicated transcript surface with onboarding. - const acceptsCommunityDeepLinks = huddleWindowChannelId() === null; + // queue or replace their dedicated surface with onboarding. + const acceptsCommunityDeepLinks = acceptsNativeDeepLinks( + currentCompanionWindowKind(), + ); useEffect(() => { if (!acceptsCommunityDeepLinks) return; diff --git a/desktop/src/app/companionWindow.test.mjs b/desktop/src/app/companionWindow.test.mjs index cec4b4cc0c..c619b685ef 100644 --- a/desktop/src/app/companionWindow.test.mjs +++ b/desktop/src/app/companionWindow.test.mjs @@ -1,7 +1,10 @@ import assert from "node:assert/strict"; import { describe, it } from "node:test"; -import { companionWindowKindForLabel } from "./companionWindow.ts"; +import { + acceptsNativeDeepLinks, + companionWindowKindForLabel, +} from "./companionWindow.ts"; describe("companionWindowKindForLabel", () => { it("classifies focused companion labels", () => { @@ -17,3 +20,11 @@ describe("companionWindowKindForLabel", () => { assert.equal(companionWindowKindForLabel("reader-document"), null); }); }); + +describe("acceptsNativeDeepLinks", () => { + it("reserves the pending-link queue for the main realm", () => { + assert.equal(acceptsNativeDeepLinks(null), true); + assert.equal(acceptsNativeDeepLinks("huddle"), false); + assert.equal(acceptsNativeDeepLinks("agent-activity"), false); + }); +}); diff --git a/desktop/src/app/companionWindow.ts b/desktop/src/app/companionWindow.ts index 1204870f91..fba526d901 100644 --- a/desktop/src/app/companionWindow.ts +++ b/desktop/src/app/companionWindow.ts @@ -24,6 +24,13 @@ export function currentCompanionWindowKind(): CompanionWindowKind | null { } } +/** Whether this realm owns the native pending deep-link queue. */ +export function acceptsNativeDeepLinks( + companionKind: CompanionWindowKind | null, +): boolean { + return companionKind === null; +} + /** Whether this webview is a focused companion rather than the primary app. */ export function isCompanionWindow(): boolean { return currentCompanionWindowKind() !== null;