feat(predict): support series ids in predictMarketHighlights cp-7.81.0#31044
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. |
| query?: string; | ||
| refresh?: RefreshConfig; | ||
| enabled?: boolean; | ||
| excludeSeriesHighlights?: boolean; |
There was a problem hiding this comment.
Is there a reason for excluding the highlights from the Explore page? My guess is that you're doing it because we don't have a compact version of those cards that looks good in the Explore page. But if that's the case, we should fix that rather than hide it. These markets bring a lot of value, so we probably want them front and center across the app.
There was a problem hiding this comment.
The crypto up/down series card is taller than the other cards, which is fine in a vertical feed but not the horizontal feed. Excluding it from the trending view would allow us to release it in the PredictView feeds now
Extends the predictMarketHighlights remote feature flag to accept series ids alongside market ids. A series-id highlight resolves at request time to its currently-live market via findLiveMarket (with findNearestMarket as fallback), so the pin stays fresh as time slots roll over for recurring crypto up/down markets. Schema is additive: markets is relaxed to optional, series?: string[] is new. Existing flag values keep working unchanged. Market-id highlights are prepended before series-resolved highlights, and dedup spans both paths. Per-series fetch failures are caught locally so one bad entry can't take down a healthy batch. getMarketsByIds keeps its existing fail-hard contract, now covered by an explicit test.
Series-resolved crypto up/down highlights now render in the Explore TrendingView carousels via a compact variant of `PredictCryptoUpDownMarketCard`, rather than being opted out per surface. This replaces the prior `excludeSeriesHighlights` plumbing (dropped from this branch) with a proper carousel-sized render keyed off the existing `isCarousel` prop that `PredictMarket` already forwards to its sibling cards. The compact variant: - Drops the sparkline and the target-line / target-price label treatment - Uses `height: 100%` + flex-column + `justifyContent: space-between`, mirroring `PredictMarketSingle` / `PredictMarketMultiple`, so the card sits flush with its neighbours in `HorizontalCarousel` - Gates `useCryptoUpDownChartData` and `useCryptoTargetPrice` with `enabled: !isCompact` to skip the historical fetch and live websocket subscription that the dropped chart would have consumed `LiveStatus` and `OutcomeButtons` now accept a discriminated `compact` union: in compact mode they render positionless flex content; in full mode they keep the existing absolute-positioned layout. The full-mode render path is unchanged. Test coverage: 4 new tests cover sparkline-not-rendered, both chart queries disabled, the compact skeleton (no chart placeholder), and that the buy sheet still opens. One existing assertion is updated for the new `enabled: true` option now passed to `useCryptoUpDownChartData` in the full path.
77b1630 to
97ef710
Compare
Drops the `FULL_CARD_HEIGHT` / `FULL_PROGRESS_LOGO_TOP` / `FULL_LIVE_BADGE_TOP` / `FULL_TITLE_TOP` / `FULL_OUTCOME_BUTTONS_TOP` constants and the `progressLogoTop` / `liveBadgeTop` / `top` props that plumbed them into `LiveStatus` and `OutcomeButtons`. Those constants only existed because the previous commit lifted them out of a now-gone `CARD_LAYOUT.compact` struct; the full-mode JSX used to carry these values inline as Tailwind arbitrary values (`h-[319px]`, `top-[112px]`, `top-[171px]`, `top-[197px]`, `top-[235px]`) and now does so again. No behavior change — `LiveStatus` and `OutcomeButtons` keep their `compact?: boolean` discriminator for the compact / full branch, just without the extra magic-number plumbing.
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 108a22c. Configure here.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #31044 +/- ##
==========================================
+ Coverage 82.86% 82.99% +0.13%
==========================================
Files 5582 5605 +23
Lines 144198 144394 +196
Branches 33521 33550 +29
==========================================
+ Hits 119483 119845 +362
+ Misses 16682 16482 -200
- Partials 8033 8067 +34 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
- Drop the flex gap between the LIVE badge and the market title (was `gap-2` → now 0; the badge and title now sit flush with only their natural text leading between them) - Tighten the bottom-group gap between the Up/Down buttons and the "Resets every …" footer from `gap-3` (12px) to `gap-2` (8px) Top/bottom padding (`p-4`, 16px) and the flex-driven space between the title and the buttons row (`justify-between`) are unchanged.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Tag selection:
Performance Test Selection: |

Description
Extends the
predictMarketHighlightsremote feature flag to accept series IDs in addition to market IDs, and renders series-resolved crypto up/down highlights in horizontally-scrolling carousels via a new compact card variant.Why
Recurring crypto up/down markets (e.g. "BTC Up or Down — 5 Minutes") expose a new market every N minutes. A market-ID pin in
predictMarketHighlightstherefore goes stale within a single time slot — once the market resolves, the pin disappears, and there is no way to express "always pin the currently-live BTC Up/Down 5m market." Resolving from a series at request time fixes this: the pin automatically rotates to whatever slot is live when the feed is fetched.Schema change (additive, backward compatible)
marketscontinue to work unchanged. Both fields are now optional; entries with neither are skipped.getMarketsByIds(markets)andgetMarketSeries(seriesId)in parallel viaPromise.all, then resolves each series response to its currently-live market via the existingfindLiveMarket()(withfindNearestMarket()as a fallback when no future market is in the fetch window).status === 'open'filter and are marked withisHighlighted: true, identical to the market-ID path.marketskeep their original ordering. Dedupe is unified across both paths so a market reachable via bothmarketsandseriesappears exactly once.Compact carousel variant
PredictCryptoUpDownMarketCardnow has two render variants, keyed off the existingisCarouselprop thatPredictMarketforwards to its sibling cards (PredictMarketSingle,PredictMarketMultiple,PredictMarketSportCard):isCarousel=false, the default) — the existing sparkline + target-line / target-price treatment used onPredictFeed,PredictHome, the wallet home carousel, and search.isCarousel=true) — drops the sparkline and target labels and switches to aheight: 100%+ flex-column +justifyContent: 'space-between'layout that mirrorsPredictMarketSingle/PredictMarketMultipleso the card sits flush with its neighbours inHorizontalCarousel. This is the variant the 5 TrendingView carousel tabs (Now, Macro, RWAs, Crypto, Sports) render for series-resolved highlights.The compact path also gates
useCryptoUpDownChartDataanduseCryptoTargetPricewithenabled: !isCompact, so the chart historical fetch and live-price websocket subscription don't run for cards that never display them.Resilience
DevLogger.log, so one unhealthy series entry can't take down a healthy batch.SERIES_MAX_EVENTS(50) forlimit. The provider returns markets inendDate ASCorder, and a fast recurrence (5m) can produce ~12 past events inside the past buffer alone — too low a limit would clip the live slot.getMarketsByIdskeeps its existing fail-hard contract; the previously misleading test"handles getMarketsByIds failure gracefully"(which actually only tested an empty-array result) was renamed accordingly, and a real rejection-propagation test was added.Test coverage
PredictController.test.ts(live-market resolution, mixed markets+series ordering, nearest-market fallback, empty-series skip, closed-market status filter, throw-silent on single series, partial-batch failure, dedupe across paths)resolvePredictFeatureFlags.test.tsPredictCryptoUpDownMarketCard.test.tsxcovering the compact variant (sparkline not rendered, both chart queries gated withenabled: false, compact skeleton renders, buy sheet still opens)Changelog
CHANGELOG entry: Added support for pinning the currently-live market of a recurring series (e.g. BTC Up/Down 5m) via the
predictMarketHighlightsremote feature flag.Related issues
Fixes: PRED-950
Manual testing steps
Both scenarios assume the
predictMarketHighlightsLaunchDarkly variation is updated to the new shape. The series ID10684corresponds to the Polymarket GammaBTC Up/Down 5mseries (also hardcoded asBTC_UP_DOWN_5M_SERIES_IDinapp/components/UI/Predict/constants/btcUpDown5mSeries.ts).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
Feed ordering and highlight resolution now depend on series API behavior and remote flag shape; carousel gating changes which data loads on Explore surfaces.
Overview
Adds optional
seriesIDs topredictMarketHighlightsso recurring crypto up/down pins resolve to the currently live market viagetMarketSeries+findLiveMarket/findNearestMarket, merged with existing market-ID highlights (parallel fetch, dedupe, open-only, market IDs first).PredictCryptoUpDownMarketCardnow honorsisCarousel: a compact layout (no sparkline/target UI, full-height flex) andenabled: falseon chart/target hooks to avoid unused network work in Explore carousels; full feed cards unchanged withenabled: trueon chart data.Controller tests cover series resolution edge cases;
getMarketsByIdsfailures now reject instead of being mislabeled as graceful handling.Reviewed by Cursor Bugbot for commit 83f5c75. Bugbot is set up for automated code reviews on this repo. Configure here.