-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore: Fix some bugs with the new link-handling system #22968
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
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. |
|
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsFallback: AI analysis did not complete successfully. Running all tests. |
| if (wasHandledByNewRouter) { | ||
| handled(); | ||
| return; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing handled callback in legacy deeplink flow
The handled() callback is only invoked when the new router processes the link, but not when falling back to the legacy system. Previously, handled() was called unconditionally after the modal check. Now when wasHandledByNewRouter returns false, the legacy switch-case executes without ever calling handled(), breaking the deeplink handling flow and preventing proper cleanup or state management that depends on this callback.



Description
Fixed critical bugs and test failures in the Universal Router feature flag integration introduced in the previous PR. The changes ensure proper fallback behavior to the legacy deep link handling system and correct TypeScript type compliance in tests.
Key Changes
Fixed delegateToLegacy behavior: Changed return value from
{ handled: true }to{ handled: false }to properly signal when the new router cannot handle a link, allowing the legacy system to process it.Corrected feature flag architecture: Moved feature flag checks from inside the
UniversalRouter.route()method to theUniversalRouterIntegration.processWithNewRouter()layer, ensuring proper system-level and action-level gating before router initialization.Fixed test expectations: Updated all test files to match the corrected behavior:
UniversalRouter.test.ts: Updated delegateToLegacy expectationsUniversalRouterIntegration.test.ts: Updated feature flag mock implementationsplatformNewLinkHandler.test.ts: Added missingcacheTimestampproperty to mock stateResolved linting issues: Fixed trailing spaces, missing semicolons, and namespace import warnings.
Why These Changes Were Needed
The original implementation had an architectural flaw where
delegateToLegacy()returnedhandled: trueeven though it didn't actually handle the link. This caused links to fail silently instead of falling back to the legacy system. Additionally, feature flag checks were performed at the wrong architectural layer, leading to incorrect fallback behavior when individual actions were disabled.Trade-offs
isNewHandlerEnabled()private method in favor of centralized feature flag checking in the integration layer, which is more architecturally sound but requires all feature flag logic to live in one place.toEqual()totoMatchObject()in some tests to allow for additional metadata fields, making tests slightly less strict but more maintainable.CHANGELOG entry
CHANGELOG entry: null
Related issues
https://consensyssoftware.atlassian.net/jira/polaris/projects/MWMR/ideas/view/8845676?selectedIssue=MWMR-10
Manual testing steps
Test Case 1: System flag disabled
Given the
platformNewLinkHandlerSystemflag isfalseWhen a deep link is opened (e.g.,
metamask://home)Then the legacy system processes the link successfully
Test Case 2: Action flag disabled
Given the
platformNewLinkHandlerSystemflag istrueAnd the
platformNewLinkHandlerActions.homeflag isfalseWhen a home deep link is opened (e.g.,
metamask://home)Then the legacy system processes the link successfully
Test Case 3: Both flags enabled
Given the
platformNewLinkHandlerSystemflag istrueAnd the
platformNewLinkHandlerActions.homeflag istrueWhen a home deep link is opened (e.g.,
metamask://home)Then the new Universal Router handles the link successfully
Screenshots/Recordings
N/A - Backend logic changes only, no UI changes.
Pre-merge author checklist
Pre-merge reviewer checklist
Suggested PR Title:
fix: correct Universal Router feature flag fallback behaviorBranch Name:
fix/universal-router-feature-flag-fixes(or with issue number if applicable)Labels to Add:
team-[your-team](required)bugfeature-flagNote
Routes deep links through the new Universal Router when system/action flags are enabled and correctly falls back to legacy when unhandled; adds selectors and updates tests.
UniversalRouterIntegrationintohandleUniversalLinkto attempt new routing first; callhandled()and return when successful.UniversalRouter.delegateToLegacyto return{ handled: false, metadata: { reason: 'no_handler' } }and remove legacy adapter usage.selectPlatformNewLinkHandlerSystemEnabledandselectPlatformNewLinkHandlerActionsunderselectors/featureFlagController/platformNewLinkHandler.UniversalRouterIntegrationto gate by system and per-action flags; normalize URL to determine action before routing; initialize and route viaUniversalRouter.UniversalRouter.test.tsexpectations tohandled: falsewithreason: 'no_handler'when unhandled/fallback.UniversalRouterIntegration.test.tsto mock new selectors and validate gated routing.platformNewLinkHandler.test.ts.Written by Cursor Bugbot for commit aac826e. This will update automatically on new commits. Configure here.