Skip to content

feat: QuickBuy stay-on-screen swap lifecycle toasts#31073

Merged
xavier-brochard merged 5 commits into
mainfrom
feat/quickbuy-swap-lifecycle-toasts
Jun 4, 2026
Merged

feat: QuickBuy stay-on-screen swap lifecycle toasts#31073
xavier-brochard merged 5 commits into
mainfrom
feat/quickbuy-swap-lifecycle-toasts

Conversation

@xavier-brochard

@xavier-brochard xavier-brochard commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description

Screen.Recording.2026-06-04.at.14.34.49.mov

Previously, submitting a QuickBuy transaction redirected the user to the Activity view. This change keeps the user on the screen where QuickBuy was triggered (e.g. token details) so they get feedback in context and can watch their balance update.

What changed:

  1. Press Buy → close immediately, submit in the background. The bottom sheet now closes the instant the CTA is pressed, and the content drops with the sheet instead of sliding horizontally on exit (isClosing gates the screen-exit transition).
  2. Swap lifecycle toasts (pending / complete / failed). BridgeStatusController.submitTx resolves when the source tx is submitted, not when the swap settles — for cross-chain bridges the destination leg can take minutes. So toasts reflect the real lifecycle, driven by BridgeStatusController status, not submit success.
  3. Global, navigation-proof watcher. Swap/bridge txs aren't covered by any existing global notification (NotificationManager only watches redesigned tx types, which exclude swap/bridge). The terminal complete/failed toast is fired from the app-root ControllerEventToastBridge via a new useQuickBuyToastRegistrations hook, so it shows even after the user navigates away. A small in-memory quickBuyTradeTracker scopes the handler to QuickBuy-initiated trades and carries the copy data (token pair, amount, rate).
  4. Design + copy. Toasts match the Swap design: an action title line plus the exchange-rate quote as a description, with mode-aware copy (Buying/Selling, Bought/Sold) and a close button.

Architecture note: everything stays within **/SocialLeaderboard/** (social-ai) by importing existing controllers/selectors, except a ~5-line wiring change in App.tsx/App.test.tsx (mobile-platform CODEOWNERS), matching the existing Predict/Perps toast-registration precedent.

Changelog

CHANGELOG entry: QuickBuy now stays on the current screen after you tap Buy and shows pending, complete, and failed swap toasts (including for slow cross-chain swaps).

Related issues

Fixes:

Manual testing steps

Feature: QuickBuy stay-on-screen swap toasts

  Scenario: user buys a token via QuickBuy
    Given the user opened QuickBuy from a token/trader screen
    And entered a valid amount with an available quote

    When the user taps the Buy CTA
    Then the bottom sheet closes immediately without sliding horizontally
    And a "Buying $X of <TOKEN> with <PAY>" toast appears on the current screen
    And a "Bought $X of <TOKEN> with <PAY>" toast appears once the swap settles

  Scenario: user navigates away before a cross-chain swap settles
    Given the user submitted a cross-chain QuickBuy
    When the user navigates to another screen
    Then the complete/failed toast still appears when the swap settles

  Scenario: submission is rejected
    Given the user submitted a QuickBuy
    When submission throws (e.g. user rejection)
    Then a "Couldn't buy/sell <TOKEN>" toast appears

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.

Made with Cursor


Note

Medium Risk
Changes bridge submit UX, global toast wiring in App.tsx, and swap status handling; mistakes could miss terminal toasts or double-fire notifications, but scope is limited to QuickBuy-tracked trades with tests.

Overview
QuickBuy no longer navigates to Activity after submit. Tapping Buy closes the sheet immediately, shows a pending toast on the current screen, and runs BridgeStatusController.submitTx in the background.

Swap lifecycle toasts use a shared builder (buildQuickBuyToastOptions) plus an in-memory quickBuyTradeTracker keyed by tx meta id. Complete / failed outcomes are driven by BridgeStatusController status via resolveQuickBuyTerminalToast, wired at app root through useQuickBuyToastRegistrations on ControllerEventToastBridge so toasts still appear after navigation or sheet unmount. Submit failures before publish show failed immediately; fast settlements are reconciled right after tracking.

UX polish: QuickBuyRoot uses requestClose / isClosing to animate the sheet down and skip horizontal screen-exit animation. Slider commits bump immediateFetchToken so quotes fetch without the typing debounce. New i18n strings for buy/sell toast copy.

Tests cover close behavior, toast registration, tracker, terminal resolve, controller confirm flow, and immediate quote fetch.

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

Pressing Buy now closes the QuickBuy sheet immediately (no horizontal
slide on exit) and submits in the background. Swap lifecycle toasts
(pending / complete / failed) fire globally via the app-root
ControllerEventToastBridge, so they surface even after the user
navigates away from the trigger screen — important for slow cross-chain
swaps. Terminal state is driven by BridgeStatusController status.

Toasts follow the Swap design: action title line plus the exchange-rate
quote as a description, with mode-aware copy (buy/sell).

Co-authored-by: Cursor <cursoragent@cursor.com>
@github-actions

github-actions Bot commented Jun 4, 2026

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.

@mm-token-exchange-service mm-token-exchange-service Bot added the team-social-ai Social & AI team label Jun 4, 2026
@github-actions github-actions Bot added the size-L label Jun 4, 2026
* App-root registration that surfaces QuickBuy swap outcomes as toasts.
*
* Mounted via `ControllerEventToastBridge` in `App.tsx`, so it outlives the
* QuickBuy bottom sheet and the trigger screen — the `complete` / `failed`

@xavier-brochard xavier-brochard Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's very important! We want to show the toasts even when the QuickBuy component is unmounted (user has navigated somewhere else in the app)

xavier-brochard and others added 3 commits June 4, 2026 14:53
This update introduces haptic feedback for QuickBuy interactions, enhancing user experience during trade confirmations. The `playImpact` function is triggered on pending trades, while `playSuccessNotification` and `playErrorNotification` are invoked based on the outcome of the transactions. Tests have been added to ensure the correct haptic responses are executed during various QuickBuy states.

Co-authored-by: Cursor <cursoragent@cursor.com>
This update introduces an `immediateFetchToken` mechanism in the QuickBuy component, allowing for immediate quote fetching when the user commits an amount via slider release, bypassing the typing debounce. The changes include new tests to ensure that quotes are fetched correctly under various scenarios, such as when the immediate fetch token increments or remains unchanged. This enhancement improves the responsiveness of the QuickBuy feature during user interactions.

Co-authored-by: Cursor <cursoragent@cursor.com>
This update modifies the QuickBuy toast options to include a transparent background color for both success and error toast notifications. This change enhances the visual consistency of the toast messages within the QuickBuy component, ensuring they blend seamlessly with the app's UI.

Co-authored-by: Cursor <cursoragent@cursor.com>
@xavier-brochard xavier-brochard marked this pull request as ready for review June 4, 2026 13:11

@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 9e39c20. Configure here.

@github-actions github-actions Bot added the risk:medium AI analysis: medium risk label Jun 4, 2026
…ations

This update introduces the `resolveQuickBuyTerminalToast` function, which reconciles tracked QuickBuy trades against the BridgeStatusController's history. It displays appropriate toast notifications for completed or failed trades, providing haptic feedback and ensuring trades are untracked after notification. Additionally, tests have been added to verify the functionality across various trade states, enhancing user experience during QuickBuy interactions.

Co-authored-by: Cursor <cursoragent@cursor.com>
@xavier-brochard xavier-brochard enabled auto-merge June 4, 2026 13:24
@github-actions github-actions Bot added size-XL and removed size-L labels Jun 4, 2026
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes are focused on the SocialLeaderboard QuickBuy feature, specifically refactoring the post-swap UX from navigation-based to toast-based feedback. Key impacts:

  1. App.tsx change (most impactful): Registers useQuickBuyToastRegistrations at the app root alongside existing Perps and Predict toast registrations. This modifies the global toastRegistrations array used by ControllerEventToastBridge. Any regression here could affect toast display for Perps withdrawals and Predictions flows — hence SmokePerps and SmokePredictions are included.

  2. QuickBuy swap flow: The controller now uses BridgeStatusController for swap lifecycle tracking and shows pending/complete/failed toasts. This is a swap/bridge flow, so SmokeSwap and SmokeConfirmations are relevant to verify the bridge/swap infrastructure still works correctly.

  3. SmokeWalletPlatform: The SocialLeaderboard is accessed via the Trending tab, which is covered by SmokeWalletPlatform. The QuickBuy feature is embedded in the TraderPositionView within Trending.

  4. No direct E2E tests for QuickBuy exist, so we rely on related smoke tests to catch regressions in the shared infrastructure (toast system, BridgeStatusController, swap flows).

The changes are well-contained within the QuickBuy feature with the exception of the App.tsx toast registration change, which has broader potential impact on the global toast system.

Performance Test Selection:
The changes are focused on UX improvements to the QuickBuy flow (toast notifications instead of navigation, animation improvements, immediate quote fetching on slider release). While there are minor optimizations (debounce cancellation for slider release), these are not expected to have measurable performance impact on the metrics tracked by performance tests (account list rendering, onboarding, login, swaps, app launch, asset loading). The App.tsx change adds one more hook to the toast registration array, which is negligible. No performance tests are warranted.

View GitHub Actions results

@xavier-brochard xavier-brochard added this pull request to the merge queue Jun 4, 2026
Merged via the queue into main with commit e409fee Jun 4, 2026
305 of 308 checks passed
@xavier-brochard xavier-brochard deleted the feat/quickbuy-swap-lifecycle-toasts branch June 4, 2026 14:38
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 4, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.81.0 Issue or pull request that will be included in release 7.81.0 label Jun 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.81.0 Issue or pull request that will be included in release 7.81.0 risk:medium AI analysis: medium risk size-XL team-social-ai Social & AI team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants