metamask-mobile icon indicating copy to clipboard operation
metamask-mobile copied to clipboard

feat: import newremote feature flag controller with override functionality

Open asalsys opened this issue 3 months ago • 3 comments

Description

This PR adds comprehensive override functionality to the RemoteFeatureFlagController that was added in this PR, allowing developers and users to locally override remote feature flags for testing and debugging purposes. The implementation also includes enhanced A/B test visibility features that provide access to available test groups.

What is the reason for the change? The need to override remote feature flags locally for development, testing, and debugging scenarios without modifying the remote configuration.

What is the improvement/solution?

  • Added local override system that takes precedence over remote flags
  • Enhanced state management to track both remote flags and local overrides separately
  • Added A/B test raw flag storage to provide visibility into available test groups
  • Implemented comprehensive API methods for managing overrides and accessing flag information

Changelog

CHANGELOG entry: Added override functionality to remote feature flags with methods to set, get, clear overrides and access A/B test groups

Related issues

Fixes:

Manual testing steps

Feature: Remote Feature Flag Override Functionality

Scenario: user sets a local override for a feature flag Given the RemoteFeatureFlagController is initialized with remote flags When user calls setFlagOverride('testFlag', true) Then testFlag selector should return the override value true And getFlagOverride('testFlag') should return true

Scenario: user clears a specific flag override Given a feature flag has a local override set When user calls clearFlagOverride('testFlag') Then testFlag selector should return the original remote value And getFlagOverride('testFlag') should return undefined

Scenario: user accesses A/B test groups Given remote flags contain A/B test configurations When user calls rawProcessedRemoteFeatureFlags selector Then it should return an array of available test groups with names and values

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.

asalsys avatar Dec 01 '25 14:12 asalsys

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.

github-actions[bot] avatar Dec 01 '25 14:12 github-actions[bot]

The engine ready checks might not be necessary assuming this context is used in the right place. We already have a ControllersGate that blocks the majority of components from rendering before the engine is initialized. Can we rely on that instead?

Yes, correct, I don't think it is necessary at all. I had that logic because I was having trouble getting it to start I thought the issue was that the controller wasn't loading but it was because the controller was broken and wasn't building

asalsys avatar Dec 03 '25 22:12 asalsys

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​metamask/​remote-feature-flag-controller@​3.0.0 ⏵ 3.1.010010076 +196 +1100

View full report

socket-security[bot] avatar Dec 17 '25 14:12 socket-security[bot]

Codecov Report

:x: Patch coverage is 77.41935% with 14 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 79.31%. Comparing base (80b13d3) to head (236faec). :warning: Report is 39 commits behind head on main.

Files with missing lines Patch % Lines
.../Views/FeatureFlagOverride/FeatureFlagOverride.tsx 50.00% 12 Missing and 2 partials :warning:
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #23487      +/-   ##
==========================================
+ Coverage   79.11%   79.31%   +0.19%     
==========================================
  Files        4053     4057       +4     
  Lines      106578   106769     +191     
  Branches    21592    21642      +50     
==========================================
+ Hits        84321    84679     +358     
+ Misses      16379    16192     -187     
- Partials     5878     5898      +20     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

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

codecov-commenter avatar Dec 19 '25 16:12 codecov-commenter

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeCore, SmokeAccounts, SmokeConfirmationsRedesigned, SmokeNetworkExpansion, SmokeTrade, SmokeWalletPlatform, SmokeWalletUX, SmokeAssets, SmokeSwaps, SmokeStake, SmokeRamps, SmokeMultiChainPermissions, SmokePerps, SmokePredictions
  • Risk Level: high
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

This PR makes significant changes to the core feature flag system which is used throughout the entire application:

  1. Package Update: The @metamask/remote-feature-flag-controller is upgraded from v3.0.0 to v3.1.0, introducing new controller methods for managing local overrides.

  2. Core Selector Changes: The selectRemoteFeatureFlags selector is modified to merge remote flags with local overrides. This selector is used in 50+ places across the codebase including:

    • Perps feature flags
    • Predictions feature flags
    • Carousel feature flags
    • Earn/Staking feature flags
    • Bridge configuration
    • Notifications
    • Network blacklist
    • Solana testnet
    • Gas fees sponsored
    • OTA updates
    • Homepage
    • Token search discovery
    • DeFi positions
    • Confirmations redesign
    • Multichain accounts
  3. State Structure Changes: The RemoteFeatureFlagController state now includes localOverrides and rawRemoteFeatureFlags fields, which affects the initial background state used in tests.

  4. Context API Changes: The FeatureFlagOverrideContext now delegates override management to the Engine's controller instead of local React state, which is a fundamental architectural change.

  5. New Feature Flag Types: Added support for A/B test feature flags (FeatureFlagAbTest) which could affect how features are rolled out.

Given that feature flags control the behavior of virtually every major feature in the app, and this change modifies the core mechanism for how flags are retrieved and overridden, comprehensive testing is warranted. The changes could potentially affect any feature that relies on feature flags, which includes confirmations, staking, swaps, bridge, multichain accounts, and more.

View GitHub Actions results

github-actions[bot] avatar Dec 19 '25 20:12 github-actions[bot]