Skip to content

[fix] fix(frontend): Send signed-out visitors to the /m sign-in so new users get the new onboarding - #7916

Merged
mmabrouk merged 1 commit into
release/v0.127.2from
fix/gate-signed-out-to-m-signin
Oct 29, 2026
Merged

mmabrouk merged 1 commit into
release/v0.127.2from
fix/gate-signed-out-to-m-signin

Conversation

@mmabrouk

Copy link
Copy Markdown
Member

Context

New users on cloud never see the new first-agent onboarding in /m. A new visitor who clicks "Get started" on the website lands on /, which redirects to /w. The classic app then sends them to its own /auth page, and they sign up there. After that they go through the classic /post-signup survey and only then reach /m. The new onboarding starts only when /m's own sign-in marks the account as new (useAuthSuccess calls markOnboardingPending). The classic sign-in never writes that mark, so most new accounts skip the new onboarding.

The cause is in the server-side gate, decideDesktopGate. On a desktop browser, it sends a visitor to /m only when the agenta-classic-mode cookie is 0. The apps write that cookie only after a sign-in, so a signed-out visitor has no cookie and stays on the classic app.

Changes

The gate now sends a signed-out desktop visitor with no agenta-classic-mode cookie from the two entry points to the /m sign-in:

Request Before After
/w (where / redirects) classic app, then classic /auth /m/auth
/auth classic /auth /m/auth
/w?template=<key> (website template link) classic app /m/?template=<key>

The template link goes to the /m root and not to /m/auth. The /m auth gate saves the template key before it opens the sign-in and picks it up again after it, and /m/auth would drop the key.

"Signed out" means the request has neither of SuperTokens' session cookies that reach a page request, sAccessToken and sFrontToken. Both use path /. The API sets sAccessToken on sign-in, and the SuperTokens frontend writes sFrontToken. The gate does not validate them. It only checks if one is there.

These cases do not change:

  1. A signed-in visitor (either session cookie present) passes as before.
  2. A visitor whose browser has agenta-classic-mode=1 stays on the classic app, signed in or not. agenta-classic-mode=0 keeps its current routing.
  3. The links that must finish on the classic app still pass, using the existing isDesktopOnlyLink list: /auth/callback/*, any /auth link with token (password reset, invites) or auth_error, /workspaces/accept, and /post-signup. The handback of an OAuth callback that /m started still goes to /m.
  4. ?view=desktop and the agenta-mobile-optout cookie still win.
  5. Phones keep the device rule, which already sent them to /m.

Deep links stay on the classic sign-in. A signed-out visitor who opens a link such as /w/<workspace>/p/<project>/agents is sent by the classic app to /auth?redirectToPath=..., and the classic sign-in returns them to that page afterwards. The /m sign-in has no return path. It always lands on the /m home screen. So moving these visitors to /m would lose the page the link pointed to, even for pages that /m has. The gate therefore leaves deep links alone, and it also leaves /auth?redirectToPath=... alone if someone reloads it.

Side effects

A person with an older account (created before 2026-08-01) who is signed out and has no agenta-classic-mode cookie in that browser now signs in on /m and stays on /m. They can turn Developer mode on from /m settings to go back to the classic app. If the browser already stores an explicit Classic mode choice for that user, /m writes agenta-classic-mode=1 after the sign-in, and the next full page load of /m sends them to /w. The sign-in itself does not reload the page, so they see the /m home screen first.

New sign-ups no longer see the classic /post-signup survey, because they sign up on /m and the /m onboarding asks the same questions. This PR does not remove the classic survey code.

Tests / notes

  • mobileGate.test.ts covers every case above: signed out with no cookie, each session cookie, both Classic mode cookie values, the desktop-only links, the /m callback handback, ?view=desktop, the opt-out cookie, the template link, and deep links. Two existing tests that used a desktop request with no cookies now set a session cookie, because they test a signed-in user with no preference.
  • pnpm test:unit in web/packages/agenta-shared passes. pnpm lint-fix in web/ is clean.
  • Live check on a local EE dev stack running this branch's web app and /m, in a fresh browser profile each time:
    1. Signed out, opening the root goes / (308) to /w (307) to /m/auth.
    2. A new email and password sign-up on that page lands on /m/.../onboarding/persona. After the sign-up the browser holds sAccessToken and sFrontToken, both on path /.
    3. A signed-in user with an explicit Classic mode choice opens the root and stays on the classic app at /w/.../apps. The gate does not redirect /w.
    4. A password reset link (/auth/reset-password?token=...) and an invite link (/auth?token=...&email=...) both open the classic page with no redirect.
    5. A signed-out deep link to /w/<ws>/p/<project>/agents opens the classic /auth?redirectToPath=....
    6. A signed-out website template link goes to /m/?template=<key>, then to /m/auth, and /m stores the template key for after the sign-in.
    7. A signed-out browser that stores an explicit Classic mode choice for a user goes to /m/auth. After the sign-in, that user sees the /m home screen and agenta-classic-mode is 1. A reload then sends them to /w.

What to QA

  • In a private window on a desktop browser, open the app root. You land on the /m sign-in, not the classic sign-in.
  • Sign up with a new account there. You reach the new /m onboarding.
  • Open the website "Use it for free" template link while signed out. You land on the /m sign-in, and after sign-up you land on that template's setup step.
  • While signed in to an account that uses the classic app, open the app root. You land on the classic app as before.
  • Open a password reset link and an invite link. Both open the classic page.
  • Regression: while signed out, open a deep link to a project page. You see the classic sign-in, and after signing in you land on that page.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 6d4f0bf and 6d4f0bf.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Signed-in visitors with either recognized session cookie are no longer treated as signed out by the desktop gate.
    • Signed-out visitors arriving at /w or /w/ are directed to mobile authentication, or to the requested template when one is specified. Visitors arriving at /auth are directed to mobile authentication when no redirect destination is provided.
    • Other paths and sign-in links with redirect destinations continue through the existing routing behavior.

The desktop gate now recognizes sAccessToken and sFrontToken cookies as session indicators. For eligible signed-out requests, it redirects /w, /w/, and /auth to mobile sign-in destinations. Other requests continue through the existing gate logic.

Changes: Mobile entry routing

Layer / File(s) Summary
Select signed-out entry destinations
web/packages/agenta-shared/src/utils/mobileGate/index.ts
A helper selects mobile sign-in destinations for /w, /w/, and /auth requests without redirectToPath. It preserves a template query when routing to /m.
Apply gate conditions and verify routing
web/packages/agenta-shared/src/utils/mobileGate/index.ts, web/packages/agenta-shared/tests/unit/mobileGate.test.ts
The gate applies entry redirects only when the Classic mode cookie and both session cookies are absent. Tests cover session cookies, preferences, callbacks, and desktop-only links.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~12 minutes

Merge Risk: Low · up to 6d4f0

Some visitors may need to re-enter their email or see the classic sign-in page. Both have workarounds.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly describes the main change: routing signed-out visitors to the /m sign-in to enable the new onboarding. It is specific and related to the changeset, despite minor repeated wording.
Description check Passed The description directly explains the gate changes, routing behavior, affected cases, tests, and validation steps. It is fully related to the changeset.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 60.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Website preview

Preview URL: https://pr-7916-agenta-website-preview.mahmoud-637.workers.dev

Built from 6d4f0bf42cd408257876ec2dd0d25989fbe02a9b. This comment updates in place on every push.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Nitpick comments: 1
web/packages/agenta-shared/src/utils/mobileGate/index.ts: 1

283-286: Trivial · Maintainability & Code Quality · Low value

Shorten the signedOutEntryRoute JSDoc.

The SESSION_COOKIES JSDoc can remain because it documents a surprising constraint in two sentences. The signedOutEntryRoute JSDoc was added with the function, so it is specifically targeted and exceeds the allowed sentence limit.

Suggested fix
 /**
- * Where a signed-out visitor with no Classic mode preference signs in, or `null` to stay.
- *
- * Only the entry points move: bare `/w` (where `/` redirects) and `/auth`. A deep link keeps the
- * desktop sign-in, which returns the user to it (`?redirectToPath=`); `/m`'s sign-in always lands
- * on its home screen. A website template link goes to the `/m` root, which keeps the key across
- * sign-in; `/m/auth` would drop it.
+ * Signed-out entry points move to mobile; deep links stay on desktop and template keys stay on `/m/`.
  */

Review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between a77e503 and 6d4f0bf.

Files selected for processing: 2
  • web/packages/agenta-shared/src/utils/mobileGate/index.ts
  • web/packages/agenta-shared/tests/unit/mobileGate.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 5 remain after this review.

@mmabrouk
mmabrouk changed the base branch from main to release/v0.127.2 October 29, 2026 20:19
@mmabrouk mmabrouk added lgtm This PR has been approved by a maintainer merge queue In the release merge queue; an agent is landing it labels Oct 29, 2026
@mmabrouk

Copy link
Copy Markdown
Member Author

🤖 The AI agent says:

Review loop result for head 6d4f0bf42cd408257876ec2dd0d25989fbe02a9b (base a77e503782159e736b4795144997f2d23de30969), 1 round (quick mode).

Lens Final rating
Correctness Low
Security Low

Fixed: nothing, because the round found no problems.
Left on purpose: nothing. The correctness review checked the order of the gate checks. The OAuth callback handback, ?view=desktop, the desktop-only links, the opt-out cookie and the device rule all run before the new signed-out branch, and a Classic mode cookie skips the new branch.

@mmabrouk

Copy link
Copy Markdown
Member Author

🤖 The AI agent says: About the CodeRabbit nitpick to shorten the signedOutEntryRoute JSDoc: I am keeping it as it is. The comment explains why deep links stay on the classic sign-in and why a template link goes to the /m root and not to /m/auth. A reader cannot see those two reasons from the code.

@mmabrouk
mmabrouk merged commit e472644 into release/v0.127.2 Oct 29, 2026
88 of 91 checks passed
@mmabrouk mmabrouk removed the merge queue In the release merge queue; an agent is landing it label Oct 29, 2026
@mmabrouk mmabrouk mentioned this pull request Oct 29, 2026
23 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant