From c63744cf7c8115d0c5ea75707fba6b92869dcffa Mon Sep 17 00:00:00 2001 From: Taylor Ho Date: Thu, 6 Aug 2026 16:52:38 -0700 Subject: [PATCH] fix(desktop): preserve routed onboarding after recovery Co-authored-by: Taylor Ho Signed-off-by: Taylor Ho --- desktop/src/app/App.tsx | 2 +- .../src/features/communities/ui/WelcomeSetup.tsx | 13 +++++++++++-- .../src/features/onboarding/OnboardingHistory.tsx | 11 +++++++---- .../onboarding/ui/MachineOnboardingFlow.tsx | 2 +- desktop/tests/e2e/community-rail.spec.ts | 6 ++++++ desktop/tests/e2e/identity-lost.spec.ts | 10 ++++++++++ 6 files changed, 36 insertions(+), 8 deletions(-) diff --git a/desktop/src/app/App.tsx b/desktop/src/app/App.tsx index 3075eb80a..df0507513 100644 --- a/desktop/src/app/App.tsx +++ b/desktop/src/app/App.tsx @@ -521,7 +521,7 @@ function CommunityApp({ if (community.needsSetup) { // Show welcome setup for first-run users with no communities appContent = ( - diff --git a/desktop/src/features/communities/ui/WelcomeSetup.tsx b/desktop/src/features/communities/ui/WelcomeSetup.tsx index 39c425aa3..40754a73e 100644 --- a/desktop/src/features/communities/ui/WelcomeSetup.tsx +++ b/desktop/src/features/communities/ui/WelcomeSetup.tsx @@ -80,7 +80,14 @@ export function WelcomeSetup({ React.useEffect(() => { const step = onboardingHistory.step; if (!step) { - onboardingHistory.replace(routeForWelcomePage(page)); + if (canReturnToMachineConfig) { + onboardingHistory.replace(routeForWelcomePage(page)); + } else { + // Leaving the final community starts a new discovery flow. Retire the + // app history behind it so browser Back cannot escape to a route that + // no longer has an active community. + onboardingHistory.reset(routeForWelcomePage(page)); + } return; } if (isMachineOnboardingRouteStep(step)) return; @@ -97,8 +104,10 @@ export function WelcomeSetup({ setIsHostedSignInOpen(false); setPage(pageForWelcomeRoute(step)); }, [ + canReturnToMachineConfig, onboardingHistory.direction, onboardingHistory.replace, + onboardingHistory.reset, onboardingHistory.step, page, ]); @@ -209,7 +218,7 @@ export function WelcomeSetup({ -{canReturnToMachineConfig ? ( + {canReturnToMachineConfig ? (