Skip to content

fix(bridge): show swap quote skeleton during refetch#29975

Merged
bfullam merged 4 commits into
mainfrom
swaps-fix-slippage-quote-fetch-flakiness
May 12, 2026
Merged

fix(bridge): show swap quote skeleton during refetch#29975
bfullam merged 4 commits into
mainfrom
swaps-fix-slippage-quote-fetch-flakiness

Conversation

@bfullam

@bfullam bfullam commented May 11, 2026

Copy link
Copy Markdown
Contributor

Description

Fixes a swap display gap during slippage-triggered quote refetches. When the BridgeController temporarily clears activeQuote before the next quote is available, BridgeView could fall through to quote mode even though QuoteDetailsCard and BridgeViewFooter had nothing usable to render. That produced the blank state seen in the ticket: no footer and no loading skeleton.

This keeps needsNewQuote scoped to its original expired-quote retry purpose, and moves the transient empty-quote handling into BridgeView content mode selection. For a non-zero input with no active quote, no retry state, and no terminal quote error/no-quotes state, the view now renders the existing quote skeleton until a refreshed quote is available. That keeps the loading state visible without adding hook-level quote history or reusing quote state across token pair changes.

The swap action smoke test custom slippage path and matching analytics expectation are restored now that the slippage refetch gap has a visible loading state.

Changelog

CHANGELOG entry: Fixed a bug that could leave the swap quote area blank during slippage refresh

Related issues

Fixes: #29615

Manual testing steps

Feature: Swap quote refetch loading state

  Background:
    Given I am logged into MetaMask Mobile
    And I am on the Wallet screen with enough ETH to swap

  Scenario: user updates custom slippage while a swap quote refetches
    Given I start a swap from ETH to USDC on Ethereum
    And a swap quote has loaded

    When user opens slippage settings
    And user enters custom slippage of "3.5"
    And the quote refetch starts
    Then the quote area should show a loading skeleton while the refreshed quote is unavailable
    And the quote area should not become blank
    And when the quote resolves, the quote details and submit action should be visible

Screenshots/Recordings

Before

N/A

After

N/A

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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
Tweaks swap/bridge UI state selection during quote refetches, which can affect whether users see actionable quote/confirm UI vs a loading skeleton. Also re-enables custom slippage in smoke tests, so failures could block CI if the new loading-state assumptions are wrong.

Overview
Prevents a blank swap/bridge quote area during slippage-triggered refetches by treating the transient state of sourceAmount > 0 with no activeQuote (and no terminal error/no-quotes state) as loading, showing the existing quote skeleton until a refreshed quote arrives.

Keeps needsNewQuote focused on expired-quote retry behavior in useBridgeQuoteData, and adds/updates tests to cover the non-zero/no-active-quote loading case.

Restores the swap action smoke test custom slippage path and updates analytics expectations to require the slippage INPUT_CHANGED event (and the total count) again.

Reviewed by Cursor Bugbot for commit a8f917d. Bugbot is set up for automated code reviews on this repo. Configure here.

@bfullam bfullam requested a review from a team as a code owner May 11, 2026 13:02
@github-actions github-actions Bot added the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label May 11, 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.

@metamaskbotv2 metamaskbotv2 Bot added the team-swaps-and-bridge Swaps and Bridge team label May 11, 2026
@bfullam bfullam removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label May 11, 2026
@bfullam bfullam changed the title Fix bridge quote refetch state during swap slippage flow fix(bridge): keep swap footer visible during quote refetch May 11, 2026
Comment thread app/components/UI/Bridge/hooks/useBridgeQuoteData/index.ts Outdated

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

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.

Reviewed by Cursor Bugbot for commit 01a4e88. Configure here.

Comment thread app/components/UI/Bridge/hooks/useBridgeQuoteData/index.ts Outdated
@bfullam bfullam changed the title fix(bridge): keep swap footer visible during quote refetch fix(bridge): show swap quote skeleton during refetch May 11, 2026
@github-actions github-actions Bot added size-S and removed size-M labels May 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeSwap, SmokeConfirmations
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 92%
click to see 🤖 AI reasoning details

E2E Test Selection:
The changes in this PR are focused on two areas:

  1. Swap E2E test fix (re-enabling slippage): tests/smoke/swap/swap-action-smoke.spec.ts re-enables the custom slippage (3.5) that was previously commented out due to bug [Bug]: Swap Footer disappears during slippage-triggered re-fetch #29615. The corresponding analytics expectations in tests/helpers/analytics/expectations/swap-action.analytics.ts are updated to expect 12 INPUT_CHANGED events (up from 11) and to validate the slippage input is present. This directly affects SmokeSwap tests.

  2. BridgeView loading state fix: app/components/UI/Bridge/Views/BridgeView/index.tsx fixes the getContentMode() logic to properly show a loading skeleton when there's no active quote yet (instead of jumping to quote mode). The condition now checks for absence of activeQuote, needsNewQuote, quoteFetchError, and isNoQuotesAvailable before returning 'loading'. This is a UI bug fix for the bridge/swap flow.

  3. Unit test addition: BridgeView.test.tsx adds a test for the new loading skeleton behavior.

  4. Comment-only change: useBridgeQuoteData/index.ts only updates a comment with no logic change.

Tag selection rationale:

  • SmokeSwap: Directly affected - the swap smoke test is modified to re-enable slippage, and the BridgeView (used in swap/bridge flows) has a UI fix.
  • SmokeConfirmations: Required per SmokeSwap tag description - "When selecting SmokeSwap, also select SmokeConfirmations (transaction confirmations are part of the flow)."

No other tags are warranted as the changes are scoped to swap/bridge functionality.

Performance Test Selection:
The changes are a UI bug fix for loading state display in BridgeView and a test re-enablement for slippage. The BridgeView logic change is a conditional rendering fix (not a performance-impacting change like list rendering, data loading, or initialization). No performance-sensitive code paths are modified.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@bfullam bfullam added this pull request to the merge queue May 12, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 12, 2026
@bfullam bfullam added this pull request to the merge queue May 12, 2026
Merged via the queue into main with commit bf7ad8e May 12, 2026
104 checks passed
@bfullam bfullam deleted the swaps-fix-slippage-quote-fetch-flakiness branch May 12, 2026 13:08
@github-actions github-actions Bot locked and limited conversation to collaborators May 12, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.78.0 Issue or pull request that will be included in release 7.78.0 label May 12, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.78.0 Issue or pull request that will be included in release 7.78.0 size-S team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Swap Footer disappears during slippage-triggered re-fetch

2 participants