From 1f3833c6f9783b68f41c0d2d596148e01f1cdac4 Mon Sep 17 00:00:00 2001 From: Brainy Bumble <607666932e190ac5b35e80f42080da5e94b6b256c1bc6ab5e5b083d68393bdea@buzz.block.builderlab.xyz> Date: Tue, 29 Sep 2026 13:12:04 -0600 Subject: [PATCH] Preserve init generation when canceling enterprise login Signed-off-by: Brainy Bumble <607666932e190ac5b35e80f42080da5e94b6b256c1bc6ab5e5b083d68393bdea@buzz.block.builderlab.xyz> Signed-off-by: bb-expert <51cde9442e46eac81c83ec71552708c3b0cb96a88ff8e1581d8fb4de281afbf3@buzz.block.builderlab.xyz> --- .../src/features/communities/useCommunityInit.test.mjs | 10 ++++++---- desktop/src/features/communities/useCommunityInit.ts | 3 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/desktop/src/features/communities/useCommunityInit.test.mjs b/desktop/src/features/communities/useCommunityInit.test.mjs index 8f8004c778..9c9165eb9f 100644 --- a/desktop/src/features/communities/useCommunityInit.test.mjs +++ b/desktop/src/features/communities/useCommunityInit.test.mjs @@ -330,7 +330,7 @@ test("useCommunityInit keeps cancellation visible while browser enterprise login try { const hook = renderHook(() => - useCommunityInit(testCommunity(), "community-key", false, true), + useCommunityInit(testCommunity(), "community-key", null, false, true), ); await waitFor(() => assert.ok("enterpriseLogin" in hook.result.current)); @@ -408,7 +408,7 @@ test("useCommunityInit surfaces recovery after rejected enterprise browser login try { const hook = renderHook(() => - useCommunityInit(testCommunity(), "community-key", false, true), + useCommunityInit(testCommunity(), "community-key", null, false, true), ); await waitFor(() => assert.ok("enterpriseLogin" in hook.result.current)); @@ -466,7 +466,7 @@ test("useCommunityInit ignores successful enterprise login completion after canc try { const hook = renderHook(() => - useCommunityInit(testCommunity(), "community-key", false, true), + useCommunityInit(testCommunity(), "community-key", 7, false, true), ); await waitFor(() => assert.ok("enterpriseLogin" in hook.result.current)); @@ -488,6 +488,7 @@ test("useCommunityInit ignores successful enterprise login completion after canc await waitFor(() => assert.equal(hook.result.current.error, "Enterprise sign-in canceled"), ); + assert.equal(hook.result.current.initAttempt, 7); assert.equal("enterpriseLogin" in hook.result.current, false); assert.equal( calls.some(([command]) => command === "apply_workspace"), @@ -540,7 +541,8 @@ test("useCommunityInit keeps a newer community prompt when stale enterprise logi try { const hook = renderHook( - ({ community, key }) => useCommunityInit(community, key, false, true), + ({ community, key }) => + useCommunityInit(community, key, null, false, true), { initialProps: { community: communityA, key: "community-a-key" } }, ); diff --git a/desktop/src/features/communities/useCommunityInit.ts b/desktop/src/features/communities/useCommunityInit.ts index e4af1ce60c..ffb9df2bac 100644 --- a/desktop/src/features/communities/useCommunityInit.ts +++ b/desktop/src/features/communities/useCommunityInit.ts @@ -152,6 +152,7 @@ type CommunityInitResult = type EnterpriseLoginController = { attemptId: string; + initAttempt: number | null; browserStarted: boolean; resolve: ((allowed: boolean) => void) | null; retired: boolean; @@ -211,6 +212,7 @@ export function useCommunityInit( isReady: false, needsSetup: false, appliedKey: null, + initAttempt: controller?.initAttempt ?? null, error: "Enterprise sign-in canceled", }); if (controller?.browserStarted) { @@ -428,6 +430,7 @@ export function useCommunityInit( }`; const enterpriseLoginController: EnterpriseLoginController = { attemptId: enterpriseLoginAttemptId, + initAttempt, browserStarted: false, resolve: null, retired: false,