From b8b7722c00d4503ed0b3ee4ce6658870145e87f4 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Sun, 31 May 2026 08:41:11 -0700 Subject: [PATCH] perf: move onboarding cleanup to modal root (#4217) --- .../components/onboarding/OnboardingFlow.tsx | 1 + .../onboarding/use-onboarding-flow.ts | 26 +++++++++---------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/renderer/src/components/onboarding/OnboardingFlow.tsx b/src/renderer/src/components/onboarding/OnboardingFlow.tsx index 06c168bc3..cc78da79a 100644 --- a/src/renderer/src/components/onboarding/OnboardingFlow.tsx +++ b/src/renderer/src/components/onboarding/OnboardingFlow.tsx @@ -185,6 +185,7 @@ export default function OnboardingFlow({ />
{ - return () => { - applyDocumentTheme(persistedThemeRef.current) - } - // eslint-disable-next-line react-hooks/exhaustive-deps - }, []) - useEffect(() => { void refreshPreflightStatus() }, [refreshPreflightStatus]) @@ -476,11 +466,18 @@ export function useOnboardingFlow( recordOnboardingTourDepthSummary(tourOutcomeTrackerRef.current, summary) }, []) - useEffect(() => { - return () => { + const setLifecycleRootRef = useCallback( + (node: HTMLElement | null): void => { + if (node !== null) { + return + } + // Why: onboarding previews theme/tour state outside this component; tie + // final cleanup to the modal root detaching instead of passive Effects. + applyDocumentTheme(persistedThemeRef.current) emitPendingTourOutcome() - } - }, [emitPendingTourOutcome]) + }, + [emitPendingTourOutcome] + ) const trackTaskSourcesSnapshot = useCallback( ( @@ -1395,6 +1392,7 @@ export function useOnboardingFlow( recordTourDepthSummary, back, jumpToStep, + setLifecycleRootRef, openFolder, continueWithExistingProject, openSshSettings,