1import { Atom } from "effect/reactivity";
2
3import { appAtomRegistry } from "../../state/atom-registry";
4
5// Signals RootStackLayout (inside the navigation tree) that an in-session
6// sign-in just completed. Holds the account id so a sign-out between the
7// request and the navigation cannot present the sheet for the wrong account.
8export const connectOnboardingRequestAtom = Atom.make<string | null>(null).pipe(
9 Atom.keepAlive,
10 Atom.withLabel("mobile:connect-onboarding-request"),
11);
12
13/**
14 * Requests the onboarding sheet for the given account. Sign-out clears the
15 * connected environments, so onboarding runs on every in-session sign-in —
16 * each new session starts with no connected devices.
17 */
18export function requestConnectOnboarding(accountId: string): void {
19 appAtomRegistry.set(connectOnboardingRequestAtom, accountId);
20}
21
22export function clearConnectOnboardingRequest(): void {
23 appAtomRegistry.set(connectOnboardingRequestAtom, null);
24}