feat(predict): bPredict Bottom Sheet Errors PRED-836#29184
Conversation
|
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. |
AI PR Analysis🚫 Merge safe: false | 🟠 Risk: high
AI analysis did not complete. Manual review recommended. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #29184 +/- ##
==========================================
+ Coverage 82.19% 82.25% +0.06%
==========================================
Files 5069 5127 +58
Lines 133674 135748 +2074
Branches 29969 30572 +603
==========================================
+ Hits 109870 111663 +1793
- Misses 16334 16462 +128
- Partials 7470 7623 +153 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 a12ac9d. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
SmokePredictions: Directly required - the buy flow, error handling, retry mechanism, and order failure UX are all changed. The full position lifecycle (opening positions, error recovery) is affected. SmokeWalletPlatform: Required per tag description - Predictions is a section inside the Trending tab, so changes to Predictions views (PredictBuyWithAnyToken, PredictBuyPreview, PredictPreviewSheetContext) affect Trending. SmokeConfirmations: Required per SmokePredictions tag description - opening/closing positions are on-chain transactions requiring confirmations. Performance Test Selection: |
|
|
✅ E2E Fixture Validation — Schema is up to date |
christopherferreira9
left a comment
There was a problem hiding this comment.
Looks good for QA




Description
When the
predictBottomSheetfeature flag is ON, this PR moves Predict buy-flowerror reporting out of the legacy
PredictOrderRetrySheetoverlay and thegeneric background-failure toast and into inline banners rendered directly inside
the buy
BottomSheet. It also auto-reopens the buy sheet with the right bannerwhen an order fails after backgrounding (e.g. ETH deposit-then-place flow).
When the flag is OFF, behavior is unchanged: the legacy retry sheet still opens
for not-fully-filled errors, and the failure toast still fires for background
failures.
Two banner variants:
price_changed(warning) - triggered byPREDICT_BUY_ORDER_NOT_FULLY_FILLED.Title: "Price changed". Body: "Couldn't buy at {price}. Try at market price?".
order_failed(error) - generic order failure / network / timeout afterbackground processing. Title: "Order failed". Body: "Your order couldn't be
filled. Try again?".
Both variants swap the primary CTA to "Retry"; tapping Retry re-runs
placeOrderwithSLIPPAGE_BEST_AVAILABLE(matching the legacy retry-sheetbehaviour). On retry failure inside sheet mode the secondary
PredictOrderRetrySheetno longer stacks on top - the inline banner re-rendersin place.
Design: https://www.figma.com/design/gsBaqApTVELyFTNA70OwKg/Predict?m=dev&node-id=14938-29764
What changed
New component:
PredictBuyErrorBanner(app/components/UI/Predict/views/PredictBuyWithAnyToken/components/PredictBuyErrorBanner/) - styled inline banner withprice_changedandorder_failedvariants. Built withBox/Text/Iconfrom@metamask/design-system-react-nativeanduseTailwind().Modified:
usePredictBuyError- returns a newbuyErrorBannerobject alongsideerrorMessage; mapsorder_not_filledtoprice_changed(withformatCentsofpreview?.sharePrice ?? outcomeTokenPrice ?? 0so the body remains accurate even on auto-reopen whenpreviewis briefly null) and other failures toorder_failed. Also exposesclearBuyErrorBannerfor sheet-dismiss/amount-change clearing. Accepts anisSheetModeflag (defaults tofalse) that gates the new behaviour: in sheet modebuyErrorBanneris populated anderrorMessagesuppresses the active-order error string; in legacy (full-screen) modebuyErrorBanneris alwaysnulland the active-order error is surfaced viaerrorMessageinstead, preserving the pre-feature contract.usePredictOrderRetry- acceptsisSheetMode. In sheet mode it skips opening the legacyPredictOrderRetrySheetboth on the initialbecameNotFilledeffect AND in thehandleRetryWithBestPricecatchblock (the second guard prevents the secondary sheet from stacking on retry failure).PredictPreviewSheetContext- tracks provider-mount state and auto-reopens the buy sheet whenactiveOrder?.errorflips on while no buy sheet is mounted, so background failures resurface inside the sheet rather than as a toast.usePredictToastRegistrations- suppresses theorder/failedtoast when the flag is ON and the preview-sheet provider is mounted; the inline banner replaces it.PredictBuyActionButton- acceptsisRetry; swaps the label to "Retry" when an actionable banner is active.PredictBuyWithAnyToken- rendersPredictBuyErrorBannerbetween the fee summary and the action button; blurs the input/closes the keyboard when a banner becomes active in sheet mode so the Retry button is unobstructed; swaps the CTA label/handler when retry is required; passesoutcomeTokenPriceandisSheetModeintousePredictBuyErrorso the banner/error-message gating is centralized in the hook (no leak of banner-driven button state into legacy mode).PredictBuyPreview,Predict.testIds.ts,contexts/index.ts- small wiring updates.locales/languages/en.json- newpredict.order.price_changed_title,price_changed_body, andretrykeys; tightenedorder_failed_bodycopy.Tests:
PredictBuyErrorBanner.test.tsx,PredictPreviewSheetContext.test.tsx(auto-reopen), and added cases inusePredictBuyError.test.ts(banner variants, fallbacks, plus alegacy mode (isSheetMode: false)describe block asserting the legacy contract),usePredictOrderRetry.test.ts(sheet-mode effect + catch-block guards),usePredictToastRegistrations.test.tsx(toast suppression),PredictBuyActionButton.test.tsx(isRetrylabel),PredictBuyWithAnyToken.test.tsx(banner rendering + keyboard blur).yarn lint:tscis clean.Changelog
CHANGELOG entry: Added inline error banners in the Predict buy bottom sheet for price-changed and order-failed scenarios, replacing the secondary retry sheet and failure toast when the predictBottomSheet flag is enabled.
Related issues
Fixes:
JIRA Ticket: https://consensyssoftware.atlassian.net/browse/PRED-836?atlOrigin=eyJpIjoiZWM0M2E2YjZiOGJmNGMwOWFiZDMwNDBhM2UxMzc0OGUiLCJwIjoiaiJ9
Manual testing steps
Screenshots/Recordings
Before
After
errorScreen.mov
Pre-merge author checklist
Performance checks (if applicable)
trace()for usage andaddTokenfor an exampleFor performance guidelines and tooling, see the Performance Guide.
Pre-merge reviewer checklist
Note
Medium Risk
Changes Predict buy-order failure UX by auto-reopening the buy bottom sheet and moving errors from toasts/
PredictOrderRetrySheetinto inline banners with a retry CTA; regressions could hide errors or alter retry behavior. Flag-gated, but touches shared order/preview-sheet and toast-registration paths.Overview
When
predictBottomSheetis enabled, buy-flow failures are now surfaced inside the buy bottom sheet via new inline banners (price_changedandorder_failed) and the primary CTA switches to Retry (retries with best-available slippage). This suppresses the legacyPredictOrderRetrySheetoverlay in sheet mode and hides the background order failed toast when the sheet provider is mounted to avoid duplicate UI.The buy preview sheet provider now tracks mount state and can auto-reopen the buy sheet with the last buy params when
activeOrder.errorappears after the sheet was dismissed, and dismissing the buy sheet clears the active order error. Copy and testIDs were updated, and extensive tests were added/updated to cover banner rendering, retry behavior, toast suppression, and auto-reopen scenarios.Reviewed by Cursor Bugbot for commit 1cc328d. Bugbot is set up for automated code reviews on this repo. Configure here.