Fix Sell Max showing entered fiat value in crypto field#6107
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
📸🩹 Test evidence — Sell Max fix (iOS sim)
sellmax crypto is max not fiat 🩹 HACK-FORCED: fixed window crypto not fiat 🩹 HACK-FORCED: BUGREPRO old ordering fiat in crypto Captured by the agent's in-app test run (build-and-test). |
b16284c to
26d6272
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ 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.
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.
26d6272 to
3b1202a
Compare




CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
none
Requirements
If you have made any visual changes to the GUI. Make sure you have:
Description
Fixes the Sell scene "Max" bug where the previously entered fiat amount was momentarily copied into the crypto field (e.g. entering
100USD, then tapping Max, showed100in the crypto field before the real max resolved).Root cause is in
handleMaxPressinRampCreateScene.tsx. On the sell path it flippedlastUsedInputto'crypto'before awaiting the async max calculation, whileamountQuerystill held the previously entered fiat value{ exchangeAmount: '100' }. During that async gapdisplayCryptoAmounttook itslastUsedInput === 'crypto'branch and returnedamountQuery.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):
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
getMaxSpendExchangeAmountwas still running.In
handleMaxPress, the sell path no longer setslastUsedInputto'crypto'before the async max completes. It sets the maxamountQueryfirst (maxExchangeAmountor{ max: true }for buy), then updateslastUsedInput, so display memos use the max branch instead of treating stale fiatexchangeAmountas 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.