Skip to content

chore(runway): cherry-pick fix: start Ramps V2 init when remote feature flags hydrate cp-7.71.0#27807

Merged
chloeYue merged 1 commit into
release/7.71.0from
runway-cherry-pick-7.71.0-1774274380
Mar 23, 2026
Merged

chore(runway): cherry-pick fix: start Ramps V2 init when remote feature flags hydrate cp-7.71.0#27807
chloeYue merged 1 commit into
release/7.71.0from
runway-cherry-pick-7.71.0-1774274380

Conversation

@runway-github
Copy link
Copy Markdown
Contributor

@runway-github runway-github Bot commented Mar 23, 2026

Description

On a fresh install, RemoteFeatureFlagController loads flags
asynchronously while Engine builds controllers. rampsControllerInit
previously read the unified buy V2 flag only once; if flags were not in
state yet, RampsController.init() never ran, so buy token lists stayed
empty until a full app restart.

This change subscribes to RemoteFeatureFlagController:stateChange
(already delegated on RampsControllerInitMessenger) and re-runs the
same V2 startup path when remote flag state updates. Order-status
subscriptions are registered at most once. RampsController.init()
remains idempotent for repeated calls.

Changelog

CHANGELOG entry: null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3350

Manual testing steps

Feature: Unified buy V2 after fresh install

  Scenario: Buy token list loads without restarting the app
    Given a dev build with unified buy V2 enabled via remote flags
    And the app is installed fresh (or remote flag cache cleared)

    When the user completes onboarding and opens Buy / token selection
    Then tokens and providers load without requiring an app restart

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

Medium Risk
Adds a new subscription-driven initialization path triggered by
RemoteFeatureFlagController:stateChange, which can change startup
behavior and potentially cause repeated init/polling if underlying
idempotency assumptions are wrong.

Overview
Ensures Unified Buy V2 startup runs even when remote feature flags
hydrate after Engine/controller initialization by subscribing to
RemoteFeatureFlagController:stateChange and re-checking the V2 flag.

Refactors V2 startup into a helper that conditionally calls
RampsController.init()/startOrderPolling() and registers
order-status subscriptions only once. Updates tests to cover the “flag
off at startup then enabled on stateChange” scenario and to include
subscribe in the thrown-state mock.

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

[c6d96b6](https://github.com/MetaMask/metamask-mobile/commit/c6d96b6ff1e0efa6ad7172666f29e817a3e3ce9e)

…re flags hydrate cp-7.71.0 (#27778)

## **Description**

On a fresh install, `RemoteFeatureFlagController` loads flags
asynchronously while Engine builds controllers. `rampsControllerInit`
previously read the unified buy V2 flag only once; if flags were not in
state yet, `RampsController.init()` never ran, so buy token lists stayed
empty until a full app restart.

This change subscribes to `RemoteFeatureFlagController:stateChange`
(already delegated on `RampsControllerInitMessenger`) and re-runs the
same V2 startup path when remote flag state updates. Order-status
subscriptions are registered at most once. `RampsController.init()`
remains idempotent for repeated calls.

## **Changelog**

CHANGELOG entry: null

## **Related issues**

Fixes: https://consensyssoftware.atlassian.net/browse/TRAM-3350

## **Manual testing steps**

```gherkin
Feature: Unified buy V2 after fresh install

  Scenario: Buy token list loads without restarting the app
    Given a dev build with unified buy V2 enabled via remote flags
    And the app is installed fresh (or remote flag cache cleared)

    When the user completes onboarding and opens Buy / token selection
    Then tokens and providers load without requiring an app restart
```

## **Screenshots/Recordings**

<div>
<a href="https://www.loom.com/share/e80a3794612d4030aa963834e5a8d7bf">
<p>Fix Ramps controller not initializing on fresh install - Watch
Video</p>
    </a>
<a href="https://www.loom.com/share/e80a3794612d4030aa963834e5a8d7bf">
<img style="max-width:300px;"
src="https://cdn.loom.com/sessions/thumbnails/e80a3794612d4030aa963834e5a8d7bf-13202ae1a2494608-full-play.gif#t=0.1">
    </a>
  </div>

### **Before**

### **After**

## **Pre-merge author checklist**

- [x] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [x] I've completed the PR template to the best of my ability
- [x] I've included tests if applicable
- [x] I've documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [x] I've applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Adds a new subscription-driven initialization path triggered by
`RemoteFeatureFlagController:stateChange`, which can change startup
behavior and potentially cause repeated init/polling if underlying
idempotency assumptions are wrong.
> 
> **Overview**
> Ensures Unified Buy V2 startup runs even when remote feature flags
hydrate *after* Engine/controller initialization by subscribing to
`RemoteFeatureFlagController:stateChange` and re-checking the V2 flag.
> 
> Refactors V2 startup into a helper that conditionally calls
`RampsController.init()`/`startOrderPolling()` and registers
order-status subscriptions only once. Updates tests to cover the “flag
off at startup then enabled on stateChange” scenario and to include
`subscribe` in the thrown-state mock.
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
78ff800. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@runway-github runway-github Bot requested a review from a team as a code owner March 23, 2026 13:59
@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-bots Bot team (for MetaMask Bot, Runway Bot, etc.) label Mar 23, 2026
@github-actions github-actions Bot added size-S risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 23, 2026
@chloeYue chloeYue added the skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run label Mar 23, 2026
@github-actions github-actions Bot added risk-high Extensive testing required · High bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Mar 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

⏭️ Smart E2E selection skipped - skip-smart-e2e-selection label found

All E2E tests pre-selected.

View GitHub Actions results

@github-actions
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

@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

@chloeYue chloeYue left a comment

Choose a reason for hiding this comment

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

LGTM

@chloeYue chloeYue merged commit ddf4721 into release/7.71.0 Mar 23, 2026
174 of 180 checks passed
@chloeYue chloeYue deleted the runway-cherry-pick-7.71.0-1774274380 branch March 23, 2026 15:38
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 23, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

risk-high Extensive testing required · High bug introduction risk size-S skip-smart-e2e-selection Skip Smart E2E selection, i.e. select all E2E tests to run team-bots Bot team (for MetaMask Bot, Runway Bot, etc.)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants