Skip to content

refactor: remove ScreenComponent any casts for Redux/shared-Props components#28189

Merged
asalsys merged 8 commits into
mainfrom
refactor/remove-screen-component-any-app-redux
Apr 6, 2026
Merged

refactor: remove ScreenComponent any casts for Redux/shared-Props components#28189
asalsys merged 8 commits into
mainfrom
refactor/remove-screen-component-any-app-redux

Conversation

@asalsys

@asalsys asalsys commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

Description

Migrate 3 complex components from prop-based route access to useRoute() hook (PR 11 of 13).

Components:

  • OnboardingSuccess — simple migration, route was already optional
  • AccountStatus — Redux connect() component; removed route from connected props, kept saveOnboardingEvent
  • RevealPrivateCredential — most complex; switched route and navigation to hooks, made cancel optional, derived hasNavigation from cancel presence to preserve the dual-mode behavior (screen vs embedded)

Changelog

CHANGELOG entry: null

Related issues

Fixes:

Manual testing steps

N/A — pure refactoring. All 127 existing tests pass across 3 suites.

Screenshots/Recordings

Before

N/A

After

N/A

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.

Made with Cursor


Note

Medium Risk
Refactors several navigation-critical screens to use useRoute()/useNavigation() and changes back-navigation behavior in RevealPrivateCredential, which could surface as runtime navigation/params issues if any route assumptions are wrong.

Overview
Migrates OnboardingSuccess, AccountStatus (Redux connect), OnboardingSheet, and RevealPrivateCredential from prop-based route/navigation access to useRoute()/useNavigation(), removing several ScreenComponent casts in App.tsx.

Updates navigation typing by adding OnboardingSheet route params to NavigationService types, and adjusts RevealPrivateCredential to use StackActions (pop/popToTop) via navigation.dispatch while making cancel optional for embedded vs screen usage. Tests are refactored accordingly to mock useRoute() params instead of passing route props.

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

…ponents

Migrate OnboardingSuccess, AccountStatus, and RevealPrivateCredential
from prop-based route access to useRoute() hook.

- OnboardingSuccess: switch to useRoute(), remove ScreenProps interface
- AccountStatus: switch to useRoute(), keep saveOnboardingEvent from
  Redux connect()
- RevealPrivateCredential: switch to useRoute() and useNavigation(),
  make cancel optional, derive hasNavigation from cancel presence
- Remove 6 as-casts from App.tsx (2 OnboardingSuccess, 3 AccountStatus,
  1 RevealPrivateCredential)
- Update all 3 test files to mock useRoute()

Made-with: Cursor
@asalsys asalsys self-assigned this Mar 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-mobile-platform Mobile Platform team label Mar 31, 2026
@asalsys asalsys marked this pull request as ready for review March 31, 2026 19:18
@asalsys asalsys requested a review from a team as a code owner March 31, 2026 19:18
@github-actions github-actions Bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Apr 2, 2026
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 3, 2026
Comment thread app/components/Nav/App/App.tsx
@asalsys asalsys requested review from a team as code owners April 3, 2026 14:09
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 3, 2026
@asalsys asalsys force-pushed the refactor/remove-screen-component-any-app-redux branch from 542eab8 to d69d3cd Compare April 3, 2026 14:14
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 3, 2026
@asalsys asalsys removed request for a team April 3, 2026 14:18
const hasNavigation = !!navigation;
const navigation = useNavigation();
const route = useRoute<RevealPrivateCredentialRouteProp>();
const hasNavigation = !cancel;

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.

hasNavigation logic changes ErrorBoundary embedded behavior

Medium Severity

Changing hasNavigation from !!navigation (prop-based) to !cancel alters behavior when both cancel and a navigation context exist. In ErrorBoundary/index.js, RevealPrivateCredential receives a cancel callback alongside a valid navigation context. Previously hasNavigation was true; now it's false. This causes handleLearnMoreClick to open an external browser instead of an in-app webview, and headerNavigationBack/navigateBack to call cancel() instead of navigation methods — a silent behavioral regression in the error-recovery SRP backup flow.

Fix in Cursor Fix in Web

@asalsys asalsys requested a review from a team as a code owner April 3, 2026 14:21
@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 3, 2026

@cursor cursor 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.

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

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

}: IRevealPrivateCredentialProps) => {
const hasNavigation = !!navigation;
const navigation = useNavigation();
const route = useRoute<RevealPrivateCredentialRouteProp>();

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.

Component crashes outside NavigationContainer after hook migration

High Severity

RevealPrivateCredential now unconditionally calls useNavigation() and useRoute(), which throw when rendered outside a NavigationContainer. The ErrorBoundary component (ErrorBoundary/index.js) imports and renders RevealPrivateCredential — error boundaries replace their children with fallback UI, potentially outside the NavigationContainer. Previously, the component accepted nullable navigation and route props to handle this case gracefully. The test 'renders when useNavigation returns null' masks this by mocking useNavigation to return null, but in production useNavigation() throws — it never returns null. This could cause a crash during error recovery (double fault).

Additional Locations (1)
Fix in Cursor Fix in Web

@github-actions github-actions Bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 3, 2026
@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeWalletPlatform, SmokeIdentity
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR refactors several navigation-related components to use React Navigation hooks (useNavigation, useRoute) instead of receiving navigation/route as props. Key changes:

  1. RevealPrivateCredential (most significant): Removed navigation and route props, now uses hooks. Changed hasNavigation logic from !!navigation to !cancel. Updated navigation calls to use StackActions.pop() and StackActions.popToTop() via navigation.dispatch(). This is a behavioral change in how navigation works after SRP/private key reveal - directly tested by SmokeAccounts (SRP export flows, RevealPrivateCredential component).

  2. OnboardingSheet, OnboardingSuccess, AccountStatus: Refactored to use useRoute() hook instead of route prop. These are part of the wallet creation/import onboarding flow. OnboardingSheet now exports OnboardingSheetParams type used in NavigationService types.

  3. NavigationService/types.ts (CRITICAL): OnboardingSheet route now accepts typed OnboardingSheetParams | undefined instead of undefined.

  4. App.tsx: Removed as ScreenComponent type casts - TypeScript-only changes.

Tag selection rationale:

  • SmokeAccounts: Directly covers RevealPrivateCredential (SRP export quiz, private key reveal), account management flows. The navigation behavior change in RevealPrivateCredential (pop/popToTop via dispatch) needs E2E validation.
  • SmokeWalletPlatform: Covers multi-SRP architecture, SRP export from Settings and account action menus. The onboarding success flow changes also affect wallet lifecycle analytics.
  • SmokeIdentity: Related to SmokeAccounts per tag description - account sync features involve onboarding flows that were modified (OnboardingSuccess, AccountStatus).

The changes are primarily TypeScript/hook refactoring with no new features, but the navigation behavior changes in RevealPrivateCredential warrant validation of the SRP reveal flow end-to-end.

Performance Test Selection:
No performance-sensitive changes in this PR. The changes are purely TypeScript refactoring (removing prop drilling in favor of hooks) with no impact on rendering performance, data loading, list components, or app startup. The hook-based approach (useNavigation, useRoute) has negligible performance difference from prop-based navigation.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented Apr 3, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Apr 3, 2026

Copy link
Copy Markdown
Contributor

E2E Fixture Validation — Schema is up to date
17 value mismatches detected (expected — fixture represents an existing user).
View details

@asalsys asalsys enabled auto-merge April 3, 2026 15:47

@tuna1207 tuna1207 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@asalsys asalsys added this pull request to the merge queue Apr 4, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 4, 2026
@asalsys asalsys added this pull request to the merge queue Apr 6, 2026
Merged via the queue into main with commit da7f034 Apr 6, 2026
97 checks passed
@asalsys asalsys deleted the refactor/remove-screen-component-any-app-redux branch April 6, 2026 10:59
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 6, 2026
@metamaskbot metamaskbot added the release-7.74.0 Issue or pull request that will be included in release 7.74.0 label Apr 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.74.0 Issue or pull request that will be included in release 7.74.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-L team-mobile-platform Mobile Platform team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants