mirror of
https://github.com/block/buzz.git
synced 2026-11-07 18:01:06 +00:00
fix(desktop): reserve deep links for main window
Co-authored-by: Rizz <302abe414ca6e3134763d2539bfcf145aea2a63fe5f8455204ed602fd40cf381@buzz.block.builderlab.xyz> Signed-off-by: Taylor Ho <taylorkmho@gmail.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user