Skip to content

chore: Move auth logic from App.tsx to sagas and use unlockWallet#24539

Merged
Cal-L merged 73 commits intomainfrom
refactor/MCWP-239-App.tsx
Jan 23, 2026
Merged

chore: Move auth logic from App.tsx to sagas and use unlockWallet#24539
Cal-L merged 73 commits intomainfrom
refactor/MCWP-239-App.tsx

Conversation

@Cal-L
Copy link
Copy Markdown
Contributor

@Cal-L Cal-L commented Jan 15, 2026

Description

This PR continues to consolidate app unlock logic. This time, we're removing the auth trigger from App.tsx and moving the responsibility to sagas. We're also leveraging the new unlockWallet method to provide a more robust and predictable user experience. Furthermore, we've moved MetaMetrics initialization in the scope of service initialization in the sagas. This ensures that the service is initialized before an authentication attempt is made.

Changelog

CHANGELOG entry:

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/MCWP-239

Manual testing steps

This change is experienced on cold starts.

Navigates to Login screen if biometrics is not enabled

  • Disable biometrics
  • Kill the app
  • Re-open the app
  • App should land on the Login screen

Automatically prompts biometrics if biometrics is enabled

  • Enable biometrics
  • Kill the app
  • Re-open the app
  • App should automatically prompt biometrics
  • Upon success, app will land on the wallet screen

Navigates to Login screen if biometrics fails

  • Enable biometrics
  • Kill the app
  • Re-open the app
  • App should automatically prompt biometrics
  • Upon failure, app will land on the Login screen

Screenshots/Recordings

Before

After

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Centralizes startup auth and telemetry in sagas for more predictable app initialization.

  • Introduces requestAuthOnAppStart saga to call Authentication.unlockWallet; on failure, resets to Routes.ONBOARDING.LOGIN
  • Adds MetaMetrics initialization to startAppServices, waits one frame to avoid navigation race, and keeps applyVaultInitialization
  • Removes navigation/auth/metrics side-effects from App.tsx (retains version migration and seedless password check); drops unused hooks/imports
  • Expands saga tests (auth flow, MetaMetrics error handling) and trims App.test.tsx to focus on multichain account routes/screens

Written by Cursor Bugbot for commit 0271e88. This will update automatically on new commits. Configure here.

Cal-L added 30 commits December 11, 2025 20:59
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Base automatically changed from refactor/MCWP-240-login-screen to main January 22, 2026 23:00
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.88%. Comparing base (129cc7c) to head (1e7672d).
⚠️ Report is 38 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #24539      +/-   ##
==========================================
- Coverage   79.88%   79.88%   -0.01%     
==========================================
  Files        4231     4244      +13     
  Lines      108283   109055     +772     
  Branches    22674    22803     +129     
==========================================
+ Hits        86503    87118     +615     
- Misses      15722    15887     +165     
+ Partials     6058     6050       -8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

tommasini
tommasini previously approved these changes Jan 22, 2026
@github-project-automation github-project-automation bot moved this from Needs dev review to Review finalised - Ready to be merged in PR review queue Jan 22, 2026
tommasini
tommasini previously approved these changes Jan 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeWalletPlatform
  • Risk Level: medium
  • AI Confidence: 75%
click to see 🤖 AI reasoning details

The PR refactors the authentication flow from the App component to Redux sagas. Key changes include:

  1. Authentication flow moved to sagas: The appTriggeredAuth logic in App.tsx has been replaced with a new requestAuthOnAppStart saga that calls Authentication.unlockWallet. This is a significant architectural change to how the app handles authentication on startup.

  2. MetaMetrics initialization moved: MetaMetrics configuration is now done in the startAppServices saga instead of a useEffect in the App component.

  3. Navigation timing changes: A requestAnimationFrame wait was added to ensure navigation stacks are rendered before authentication is triggered.

The changes are well-tested with unit tests (sagas.test.ts), but E2E testing is important to verify:

  • The app still starts correctly and authenticates users properly
  • Auto-lock functionality still works (e2e/specs/accounts/auto-lock.spec.ts uses LoginView)
  • Account management flows that depend on authentication work correctly
  • Wallet platform features that rely on proper app initialization work

Selected tags:

  • SmokeAccounts: Tests account security, authentication flows, and wallet unlock scenarios. The auto-lock test specifically tests the login flow which is affected by these changes.
  • SmokeWalletPlatform: Tests core wallet platform features including app lifecycle and startup behavior, which are directly affected by moving authentication to sagas.

The risk is medium because:

  • The changes are architectural but the core authentication logic (Authentication.unlockWallet) already existed
  • Unit tests cover the new saga behavior
  • The changes don't modify the actual authentication mechanisms, just when/how they're triggered

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@Cal-L Cal-L added this pull request to the merge queue Jan 23, 2026
Merged via the queue into main with commit 4b45ef0 Jan 23, 2026
96 of 97 checks passed
@Cal-L Cal-L deleted the refactor/MCWP-239-App.tsx branch January 23, 2026 01:32
@github-project-automation github-project-automation bot moved this from Review finalised - Ready to be merged to Merged, Closed or Archived in PR review queue Jan 23, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Jan 23, 2026
@github-actions github-actions bot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Jan 23, 2026
@metamaskbot metamaskbot added the release-7.64.0 Issue or pull request that will be included in release 7.64.0 label Jan 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

no changelog required No changelog entry is required for this change No QA Needed Apply this label when your PR does not need any QA effort. no-changelog no-changelog Indicates no external facing user changes, therefore no changelog documentation needed release-7.64.0 Issue or pull request that will be included in release 7.64.0 size-L skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-mobile-platform Mobile Platform team

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

5 participants