Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
Onboarding flow update (#2446)
Evan Hutnikc97db8903719
diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsxindex 1daef4b66f..694d398397 100644--- a/js/app/packages/app/component/Root.tsx+++ b/js/app/packages/app/component/Root.tsx@@ -189,7 +189,7 @@ function BasePathComponent() {when={!userInfoQuery.isLoading && !userInfoQuery.data?.authenticated}><Navigate- href={`${isNativeMobilePlatform() ? '/login' : '/signup'}${window.location.search}`}+ href={`${isNativeMobilePlatform() ? '/welcome' : '/welcome'}${window.location.search}`}/></Match><Match when={userInfoQuery.data?.authenticated}>diff --git a/js/app/packages/app/component/auth/Signup.tsx b/js/app/packages/app/component/auth/Signup.tsxindex c43f08cfc8..b746b3a7bc 100644--- a/js/app/packages/app/component/auth/Signup.tsx+++ b/js/app/packages/app/component/auth/Signup.tsx@@ -12,7 +12,6 @@ import { LoginOptions } from './LoginOptions';import type { Stage } from './Shared';function PostSignupRedirect() {- const userInfo = useUserInfo();const navigate = useNavigate();const { initEmailLink } = useEmailLinks();@@ -28,7 +27,7 @@ function PostSignupRedirect() {}});- navigate(userInfo()?.tutorialComplete ? '/' : '/welcome', {+ navigate('/', {replace: true,});});diff --git a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsxindex 6308daeefd..ce67d9c13a 100644--- a/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx+++ b/js/app/packages/app/component/interactive-onboarding/InteractiveOnboarding.tsx@@ -1,5 +1,6 @@import { useSplitPanel } from '@app/component/split-layout/layoutUtils';import MacroLogo from '@core/component/MacroLogo';+import LogoIcon from '@macro-icons/macro-logo.svg';import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';import { useLocation, useNavigate } from '@solidjs/router';import {@@ -20,15 +21,13 @@ import { createOnboardingState } from './create-onboarding-state';import { LESSONS } from './lessons';import { ContinueButton, SkipButton } from './components-lib';import { OnboardingProgress } from './OnboardingProgress';-import {- clearCompletedLessons,- loadCompletedLessons,- saveCompletedLesson,-} from './persistence';import { ClippedPanel } from '@core/component/ClippedPanel';import { PcNoiseGrid } from '@core/component/PcNoiseGrid';import { useAnalytics } from '@app/component/analytics-context';import { useHasPaidAccess } from '@core/auth/license';+import { useIsAuthenticated } from '@core/auth';+import { fetchToken } from '@core/util/fetchWithToken';+import { isMobile } from '@core/mobile/isMobile';import { isTouchDevice } from '@core/mobile/isTouchDevice';export default function InteractiveOnboarding() {@@ -42,17 +41,26 @@ export default function InteractiveOnboarding() {const isTouch = isTouchDevice();const hasPaid = useHasPaidAccess();- const allLessons = hasPaid()- ? LESSONS.filter((l) => l.id !== 'choose-plan')- : LESSONS;+ const isAuthenticated = useIsAuthenticated();+ const allLessons = LESSONS.filter((l) => {+ if (l.id === 'choose-plan' && (hasPaid() || tutorialCompleted()))+ return false;+ if (l.id === 'about-us' && isAuthenticated()) return false;+ if (l.id === 'launch' && !isMobile()) return false;+ return true;+ });const lessons = isTouch- ? allLessons.filter((l) => l.id === 'welcome' || l.id === 'choose-plan')+ ? allLessons.filter(+ (l) =>+ l.id === 'welcome' ||+ l.id === 'about-us' ||+ l.id === 'email-invite' ||+ l.id === 'choose-plan' ||+ l.id === 'launch'+ ): allLessons;const testMode = new URLSearchParams(location.search).has('test');- if (testMode) {- clearCompletedLessons();- }const params = new URLSearchParams(location.search);const slideParam = params.get('slide');@@ -67,9 +75,24 @@ export default function InteractiveOnboarding() {? new Set(sortedLessons.slice(0, slideIndex).map((l) => l.id)): undefined;+ // Detect a return-from-OAuth param synchronously so we can pre-populate+ // completed lessons before the first render, avoiding a flash of the first slide.+ // Search the unfiltered LESSONS list — the returning lesson (e.g. about-us) may+ // have been filtered out now that the user is authenticated.+ const returningLesson = LESSONS.find(+ (l) => l.completeOnParam && params.has(l.completeOnParam)+ );+ const returnCompleted = returningLesson+ ? new Set(+ sortedLessons+ .filter((l) => (l.order ?? 0) <= (returningLesson.order ?? 0))+ .map((l) => l.id)+ )+ : undefined;+const state = createOnboardingState({definitions: lessons,- initialCompleted: debugCompleted ?? loadCompletedLessons(),+ initialCompleted: debugCompleted ?? returnCompleted ?? new Set(),});const [readyToContinue, setReadyToContinue] = createSignal(false);@@ -78,24 +101,24 @@ export default function InteractiveOnboarding() {);const [lessonKey, setLessonKey] = createSignal(0);+ const navigate = useNavigate();+const navigateAway = () => {- splitPanel?.handle.replace({- next: { type: 'component', id: 'unified-list' },- });+ if (splitPanel) {+ splitPanel.handle.replace({+ next: { type: 'component', id: 'unified-list' },+ });+ } else {+ navigate('/', { replace: true });+ }};- // Redirect away if the backend already marks the tutorial as complete- // before the user starts. We set tutorialComplete early (after the invite- // step) so we track whether the flow has started to avoid a mid-flow redirect.- const [onboardingStarted, setOnboardingStarted] = createSignal(false);- const navigate = useNavigate();+ // Redirect away if the backend already marks the tutorial as complete.+ // Skip the redirect when returning from OAuth — we just marked it complete+ // ourselves and still have remaining lessons to show.createEffect(() => {- if (tutorialCompleted() && !onboardingStarted() && !testMode) {- if (splitPanel) {- navigateAway();- } else {- navigate('/', { replace: true });- }+ if (tutorialCompleted() && !returningLesson && !testMode) {+ navigateAway();}});@@ -117,11 +140,24 @@ export default function InteractiveOnboarding() {state: 'completed',});- setOnboardingStarted(true);- state.completeLesson(current.definition.id);- if (!testMode) {- saveCompletedLesson(current.definition.id);+ if (current.definition.onContinue) {+ // On web this redirects (returns void). On native mobile it resolves+ // with true after inline auth succeeds, so we advance the lesson.+ const result = current.definition.onContinue();+ if (result instanceof Promise) {+ result.then((shouldAdvance) => {+ if (shouldAdvance) {+ state.completeLesson(current.definition.id);+ setReadyToContinue(false);+ setContinueLabel(undefined);+ setLessonKey((k) => k + 1);+ }+ });+ }+ return;}++ state.completeLesson(current.definition.id);setReadyToContinue(false);setContinueLabel(undefined);setLessonKey((k) => k + 1);@@ -138,12 +174,7 @@ export default function InteractiveOnboarding() {state: 'skipped',});- setOnboardingStarted(true);state.skipLesson(current.definition.id);- if (!testMode) {- saveCompletedLesson(current.definition.id);- }-setReadyToContinue(false);setContinueLabel(undefined);setLessonKey((k) => k + 1);@@ -158,6 +189,27 @@ export default function InteractiveOnboarding() {attachHotkeys(shellRef);shellRef.focus();}++ // When returning from an external auth flow (e.g. Google OAuth), clean the+ // return param from the URL and run side-effects. The lessons are already+ // pre-completed synchronously via returnCompleted above.+ if (returningLesson) {+ const cleanParams = new URLSearchParams(window.location.search);+ cleanParams.delete(returningLesson.completeOnParam!);+ const qs = cleanParams.toString();+ window.history.replaceState(+ null,+ '',+ qs ? `${window.location.pathname}?${qs}` : window.location.pathname+ );++ // Ensure the JWT is refreshed before making authenticated API calls.+ // On a fresh page load after OAuth redirect, the session cookie is set+ // but no fetchWithToken call has triggered a token refresh yet.+ if (returningLesson.onCompleteParam) {+ fetchToken().then(() => returningLesson.onCompleteParam!());+ }+ }});const reg = registerHotkey({@@ -240,14 +292,14 @@ export default function InteractiveOnboarding() {// Mark tutorial complete on the backend once the email-invite lesson is// completed or skipped — before the paywall step. On touch devices there is- // no email-invite step, so we complete after the welcome lesson instead.+ // no email-invite step, so we complete after the about-us lesson instead.createEffect(() => {if (testMode) return;if (isTouch) {- const welcome = state+ const aboutUs = state.lessons()- .find((l) => l.definition.id === 'welcome');- if (welcome && (welcome.completed || welcome.skipped)) {+ .find((l) => l.definition.id === 'about-us');+ if (aboutUs && (aboutUs.completed || aboutUs.skipped)) {completeTutorial.mutate(undefined);}} else {@@ -375,11 +427,16 @@ export default function InteractiveOnboarding() {<div class="size-full flex flex-col items-center overflow-y-auto p-6"><divstyle={bodyStyle()}- class="flex flex-col items-center text-center gap-6 w-full max-w-md my-auto"+ class="flex flex-col items-start text-left gap-6 w-full max-w-md mt-4">- <div class="w-24 opacity-20">- <MacroLogo class="fill-ink" />- </div>+ <Show+ when={+ lesson().definition.id === 'welcome' ||+ lesson().definition.id === 'launch'+ }+ >+ <LogoIcon class="size-16 text-accent self-center" />+ </Show><h2 class="text-3xl font-semibold text-ink">{lesson().definition.title}</h2>@@ -396,8 +453,14 @@ export default function InteractiveOnboarding() {scopeId={scopeId}/></div>- {/* Show plan cards inline on touch for choose-plan */}- <Show when={lesson().definition.demo}>+ {/* Show demo inline on touch — skip email-invite's MockAppChrome */}+ <Show+ when={+ lesson().definition.id !== 'email-invite'+ ? lesson().definition.demo+ : undefined+ }+ >{(Demo) => (<div class="w-full"><Dynamic@@ -418,7 +481,14 @@ export default function InteractiveOnboarding() {onClick={handleContinue}label={continueLabel()}disabled={!readyToContinue()}+ centered={lesson().definition.centeredButton}/>+ <Show when={lesson().definition.skippable}>+ <SkipButton onClick={handleSkip} />+ </Show>+ <Show when={lesson().definition.secondaryAction}>+ {(Action) => <Dynamic component={Action()} />}+ </Show></div></Show></div>@@ -463,10 +533,14 @@ export default function InteractiveOnboarding() {onClick={handleContinue}label={continueLabel()}disabled={!readyToContinue()}+ centered={lesson().definition.centeredButton}/><Show when={lesson().definition.skippable}><SkipButton onClick={handleSkip} /></Show>+ <Show when={lesson().definition.secondaryAction}>+ {(Action) => <Dynamic component={Action()} />}+ </Show></div></Show></div>diff --git a/js/app/packages/app/component/interactive-onboarding/components-lib.tsx b/js/app/packages/app/component/interactive-onboarding/components-lib.tsxindex eabd3c362b..9cd89562a1 100644--- a/js/app/packages/app/component/interactive-onboarding/components-lib.tsx+++ b/js/app/packages/app/component/interactive-onboarding/components-lib.tsx@@ -153,6 +153,7 @@ interface ContinueButtonProps {label?: string;disabled?: boolean;ref?: (el: HTMLButtonElement) => void;+ centered?: boolean;}export function ContinueButton(props: ContinueButtonProps) {@@ -161,7 +162,8 @@ export function ContinueButton(props: ContinueButtonProps) {ref={props.ref}type="button"class={cn(- 'w-full px-3 py-2.5 text-lg font-bold rounded-xs flex items-center justify-between gap-2 bracket-never border-none',+ 'w-full px-3 py-2.5 text-lg font-bold rounded-xs flex items-center gap-2 bracket-never border-none',+ props.centered ? 'justify-center' : 'justify-between',{'bg-transparent text-ink/40 font-normal ring-1 ring-edge-muted/50':props.disabled,diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/about-us.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/about-us.tsxnew file mode 100644index 0000000000..4abbb5100b--- /dev/null+++ b/js/app/packages/app/component/interactive-onboarding/lessons/about-us.tsx@@ -0,0 +1,135 @@+import { onMount, For } from 'solid-js';+import type { JSX } from 'solid-js';+import type { LessonContentProps, LessonDefinition } from '../types';+import { isTouchDevice } from '@core/mobile/isTouchDevice';+import EyeSlash from '@phosphor-icons/core/regular/eye-slash.svg?component-solid';+import UsersThree from '@phosphor-icons/core/regular/users-three.svg?component-solid';+import { startSsoLogin } from '@core/auth/sso';+import { initAndStartEmailSync } from '@core/email-link';+import { ROUTER_BASE_CONCAT } from '@app/constants/routerBase';+import { isTauri } from '@core/util/platform';++function AboutUsContent(props: LessonContentProps) {+ onMount(() => {+ setTimeout(() => props.onComplete('Connect with Google'));+ });++ return (+ <div class="flex flex-col gap-3 onboarding-stagger">+ <p>+ Macro connects to your calendar and inbox for our AI, email client, and+ unified inbox features. We will never share your data or send emails+ without your explicit permission.+ </p>+ </div>+ );+}++const PANELS: { icon: () => JSX.Element; label: string }[] = [+ {+ icon: () => (+ <svg+ viewBox="0 0 48 48"+ fill="none"+ class="size-12 text-accent"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ d="M24 4L6 12v12c0 11.1 7.7 21.5 18 24 10.3-2.5 18-12.9 18-24V12L24 4z"+ fill="currentColor"+ opacity="0.15"+ />+ <path+ d="M24 4L6 12v12c0 11.1 7.7 21.5 18 24 10.3-2.5 18-12.9 18-24V12L24 4z"+ stroke="currentColor"+ stroke-width="2.5"+ stroke-linejoin="round"+ fill="none"+ />+ <path+ d="M17 24l5 5 9-10"+ stroke="currentColor"+ stroke-width="2.5"+ stroke-linecap="round"+ stroke-linejoin="round"+ />+ </svg>+ ),+ label: 'SOC 2 certified and pen tested',+ },+ {+ icon: () => <EyeSlash class="size-12 text-accent" />,+ label: 'Your data is never used to train AI models',+ },+ {+ icon: () => <UsersThree class="size-12 text-accent" />,+ label: 'Trusted by over 170k users',+ },+];++function AboutUsDemo() {+ return (+ <div class="h-full w-full flex items-center justify-center px-8">+ <div+ class="w-full max-w-2xl items-start"+ classList={{+ 'flex flex-col gap-3': isTouchDevice(),+ 'flex gap-4': !isTouchDevice(),+ }}+ >+ <For each={PANELS}>+ {(panel) => (+ <div class="flex-1 w-full flex flex-col">+ <div class="border border-edge-muted bg-panel rounded-xs overflow-hidden">+ <div class="p-6 flex flex-col items-center gap-4 text-center">+ {panel.icon()}+ <p class="text-sm text-ink/70 font-medium">{panel.label}</p>+ </div>+ </div>+ </div>+ )}+ </For>+ </div>+ </div>+ );+}++export const aboutUsLesson: LessonDefinition = {+ id: 'about-us',+ title: 'Security and privacy',+ content: AboutUsContent,+ centeredButton: true,+ demo: AboutUsDemo,+ order: 60,+ onContinue: async () => {+ const success = await startSsoLogin({+ returnPath: `${ROUTER_BASE_CONCAT}welcome?google=1`,+ });+ // On web, startSsoLogin redirects and never resolves.+ // On native mobile, auth completes inline. Reload the page with the+ // return param so it goes through the normal completeOnParam flow —+ // this avoids Suspense blanking the screen when auth state changes.+ if (success) {+ // Reload into the completeOnParam flow. Tauri uses HashRouter so the+ // route + query must go inside the hash fragment.+ if (isTauri()) {+ window.location.hash = '#/welcome?google=1';+ window.location.reload();+ } else {+ window.location.href = `${window.location.origin}${ROUTER_BASE_CONCAT}welcome?google=1`;+ }+ }+ // Never resolves — page reloads (native) or redirects (web).+ return new Promise<boolean>(() => {});+ },+ completeOnParam: 'google',+ onCompleteParam: () =>+ initAndStartEmailSync().match(+ () => true,+ (e) => {+ if (e.tag === 'AlreadyInitialized') return true;+ console.error('Failed to init email link after Google auth', e);+ return false;+ }+ ),+};diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/index.ts b/js/app/packages/app/component/interactive-onboarding/lessons/index.tsindex 488070d9ee..7145d2c76b 100644--- a/js/app/packages/app/component/interactive-onboarding/lessons/index.ts+++ b/js/app/packages/app/component/interactive-onboarding/lessons/index.ts@@ -6,8 +6,10 @@ import { commandKLesson } from './command-k';import { createEntityLesson } from './create-entity';import { markdownMentionsLesson } from './markdown-mentions';// import { composersPreviewLesson } from './composers-preview';+import { aboutUsLesson } from './about-us';import { emailInviteLesson } from './email-invite';import { choosePlanLesson } from './choose-plan';+import { launchLesson } from './launch';export const LESSONS: LessonDefinition[] = [welcomeLesson,@@ -17,6 +19,8 @@ export const LESSONS: LessonDefinition[] = [createEntityLesson,markdownMentionsLesson,// composersPreviewLesson,+ aboutUsLesson,emailInviteLesson,choosePlanLesson,+ launchLesson,];diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/launch.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/launch.tsxnew file mode 100644index 0000000000..71dea70616--- /dev/null+++ b/js/app/packages/app/component/interactive-onboarding/lessons/launch.tsx@@ -0,0 +1,19 @@+import { onMount } from 'solid-js';+import type { LessonContentProps, LessonDefinition } from '../types';++function LaunchContent(props: LessonContentProps) {+ onMount(() => setTimeout(() => props.onComplete('Launch')));++ return (+ <div class="flex flex-col gap-3 onboarding-stagger">+ <p>You're all set! Let's dive in.</p>+ </div>+ );+}++export const launchLesson: LessonDefinition = {+ id: 'launch',+ title: 'Welcome to Macro',+ content: LaunchContent,+ order: 100,+};diff --git a/js/app/packages/app/component/interactive-onboarding/lessons/welcome.tsx b/js/app/packages/app/component/interactive-onboarding/lessons/welcome.tsxindex 427f07c4b6..b9fd947514 100644--- a/js/app/packages/app/component/interactive-onboarding/lessons/welcome.tsx+++ b/js/app/packages/app/component/interactive-onboarding/lessons/welcome.tsx@@ -1,4 +1,5 @@import { onMount } from 'solid-js';+import { A } from '@solidjs/router';import type { LessonContentProps, LessonDefinition } from '../types';import { isTouchDevice } from '@core/mobile/isTouchDevice';@@ -17,9 +18,24 @@ function WelcomeContent(props: LessonContentProps) {);}+function WelcomeSecondaryAction() {+ return (+ <>+ <p class="text-sm text-ink/50 mt-10">Already have an account?</p>+ <A+ href="/login"+ class="w-full px-3 py-2.5 text-lg rounded-xs flex items-center justify-between gap-2 bracket-never border-none bg-transparent text-ink/50 hover:bg-hover/60 ring-1 ring-edge-muted/50"+ >+ Login+ </A>+ </>+ );+}+export const welcomeLesson: LessonDefinition = {id: 'welcome',title: 'Welcome to Macro',content: WelcomeContent,+ secondaryAction: WelcomeSecondaryAction,order: 0,};diff --git a/js/app/packages/app/component/interactive-onboarding/persistence.ts b/js/app/packages/app/component/interactive-onboarding/persistence.tsdeleted file mode 100644index 92479bb81d..0000000000--- a/js/app/packages/app/component/interactive-onboarding/persistence.ts+++ /dev/null@@ -1,25 +0,0 @@-import type { LessonId } from './types';--const STORAGE_KEY = 'macro:onboarding:completed';--export function loadCompletedLessons(): Set<LessonId> {- try {- const raw = localStorage.getItem(STORAGE_KEY);- if (!raw) return new Set();- const parsed: unknown = JSON.parse(raw);- if (!Array.isArray(parsed)) return new Set();- return new Set(parsed.filter((v): v is string => typeof v === 'string'));- } catch {- return new Set();- }-}--export function saveCompletedLesson(id: LessonId): void {- const current = loadCompletedLessons();- current.add(id);- localStorage.setItem(STORAGE_KEY, JSON.stringify([...current]));-}--export function clearCompletedLessons(): void {- localStorage.removeItem(STORAGE_KEY);-}diff --git a/js/app/packages/app/component/interactive-onboarding/types.ts b/js/app/packages/app/component/interactive-onboarding/types.tsindex bdf7174584..bea52410a8 100644--- a/js/app/packages/app/component/interactive-onboarding/types.ts+++ b/js/app/packages/app/component/interactive-onboarding/types.ts@@ -14,6 +14,16 @@ export interface LessonDefinition {skippable?: boolean;/** Hide the continue/skip buttons entirely — the lesson drives its own advancement. */hideContinue?: boolean;+ /** Called instead of the default complete-and-advance flow. On web, redirects externally (returns void). On native mobile, performs auth inline and returns true to advance. */+ onContinue?: () => void | Promise<boolean>;+ /** If this URL search param is present on mount, auto-complete this lesson and advance (used for returning from external OAuth flows). */+ completeOnParam?: string;+ /** Called when completeOnParam is detected, before the lesson is advanced. Return false to abort the fast-forward (e.g. when initialization fails). */+ onCompleteParam?: () => Promise<boolean>;+ /** Center the continue button label. */+ centeredButton?: boolean;+ /** Optional secondary button rendered below the continue button. */+ secondaryAction?: Component;}export interface LessonContentProps {diff --git a/js/app/packages/core/auth/sso.ts b/js/app/packages/core/auth/sso.tsnew file mode 100644index 0000000000..8ffbf37c26--- /dev/null+++ b/js/app/packages/core/auth/sso.ts@@ -0,0 +1,82 @@+import { SERVER_HOSTS } from '@core/constant/servers';+import { GOOGLE_GMAIL_IDP } from './email';+import { isNativeMobilePlatform } from '@core/mobile/isNativeMobilePlatform';+import { getNativeMobilePlatform } from '@core/util/platform';+import { invoke } from '@tauri-apps/api/core';+import { unsetTokenPromise } from '@core/util/fetchWithToken';+import { isOk } from '@core/util/maybeResult';+import { authServiceClient } from '@service-auth/client';+import { invalidateAllAfterLogin } from '@queries/auth/user-info';++export type StartSsoLoginParams = {+ idpName?: string;+ /** Where to redirect after auth on web. Ignored on native mobile. */+ returnPath?: string;+};++/**+ * Starts an SSO login flow.+ * - Native iOS: performs auth inline via Tauri plugin, returns true on success.+ * - Web: redirects to the SSO URL (the returned promise never resolves).+ */+export async function startSsoLogin(+ params: StartSsoLoginParams = {}+): Promise<boolean> {+ const idpName = params.idpName ?? GOOGLE_GMAIL_IDP;+ const authUrl = new URL(`${SERVER_HOSTS['auth-service']}/login/sso`);+ authUrl.searchParams.set('idp_name', idpName);++ const referralCode = new URL(window.location.href).searchParams.get(+ 'referral_code'+ );+ if (referralCode) authUrl.searchParams.set('referral_code', referralCode);++ if (isNativeMobilePlatform()) {+ authUrl.searchParams.set('is_mobile', 'true');+ }++ if (getNativeMobilePlatform() === 'ios') {+ authUrl.searchParams.set('original_url', 'macro://login');++ const result = await invoke<{+ success: boolean;+ token?: string;+ error?: string;+ }>('plugin:auth|authenticate', {+ payload: {+ authUrl: authUrl.toString(),+ callbackScheme: 'macro',+ ephemeralSession: true,+ },+ });++ if (!result.success || !result.token) {+ console.error('Authentication failed:', result.error);+ return false;+ }++ unsetTokenPromise();+ const res = await authServiceClient.sessionLogin({+ session_code: result.token,+ });++ if (isOk(res)) {+ await invalidateAllAfterLogin();+ return true;+ }++ return false;+ }++ // Web: redirect to SSO — page navigates away, promise never resolves.+ if (params.returnPath) {+ authUrl.searchParams.set(+ 'original_url',+ `${window.location.origin}${params.returnPath}`+ );+ } else {+ authUrl.searchParams.set('original_url', window.location.href);+ }+ window.location.href = authUrl.toString();+ return new Promise(() => {});+}diff --git a/js/app/packages/core/component/TopBar/LoginButton.tsx b/js/app/packages/core/component/TopBar/LoginButton.tsxindex 4a0dbc6999..9b5655bab7 100644--- a/js/app/packages/core/component/TopBar/LoginButton.tsx+++ b/js/app/packages/core/component/TopBar/LoginButton.tsx@@ -28,7 +28,7 @@ export function LoginButton() {variant="accent"size="sm"class="rounded-xs"- onClick={() => navigate(`/signup${window.location.search}`)}+ onClick={() => navigate(`/welcome${window.location.search}`)}>Sign Up</Button>diff --git a/js/app/packages/core/email-link/index.ts b/js/app/packages/core/email-link/index.tsindex ab2b5864d2..c8ff671f6f 100644--- a/js/app/packages/core/email-link/index.ts+++ b/js/app/packages/core/email-link/index.ts@@ -122,6 +122,20 @@ function connectEmail(): ResultAsync<void, TimeoutError> {return authenticateWithEmailPermissions();}+/**+ * Initializes email syncing, starts polling, and invalidates relevant queries.+ * Unlike useEmailLinks().initEmailLink, this does not require SolidJS context.+ */+export function initAndStartEmailSync() {+ const invalidations = async () => {+ invalidateEmailLinks();+ await updateUserAuth();+ await invalidateUserInfo();+ };++ return initEmailLink().map(startEmailPolling).map(invalidations);+}+/*** Hooks for interacting with email links.*/