Skip to content

fix(perps): privacy mode#27128

Merged
aganglada merged 3 commits into
mainfrom
fix/perps-privacy-test
Mar 6, 2026
Merged

fix(perps): privacy mode#27128
aganglada merged 3 commits into
mainfrom
fix/perps-privacy-test

Conversation

@aganglada
Copy link
Copy Markdown
Contributor

@aganglada aganglada commented Mar 6, 2026

Description

Perps screens had no privacy mode support — enabling the wallet privacy toggle had no effect on any financial values displayed in the perpetuals trading UI.

This PR integrates SensitiveText (with selectPrivacyMode) across all Perps components that render sensitive financial data, following the same pattern already established by the Predict feature.

What changed:

  • PerpsMarketBalanceActions — total balance and available balance value hidden behind dots; transaction in-progress amounts (deposit/withdrawal) also hidden
  • PerpsCard — position value and PnL/ROE label on the home screen cards hidden
  • PerpsPositionCard — comprehensive coverage: PnL, ROE, position value, size, margin, entry price, liquidation price, TP/SL prices, and funding payments all hidden; liquidation distance % and icon suppressed
  • PerpsPositionsView — all four account summary values (total balance, available balance, margin used, total unrealized PnL) hidden
  • PerpsHomeView — positions section PnL subtitle hidden

Color leaking fix: Values with directional colors (green for profit, red for loss) are forced to TextColor.Default when privacy mode is on, so the color itself cannot reveal whether a position is profitable or not.

Tests: Privacy mode test blocks added to all four affected test files. PerpsCard.test.tsx also received a missing react-redux mock that was required after the useSelector call was introduced.

Changelog

CHANGELOG entry: Fixed privacy mode not hiding financial values on Perps screens

Related issues

Fixes: #23187

Manual testing steps

Feature: Perps privacy mode

  Scenario: user enables privacy mode and navigates to Perps home
    Given the user has a funded Perps account with open positions
    And privacy mode is disabled

    When user enables privacy mode from wallet settings
    And navigates to the Perps home screen

    Then the total balance is replaced with bullet dots
    And the available balance amount is replaced with bullet dots
    And the "available" label remains visible
    And each position card shows bullet dots instead of position value and PnL
    And the positions section PnL subtitle is hidden

  Scenario: user views position detail with privacy mode enabled
    Given privacy mode is enabled
    And the user has an open ETH position

    When user taps on a position card

    Then PnL, ROE, size, margin, entry price, liquidation price, TP/SL prices, and funding payments all show bullet dots
    And none of the hidden values are displayed in green or red (color does not reveal direction)

  Scenario: user views the Positions tab with privacy mode enabled
    Given privacy mode is enabled

    When user navigates to the Positions tab

    Then total balance, available balance, margin used, and total unrealized PnL in the account summary all show bullet dots
    And the row labels (Total balance, Available balance, etc.) remain visible

  Scenario: user disables privacy mode
    Given privacy mode was previously enabled

    When user disables privacy mode

    Then all financial values are visible again with their correct amounts and directional colors

Screenshots/Recordings

Before

Before 1 Before 2 Before 3

After

After 1 After 2 After 3

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

Medium Risk
Touches multiple Perps UI surfaces and display logic to conditionally hide values and neutralize PnL coloring; risk is mainly UI regressions or incorrectly hidden/shown fields, not core trading behavior.

Overview
Adds Perps support for wallet privacy mode by wiring selectPrivacyMode into the home, positions list, and position-detail surfaces and replacing sensitive numeric fields with SensitiveText dots.

This also prevents profit/loss direction leakage by forcing neutral text colors and suppressing liquidation distance UI when privacy mode is on, and updates/extends unit tests to cover privacy-on/off rendering (including required Redux selector mocks).

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

@aganglada aganglada self-assigned this Mar 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

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-social-ai Social & AI team label Mar 6, 2026
@aganglada aganglada added team-perps Perps team and removed team-social-ai Social & AI team labels Mar 6, 2026
@github-actions github-actions Bot added the size-L label Mar 6, 2026
@aganglada aganglada marked this pull request as ready for review March 6, 2026 14:37
@aganglada aganglada requested a review from a team as a code owner March 6, 2026 14:37
@aganglada aganglada enabled auto-merge March 6, 2026 14:39
Comment thread app/components/UI/Perps/components/PerpsCard/PerpsCard.tsx
Comment thread app/components/UI/Perps/components/PerpsCard/PerpsCard.test.tsx
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: @PerformancePreps
  • Risk Level: medium
  • AI Confidence: 90%
click to see 🤖 AI reasoning details

E2E Test Selection:
This PR adds privacy mode support to the Perps (perpetuals trading) feature. The changes are focused on UI components within the Perps module:

  1. PerpsHomeView.tsx: Conditionally hides positions subtitle (PnL values) when privacy mode is enabled
  2. PerpsPositionsView.tsx: Replaces Text with SensitiveText for account balances (total balance, available balance, margin used, total unrealized PnL)
  3. PerpsCard.tsx: Hides position values and PnL labels using SensitiveText
  4. PerpsMarketBalanceActions.tsx: Hides balance values using SensitiveText
  5. PerpsPositionCard.tsx: Extensive privacy mode support - hides PnL, ROE, margin, size, entry price, liquidation price, funding payments

All changes use the existing selectPrivacyMode selector and SensitiveText component to mask financial values. The changes are well-tested with comprehensive unit tests for privacy mode functionality.

Tag selection rationale:

  • SmokePerps: Directly required - all changes are in Perps components (PerpsHomeView, PerpsPositionsView, PerpsCard, PerpsMarketBalanceActions, PerpsPositionCard)
  • SmokeWalletPlatform: Required per tag description - Perps is a section inside the Trending tab, so changes to Perps views affect Trending
  • SmokeConfirmations: Required per tag description - when selecting SmokePerps, also select SmokeConfirmations (Add Funds deposits are on-chain transactions)

Performance Test Selection:
The changes add multiple useSelector calls to read privacyMode state and replace Text components with SensitiveText components across several Perps UI components. While these are relatively minor changes, they could potentially impact rendering performance of the Perps views. The @PerformancePreps tag covers perps market loading, position management, add funds flow, and order execution - all areas touched by these privacy mode changes. Running this performance test will validate that the privacy mode additions don't negatively impact Perps UI responsiveness.

View GitHub Actions results

Copy link
Copy Markdown
Contributor

@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 is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

<PerpsHomeSection
title={strings('perps.home.positions')}
subtitle={positionsSubtitle}
subtitle={privacyMode ? undefined : positionsSubtitle}
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.

Subtitle color still leaks PnL direction in privacy mode

Low Severity

When privacy mode is on, subtitle is correctly set to undefined so it won't render, but subtitleColor is still passed with the directional color (TextColor.Success or TextColor.Error). Currently this is safe because PerpsHomeSection guards with {subtitle && (...)}. However, every other component in this PR explicitly forces TextColor.Default when privacy mode is on (e.g., PerpsPositionsView, PerpsPositionCard, PerpsCard), making this the only place that omits the color-neutralization pattern described in the PR's "Color leaking fix."

Fix in Cursor Fix in Web

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 doesn't as you can see on the screenshot

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

⚠️ E2E Fixture Validation — Structural changes detected

Category Count
New keys 68
Missing keys 11
Type mismatches 0
Value mismatches 7 (informational)

The committed fixture schema is out of date. To update, comment:

@metamaskbot update-mobile-fixture

View full details | Download diff report

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 6, 2026

@aganglada aganglada added this pull request to the merge queue Mar 6, 2026
Merged via the queue into main with commit 9d784ce Mar 6, 2026
176 of 178 checks passed
@aganglada aganglada deleted the fix/perps-privacy-test branch March 6, 2026 16:21
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 6, 2026
@metamaskbot metamaskbot added the release-7.70.0 Issue or pull request that will be included in release 7.70.0 label Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.70.0 Issue or pull request that will be included in release 7.70.0 size-L team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Predict - Perps - Hidden amounts is not respected for predict and perps features

3 participants