Conversation
When the user changes a quote parameter (e.g. swaps the buy token) after a previous quote returned an error such as 'insufficient liquidity', the old error remained displayed until the next quote response. The form showed a stale error for an unrelated token pair while loading. Clear `error` in `setLoading` whenever `hasParamsChanged` is true so the form transitions cleanly into loading state for the new params. Fixes cowprotocol#7438
|
@tenderdeve is attempting to deploy a commit to the cow-dev Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough
ChangesTrade Quote Error Reset
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Cloudflare Pages preview mirror Preview branch URL: https://github.com/cowprotocol/cowswap/tree/cf-preview/pr-7728 Source fork branch:
|
Clearing the error on every params change made smart slippage recompute (it returns null while an error is shown), which flipped the quote params back and re-triggered the loading branch — flickering the form between the error and loading states. Restrict the error clear to genuine trade-subject changes (token pair, amount or order kind) and ignore slippage-only param changes, so the stale error is still dropped on token switch without the flicker. Addresses @elena-zh's review feedback.
|
@elena-zh updated in a51ef4c — fixed the flicker. The blink came from clearing the error on every params change: while an error is shown smart slippage returns |
Guards the flicker regression: a slippage-only params change must keep the existing error (clearing it would let smart slippage recompute and loop), while a token-pair or amount change clears the stale error.
Closes #7438
Problem
After a quote returns an error (e.g. insufficient liquidity), switching to a different token keeps the old error visible until the next quote response arrives. The form briefly shows an error that no longer applies to the current pair.
Repro:
0x583019fF0f430721aDa9cfb4fac8F06cA104d0B4→ "insufficient liquidity"Cause
useTradeQuoteManager.setLoadingflipsisLoadingandhasParamsChangedbut leaves the previouserrorin state. The form keeps rendering the stale error while the new quote is fetched.Fix
When
hasParamsChangedis true, clearerrorinsetLoading. Same-param polling refreshes are untouched, so transient error flicker during a normal refresh is not affected.Testing
Summary by CodeRabbit