fix(predict): improve crypto up/down cp-7.79.0#30662
Conversation
- Gate PredictCryptoUpDownMarketCard with predictUpDownEnabled flag (matches details page) - Show 'Resets every X' as natural language (1 day, 4 hours, 2 weeks) - Format TimeSlotPicker daily countdown as H:MM:SS instead of MM:SS - Scale chart bottom padding responsively to handle different chart heights + font scales - Decouple current price callback from chart loading; show Skeleton for Price to beat / Current price until first tick arrives - Stabilize seriesMarkets cache to prevent layout shift on time-slot switch
Each `usePredictSeries` refetch produces fresh market object references via `attachSeriesToMarket` spreading. With the prior naive memo, this cascaded through outcome/token refs and — when the resolver briefly picked a different market on a refresh — pushed brand-new tokenIds into the live-price hook, clearing its Map and flashing the Up/Down buttons to `token.price` defaults (~0.51/0.49) for ~1s every few seconds. Return the previous resolved market when its id matches the candidate so downstream identity stays stable; advance only on a real market id change.
|
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. |
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 de7a59c. Configure here.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #30662 +/- ##
==========================================
- Coverage 82.34% 82.34% -0.01%
==========================================
Files 5513 5545 +32
Lines 148432 149577 +1145
Branches 34145 34505 +360
==========================================
+ Hits 122231 123173 +942
- Misses 17913 18029 +116
- Partials 8288 8375 +87 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…ements # Conflicts: # app/components/UI/Predict/components/PredictCryptoUpDownMarketCard/PredictCryptoUpDownMarketCard.tsx # app/components/UI/Predict/components/PredictMarket/PredictMarket.tsx
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Tag selection rationale:
The changes are medium risk - they refactor core prediction market logic (price resolution, chart data, live price caching) but are well-contained within the Predict feature module. The price precedence fix (sell→buy) and target price resolution changes could affect market display and betting flows. Performance Test Selection: |
|




Description
Improves the crypto up/down market experience on the feed series card and market details screen.
These changes are scoped to the existing crypto up/down work behind the Predict up/down feature flag. They improve release quality for the upcoming crypto up/down experience, where the current UX is unstable for users, with minimal regression risk outside the gated feature.
This PR fixes several visible stability issues:
bestAsk→ RESTentry.buy→ static market token price.priceToBeatmetadata as the target-line fallback for hourly/daily crypto up/down markets whose target price API can be unavailable.priceToBeatmetadata.Changelog
CHANGELOG entry: null
Related issues
Fixes: N/A
Manual testing steps
Screenshots/Recordings
Before
N/A
After
N/A
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
Touches live pricing, chart anchoring, and controller fallbacks across Predict crypto up/down flows, but scope is largely behind the up/down feature flag with broad test coverage.
Overview
This PR tightens the gated crypto up/down Predict experience (feed card, details, and routing) so prices, charts, and target lines stay stable during live updates and time-slot changes.
Pricing & live data: Buy CTAs now share
getPredictBuyPrice(livebestAsk→ RESTentry.buy→ token price).useLiveMarketPricescaches recent updates so remounts do not flash stale REST/static prices. Chart loading stays active until at least two renderable points exist; current price can still propagate while loading.Details screen: The chart stays on the live series market while the picker only changes the selected slot (target line, Up/Down actions, share). Series markets are held in a ref during refetch so positions/chart height do not jump. Target/current summaries use
resolveCryptoTargetPricewith skeletons when appropriate; chart bottom padding scales with height and font scale.Target price & Polymarket: Event
priceToBeatis parsed onto markets;PredictControllerand UI fall back through fetched price → event metadata →groupItemThreshold. Hourly recurrence is supported in duration helpers.UX polish: Longer countdowns use
H:MM:SSwhen ≥1 hour; reset copy uses readable hour/day/week strings. Up/down feed cards requireselectPredictUpDownEnabledFlagin addition toisCryptoUpDown.Reviewed by Cursor Bugbot for commit 31cc179. Bugbot is set up for automated code reviews on this repo. Configure here.