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>
This commit is contained in:
Brainy Bumble
2026-09-29 13:12:04 -06:00
committed by bb-expert
parent e49d3fe976
commit 1f3833c6f9
2 changed files with 9 additions and 4 deletions

View File

@@ -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" } },
);

View File

@@ -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,