Skip to content

Fix Sell Max showing entered fiat value in crypto field#6107

Open
j0ntz wants to merge 1 commit into
developfrom
jon/sell-max-value-switch
Open

Fix Sell Max showing entered fiat value in crypto field#6107
j0ntz wants to merge 1 commit into
developfrom
jon/sell-max-value-switch

Conversation

@j0ntz

@j0ntz j0ntz commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Requirements

If you have made any visual changes to the GUI. Make sure you have:

  • Tested on iOS device
  • Tested on Android device
  • Tested on small-screen device (iPod Touch)
  • Tested on large-screen device (tablet)

Description

Fixes the Sell scene "Max" bug where the previously entered fiat amount was momentarily copied into the crypto field (e.g. entering 100 USD, then tapping Max, showed 100 in the crypto field before the real max resolved).

Root cause is in handleMaxPress in RampCreateScene.tsx. On the sell path it flipped lastUsedInput to 'crypto' before awaiting the async max calculation, while amountQuery still held the previously entered fiat value { exchangeAmount: '100' }. During that async gap displayCryptoAmount took its lastUsedInput === 'crypto' branch and returned amountQuery.exchangeAmount (the fiat number), so the crypto field rendered the fiat value. On large wallets the max calculation (getMaxSpendable) is slow, so the wrong value lingered and routing stalled.

The fix sets the max amount query before flipping the input type (and no longer flips it before the await), so the display memos take their max branch immediately and the crypto field only ever shows the computed max. Buy is unchanged (its branch has no await, so its state updates already batch).

Asana: https://app.asana.com/0/1215088146871429/1215965639107175

Testing (iOS sim, edge-funds, My Ether 4 / ETH, Sell scene):

  • Entered a fiat amount, tapped Max: the crypto field shows the wallet's max spendable amount, not the fiat value.
  • Hack-verified the transient by temporarily widening the async window: with the fix, during the window the crypto field shows the converted value (not the entered fiat number); reverting to the old ordering under the same widened window reproduces the fiat-in-crypto flash. All temporary edits reverted; working tree clean.

Note

Low Risk
Localized ramp UI state ordering and async cancellation in RampCreateScene; no auth, payments, or shared API contract changes.

Overview
Fixes a Sell scene bug where tapping Max briefly showed the previously entered fiat value in the crypto field while getMaxSpendExchangeAmount was still running.

In handleMaxPress, the sell path no longer sets lastUsedInput to 'crypto' before the async max completes. It sets the max amountQuery first (maxExchangeAmount or { max: true } for buy), then updates lastUsedInput, so display memos use the max branch instead of treating stale fiat exchangeAmount as crypto.

Adds maxRequestIdRef: increments on Max, crypto wallet change (sell), and fiat dropdown open—stale in-flight max results are ignored after wallet/fiat switches or a superseded Max tap.

CHANGELOG updated for the fix.

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

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@j0ntz

j0ntz commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

📸🩹 Test evidence — Sell Max fix (iOS sim)

🩹 Some screenshots below are HACK-FORCED. The marked frames show a state forced by a temporary uncommitted local edit (the natural trigger could not be reproduced on the sim). The hack is not in this PR's diff; the pixels prove the rendering, not the trigger.

sellmax crypto is max not fiat

sellmax crypto is max not fiat

🩹 HACK-FORCED: fixed window crypto not fiat

🩹 HACK-FORCED: fixed window crypto not fiat

🩹 HACK-FORCED: BUGREPRO old ordering fiat in crypto

🩹 HACK-FORCED: BUGREPRO old ordering fiat in crypto

Captured by the agent's in-app test run (build-and-test).

Comment thread src/components/scenes/RampCreateScene.tsx
@j0ntz
j0ntz force-pushed the jon/sell-max-value-switch branch from b16284c to 26d6272 Compare July 24, 2026 22:17

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 26d6272. Configure here.

Comment thread src/components/scenes/RampCreateScene.tsx
Tapping Max on the Sell scene flipped lastUsedInput to 'crypto' before the
async max calculation finished, while amountQuery still held the previously
entered fiat amount. displayCryptoAmount then rendered that fiat value in the
crypto field (e.g. 100 USD shown as 100 BTC) until the max resolved. Set the
max amount query before flipping the input type so the display always shows the
computed max.
@j0ntz
j0ntz force-pushed the jon/sell-max-value-switch branch from 26d6272 to 3b1202a Compare July 24, 2026 22:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant