Skip to content

Commit 1fdb73e

Browse files
morgmartclaude
andauthored
Speed up the Welcome kickoff and show the team arriving (#2066)
Co-authored-by: Claude <[email protected]>
1 parent 1bdd938 commit 1fdb73e

17 files changed

Lines changed: 1067 additions & 88 deletions

‎desktop/src/app/App.tsx‎

Lines changed: 81 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -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

‎desktop/src/features/channels/ui/ChannelPane.tsx‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ export const ChannelPane = React.memo(function ChannelPane({
8888
isTimelineLoading,
8989
entranceMessageId = null,
9090
onEntranceMessageComplete,
91+
welcomeKickoffStage = null,
92+
welcomeKickoffSettingUp = false,
9193
messages,
9294
threadSummaries,
9395
firstUnreadMessageId = null,
@@ -684,7 +686,13 @@ export const ChannelPane = React.memo(function ChannelPane({
684686
expiresAtMs={timeoutState.expiresAtMs}
685687
/>
686688
) : isActiveWelcomeChannel ? (
687-
<WelcomeComposerBanner state={welcomeComposerBannerState} />
689+
<div className="relative">
690+
{welcomeKickoffStage}
691+
<WelcomeComposerBanner
692+
settingUp={welcomeKickoffSettingUp}
693+
state={welcomeComposerBannerState}
694+
/>
695+
</div>
688696
) : null}
689697
<MessageComposer
690698
channelId={activeChannel?.id ?? null}

‎desktop/src/features/channels/ui/ChannelPane.types.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ export type ChannelPaneProps = {
5656
/** Newly-created message that should receive the one-shot conversation arrival motion. */
5757
entranceMessageId?: string | null;
5858
onEntranceMessageComplete?: (messageId: string) => void;
59+
/** Welcome kickoff characters, rendered standing on the Welcome composer banner. */
60+
welcomeKickoffStage?: React.ReactNode;
61+
/** The kickoff is still setting up the team — the banner copy reads as setup status. */
62+
welcomeKickoffSettingUp?: boolean;
5963
messages: TimelineMessage[];
6064
threadSummaries?: ReadonlyMap<string, ChannelWindowThreadSummary>;
6165
firstUnreadMessageId?: string | null;

‎desktop/src/features/channels/ui/ChannelScreen.tsx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { mergeChannelKnownAgentPubkeys } from "@/features/agents/knownAgentPubke
2929
import { useKnownAgentPubkeys } from "@/features/agents/useKnownAgentPubkeys";
3030
import { pickWelcomeGuideAgent } from "@/features/onboarding/welcomeGuide";
3131
import { useWelcomeKickoffEntrance } from "@/features/onboarding/useWelcomeKickoffEntrance";
32+
import { useWelcomeKickoffStagePresence } from "@/features/onboarding/useWelcomeKickoffStagePresence";
3233
import { useWelcomeAgentCreate } from "@/features/channels/useWelcomeAgentCreate";
3334
import {
3435
mergeMessages,
@@ -257,6 +258,7 @@ export function ChannelScreen({
257258
resolvedMessages,
258259
threadReplyEvents,
259260
);
261+
260262
const messageEventProfilePubkeys = useMessageEventProfilePubkeys(
261263
resolvedMessages,
262264
threadReplyEvents,
@@ -622,6 +624,12 @@ export function ChannelScreen({
622624
timelineLoadingNow,
623625
);
624626
settledChannelIdRef.current = settledChannelId;
627+
const { welcomeKickoffStage, welcomeKickoffSettingUp } =
628+
useWelcomeKickoffStagePresence(
629+
activeChannel,
630+
timelineMessages,
631+
isTimelineLoading,
632+
);
625633
const resetComposerTargets = React.useCallback(
626634
(_channelId: string | null) => {
627635
setExpandedThreadReplyIds(new Set());
@@ -842,6 +850,8 @@ export function ChannelScreen({
842850
isFetchingOlder={isFetchingOlder}
843851
entranceMessageId={welcomeEntranceMessageId}
844852
onEntranceMessageComplete={handleWelcomeEntranceComplete}
853+
welcomeKickoffStage={welcomeKickoffStage}
854+
welcomeKickoffSettingUp={welcomeKickoffSettingUp}
845855
editTarget={
846856
editTargetMessage
847857
? {

‎desktop/src/features/channels/ui/WelcomeComposerBanner.tsx‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,19 @@ function WelcomeComposerPersonaMention() {
288288

289289
type WelcomeComposerBannerProps = {
290290
state: WelcomeComposerBannerState;
291+
/**
292+
* While the Welcome kickoff is still setting up the team, the banner's
293+
* prompt copy reads as a setup status ("Setting up your welcome team…")
294+
* instead of the mention hint — the kickoff characters stand on top of the
295+
* banner during this window.
296+
*/
297+
settingUp?: boolean;
291298
};
292299

293-
export function WelcomeComposerBanner({ state }: WelcomeComposerBannerProps) {
300+
export function WelcomeComposerBanner({
301+
settingUp = false,
302+
state,
303+
}: WelcomeComposerBannerProps) {
294304
if (state === "hidden") {
295305
return null;
296306
}
@@ -382,6 +392,18 @@ export function WelcomeComposerBanner({ state }: WelcomeComposerBannerProps) {
382392
>
383393
Nice work.
384394
</motion.span>
395+
) : settingUp ? (
396+
<motion.span
397+
animate="animate"
398+
className="min-w-0"
399+
data-testid="welcome-composer-setting-up-copy"
400+
exit="exit"
401+
initial="initial"
402+
key="setting-up-copy"
403+
variants={welcomeComposerBannerContentVariants}
404+
>
405+
Setting up your welcome team…
406+
</motion.span>
385407
) : (
386408
<motion.span
387409
animate="animate"

‎desktop/src/features/onboarding/communityOnboarding.tsx‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,13 @@ export type CommunityOnboardingStage =
1818
| "connecting"
1919
| "profile"
2020
| "team-intro"
21-
| "finalizing";
21+
| "finalizing"
22+
/**
23+
* Backend setup is done and the app is mounting directly on the Welcome
24+
* channel underneath the onboarding screen, which stays up as an opaque
25+
* curtain until Welcome reports settled (or a safety timeout), then fades.
26+
*/
27+
| "entering";
2228

2329
export type CommunityOnboardingTransaction = {
2430
id: string;
@@ -84,9 +90,14 @@ function isTransaction(
8490
typeof transaction.communityName === "string" &&
8591
typeof transaction.createdAt === "string" &&
8692
typeof transaction.updatedAt === "string" &&
87-
["claiming", "connecting", "profile", "team-intro", "finalizing"].includes(
88-
transaction.stage ?? "",
89-
)
93+
[
94+
"claiming",
95+
"connecting",
96+
"profile",
97+
"team-intro",
98+
"finalizing",
99+
"entering",
100+
].includes(transaction.stage ?? "")
90101
);
91102
}
92103

0 commit comments

Comments
 (0)