Skip to content

refactor(onboarding): remove legacy start-trial flow and endpoint - #3569

Merged
ygrishajev merged 1 commit into
mainfrom
fix/start-trial-n-old-onboarding
Aug 10, 2026
Merged

refactor(onboarding): remove legacy start-trial flow and endpoint#3569
ygrishajev merged 1 commit into
mainfrom
fix/start-trial-n-old-onboarding

Conversation

@ygrishajev

@ygrishajev ygrishajev commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Why

Trial wallet provisioning is now fully server-side: the wallet is ensured at registration,
activation is dispatched off registration/email-verification, and the UI polls until it is ready.
The client-triggered POST /v1/start-trial path — and the /signup wizard that used to drive it
(already removed) — are redundant, but their client plumbing was left dead-exposed in the managed
wallet context.

Removing that wizard also makes passwordless email login the sole entry point, which exposed a bug:
after the code was verified the app bounced back to the email step (and flashed the login form)
instead of proceeding, so a fresh sign-in never landed on the app; only a manual refresh recovered.

Closes CON-756

What

Decommission POST /v1/start-trial

  • Remove the route, controller shim, request/response schemas, and the now-unused create-UserWallet
    ability.
  • Remove the dead client: ManagedWalletHttpService.createWallet, useCreateManagedWalletMutation,
    and the createWallet / isWalletCreating / walletError plumbing in WalletProvider and
    useManagedWallet (now reporting-only).
  • Drop the trial_started response interceptor and analytics event.
  • Regenerate swagger/openapi.json and console-api-types.

API contract change: POST /v1/start-trial is removed. It has no remaining consumers — trial
provisioning happens server-side at registration.

Fix the passwordless email verification flow

Root cause: the verify handler cleared the persisted email, and the anonymous→authenticated
transition remounts the auth screen (an ancestor provider swaps on login), re-reading the now-empty
email. The "missing email → go back to entry" guard then fired and router.replace'd back to the
email step, clobbering the post-verify navigation; the login form also flashed during the outgoing
redirect.

  • Gate the "missing email → entry" guard on the anonymous state (it exists for unauthenticated
    deep-links/reloads, not for the post-verify transition).
  • Drive the post-verify redirect from the authenticated state, so it survives the remount.
  • Render the boot loader instead of the auth forms while an authenticated visitor is redirected
    away — removing the login-form flash and bridging into the destination's loader.
  • Merge the resolved user settings into the verify session so it carries userId, matching the
    OAuth callback path.

Summary by CodeRabbit

  • Changes
    • Removed the start-trial API endpoint and managed-wallet creation flow.
    • Regular users can read and sign only their own wallets.
    • Wallet interfaces no longer show creation controls, loading indicators, or creation errors.
    • Authentication now displays a loading state and redirects authenticated users appropriately.
    • User settings are preserved after email-code verification.
  • Tests
    • Updated coverage for wallet access, authentication behavior, and session settings.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 938e7333-2071-4e69-b157-d0ff8c8550f1

📥 Commits

Reviewing files that changed from the base of the PR and between aa4fbb9 and 660b114.

⛔ Files ignored due to path filters (1)
  • apps/api/test/functional/__snapshots__/docs.spec.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (11)
  • apps/api/src/billing/controllers/wallet/wallet.controller.spec.ts
  • apps/api/src/billing/http-schemas/wallet.schema.ts
  • apps/api/swagger/openapi.json
  • apps/deploy-web/src/components/auth/PasswordlessAuth/PasswordlessAuth.spec.tsx
  • apps/deploy-web/src/hooks/useEnsureTrialStarted.spec.ts
  • apps/deploy-web/src/hooks/useEnsureTrialStarted.ts
  • apps/deploy-web/src/hooks/useManagedWallet.spec.tsx
  • apps/deploy-web/src/hooks/useManagedWallet.ts
  • apps/deploy-web/src/lib/nextjs/api-routes-specs/auth-email-code-verify.spec.ts
  • apps/deploy-web/src/services/analytics/analytics.service.ts
  • packages/console-api-types/src/schema.d.ts
💤 Files with no reviewable changes (3)
  • packages/console-api-types/src/schema.d.ts
  • apps/deploy-web/src/services/analytics/analytics.service.ts
  • apps/api/swagger/openapi.json
🚧 Files skipped from review as they are similar to previous changes (4)
  • apps/api/src/billing/controllers/wallet/wallet.controller.spec.ts
  • apps/deploy-web/src/lib/nextjs/api-routes-specs/auth-email-code-verify.spec.ts
  • apps/deploy-web/src/hooks/useManagedWallet.spec.tsx
  • apps/deploy-web/src/components/auth/PasswordlessAuth/PasswordlessAuth.spec.tsx

📝 Walkthrough

Walkthrough

Changes

The legacy /v1/start-trial wallet-creation flow was removed from the API and web applications. Managed-wallet retrieval, signing, initialization, and passwordless session handling remain.

Legacy trial API removal

Layer / File(s) Summary
Remove the start-trial API
apps/api/src/auth/..., apps/api/src/billing/..., apps/api/src/routers/..., apps/api/swagger/openapi.json, packages/console-api-types/src/schema.d.ts
Removed wallet creation permissions, controller logic, route registration, trial schemas, 3DS response fields, and OpenAPI definitions.

Managed wallet state

Layer / File(s) Summary
Retain managed-wallet retrieval
apps/deploy-web/src/queries/..., apps/deploy-web/src/hooks/useManagedWallet..., packages/http-sdk/src/managed-wallet-http/...
Removed wallet creation mutations, cache updates, creation query keys, and the creation HTTP method. Query-based wallet retrieval remains.
Update wallet context and onboarding state
apps/deploy-web/src/context/WalletProvider/..., apps/deploy-web/src/hooks/useOnboardingChrome..., apps/deploy-web/src/services/..., apps/deploy-web/tests/seeders/wallet.ts
Removed creation fields, wallet-error handling, trial-start analytics, response interception, and creation-specific fixtures and tests.

Passwordless authentication

Layer / File(s) Summary
Handle authenticated sessions and persist settings
apps/deploy-web/src/components/auth/PasswordlessAuth/..., apps/deploy-web/src/pages/api/auth/email-code-verify.ts, apps/deploy-web/src/lib/nextjs/api-routes-specs/auth-email-code-verify.spec.ts
Authenticated users now navigate back and see BootLoading. Email-code verification merges userSettings into the session user.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Suggested reviewers: stalniy, baktun14

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/start-trial-n-old-onboarding

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/api/src/billing/controllers/wallet/wallet.controller.spec.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

apps/api/src/billing/http-schemas/wallet.schema.ts

ESLint skipped: the ESLint configuration for this file references a package that is not available in the sandbox.

apps/deploy-web/src/components/auth/PasswordlessAuth/PasswordlessAuth.spec.tsx

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

  • 5 others

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

@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.77%. Comparing base (a7f15fe) to head (660b114).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3569      +/-   ##
==========================================
- Coverage   76.37%   75.77%   -0.60%     
==========================================
  Files        1137     1073      -64     
  Lines       29658    27699    -1959     
  Branches     7385     6974     -411     
==========================================
- Hits        22651    20989    -1662     
+ Misses       6174     5909     -265     
+ Partials      833      801      -32     
Flag Coverage Δ *Carryforward flag
api 89.03% <ø> (+0.05%) ⬆️
deploy-web 66.25% <100.00%> (-0.01%) ⬇️
log-collector ?
notifications 93.84% <ø> (ø)
provider-console 81.38% <ø> (ø) Carriedforward from a7f15fe
provider-inventory ?
provider-proxy 88.17% <ø> (ø) Carriedforward from a7f15fe
tx-signer 86.72% <ø> (ø)

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
...s/api/src/auth/services/ability/ability.service.ts 95.45% <ø> (ø)
...rc/billing/controllers/wallet/wallet.controller.ts 100.00% <ø> (ø)
...ponents/auth/PasswordlessAuth/PasswordlessAuth.tsx 94.73% <100.00%> (+0.39%) ⬆️
...-web/src/context/WalletProvider/WalletProvider.tsx 96.96% <100.00%> (-0.26%) ⬇️
apps/deploy-web/src/hooks/useEnsureTrialStarted.ts 100.00% <100.00%> (ø)
apps/deploy-web/src/hooks/useManagedWallet.ts 92.85% <100.00%> (+0.85%) ⬆️
apps/deploy-web/src/hooks/useOnboardingChrome.ts 100.00% <100.00%> (ø)
...deploy-web/src/pages/api/auth/email-code-verify.ts 100.00% <100.00%> (ø)
...ps/deploy-web/src/queries/useManagedWalletQuery.ts 90.90% <ø> (+5.19%) ⬆️
...oy-web/src/services/analytics/analytics.service.ts 94.61% <ø> (ø)
... and 1 more

... and 66 files with indirect coverage changes

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ygrishajev
ygrishajev force-pushed the fix/start-trial-n-old-onboarding branch 2 times, most recently from c7c895d to 6ffcae5 Compare August 7, 2026 09:52

@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)
apps/deploy-web/src/components/wallet/ConnectManagedWalletButton.tsx (1)

29-31: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a click-navigation assertion.

ConnectManagedWalletButton.spec.tsx tests only enabled and disabled states. Add a test that verifies router.push receives UrlService.onboardingPicker(). This protects the changed destination from regression.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/deploy-web/src/components/wallet/ConnectManagedWalletButton.tsx` around
lines 29 - 31, Extend ConnectManagedWalletButton.spec.tsx with an enabled-button
click test that invokes the handler and asserts router.push receives
UrlService.onboardingPicker(). Reuse the existing router mock and button setup
while preserving the current enabled and disabled state tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/api/src/billing/controllers/wallet/wallet.controller.spec.ts`:
- Around line 64-68: Update the AuthService mock setup around the rootContainer
registration: create the mock without the inline ability override, then assign
the real createMongoAbility result to its ability property afterward so CASL
internals are not recursively mocked. Ensure authorization assertions use a
throwUnlessCan implementation that delegates to the assigned ability when
needed.

---

Nitpick comments:
In `@apps/deploy-web/src/components/wallet/ConnectManagedWalletButton.tsx`:
- Around line 29-31: Extend ConnectManagedWalletButton.spec.tsx with an
enabled-button click test that invokes the handler and asserts router.push
receives UrlService.onboardingPicker(). Reuse the existing router mock and
button setup while preserving the current enabled and disabled state tests.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 167fa368-db2a-4ca7-ac3d-870ac472a31e

📥 Commits

Reviewing files that changed from the base of the PR and between 7e19b74 and 558ca82.

📒 Files selected for processing (55)
  • apps/api/src/auth/services/ability/ability.service.ts
  • apps/api/src/billing/controllers/wallet/wallet.controller.spec.ts
  • apps/api/src/billing/controllers/wallet/wallet.controller.ts
  • apps/api/src/billing/http-schemas/wallet.schema.ts
  • apps/api/src/billing/routes/index.ts
  • apps/api/src/billing/routes/start-trial/start-trial.router.ts
  • apps/api/src/routers/open-api-handlers.ts
  • apps/api/swagger/openapi.json
  • apps/deploy-web/src/components/deployments/DeploymentDetailTopBar/DeploymentDetailTopBar.spec.tsx
  • apps/deploy-web/src/components/deployments/ManifestUpdate/ManifestUpdate.spec.tsx
  • apps/deploy-web/src/components/home/YourAccount/YourAccount.spec.tsx
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.tsx
  • apps/deploy-web/src/components/onboarding/OnboardingPage.tsx
  • apps/deploy-web/src/components/onboarding/OnboardingStepper/OnboardingStepper.tsx
  • apps/deploy-web/src/components/onboarding/OnboardingView/OnboardingView.tsx
  • apps/deploy-web/src/components/onboarding/VerifyEmailPage/VerifyEmailPage.spec.tsx
  • apps/deploy-web/src/components/onboarding/VerifyEmailPage/VerifyEmailPage.tsx
  • apps/deploy-web/src/components/onboarding/steps/EmailVerificationContainer/EmailVerificationContainer.spec.tsx
  • apps/deploy-web/src/components/onboarding/steps/EmailVerificationContainer/EmailVerificationContainer.tsx
  • apps/deploy-web/src/components/onboarding/steps/EmailVerificationStep/EmailVerificationStep.spec.tsx
  • apps/deploy-web/src/components/onboarding/steps/EmailVerificationStep/EmailVerificationStep.tsx
  • apps/deploy-web/src/components/onboarding/steps/FreeTrialLandingStep/FreeTrialLandingStep.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodContainer/PaymentMethodContainer.spec.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodContainer/PaymentMethodContainer.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodStep/PaymentMethodStep.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/EmptyPaymentMethods.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/ErrorAlert.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/PaymentMethodsDisplay.test.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/PaymentMethodsDisplay.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/TermsAndConditions.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/TrialStartButton.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentVerificationCard/PaymentVerificationCard.tsx
  • apps/deploy-web/src/components/onboarding/steps/WelcomeStep/TemplateCard.tsx
  • apps/deploy-web/src/components/onboarding/steps/WelcomeStep/TrialStatusBar.tsx
  • apps/deploy-web/src/components/onboarding/steps/WelcomeStep/WelcomeStep.tsx
  • apps/deploy-web/src/components/wallet/ConnectManagedWalletButton.tsx
  • apps/deploy-web/src/context/WalletProvider/WalletProvider.tsx
  • apps/deploy-web/src/hooks/useManagedWallet.spec.tsx
  • apps/deploy-web/src/hooks/useManagedWallet.ts
  • apps/deploy-web/src/hooks/useOnboardingChrome.spec.ts
  • apps/deploy-web/src/hooks/useOnboardingChrome.ts
  • apps/deploy-web/src/hooks/useReturnTo/useReturnTo.ts
  • apps/deploy-web/src/pages/signup/index.tsx
  • apps/deploy-web/src/queries/queryKeys.ts
  • apps/deploy-web/src/queries/useManagedWalletQuery.spec.tsx
  • apps/deploy-web/src/queries/useManagedWalletQuery.ts
  • apps/deploy-web/src/services/analytics/analytics.service.ts
  • apps/deploy-web/src/services/app-di-container/app-di-container.ts
  • apps/deploy-web/src/utils/urlUtils.ts
  • apps/deploy-web/tests/seeders/wallet.ts
  • apps/deploy-web/tests/ui/pages/HomePage.ts
  • apps/deploy-web/tests/ui/pages/OnboardingPage.ts
  • packages/console-api-types/src/schema.d.ts
  • packages/http-sdk/src/managed-wallet-http/managed-wallet-http.service.ts
💤 Files with no reviewable changes (39)
  • apps/deploy-web/src/components/home/YourAccount/YourAccount.spec.tsx
  • apps/api/src/billing/routes/index.ts
  • apps/deploy-web/src/components/onboarding/steps/WelcomeStep/TrialStatusBar.tsx
  • apps/deploy-web/src/components/deployments/ManifestUpdate/ManifestUpdate.spec.tsx
  • apps/deploy-web/src/components/onboarding/steps/WelcomeStep/TemplateCard.tsx
  • apps/deploy-web/src/components/onboarding/OnboardingPage.tsx
  • apps/deploy-web/src/pages/signup/index.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/ErrorAlert.tsx
  • apps/deploy-web/tests/seeders/wallet.ts
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.spec.tsx
  • apps/api/swagger/openapi.json
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodContainer/PaymentMethodContainer.spec.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/TermsAndConditions.tsx
  • apps/api/src/routers/open-api-handlers.ts
  • packages/http-sdk/src/managed-wallet-http/managed-wallet-http.service.ts
  • apps/deploy-web/src/components/onboarding/steps/EmailVerificationContainer/EmailVerificationContainer.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodStep/PaymentMethodStep.tsx
  • apps/deploy-web/src/components/onboarding/steps/WelcomeStep/WelcomeStep.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/PaymentMethodsDisplay.tsx
  • apps/deploy-web/src/components/onboarding/steps/FreeTrialLandingStep/FreeTrialLandingStep.tsx
  • apps/deploy-web/src/components/onboarding/OnboardingContainer/OnboardingContainer.tsx
  • apps/deploy-web/src/utils/urlUtils.ts
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodContainer/PaymentMethodContainer.tsx
  • packages/console-api-types/src/schema.d.ts
  • apps/deploy-web/tests/ui/pages/OnboardingPage.ts
  • apps/deploy-web/src/components/onboarding/OnboardingStepper/OnboardingStepper.tsx
  • apps/deploy-web/src/services/analytics/analytics.service.ts
  • apps/deploy-web/src/queries/queryKeys.ts
  • apps/deploy-web/src/components/deployments/DeploymentDetailTopBar/DeploymentDetailTopBar.spec.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/PaymentMethodsDisplay.test.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/TrialStartButton.tsx
  • apps/api/src/billing/routes/start-trial/start-trial.router.ts
  • apps/deploy-web/src/components/onboarding/steps/PaymentMethodsDisplay/EmptyPaymentMethods.tsx
  • apps/deploy-web/src/components/onboarding/steps/EmailVerificationStep/EmailVerificationStep.spec.tsx
  • apps/api/src/billing/http-schemas/wallet.schema.ts
  • apps/deploy-web/src/components/onboarding/OnboardingView/OnboardingView.tsx
  • apps/deploy-web/src/components/onboarding/steps/EmailVerificationStep/EmailVerificationStep.tsx
  • apps/deploy-web/src/components/onboarding/steps/PaymentVerificationCard/PaymentVerificationCard.tsx
  • apps/deploy-web/src/components/onboarding/steps/EmailVerificationContainer/EmailVerificationContainer.spec.tsx

Comment thread apps/api/src/billing/controllers/wallet/wallet.controller.spec.ts Outdated
Comment thread apps/api/src/routers/open-api-handlers.ts
Comment thread apps/deploy-web/tests/ui/pages/OnboardingPage.ts Outdated
Comment thread apps/deploy-web/src/services/analytics/analytics.service.ts
@ygrishajev
ygrishajev force-pushed the fix/start-trial-n-old-onboarding branch 2 times, most recently from 7dafe5b to aa4fbb9 Compare August 10, 2026 15:02

@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: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/deploy-web/src/components/auth/PasswordlessAuth/PasswordlessAuth.spec.tsx`:
- Around line 86-98: Update the authenticated test around PasswordlessAuth to
inject a BootLoading mock, retain the existing assertions that EmailCodeStart
and EmailCodeVerify are not called, and add a meaningful assertion that the
BootLoading mock is rendered.

In
`@apps/deploy-web/src/lib/nextjs/api-routes-specs/auth-email-code-verify.spec.ts`:
- Around line 30-39: Update the test around callHandler and the setSession
assertion to also verify subscribedToNewsletter is true alongside userId and
username, ensuring every supplied user setting is preserved in the persisted
session user.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 4fb540f3-953c-4892-8545-fd430b396c27

📥 Commits

Reviewing files that changed from the base of the PR and between 963921a and aa4fbb9.

📒 Files selected for processing (4)
  • apps/deploy-web/src/components/auth/PasswordlessAuth/PasswordlessAuth.spec.tsx
  • apps/deploy-web/src/components/auth/PasswordlessAuth/PasswordlessAuth.tsx
  • apps/deploy-web/src/lib/nextjs/api-routes-specs/auth-email-code-verify.spec.ts
  • apps/deploy-web/src/pages/api/auth/email-code-verify.ts

@ygrishajev
ygrishajev force-pushed the fix/start-trial-n-old-onboarding branch from aa4fbb9 to 5a48071 Compare August 10, 2026 15:14
Comment thread apps/api/src/billing/http-schemas/wallet.schema.ts Outdated
Comment thread apps/deploy-web/src/pages/api/auth/email-code-verify.ts
Comment thread apps/deploy-web/src/hooks/useManagedWallet.ts
@ygrishajev
ygrishajev force-pushed the fix/start-trial-n-old-onboarding branch from 5a48071 to 8916424 Compare August 10, 2026 15:48
Trial wallet provisioning is fully server-side: the wallet is ensured at registration, activation
is dispatched off registration/email-verification, and the UI polls until it is ready. The
client-triggered POST /v1/start-trial path is now redundant, and the /signup wizard that used to
drive it is already gone; its client plumbing was left dead-exposed in the managed wallet context.

Remove POST /v1/start-trial (router, controller shim, request/response schemas, the unused
create-UserWallet ability) and its dead client: ManagedWalletHttpService.createWallet,
useCreateManagedWalletMutation, and the createWallet/isWalletCreating/walletError plumbing in
WalletProvider and useManagedWallet (now reporting-only). Drop the trial_started interceptor and
event. Swagger and console-api-types regenerated.

Also fix the passwordless email verification flow this leaves as the sole entry point. After the
code was verified the handler cleared the persisted email, and the anon->authed transition remounts
the auth screen from an ancestor provider, re-reading the now-empty email; the "missing email ->
entry" guard then fired and bounced back to the email step, clobbering the success navigation.
Gate that guard on the anonymous state, drive the post-verify redirect from the authenticated
state, and render the boot loader instead of the auth forms while an authenticated visitor is
redirected away (removing the login-form flash). Persist the resolved user settings on the verify
session so it carries userId like the OAuth callback path.
@ygrishajev
ygrishajev force-pushed the fix/start-trial-n-old-onboarding branch from 8916424 to 660b114 Compare August 10, 2026 15:51
@github-actions github-actions Bot added size: XL and removed size: L labels Aug 10, 2026
@ygrishajev
ygrishajev added this pull request to the merge queue Aug 10, 2026

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I reviewed this PR and didn't find any new bugs. Given the size (XL) and that it touches authentication flow logic and removes a public API endpoint, a human look is still worthwhile.

  • Checked the /v1/start-trial removal end-to-end: route, controller, schemas, OpenAPI/snapshot regeneration, and SDK client — all consistently pruned, no dangling references found.
  • Checked the UserWallet ability change (create removed) against the deleted route — no other caller relied on create-ability.
  • Checked the passwordless auth redirect fix (anonymous-gated guard, boot-loader render, post-verify navigation) against the described remount bug — the fix targets the right condition.
  • Prior bug-hunter findings from earlier runs (docs snapshot, dead schema fields, stale E2E helper, dead analytics events) all appear resolved in the current diff.
Extended reasoning...

Overview

This PR decommissions the legacy POST /v1/start-trial endpoint and its client plumbing (route, controller shim, schemas, SDK method, mutation hook, WalletProvider/useManagedWallet creation state, analytics interceptor), and separately fixes a passwordless email-verification bug where a successful login bounced back to the email-entry step due to a remount clearing the persisted email. Changes span apps/api (routing, ability rules, OpenAPI generation) and apps/deploy-web (auth flow, wallet hooks, analytics types), plus generated SDK/OpenAPI artifacts.

Security risks

The AbilityService change narrows UserWallet permissions for REGULAR_USER/REGULAR_PAYING_USER from ["create","read","sign"] to ["read","sign"], consistent with removing the only code path that used create. No new attack surface is introduced; if anything this reduces surface by removing an endpoint and an ability grant. The auth flow fix changes redirect/guard logic based on authenticated state — a subtle misordering here could theoretically strand or misroute a user, but it doesn't create an authorization bypass since it only affects client-side navigation, not server-side access control.

Level of scrutiny

This warrants more than a rubber stamp: it's an XL PR touching route removal (API contract change), ability rules, and authentication UI flow — areas where subtle regressions (e.g. redirect loops, flashing forms) are easy to introduce and hard to catch outside manual/E2E testing. The bug-hunting system already went through several rounds here and the issues raised (CI-breaking snapshot, dead-code E2E helper, dead schema fields, duplicate loading flags) all appear to have been addressed in the current diff. This run found nothing further.

Other factors

Test coverage is substantial and was updated in lockstep with the behavior changes (new tests for the boot-loader render, the authenticated-redirect guard, and the session merge). CodeRabbit also left minor test-assertion suggestions (assert BootLoading renders, assert the full merged settings) which are non-blocking polish. Given the breadth of surface changed and the auth-adjacent nature of the fix, I'm deferring for a human pass rather than approving outright.

Merged via the queue into main with commit 6925bf4 Aug 10, 2026
60 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants