perf: move onboarding cleanup to modal root (#4217)

This commit is contained in:
Neil
2026-05-31 08:41:11 -07:00
committed by GitHub
parent e82e48d290
commit b8b7722c00
2 changed files with 13 additions and 14 deletions
@@ -185,6 +185,7 @@ export default function OnboardingFlow({
/>
<section
ref={flow.setLifecycleRootRef}
role="dialog"
aria-label="Orca onboarding"
aria-modal="true"
@@ -359,16 +359,6 @@ export function useOnboardingFlow(
applyDocumentTheme(theme)
}, [theme])
// Why: the theme step previews on the document before persistence. Revert to
// the persisted theme only on wizard unmount so saving (which updates
// settings.theme) doesn't trigger a one-frame revert/reapply flicker.
useEffect(() => {
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,