Skip to content

Commit 34ef702

Browse files
wesbillmanPinky
andauthored
fix(desktop): route first community deep links into onboarding (#2055)
Signed-off-by: Wes <[email protected]> Co-authored-by: Pinky <44b8e82baa6e0e254e0208d68f335c283c94e7b78dd1fa10d5a49d3f13dd0435@sprout-oss.stage.blox.sqprod.co>
1 parent 812850e commit 34ef702

2 files changed

Lines changed: 50 additions & 3 deletions

File tree

‎desktop/src/app/App.tsx‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ import { CommunityApplyErrorScreen } from "@/features/communities/ui/CommunityAp
4040
import { CommunityChangeOverlay } from "@/features/communities/ui/CommunityChangeOverlay";
4141
import { createBuzzQueryClient } from "@/shared/api/queryClient";
4242
import { isSharedIdentity as isSharedIdentityCmd } from "@/shared/api/tauri";
43-
import { listenForDeepLinks } from "@/shared/deep-link";
43+
import {
44+
type AddCommunityDeepLinkPayload,
45+
listenForDeepLinks,
46+
} from "@/shared/deep-link";
4447
import { cn } from "@/shared/lib/cn";
4548
import { BuzzMark } from "@/shared/ui/buzz-logo/BuzzMark";
4649
import { FlappingBee } from "@/shared/ui/buzz-logo/FlappingBee";
@@ -421,6 +424,18 @@ function MachineBootstrap({ sharedIdentity }: { sharedIdentity: boolean }) {
421424
[machine.complete],
422425
);
423426

427+
const openAddCommunity = useCallback(
428+
(payload: AddCommunityDeepLinkPayload & { requestId: string }) =>
429+
activeCommunity
430+
? requestAddCommunityPrefill(payload)
431+
: communityOnboarding.start({
432+
source: "add-community",
433+
relayUrl: payload.relayUrl,
434+
communityName: payload.name,
435+
}),
436+
[activeCommunity, communityOnboarding.start],
437+
);
438+
424439
// Deep links are captured here — above the machine-onboarding gate — not in
425440
// CommunityApp. The Rust side queues them; draining into the persisted
426441
// community-onboarding transaction immediately means an invite opened on a
@@ -429,13 +444,13 @@ function MachineBootstrap({ sharedIdentity }: { sharedIdentity: boolean }) {
429444
useEffect(() => {
430445
const unlisten = listenForDeepLinks({
431446
startCommunityOnboarding: communityOnboarding.start,
432-
openAddCommunity: requestAddCommunityPrefill,
447+
openAddCommunity,
433448
onAddCommunityAvailable: onAddCommunityPrefillAvailable,
434449
});
435450
return () => {
436451
void unlisten.then((fn) => fn());
437452
};
438-
}, [communityOnboarding.start]);
453+
}, [communityOnboarding.start, openAddCommunity]);
439454

440455
if (machine.stage === "reset-failed") return <ResetFailedScreen />;
441456
if (machine.stage === "keyring-locked") return <KeyringLockedScreen />;

‎desktop/tests/e2e/deep-link-invite.spec.ts‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,38 @@ test("connect deep link shows a static acknowledgment during setup", async ({
110110
.toContain('"acknowledged":true');
111111
});
112112

113+
test("add-community deep link starts onboarding when no community is configured", async ({
114+
page,
115+
}) => {
116+
await installMockBridge(
117+
page,
118+
{ pendingCommunityDeepLinks: [PENDING_ADD_COMMUNITY_LINK] },
119+
{ skipCommunitySeed: true },
120+
);
121+
await page.goto("/");
122+
123+
await expect(page.getByTestId("community-onboarding-flow")).toBeVisible();
124+
await expect(
125+
page.getByRole("heading", { name: "Build your profile" }),
126+
).toBeVisible();
127+
await expect
128+
.poll(() =>
129+
page.evaluate(
130+
(key) => window.localStorage.getItem(key),
131+
TRANSACTION_STORAGE_KEY,
132+
),
133+
)
134+
.toContain('"source":"add-community"');
135+
await expect
136+
.poll(() =>
137+
page.evaluate(
138+
(key) => window.localStorage.getItem(key),
139+
TRANSACTION_STORAGE_KEY,
140+
),
141+
)
142+
.toContain('"communityName":"Acme Team"');
143+
});
144+
113145
test("add-community deep link opens one editable prefill and acknowledges the queue", async ({
114146
page,
115147
}) => {

0 commit comments

Comments
 (0)