Skip to content

chore: set user timezone in chart#29654

Merged
sahar-fehri merged 4 commits into
mainfrom
fix/set-chart-timezone
May 5, 2026
Merged

chore: set user timezone in chart#29654
sahar-fehri merged 4 commits into
mainfrom
fix/set-chart-timezone

Conversation

@sahar-fehri

@sahar-fehri sahar-fehri commented May 4, 2026

Copy link
Copy Markdown
Contributor

Description

The advanced chart time axis was always displaying in UTC regardless of the user's locale.

Root cause: The timezone property was missing from the TradingView.widget constructor. When omitted, falls back to the symbol's resolveSymbol timezone — hardcoded to Etc/UTC for our crypto data.

Fix: Detect the user's timezone via Intl.DateTimeFormat().resolvedOptions().timeZone and pass it to the widget constructor. The value is validated against TradingView's supported timezone list with a fallback to Etc/UTC.

Note: the timezone: 'Etc/UTC' in resolveSymbol is unchanged, it declares data alignment, which is separate from the display timezone.

Changelog

CHANGELOG entry: Fixed advanced chart displaying timestamps in UTC instead of the user's local timezone

Related issues

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

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

After

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
Low risk: only affects AdvancedChart display settings by passing a validated timezone into the TradingView widget, with a safe fallback to Etc/UTC if detection/mapping fails.

Overview
Fixes AdvancedChart timestamps always rendering in UTC by detecting the user’s device timezone (Intl.DateTimeFormat().resolvedOptions().timeZone) and passing it to TradingView.widget via the timezone option.

Adds a whitelist of TradingView-supported IANA timezone IDs plus a small canonical-to-TradingView alias map, and falls back to Etc/UTC when the device timezone is unsupported or detection throws (applied in both chartLogic.js and the injected chartLogicString.ts).

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

@github-actions

github-actions Bot commented May 4, 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 size-M label May 4, 2026
@sahar-fehri sahar-fehri requested a review from geositta May 4, 2026 12:35
@sahar-fehri sahar-fehri marked this pull request as ready for review May 4, 2026 12:40

@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 da05fb8. Configure here.

Comment thread app/components/UI/Charts/AdvancedChart/webview/chartLogic.js Outdated
@sahar-fehri sahar-fehri added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label May 4, 2026
Comment thread app/components/UI/Charts/AdvancedChart/webview/chartLogic.js
@github-actions

github-actions Bot commented May 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 changes are confined to two files that form a source/generated pair: chartLogic.js (the source) and chartLogicString.ts (auto-generated from it via syncChartLogic.js). The modification adds timezone detection logic to the TradingView chart widget embedded in a WebView within the AdvancedChart component. Specifically, it:

  1. Defines a list of TradingView-supported IANA timezone IDs
  2. Maps canonical IANA names to TradingView legacy aliases (e.g., America/Denver → US/Mountain)
  3. Detects the user's device timezone and passes it to the TradingView widget, falling back to Etc/UTC for unsupported timezones

The AdvancedChart component is used in AssetOverview/Price and TokenDetails screens for displaying token price charts. None of the available E2E test tags (SmokeAccounts, SmokeConfirmations, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeSwap, SmokeStake, SmokeWalletPlatform, SmokeMoney, SmokePerps, SmokeMultiChainAPI, SmokePredictions, SmokeSeedlessOnboarding, SmokeBrowser, SmokeSnaps) directly cover the AdvancedChart/token price chart WebView functionality. The change is a pure bug fix for chart timezone display — it's isolated to a WebView-embedded JavaScript file, has no impact on navigation, controllers, confirmations, or any other shared infrastructure, and includes a safe UTC fallback. No E2E tests need to run for this change.

Performance Test Selection:
The timezone detection logic runs as a single IIFE at chart initialization time with negligible overhead (array lookup + string comparison). It does not affect rendering performance, data loading, account/network lists, or any other performance-sensitive paths. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud

sonarqubecloud Bot commented May 5, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@sahar-fehri sahar-fehri added this pull request to the merge queue May 5, 2026
Merged via the queue into main with commit 3e8cfca May 5, 2026
96 of 100 checks passed
@sahar-fehri sahar-fehri deleted the fix/set-chart-timezone branch May 5, 2026 20:27
@github-actions github-actions Bot locked and limited conversation to collaborators May 5, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.77.0 Issue or pull request that will be included in release 7.77.0 label May 5, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.77.0 Issue or pull request that will be included in release 7.77.0 size-M skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-assets

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants