Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(onboarding): one click per step, and a sign-in link on sign-up (#7544)

teo065ed2baf101
diff --git a/apps/web/src/features/auth/auth.tsx b/apps/web/src/features/auth/auth.tsx
index 755dd0b367..55678a3828 100644
--- a/apps/web/src/features/auth/auth.tsx
+++ b/apps/web/src/features/auth/auth.tsx
@@ -23,6 +23,7 @@ import { MobileWebSignupView } from './views/mobile-web-signup-view';
*/
export function Login(props: { signupMode?: boolean }) {
const [params] = useSearchParams();
+ const navigate = useNavigate();
const email = typeof params.email === 'string' ? params.email : undefined;
const desktopSignup = () =>
props.signupMode === true && !isMobile() && !isNativeMobilePlatform();
@@ -47,6 +48,7 @@ export function Login(props: { signupMode?: boolean }) {
? (slots) => <OnboardingSignup {...slots} />
: undefined
}
+ onSignIn={() => navigate('/login')}
signedIn={(user) => <PostAuthGate user={user} />}
/>
</AuthProvider>
diff --git a/apps/web/src/features/auth/browser-test/auth.browser.e2e.ts b/apps/web/src/features/auth/browser-test/auth.browser.e2e.ts
index fbc6d38b5e..83f0966984 100644
--- a/apps/web/src/features/auth/browser-test/auth.browser.e2e.ts
+++ b/apps/web/src/features/auth/browser-test/auth.browser.e2e.ts
@@ -106,6 +106,22 @@ test('desktop sign-up: slides, Google, then onboarding resumes at the work inbox
).toBe('#b8a1ed');
});
+test('a returning visitor on sign-up can switch to sign in', async ({
+ page,
+}) => {
+ await openFixture(page, '/?page=signup');
+ await expect(
+ page.getByRole('heading', { level: 1, name: 'Create your workspace' })
+ ).toBeVisible();
+ await page.getByRole('button', { name: 'Sign in instead' }).click();
+ await expect(
+ page.getByRole('heading', { level: 1, name: 'Welcome to Macro' })
+ ).toBeVisible();
+ await page.getByRole('button', { name: 'Continue with email' }).click();
+ await signInWithCode(page, '[email protected]', '424242');
+ await expectLanded(page, '/');
+});
+
test('a mobile-web visitor gets a desktop link instead of signing up', async ({
page,
}) => {
diff --git a/apps/web/src/features/auth/browser-test/fixture.tsx b/apps/web/src/features/auth/browser-test/fixture.tsx
index fb346226b7..0df6a5075b 100644
--- a/apps/web/src/features/auth/browser-test/fixture.tsx
+++ b/apps/web/src/features/auth/browser-test/fixture.tsx
@@ -158,6 +158,7 @@ function Fixture() {
? (slots) => <SignupJourney {...slots} />
: undefined
}
+ onSignIn={() => location.assign(`${location.pathname}?page=login`)}
signedIn={(user) => <SignedIn user={user} />}
/>
</Match>
diff --git a/apps/web/src/features/auth/views/auth-view.test.tsx b/apps/web/src/features/auth/views/auth-view.test.tsx
index 9b2d8337fc..a419093616 100644
--- a/apps/web/src/features/auth/views/auth-view.test.tsx
+++ b/apps/web/src/features/auth/views/auth-view.test.tsx
@@ -21,6 +21,7 @@ function setup(
} = {}
) {
const verified = vi.fn();
+ const signIn = vi.fn();
const { fake } = renderWithFakeAuth(
() => (
<AuthView
@@ -31,6 +32,7 @@ function setup(
autoStart={options.autoStart}
token={options.token}
onVerified={verified}
+ onSignIn={signIn}
signupJourney={options.signupJourney}
signedIn={(user) => (
<p data-testid="signed-in">
@@ -41,7 +43,7 @@ function setup(
),
options.world
);
- return { fake, verified };
+ return { fake, verified, signIn };
}
const click = (name: string | RegExp) =>
@@ -203,6 +205,9 @@ function Journey(props: SignupJourneySlots) {
<button type="button" onClick={() => void props.onGoogle()}>
Connect work email
</button>
+ <button type="button" onClick={props.onSignIn}>
+ Sign in instead
+ </button>
<p data-testid="showing-email">{String(props.showingEmail)}</p>
{props.emailForm}
</section>
@@ -231,4 +236,13 @@ describe('desktop sign-up', () => {
expect(screen.getByTestId('showing-email').textContent).toBe('true');
expect(screen.getByDisplayValue('[email protected]')).toBeTruthy();
});
+
+ it('lets the slides send a returning visitor to sign in', () => {
+ const { signIn } = setup({
+ intent: 'signup',
+ signupJourney: (slots) => <Journey {...slots} />,
+ });
+ fireEvent.click(screen.getByRole('button', { name: 'Sign in instead' }));
+ expect(signIn).toHaveBeenCalledOnce();
+ });
});
diff --git a/apps/web/src/features/auth/views/auth-view.tsx b/apps/web/src/features/auth/views/auth-view.tsx
index 39c2948871..b9ca527a52 100644
--- a/apps/web/src/features/auth/views/auth-view.tsx
+++ b/apps/web/src/features/auth/views/auth-view.tsx
@@ -19,6 +19,7 @@ import {
export type SignupJourneySlots = {
onGoogle: () => Promise<void>;
onBackFromEmail: () => void;
+ onSignIn: () => void;
emailForm: JSX.Element;
showingEmail: boolean;
};
@@ -36,6 +37,8 @@ export function AuthView(props: {
onVerified?: () => void;
/** Desktop sign-up: onboarding's slides host Google and the email form. */
signupJourney?: (slots: SignupJourneySlots) => JSX.Element;
+ /** Switches a returning visitor from sign-up to sign-in. */
+ onSignIn?: () => void;
/** What a signed-in visitor sees instead. */
signedIn: (user: AuthUser) => JSX.Element;
}) {
@@ -62,6 +65,7 @@ export function AuthView(props: {
journey()({
onGoogle: () => context.startSso('google', 'signup'),
onBackFromEmail: login.back,
+ onSignIn: () => props.onSignIn?.(),
showingEmail: login.step() !== 'choose',
emailForm: (
<Show when={login.step() !== 'choose'}>
diff --git a/apps/web/src/features/onboarding/browser-test/fixture-keys.ts b/apps/web/src/features/onboarding/browser-test/fixture-keys.ts
index 9fd99f3109..6fa5c9eefc 100644
--- a/apps/web/src/features/onboarding/browser-test/fixture-keys.ts
+++ b/apps/web/src/features/onboarding/browser-test/fixture-keys.ts
@@ -12,4 +12,7 @@ export const FIXTURE_KEYS = {
checkoutOutcome: 'onboarding-fixture:checkout-outcome',
} as const;
-export type FixtureLanding = { t: 'app'; target: string } | { t: 'signed-out' };
+export type FixtureLanding =
+ | { t: 'app'; target: string }
+ | { t: 'signed-out' }
+ | { t: 'sign-in' };
diff --git a/apps/web/src/features/onboarding/browser-test/fixture.tsx b/apps/web/src/features/onboarding/browser-test/fixture.tsx
index 1274d7ddd9..82b9d4e0b6 100644
--- a/apps/web/src/features/onboarding/browser-test/fixture.tsx
+++ b/apps/web/src/features/onboarding/browser-test/fixture.tsx
@@ -73,7 +73,11 @@ const landed = (): FixtureLanding | undefined => {
};
const landingText = (landing: FixtureLanding | undefined) =>
- landing?.t === 'app' ? `Entered Macro at ${landing.target}` : 'Signed out';
+ landing?.t === 'app'
+ ? `Entered Macro at ${landing.target}`
+ : landing?.t === 'sign-in'
+ ? 'Sign in'
+ : 'Signed out';
declare global {
interface Window {
@@ -105,6 +109,7 @@ function Fixture() {
<SignupJourneyView
onGoogle={signUpWithGoogle}
onBackFromEmail={() => {}}
+ onSignIn={() => land({ t: 'sign-in' })}
showingEmail={false}
/>
</Match>
diff --git a/apps/web/src/features/onboarding/browser-test/onboarding.browser.e2e.ts b/apps/web/src/features/onboarding/browser-test/onboarding.browser.e2e.ts
index e274922a24..4c6340839e 100644
--- a/apps/web/src/features/onboarding/browser-test/onboarding.browser.e2e.ts
+++ b/apps/web/src/features/onboarding/browser-test/onboarding.browser.e2e.ts
@@ -230,6 +230,29 @@ test('a finished user is sent straight into the app', async ({ page }) => {
test.describe('with motion', () => {
test.use({ contextOptions: { reducedMotion: 'no-preference' } });
+ test('a click lands as soon as the next slide appears, not after its animation', async ({
+ page,
+ }) => {
+ await openFixture(page, '/?view=signup', { viewer: null });
+ const steps: [string, string | RegExp][] = [
+ ['Get started', 'Which features do you want to try first?'],
+ ['Continue', 'A workspace built to earn your trust.'],
+ ['Continue', /Connect your work/],
+ ];
+ await expect(heading(page, 'Create your workspace')).toBeVisible();
+ for (const [button, next] of steps) {
+ // A person clicks once the slide is visible, well before its flight ends.
+ await page.waitForTimeout(400);
+ const box = await page
+ .getByRole('button', { name: button })
+ .last()
+ .boundingBox();
+ if (!box) throw new Error(`${button} is not on screen`);
+ await page.mouse.click(box.x + box.width / 2, box.y + box.height / 2);
+ await expect(heading(page, next)).toBeVisible({ timeout: 1_000 });
+ }
+ });
+
test('the story handoffs finish and leave the next step interactive', async ({
page,
}) => {
diff --git a/apps/web/src/features/onboarding/components/motion/security-handoff.ts b/apps/web/src/features/onboarding/components/motion/security-handoff.ts
index 0ea01473a6..f817eb78ca 100644
--- a/apps/web/src/features/onboarding/components/motion/security-handoff.ts
+++ b/apps/web/src/features/onboarding/components/motion/security-handoff.ts
@@ -1,3 +1,6 @@
+/** When the incoming step starts to fade in (the 180ms delay at the 1.5× pace below). */
+const CONTENT_FADE_DELAY_MS = 180 * 1.5;
+
/** Fade the slide and carry its visual anchors downward into the next proof row. */
export function animateSecurityHandoff(
content: HTMLElement,
@@ -116,16 +119,26 @@ export function animateSecurityHandoff(
const scroller = content.closest('[data-onboarding-scroll]');
const animations: Animation[] = [];
let finished = false;
+ let released = false;
+ let releaseTimer: ReturnType<typeof setTimeout> | undefined;
+ // Hand the new step back to the user as soon as it starts to appear; the
+ // decorative flight keeps running, and a click on the new step cancels it.
+ const release = () => {
+ if (released) return;
+ released = true;
+ clearTimeout(releaseTimer);
+ content.inert = originalInert;
+ if (originalBusy === null) content.removeAttribute('aria-busy');
+ else content.setAttribute('aria-busy', originalBusy);
+ delete content.dataset.securityHandoff;
+ };
const finish = (focus: boolean) => {
if (finished) return;
finished = true;
animations.forEach((animation) => animation.cancel());
overlay.remove();
content.style.opacity = originalOpacity;
- content.inert = originalInert;
- if (originalBusy === null) content.removeAttribute('aria-busy');
- else content.setAttribute('aria-busy', originalBusy);
- delete content.dataset.securityHandoff;
+ release();
window.removeEventListener('resize', settle);
scroller?.removeEventListener('scroll', settleScroll);
if (focus && content.isConnected)
@@ -178,6 +191,8 @@ export function animateSecurityHandoff(
animate(snapshot, [{ opacity: 1 }, { opacity: 0 }], 200);
animate(content, [{ opacity: 0 }, { opacity: 1 }], 300, 180);
+ // Blocking until the fade-in starts still swallows a double-click.
+ releaseTimer = setTimeout(release, CONTENT_FADE_DELAY_MS);
ghosts.forEach((ghost, index) => {
const source = sourceBounds[index];
const to = targetBounds[index % targetBounds.length];
diff --git a/apps/web/src/features/onboarding/components/sign-in-instead.tsx b/apps/web/src/features/onboarding/components/sign-in-instead.tsx
new file mode 100644
index 0000000000..3f8350d370
--- /dev/null
+++ b/apps/web/src/features/onboarding/components/sign-in-instead.tsx
@@ -0,0 +1,15 @@
+/** For returning users who landed on sign-up, pinned below the first slide. */
+export function SignInInstead(props: { onSignIn: () => void }) {
+ return (
+ <p class="absolute bottom-[30px] left-1/2 -translate-x-1/2 whitespace-nowrap text-xs leading-5 text-ink-extra-muted">
+ Already have an account?{' '}
+ <button
+ type="button"
+ class="rounded-sm text-ink-muted underline underline-offset-2 transition-colors hover:text-ink focus-visible:outline-1 focus-visible:outline-offset-4 focus-visible:outline-ink-muted"
+ onClick={() => props.onSignIn()}
+ >
+ Sign in instead
+ </button>
+ </p>
+ );
+}
diff --git a/apps/web/src/features/onboarding/onboarding.tsx b/apps/web/src/features/onboarding/onboarding.tsx
index 5a2fab900b..34d1f0925b 100644
--- a/apps/web/src/features/onboarding/onboarding.tsx
+++ b/apps/web/src/features/onboarding/onboarding.tsx
@@ -48,6 +48,7 @@ export function Onboarding() {
export function OnboardingSignup(props: {
onGoogle: () => Promise<void>;
onBackFromEmail: () => void;
+ onSignIn: () => void;
emailForm?: JSX.Element;
showingEmail: boolean;
}) {
diff --git a/apps/web/src/features/onboarding/views/signup-journey-view.test.tsx b/apps/web/src/features/onboarding/views/signup-journey-view.test.tsx
index ac0d0b4258..7053ba0ac9 100644
--- a/apps/web/src/features/onboarding/views/signup-journey-view.test.tsx
+++ b/apps/web/src/features/onboarding/views/signup-journey-view.test.tsx
@@ -19,17 +19,19 @@ afterEach(() => {
function setup() {
const google = vi.fn().mockResolvedValue(undefined);
+ const signIn = vi.fn();
renderWithFakeOnboarding(
() => (
<SignupJourneyView
onGoogle={google}
onBackFromEmail={() => {}}
+ onSignIn={signIn}
showingEmail={false}
/>
),
{ viewer: null }
);
- return { google };
+ return { google, signIn };
}
describe('sign-up starts before authentication', () => {
@@ -89,4 +91,14 @@ describe('sign-up starts before authentication', () => {
authenticating: false,
});
});
+
+ it('offers returning users a way to sign in from the first slide only', () => {
+ const { signIn } = setup();
+ fireEvent.click(screen.getByRole('button', { name: 'Sign in instead' }));
+ expect(signIn).toHaveBeenCalledOnce();
+ fireEvent.click(screen.getByRole('button', { name: 'Get started' }));
+ expect(
+ screen.queryByRole('button', { name: 'Sign in instead' })
+ ).toBeNull();
+ });
});
diff --git a/apps/web/src/features/onboarding/views/signup-journey-view.tsx b/apps/web/src/features/onboarding/views/signup-journey-view.tsx
index 4b18b1c9f2..7f5e92395f 100644
--- a/apps/web/src/features/onboarding/views/signup-journey-view.tsx
+++ b/apps/web/src/features/onboarding/views/signup-journey-view.tsx
@@ -5,6 +5,7 @@ import {
focusStepHeading,
} from '../components/motion/step-change';
import { OnboardingShell } from '../components/onboarding-shell';
+import { SignInInstead } from '../components/sign-in-instead';
import { OnboardingTrustDetails } from '../components/trust-details';
import {
nextSignupStep,
@@ -19,6 +20,8 @@ export function SignupJourneyView(props: {
/** Starts Google sign-up; on web the page navigates away. */
onGoogle: () => Promise<void>;
onBackFromEmail: () => void;
+ /** Sends a returning user to sign in. */
+ onSignIn: () => void;
/** The host's email sign-up form, shown in place of Google when chosen. */
emailForm?: JSX.Element;
showingEmail: boolean;
@@ -53,6 +56,11 @@ export function SignupJourneyView(props: {
else goTo(previousSignupStep(journey.step()));
}
}
+ heroFooter={
+ journey.step() === 'welcome' && !props.showingEmail ? (
+ <SignInInstead onSignIn={props.onSignIn} />
+ ) : undefined
+ }
explainer={
journey.step() === 'security' || journey.step() === 'work' ? (
<OnboardingTrustDetails
diff --git a/docs/AGENT_GUIDE/login.md b/docs/AGENT_GUIDE/login.md
index 0a4c64fc7e..04d8ca3836 100644
--- a/docs/AGENT_GUIDE/login.md
+++ b/docs/AGENT_GUIDE/login.md
@@ -94,7 +94,8 @@ New desktop users enter the same flow from
open `/app/signup`. Existing members and native mobile keep their existing routes.
Signed-out `/app/signup` starts at the workspace color picker, followed by feature
-interests and security. No account is required for these slides. At the work-email
+interests and security. No account is required for these slides. Below the color
+picker, "Already have an account? Sign in instead" opens `/app/login`. At the work-email
step, Connect work email uses Google sign-up to create the Macro account and link
the primary inbox. This step offers Google sign-up only, with no alternate email
button. The chosen accent and work step survive the OAuth