Skip to content

fix: stabilize token details headline price#30940

Merged
sahar-fehri merged 2 commits into
mainfrom
fix/fix-token-details-headline-price-jump
Jun 4, 2026
Merged

fix: stabilize token details headline price#30940
sahar-fehri merged 2 commits into
mainfrom
fix/fix-token-details-headline-price-jump

Conversation

@sahar-fehri

@sahar-fehri sahar-fehri commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Description

When switching between time ranges (1H, 1D, 1W, 1M, 1Y) on the token details advanced chart, the headline price visibly jumps through 3-4 intermediate values before settling (~$3+ range on ETH). This creates a jarring flicker experience.
Root cause: Three data sources provide slightly different "current price" values, and during a time-range switch the headline cycles through all of them in sequence:

  1. Stale lastBarClose from the previous time range's ohlcvData (still in memory before the new API call returns)
  2. New lastBarClose from the fresh /v3/ohlcv-chart response (bucketed candle close — lags behind real price by minutes/hours depending on interval granularity)
  3. /v3/ohlcv/latest poll result (fresher candle snapshot)
  4. WebSocket tick (true real-time price)
    When the user switches time ranges, the WS unsubscribes and realtimeClose becomes undefined, causing the headline to fall back to stale candle data. The coarser the candle interval, the more pronounced the stale price (daily candles on 1Y can be hours old).

Fix

Hold the last known WS/realtime price in a ref during time-range transitions. The headline stays stable until fresh realtime data arrives from /latest or WS (~500ms after switch).

const lastRealtimeRef = useRef<number | undefined>(undefined);
if (realtimeClose !== undefined) {
  lastRealtimeRef.current = realtimeClose;
}
const stablePrice = realtimeClose ?? lastRealtimeRef.current;

const displayPrice =
  crosshairData?.close ?? stablePrice ?? lastBarClose ?? currentPrice;

Changelog

CHANGELOG entry: stabilize headline price in token details.

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-3314

Manual testing steps

Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

Screen.Recording.2026-06-02.at.16.11.55.mov

After

Screen.Recording.2026-06-02.at.16.10.37.mov

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Low Risk
Localized display logic in Price.advanced.tsx with no auth, persistence, or API contract changes.

Overview
Fixes headline price flicker on the token details advanced chart when users switch time ranges (1H–1Y). During a range change, WebSocket updates pause and the UI was falling through to stale or bucketed OHLCV candle closes, so the displayed price jumped across several values.

Price.advanced.tsx now keeps the last known realtime close in a ref and uses stablePrice (realtimeClose ?? lastRealtimeRef) for displayPrice and displayDiff, so the headline stays on the previous live price until fresh realtime data returns—aligned with the existing stable compare price pattern used while series data reloads.

Reviewed by Cursor Bugbot for commit 82234da. Bugbot is set up for automated code reviews on this repo. Configure here.

@sahar-fehri sahar-fehri requested a review from a team as a code owner June 2, 2026 14:12
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 2, 2026
@github-actions github-actions Bot added size-S risk:low AI analysis: low risk labels Jun 2, 2026
@sahar-fehri sahar-fehri removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label Jun 2, 2026
@sahar-fehri sahar-fehri enabled auto-merge June 3, 2026 07:19

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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 82234da. Configure here.

Comment thread app/components/UI/AssetOverview/Price/Price.advanced.tsx
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: None (no tests recommended)
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: low
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
The change in Price.advanced.tsx is a narrow, targeted UI rendering fix. It introduces a useRef to cache the last WebSocket price during time-range transitions to prevent a "stale API flicker" effect. Specifically:

  1. Scope: Only Price.advanced.tsx is changed — a single component responsible for displaying the advanced price chart in the asset/token detail view.
  2. Nature of change: Adds a useRef (zero-cost, no re-renders) to hold the last known WS price, then uses stablePrice (which falls back to the cached value) instead of realtimeClose directly. This is a pure display stability fix.
  3. No E2E test coverage gap: No existing E2E spec files reference AssetOverview, PriceAdvanced, or the price chart component. The fix doesn't affect any user flows tested by the available tags (account management, confirmations, swaps, staking, network management, etc.).
  4. No shared infrastructure impact: No changes to controllers, Engine, navigation, modals, or any shared components that could break other tests.
  5. No performance impact: useRef is a React primitive with no rendering overhead; the change actually improves display stability by reducing unnecessary re-renders from flickering.

No E2E tags are warranted for this isolated UI rendering fix.

Performance Test Selection:
The change uses useRef (zero rendering cost) to stabilize price display during time-range transitions. This actually reduces unnecessary UI updates (flicker), so it has a neutral-to-positive performance impact. No performance test tags are needed.

View GitHub Actions results

@github-actions github-actions Bot added risk:medium AI analysis: medium risk and removed risk:low AI analysis: low risk labels Jun 4, 2026
@sahar-fehri sahar-fehri added this pull request to the merge queue Jun 4, 2026
Merged via the queue into main with commit 22e007d Jun 4, 2026
175 of 200 checks passed
@sahar-fehri sahar-fehri deleted the fix/fix-token-details-headline-price-jump branch June 4, 2026 07:20
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

risk:medium AI analysis: medium risk size-S team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants