Commit 87e58f8
authored
fix: fix price line color with ambient TDP theme (#32164)
<!--
Please submit this PR as a draft initially.
Do not mark it as "Ready for review" until this PR meets the canonical
Definition of Ready For Review in `docs/readme/ready-for-review.md`.
In short: the template must be materially complete (not just section
titles
present), all status checks must be currently passing, and the only
expected
follow-up commits must be reviewer-driven.
-->
<!--
mms-check directive vocabulary — read by
.github/scripts/shared/pr-template-checks.ts
at module load to build the validation plan. Directives are invisible in
rendered
markdown and must NOT be removed or edited without updating the
validator registry.
type=text Section must contain non-placeholder prose.
type=changelog Section must have a valid CHANGELOG entry: line.
type=issue-link Section must have a Fixes:/Closes:/Refs: line with a
value.
type=manual-testing Section must have real testing steps or an explicit
N/A.
type=screenshot Section must have evidence (image/URL) or an explicit
N/A.
type=checklist Section must have all checkboxes consciously checked.
required=true|false Whether a missing/invalid section runs the validator
at all.
blocking=true|false Whether a failure of this check fails the CI
workflow.
Default: false — failures are shown as warnings in the sticky
comment but do not block the PR.
Sections without a directive are checked for structural presence only.
-->
## **Description**
<!-- mms-check: type=text required=true -->
When the ambient price color experiment is enabled on Token Details
(`useAmbientPriceColor` treatment), the advanced chart correctly
hot-swaps the **series line** and **filled last-close price pill** to
orange when price is negative — but the **dashed last-price horizontal
line** stayed green.
**Root cause:** `createLastPriceLine` and the `SET_THEME_COLORS` shape
update for candle-mode dashed lines resolved color via
`currentPriceColor || successColor` instead of following `lineColor`
(which ambient pricing drives independently of `successColor`). Realtime
bar updates then recreated the dashed line with the same wrong fallback
on every tick.
**Changes (WebView only — `chartLogic.js`, synced to
`chartLogicString.ts`):**
* **`createLastPriceLine`:** Dashed line color now uses the same
resolution as line-chart mode.
* **`handleSetThemeColors`:** Updates and recreates dashed last-price
shapes using the corrected color;
* **Refactor:** Introduced `getThemeLineColor()` and
`getThemeLastPriceLineColor()` helpers so series line, filled pill, end
marker, and dashed line share one color source and cannot drift again.
**No behavior change when the ambient feature flag is off** —
`lineColor` and `successColor` are identical in that path.
## **Changelog**
<!-- mms-check: type=changelog required=true blocking=true -->
<!--
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: Fixed token details advanced chart dashed last-price
line not matching ambient price color when price is negative.
## **Related issues**
<!-- mms-check: type=issue-link required=true -->
Fixes: https://consensyssoftware.atlassian.net/browse/ASSETS-3430
## **Manual testing steps**
<!-- mms-check: type=manual-testing required=true -->
```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**
<!-- mms-check: type=screenshot required=true -->
<!-- If applicable, add screenshots and/or recordings to visualize the
before and after of your change. -->
### **Before**
<!-- [screenshots/recordings] -->
### **After**
<!-- [screenshots/recordings] -->
https://github.com/user-attachments/assets/a06e93a9-01ec-4100-9e92-288e37d94b5d
## **Pre-merge author checklist**
<!-- mms-check: type=checklist required=true -->
<!--
Every checklist item must be consciously assessed before marking this PR
as
"Ready for review". A checked box means you deliberately considered that
responsibility, not that you literally performed every action listed.
Unchecked boxes are ambiguous: they are not an implicit "N/A" and they
are not
a silent "skip". See `docs/readme/ready-for-review.md` for the full
checklist
semantics.
-->
- [ ] 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.
#### 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](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/edit-v2/401401446401?draftShareId=9d77e1e1-4bdc-4be1-9ebb-ccd916988d93)
to import wallets with many accounts and tokens
- [ ] I've instrumented key operations with Sentry traces for production
performance metrics
- See [`trace()`](/app/util/trace.ts) for usage and
[`addToken`](/app/components/Views/AddAsset/components/AddCustomToken/AddCustomToken.tsx#L274)
for an example
For performance guidelines and tooling, see the [Performance
Guide](https://consensyssoftware.atlassian.net/wiki/spaces/TL1/pages/400085549067/Performance+Guide+for+Engineers).
## **Pre-merge reviewer checklist**
<!--
Reviewer checklist items follow the same semantics as the author
checklist: an
unchecked box is ambiguous, a checked box means the reviewer consciously
assessed that responsibility. See `docs/readme/ready-for-review.md`.
-->
- [ ] 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]
> **Low Risk**
> WebView-only chart styling refactor with centralized fallbacks; no
auth, data, or API changes.
>
> **Overview**
> Fixes the token details advanced chart so the **dashed last-price
horizontal line** matches ambient pricing when `useAmbientPriceColor` is
on (e.g. orange for negative moves instead of staying green).
>
> The WebView chart logic now uses shared **`getThemeLineColor()`** and
**`getThemeLastPriceLineColor()`** helpers (`lineColor` →
`successColor`, and `currentPriceColor` → line color) everywhere series
strokes, last-close pills, end dots, and dashed overlays are
painted—including **`createLastPriceLine`**,
**`createLineLastPriceLine`**, **`handleSetThemeColors`**, chart init,
and realtime redraw paths. The same edits are mirrored in
**`chartLogicString.ts`**.
>
> When ambient pricing is off, behavior is unchanged because `lineColor`
and `successColor` stay aligned on the existing path.
>
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
291d35d. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent c2bb189 commit 87e58f8
2 files changed
Lines changed: 74 additions & 38 deletions
Lines changed: 37 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
818 | 818 | | |
819 | 819 | | |
820 | 820 | | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
821 | 846 | | |
822 | 847 | | |
823 | 848 | | |
| |||
848 | 873 | | |
849 | 874 | | |
850 | 875 | | |
851 | | - | |
852 | | - | |
| 876 | + | |
853 | 877 | | |
854 | 878 | | |
855 | 879 | | |
| |||
895 | 919 | | |
896 | 920 | | |
897 | 921 | | |
898 | | - | |
899 | | - | |
| 922 | + | |
| 923 | + | |
900 | 924 | | |
901 | 925 | | |
902 | 926 | | |
| |||
927 | 951 | | |
928 | 952 | | |
929 | 953 | | |
930 | | - | |
| 954 | + | |
931 | 955 | | |
932 | 956 | | |
933 | 957 | | |
934 | 958 | | |
935 | 959 | | |
936 | 960 | | |
937 | 961 | | |
938 | | - | |
| 962 | + | |
939 | 963 | | |
940 | 964 | | |
941 | 965 | | |
| |||
1412 | 1436 | | |
1413 | 1437 | | |
1414 | 1438 | | |
1415 | | - | |
| 1439 | + | |
1416 | 1440 | | |
1417 | 1441 | | |
1418 | 1442 | | |
| |||
2163 | 2187 | | |
2164 | 2188 | | |
2165 | 2189 | | |
2166 | | - | |
2167 | | - | |
| 2190 | + | |
2168 | 2191 | | |
2169 | 2192 | | |
2170 | 2193 | | |
| |||
2318 | 2341 | | |
2319 | 2342 | | |
2320 | 2343 | | |
2321 | | - | |
| 2344 | + | |
2322 | 2345 | | |
2323 | 2346 | | |
2324 | 2347 | | |
| |||
2374 | 2397 | | |
2375 | 2398 | | |
2376 | 2399 | | |
2377 | | - | |
2378 | | - | |
| 2400 | + | |
2379 | 2401 | | |
2380 | 2402 | | |
2381 | 2403 | | |
| |||
2460 | 2482 | | |
2461 | 2483 | | |
2462 | 2484 | | |
2463 | | - | |
2464 | | - | |
2465 | | - | |
2466 | | - | |
| 2485 | + | |
2467 | 2486 | | |
2468 | 2487 | | |
2469 | 2488 | | |
| |||
3245 | 3264 | | |
3246 | 3265 | | |
3247 | 3266 | | |
3248 | | - | |
3249 | | - | |
| 3267 | + | |
3250 | 3268 | | |
3251 | 3269 | | |
3252 | 3270 | | |
| |||
4515 | 4533 | | |
4516 | 4534 | | |
4517 | 4535 | | |
4518 | | - | |
| 4536 | + | |
4519 | 4537 | | |
4520 | 4538 | | |
4521 | 4539 | | |
| |||
Lines changed: 37 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
827 | 827 | | |
828 | 828 | | |
829 | 829 | | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
830 | 855 | | |
831 | 856 | | |
832 | 857 | | |
| |||
857 | 882 | | |
858 | 883 | | |
859 | 884 | | |
860 | | - | |
861 | | - | |
| 885 | + | |
862 | 886 | | |
863 | 887 | | |
864 | 888 | | |
| |||
904 | 928 | | |
905 | 929 | | |
906 | 930 | | |
907 | | - | |
908 | | - | |
| 931 | + | |
| 932 | + | |
909 | 933 | | |
910 | 934 | | |
911 | 935 | | |
| |||
936 | 960 | | |
937 | 961 | | |
938 | 962 | | |
939 | | - | |
| 963 | + | |
940 | 964 | | |
941 | 965 | | |
942 | 966 | | |
943 | 967 | | |
944 | 968 | | |
945 | 969 | | |
946 | 970 | | |
947 | | - | |
| 971 | + | |
948 | 972 | | |
949 | 973 | | |
950 | 974 | | |
| |||
1421 | 1445 | | |
1422 | 1446 | | |
1423 | 1447 | | |
1424 | | - | |
| 1448 | + | |
1425 | 1449 | | |
1426 | 1450 | | |
1427 | 1451 | | |
| |||
2172 | 2196 | | |
2173 | 2197 | | |
2174 | 2198 | | |
2175 | | - | |
2176 | | - | |
| 2199 | + | |
2177 | 2200 | | |
2178 | 2201 | | |
2179 | 2202 | | |
| |||
2327 | 2350 | | |
2328 | 2351 | | |
2329 | 2352 | | |
2330 | | - | |
| 2353 | + | |
2331 | 2354 | | |
2332 | 2355 | | |
2333 | 2356 | | |
| |||
2383 | 2406 | | |
2384 | 2407 | | |
2385 | 2408 | | |
2386 | | - | |
2387 | | - | |
| 2409 | + | |
2388 | 2410 | | |
2389 | 2411 | | |
2390 | 2412 | | |
| |||
2469 | 2491 | | |
2470 | 2492 | | |
2471 | 2493 | | |
2472 | | - | |
2473 | | - | |
2474 | | - | |
2475 | | - | |
| 2494 | + | |
2476 | 2495 | | |
2477 | 2496 | | |
2478 | 2497 | | |
| |||
3254 | 3273 | | |
3255 | 3274 | | |
3256 | 3275 | | |
3257 | | - | |
3258 | | - | |
| 3276 | + | |
3259 | 3277 | | |
3260 | 3278 | | |
3261 | 3279 | | |
| |||
4524 | 4542 | | |
4525 | 4543 | | |
4526 | 4544 | | |
4527 | | - | |
| 4545 | + | |
4528 | 4546 | | |
4529 | 4547 | | |
4530 | 4548 | | |
| |||
0 commit comments