@@ -329,75 +329,101 @@ function CommunityApp({
329329 communityOnboarding . update ( { stage : "profile" , error : undefined } ) ;
330330 }
331331 } , [ communityOnboarding . update , targetIsReady , transaction ?. stage ] ) ;
332- if ( transaction ) {
333- return (
334- < CommunityOnboardingFlow onConnect = { handleCommunityOnboardingConnect } />
335- ) ;
336- }
332+ // During "entering" the transaction stays alive as a curtain: the app mounts
333+ // underneath (already pointed at the Welcome channel route) while the
334+ // onboarding screen covers it, then fades once Welcome reports ready.
335+ //
336+ // The flow must keep ONE stable position in the element tree across every
337+ // stage. Rendering it from a different slot when the stage flips to
338+ // "entering" would remount it — React state resets and the "Meet your
339+ // starter team" screen visibly restarts mid-handoff.
340+ const isEnteringCurtain = transaction ?. stage === "entering" ;
337341
338- // Show welcome setup for first-run users with no communities
339- if ( community . needsSetup ) {
340- return (
341- < WelcomeSetup
342- defaultRelayUrl = { community . defaultRelayUrl }
343- onBack = { onBackToMachineConfig }
344- />
345- ) ;
346- }
342+ // The app mounts (and starts loading data) beneath the splash overlay; the
343+ // overlay just keeps the bee on screen long enough to be seen, then fades.
344+ // Community switches keep their quiet gate.
345+ const showBootSplashOverlay =
346+ bootSplashPhase !== "done" && ! isCommunitySwitch ;
347347
348- // Surface apply failures so the user can retry or change community.
349- if ( "error" in community && community . error ) {
350- return (
351- < >
352- < CommunityApplyErrorScreen
353- error = { community . error }
354- onChangeCommunity = { ( ) => setIsCommunityChangeOpen ( true ) }
355- onRetry = { reconnectCommunity }
348+ let appContent : ReactNode = null ;
349+ if ( ! transaction ) {
350+ if ( community . needsSetup ) {
351+ // Show welcome setup for first-run users with no communities
352+ appContent = (
353+ < WelcomeSetup
354+ defaultRelayUrl = { community . defaultRelayUrl }
355+ onBack = { onBackToMachineConfig }
356356 />
357- { isCommunityChangeOpen ? (
358- < CommunityChangeOverlay
359- onClose = { ( ) => setIsCommunityChangeOpen ( false ) }
357+ ) ;
358+ } else if ( "error" in community && community . error ) {
359+ // Surface apply failures so the user can retry or change community.
360+ appContent = (
361+ < >
362+ < CommunityApplyErrorScreen
363+ error = { community . error }
364+ onChangeCommunity = { ( ) => setIsCommunityChangeOpen ( true ) }
365+ onRetry = { reconnectCommunity }
360366 />
361- ) : null }
362- </ >
363- ) ;
367+ { isCommunityChangeOpen ? (
368+ < CommunityChangeOverlay
369+ onClose = { ( ) => setIsCommunityChangeOpen ( false ) }
370+ />
371+ ) : null }
372+ </ >
373+ ) ;
374+ }
364375 }
365-
366376 // Wait for this exact community config to be applied to the backend before
367377 // rendering anything that connects to the relay. The appliedKey check avoids
368- // a one-render race where React sees the new active community while the Tauri
369- // backend is still configured for the previous one.
370- if ( ! community . isReady || community . appliedKey !== communityKey ) {
371- return isCommunitySwitch ? < CommunitySwitchGate /> : < AppLoadingGate /> ;
378+ // a one-render race where React sees the new active community while the
379+ // Tauri backend is still configured for the previous one.
380+ const communityApplied =
381+ community . isReady && community . appliedKey === communityKey ;
382+ if ( appContent === null && ( ! transaction || isEnteringCurtain ) ) {
383+ appContent = communityApplied ? (
384+ < CommunityQueryProvider key = { communityKey } >
385+ < AppReady
386+ isCommunitySwitch = { isCommunitySwitch }
387+ key = { communityKey }
388+ isSharedIdentity = { sharedIdentity }
389+ />
390+ { showBootSplashOverlay ? (
391+ < div
392+ aria-hidden = "true"
393+ className = { cn (
394+ "fixed inset-0 z-50 transition-opacity" ,
395+ bootSplashPhase === "fading" ? "opacity-0" : "opacity-100" ,
396+ ) }
397+ data-testid = "boot-splash-overlay"
398+ style = { { transitionDuration : `${ BOOT_SPLASH_FADE_MS } ms` } }
399+ >
400+ < AppLoadingGate />
401+ </ div >
402+ ) : null }
403+ </ CommunityQueryProvider >
404+ ) : isCommunitySwitch ? (
405+ < CommunitySwitchGate />
406+ ) : (
407+ < AppLoadingGate />
408+ ) ;
372409 }
373410
374- // The app mounts (and starts loading data) beneath the splash overlay; the
375- // overlay just keeps the bee on screen long enough to be seen, then fades.
376- // Community switches keep their quiet gate.
377- const showBootSplashOverlay =
378- bootSplashPhase !== "done" && ! isCommunitySwitch ;
379-
380411 return (
381- < CommunityQueryProvider key = { communityKey } >
382- < AppReady
383- isCommunitySwitch = { isCommunitySwitch }
384- key = { communityKey }
385- isSharedIdentity = { sharedIdentity }
386- />
387- { showBootSplashOverlay ? (
412+ < >
413+ { appContent }
414+ { transaction ? (
388415 < div
389- aria-hidden = "true"
390- className = { cn (
391- "fixed inset-0 z-50 transition-opacity" ,
392- bootSplashPhase === "fading" ? "opacity-0" : "opacity-100" ,
393- ) }
394- data-testid = "boot-splash-overlay"
395- style = { { transitionDuration : `${ BOOT_SPLASH_FADE_MS } ms` } }
416+ className = { isEnteringCurtain ? "fixed inset-0 z-50" : undefined }
417+ data-testid = {
418+ isEnteringCurtain ? "onboarding-entering-curtain" : undefined
419+ }
396420 >
397- < AppLoadingGate />
421+ < CommunityOnboardingFlow
422+ onConnect = { handleCommunityOnboardingConnect }
423+ />
398424 </ div >
399425 ) : null }
400- </ CommunityQueryProvider >
426+ </ >
401427 ) ;
402428}
403429
0 commit comments