Skip to content

feat(predict): cp-7.62.0 improve chart loading state and timestamp positioning#24806

Merged
matallui merged 1 commit intomainfrom
predict/chart-fixes
Jan 16, 2026
Merged

feat(predict): cp-7.62.0 improve chart loading state and timestamp positioning#24806
matallui merged 1 commit intomainfrom
predict/chart-fixes

Conversation

@caieu
Copy link
Copy Markdown
Contributor

@caieu caieu commented Jan 16, 2026

Description

  • Add ActivityIndicator spinner during chart loading instead of blank background
  • Implement dynamic timestamp positioning to prevent text overflow at chart edges
    • Anchor timestamp to left when near left boundary
    • Anchor timestamp to right when near right boundary
    • Center timestamp when in the middle of the chart
  • Fix timestamp conversion to handle both seconds and milliseconds formats
  • Improve chart data loading detection to check for actual data presence
  • Fix TimeframeSelector padding for better spacing
  • Fix PredictPicks cash out button background for light mode only

Changelog

CHANGELOG entry: null

Related issues

Fixes:

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

https://www.loom.com/share/d3841593361b418e81f6034dae4a2cb2

Before

After

Pre-merge author checklist

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

Improves chart usability and data handling with better loading UX, timestamp rendering, and parsing.

  • Implements edge-aware tooltip timestamp: clamps x to chart bounds and switches textAnchor between start/middle/end using TIMESTAMP_TEXT_HALF_WIDTH
  • Adds toMilliseconds to normalize seconds vs milliseconds timestamps for history data
  • Refines loading detection: require both series to have data; updates isLoading and initial live data logic
  • Replaces blank loading state with centered ActivityIndicator; disables TimeframeSelector while loading
  • UI polish: adjust TimeframeSelector padding; set PredictPicks cash-out button background for light mode only
  • Tests: expand ChartTooltip tests to cover timestamp edge positioning and update SVG Text mock to include textAnchor

Written by Cursor Bugbot for commit 2cb500d. This will update automatically on new commits. Configure here.

@github-actions
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.

@metamaskbot metamaskbot added the team-predict Predict team label Jan 16, 2026
@github-actions
Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePredictions
  • Risk Level: low
  • AI Confidence: 95%
click to see 🤖 AI reasoning details

All 7 changed files are within the app/components/UI/Predict/ directory, which is the prediction market feature. The changes include:

  1. ChartTooltip.tsx - UI fix for timestamp positioning at chart edges
  2. ChartTooltip.test.tsx - Unit tests for the timestamp edge positioning
  3. PredictGameChart.constants.ts - New constant for timestamp text width
  4. PredictGameChart.tsx - Bug fixes for timestamp conversion (seconds to milliseconds) and improved loading state detection
  5. PredictGameChartContent.tsx - Added ActivityIndicator during loading
  6. TimeframeSelector.tsx - Minor styling adjustment (padding/margin)
  7. PredictPicks.tsx - Dark/light mode styling fix

These are all self-contained changes to the Predict feature with no impact on core wallet functionality, controllers, or other features. The changes are primarily UI/UX improvements and bug fixes within the prediction market components. The SmokePredictions tag is the appropriate and only necessary tag to validate these changes.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

@caieu caieu marked this pull request as ready for review January 16, 2026 15:44
@caieu caieu requested a review from a team as a code owner January 16, 2026 15:44
Copy link
Copy Markdown

@cursor cursor bot left a comment

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.

const isLoading =
isFetching ||
(isLive && !initialDataLoadedRef.current && chartData.length === 0);
isFetching || !hasChartData || (isLive && !initialDataLoadedRef.current);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Infinite loading spinner when no price data exists

Medium Severity

The isLoading calculation includes !hasChartData as an unconditional OR condition. When the API successfully completes (isFetching is false) but returns empty data arrays, hasChartData becomes false, making isLoading true. Since PredictGameChartContent checks isLoading before checking for empty data (!hasData), the "No price history available" message can never be displayed—instead, the loading spinner shows indefinitely.

Fix in Cursor Fix in Web

@matallui matallui added this pull request to the merge queue Jan 16, 2026
@matallui matallui removed this pull request from the merge queue due to a manual request Jan 16, 2026
github-merge-queue bot pushed a commit that referenced this pull request Jan 16, 2026
…24806)

<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until the template has been
completely filled out, and PR status checks have passed at least once.
-->

## **Description**

- Add ActivityIndicator spinner during chart loading instead of blank
background
- Implement dynamic timestamp positioning to prevent text overflow at
chart edges
  - Anchor timestamp to left when near left boundary
  - Anchor timestamp to right when near right boundary
  - Center timestamp when in the middle of the chart
- Fix timestamp conversion to handle both seconds and milliseconds
formats
- Improve chart data loading detection to check for actual data presence
- Fix TimeframeSelector padding for better spacing
- Fix PredictPicks cash out button background for light mode only

<!--
Write a short description of the changes included in this pull request,
also include relevant motivation and context. Have in mind the following
questions:
1. What is the reason for the change?
2. What is the improvement/solution?
-->

## **Changelog**

<!--
If this PR is not End-User-Facing and should not show up in the
CHANGELOG, you can choose to either:
1. Write `CHANGELOG entry: null`
2. Label with `no-changelog`

If this PR is End-User-Facing, please write a short User-Facing
description in the past tense like:
`CHANGELOG entry: Added a new tab for users to see their NFTs`
`CHANGELOG entry: Fixed a bug that was causing some NFTs to flicker`

(This helps the Release Engineer do their job more quickly and
accurately)
-->

CHANGELOG entry: null

## **Related issues**

Fixes:

## **Manual testing steps**

```gherkin
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**

https://www.loom.com/share/d3841593361b418e81f6034dae4a2cb2

<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->

### **Before**

<!-- [screenshots/recordings] -->

### **After**

<!-- [screenshots/recordings] -->

## **Pre-merge author checklist**

- [ ] I’ve followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile
Coding
Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **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.


<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> Improves chart usability and data handling with better loading UX,
timestamp rendering, and parsing.
> 
> - Implements edge-aware tooltip timestamp: clamps `x` to chart bounds
and switches `textAnchor` between `start`/`middle`/`end` using
`TIMESTAMP_TEXT_HALF_WIDTH`
> - Adds `toMilliseconds` to normalize seconds vs milliseconds
timestamps for history data
> - Refines loading detection: require both series to have data; updates
`isLoading` and initial live data logic
> - Replaces blank loading state with centered `ActivityIndicator`;
disables `TimeframeSelector` while loading
> - UI polish: adjust `TimeframeSelector` padding; set PredictPicks
cash-out button background for light mode only
> - Tests: expand `ChartTooltip` tests to cover timestamp edge
positioning and update SVG `Text` mock to include `textAnchor`
> 
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
2cb500d. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@matallui matallui changed the title feat(predict): improve chart loading state and timestamp positioning feat(predict): cp-7.62.0 improve chart loading state and timestamp positioning Jan 16, 2026
@matallui matallui enabled auto-merge January 16, 2026 16:10
@matallui matallui added this pull request to the merge queue Jan 16, 2026
Merged via the queue into main with commit 8e71c07 Jan 16, 2026
109 of 111 checks passed
@matallui matallui deleted the predict/chart-fixes branch January 16, 2026 16:34
@github-actions github-actions bot locked and limited conversation to collaborators Jan 16, 2026
@metamaskbot metamaskbot added the release-7.63.0 Issue or pull request that will be included in release 7.63.0 label Jan 16, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.63.0 Issue or pull request that will be included in release 7.63.0 size-M team-predict Predict team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants