Skip to content

Tx page: show historical $ value#3272

Merged
isstuev merged 3 commits intomainfrom
fe-2293
Mar 3, 2026
Merged

Tx page: show historical $ value#3272
isstuev merged 3 commits intomainfrom
fe-2293

Conversation

@isstuev
Copy link
Copy Markdown
Contributor

@isstuev isstuev commented Feb 9, 2026

Description and Related Issue(s)

resolves #2293

Additional Information

historical exchange rate would be set to null for the latest txs in the 10.0 backend release

Checklist for PR author

  • I have tested these changes locally.
  • I added tests to cover any new functionality, following this guide
  • Whenever I fix a bug, I include a regression test to ensure that the bug does not reappear silently.
  • If I have added a feature or functionality that is not privacy-compliant (e.g., tracking, analytics, third-party services), I have disabled it for private mode.
  • If I have added, changed, renamed, or removed an environment variable
    • I updated the list of environment variables in the documentation
    • I made the necessary changes to the validator script according to the guide
    • I added "ENVs" label to this pull request

Note

Medium Risk
Touches shared value/fee rendering used across transaction pages and lists, adding new toggle state and a new historic_exchange_rate field; mistakes could cause incorrect USD display or inconsistent tooltips across many views.

Overview
Adds support for a historic_exchange_rate on Transaction data (types, RPC formatting, and stubs/mocks) so the UI can distinguish no historical rate provided vs explicitly null.

Updates AssetValue/SimpleValue (and wiring through NativeCoinValue/TxFee) to display USD using the historical rate by default when available, with an optional clickable tag to toggle between historical and current USD values and clearer tooltip labeling. Propagates this through multiple tx views (tx details, fees/burnt fees, rollup fee rows, and tx list/table items), and adds Playwright screenshot coverage for the new AssetValue behaviors.

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

@isstuev isstuev force-pushed the fe-2293 branch 5 times, most recently from 92957f0 to 0bf78fe Compare February 10, 2026 22:06
@isstuev isstuev marked this pull request as ready for review February 11, 2026 09:05
Comment thread ui/tx/details/TxInfo.tsx Outdated
Comment thread ui/shared/value/AssetValue.tsx Outdated
@isstuev isstuev requested review from tom2drum February 16, 2026 13:30
Comment thread ui/shared/value/AssetValue.tsx Outdated
const hasCurrent = Boolean(exchangeRate);
const hasToggle = hasHistoric && hasCurrent && hasExchangeRateToggle && amount !== '0';

const [ showHistoric, setShowHistoric ] = React.useState(hasHistoric);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I believe the correct adjective will be "historical" not "historic"

In general, historic means ‘notable in history, significant in history,’ as in a Supreme Court decision, a battlefield, or a great discovery. Historical means ‘relating to history or past events’: (‘historical society’; ‘historical documents’). To write historic instead of historical may imply a greater significance than is warranted: a historical lecture may simply tell about something that happened, whereas a historic lecture would in some way change the course of human events.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's the name from the API

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nevertheless, I don't think we should copy their error into our code.

Comment thread ui/shared/value/SimpleValue.tsx Outdated
Comment thread ui/shared/value/AssetValue.tsx
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 2, 2026

Important

Review skipped

Auto reviews are disabled on this repository. To trigger a review, include @coderabbitai review in the PR description. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Stale state causes brief wrong exchange rate display
    • Replaced synced derived state with a user-only override so historic-rate visibility now defaults directly from props without a post-paint state sync gap.

Create PR

Or push these changes by commenting:

@cursor push 169b339a97
Preview (169b339a97)
diff --git a/ui/shared/value/AssetValue.tsx b/ui/shared/value/AssetValue.tsx
--- a/ui/shared/value/AssetValue.tsx
+++ b/ui/shared/value/AssetValue.tsx
@@ -45,17 +45,14 @@
   const hasCurrent = Boolean(exchangeRate);
   const hasToggle = hasHistoric && hasCurrent && hasExchangeRateToggle && amount !== '0';
 
-  const [ showHistoric, setShowHistoric ] = React.useState(hasHistoric);
+  const [ showHistoricOverride, setShowHistoricOverride ] = React.useState<boolean | undefined>(undefined);
+  const showHistoric = hasHistoric && (showHistoricOverride ?? true);
 
-  React.useEffect(() => {
-    setShowHistoric(hasHistoric);
-  }, [ hasHistoric ]);
-
   const activeExchangeRate = showHistoric ? historicExchangeRate : exchangeRate;
 
   const handleToggle = React.useCallback(() => {
     if (hasToggle) {
-      setShowHistoric(prev => !prev);
+      setShowHistoricOverride(prev => (prev === undefined ? false : !prev));
     }
   }, [ hasToggle ]);
This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Comment thread ui/shared/value/AssetValue.tsx Outdated

React.useEffect(() => {
setShowHistoric(hasHistoric);
}, [ hasHistoric ]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale state causes brief wrong exchange rate display

Low Severity

The showHistoric state is initialized from hasHistoric on mount and synced via useEffect, but since effects fire after paint, there's a render frame where showHistoric is stale. When data loads (stub has historic_exchange_rate: null, real data has a string), hasHistoric becomes true but showHistoric remains false for one render, causing activeExchangeRate to use exchangeRate (current) instead of historicExchangeRate. This briefly displays the wrong USD value before the effect corrects it. Deriving the default from props directly — and using state only for the user's explicit toggle override — would avoid this flash.

Additional Locations (1)

Fix in Cursor Fix in Web

@isstuev isstuev merged commit 0cce38d into main Mar 3, 2026
13 checks passed
@isstuev isstuev deleted the fe-2293 branch March 3, 2026 11:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tx page: show historical $ value

2 participants