fix(predict): keep live position data in sync across screens#29527
Conversation
- gate live predict position subscriptions and cache sync by screen focus - avoid unsubscribing overlapping market tokens still used elsewhere - move positions header claimable data onto usePredictPositions - update hook and websocket manager tests for subscription lifecycle
|
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. |
…-position-data-consistency-on-home-screen
|
Hey @caieu , some things i picked up on High Severity1.
|
…-position-data-consistency-on-home-screen
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
❌ 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 fa804eb. Configure here.
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsE2E Test Selection:
Tag selection rationale:
No other tags are needed as changes are fully contained within the Predict feature with no impact on navigation, shared components, Engine, or other feature areas. Performance Test Selection: |
|
MarioAslau
left a comment
There was a problem hiding this comment.
LGTM ! Thanks for addressing the review




Description
This PR fixes inconsistencies in Predict position values across the home screen, market details, and card/list surfaces.
It moves active-position live updates into
usePredictPositionsviausePredictLivePositions, syncs websocket-derived values back into the shared React Query positions cache, removes duplicate component-level live subscriptions, scopes live subscriptions to focused screens only, and fixes market websocket unsubscribe behavior so overlapping token subscriptions do not break updates on other active screens. It also updates the positions header to read claimable positions fromusePredictPositionsinstead of Redux/controller state so it stays aligned with the shared query source.Changelog
CHANGELOG entry: Fixed live prediction position values so they stay updated across the home screen and market details views.
Related issues
Refs: https://consensyssoftware.atlassian.net/browse/PRED-820
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
Moderate risk because it changes how live price updates propagate through shared React Query caches and alters WebSocket subscription/unsubscribe behavior, which could affect update frequency and data correctness across multiple screens.
Overview
Ensures Predict active position values stay consistent across home, market details, and card surfaces by adding an opt-in
livePriceUpdatesflag tousePredictPositionsthat enablesusePredictLivePositionsto sync websocket-derived PnL/value updates back into the shared positions query cache.Removes component-level live position mapping (
PredictPicks,PredictPicksForCard) in favor of consuming already-updatedusePredictPositionsdata, and scopes live subscriptions to focused screens while skipping claimable positions.Fixes Polymarket market-price WebSocket unsubscribe logic to avoid unsubscribing token IDs still required by other active subscriptions, and updates
PredictPositionsHeaderto derive won/claimable positions fromusePredictPositionsinstead of Redux state; tests were updated/added to cover the new live-update and unsubscribe semantics.Reviewed by Cursor Bugbot for commit 8eda7a8. Bugbot is set up for automated code reviews on this repo. Configure here.