Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion desktop/src/features/channels/ui/ChannelPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,11 @@ export const ChannelPane = React.memo(function ChannelPane({
bannerState: welcomeComposerBannerState,
completeBanner: completeWelcomeComposerBanner,
dismissBanner: handleDismissWelcomeBanner,
} = useWelcomeComposerBanner(activeChannelId, isActiveWelcomeChannel);
} = useWelcomeComposerBanner(
activeChannelId,
isActiveWelcomeChannel,
currentPubkey ?? null,
);
const isEditInThread =
editTarget != null &&
threadHeadMessage != null &&
Expand Down
4 changes: 4 additions & 0 deletions desktop/src/features/channels/ui/WelcomeComposerBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,10 @@ export function WelcomeComposerGuidanceLayer({
settingUp,
state,
}: WelcomeComposerGuidanceLayerProps) {
if (state === "hidden") {
return null;
}

return (
<div className="relative" data-testid="welcome-composer-guidance-layer">
<ComposerDockGlassBackdrop
Expand Down
39 changes: 27 additions & 12 deletions desktop/src/features/channels/ui/useWelcomeComposerBanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import {
type WelcomeComposerBannerState,
} from "@/features/channels/ui/WelcomeComposerBanner";

const completedWelcomeComposerIdentityPubkeys = new Set<string>();

/**
* Manages the Welcome-channel composer hint banner's state machine.
*
* Tracks which channels have been completed within the session so the banner
* stays hidden on re-entry. Exposes three transitions:
* Remembers completion across the Welcome experience per identity for this app
* session, so the hint stays hidden while moving between the private and
* starter Welcome channels without leaking dismissal to another identity.
* - `completeBanner`: agent-mention path — plays the "Nice work." success
* animation before auto-dismissing.
* - `dismissBanner`: manual X-button path — immediately begins the slide-down
Expand All @@ -21,12 +24,12 @@ import {
export function useWelcomeComposerBanner(
activeChannelId: string | null,
isActiveWelcomeChannel: boolean,
identityPubkey: string | null,
): {
bannerState: WelcomeComposerBannerState;
completeBanner: () => void;
dismissBanner: () => void;
} {
const completedChannelIdsRef = React.useRef(new Set<string>());
const dismissTimerRef = React.useRef<number | null>(null);
const hideTimerRef = React.useRef<number | null>(null);
const [bannerState, setBannerState] =
Expand All @@ -48,15 +51,15 @@ export function useWelcomeComposerBanner(
React.useEffect(() => {
clearTimers();
if (
activeChannelId &&
isActiveWelcomeChannel &&
completedChannelIdsRef.current.has(activeChannelId)
identityPubkey &&
completedWelcomeComposerIdentityPubkeys.has(identityPubkey)
) {
setBannerState("hidden");
return;
}
setBannerState("prompt");
}, [activeChannelId, clearTimers, isActiveWelcomeChannel]);
}, [clearTimers, identityPubkey, isActiveWelcomeChannel]);

const scheduleHide = React.useCallback(() => {
hideTimerRef.current = window.setTimeout(
Expand All @@ -70,30 +73,42 @@ export function useWelcomeComposerBanner(
}, []);

const completeBanner = React.useCallback(() => {
if (!activeChannelId || !isActiveWelcomeChannel) {
if (!activeChannelId || !isActiveWelcomeChannel || !identityPubkey) {
return;
}

clearTimers();
completedChannelIdsRef.current.add(activeChannelId);
completedWelcomeComposerIdentityPubkeys.add(identityPubkey);
setBannerState("complete");
dismissTimerRef.current = window.setTimeout(() => {
setBannerState("dismissing");
dismissTimerRef.current = null;
scheduleHide();
}, WELCOME_PERSONA_ROTATION_MS + WELCOME_COMPOSER_BANNER_SUCCESS_SETTLE_MS);
}, [activeChannelId, clearTimers, isActiveWelcomeChannel, scheduleHide]);
}, [
activeChannelId,
clearTimers,
identityPubkey,
isActiveWelcomeChannel,
scheduleHide,
]);

const dismissBanner = React.useCallback(() => {
if (!activeChannelId || !isActiveWelcomeChannel) {
if (!activeChannelId || !isActiveWelcomeChannel || !identityPubkey) {
return;
}

clearTimers();
completedChannelIdsRef.current.add(activeChannelId);
completedWelcomeComposerIdentityPubkeys.add(identityPubkey);
setBannerState("dismissing");
scheduleHide();
}, [activeChannelId, clearTimers, isActiveWelcomeChannel, scheduleHide]);
}, [
activeChannelId,
clearTimers,
identityPubkey,
isActiveWelcomeChannel,
scheduleHide,
]);

return { bannerState, completeBanner, dismissBanner };
}
4 changes: 3 additions & 1 deletion desktop/tests/e2e/onboarding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3218,7 +3218,9 @@ test("welcome-everywhere banner: dismiss persists after channel re-entry", async

// Return — banner must stay hidden.
await page.getByTestId("channel-welcome-everyone").click();
await expect(page.getByTestId("chat-title")).toContainText("Welcome");
await expect(page.getByTestId("chat-title")).toContainText(
"welcome-everyone",
);
await expect(banner).toHaveCount(0);
});

Expand Down
Loading