Skip to content

feat: hoist perps providers for homepage hub tabs UI cp-7.77.0 #29757

Merged
vinnyhoward merged 59 commits into
mainfrom
feat-tmcu-591-homepage-hub-tabs-ui-perps-providers-hoist
May 13, 2026
Merged

feat: hoist perps providers for homepage hub tabs UI cp-7.77.0 #29757
vinnyhoward merged 59 commits into
mainfrom
feat-tmcu-591-homepage-hub-tabs-ui-perps-providers-hoist

Conversation

@vinnyhoward

@vinnyhoward vinnyhoward commented May 5, 2026

Copy link
Copy Markdown
Contributor

Description

Optimizes the hub page discovery tabs for Perps WebSocket efficiency and eliminates a double provider instance introduced by the tabs feature.

Provider hoisting: PerpsConnectionProvider and PerpsStreamProvider were instantiated twice under the hub tabs flag, once inside the Perps tab and again inside Homepage (for PerpsSection on the Portfolio tab). Both consumed the same singleton stream manager but mounted separate React provider trees. Providers are now hoisted to the HomepageDiscoveryTabs root so both tabs share one instance under the Tabs UI feature flag. Homepage accepts a perpsProvidersHoisted prop to skip its own providers when a parent already provides them.

WS pause/resume: Added pauseAllChannels() and resumeAllChannels() to PerpsStreamManager. When the user navigates to the Predictions tab , the only tab with no Perps consumers. All stream channels are paused, stopping subscriber notifications while keeping the WebSocket subscribed and the cache warm. Channels resume immediately on return to Portfolio or Perpetuals. A cleanup useEffect ensures channels are never left paused if the component unmounts mid-transition.

Extensibility: Tab indices that require live Perps data are declared in a PERPS_WS_TABS Set, making future tab additions a one-line change.

Changelog

CHANGELOG entry:null

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/TMCU-737

Manual testing steps

Feature: Perps WebSocket efficiency on hub page tabs

  Scenario: navigating to Predictions pauses Perps WS
    Given the hub page discovery tabs UI is enabled
    And the user is on the Portfolio or Perpetuals tab
    When user taps the Predictions tab
    Then Perps stream channels are paused (no active polling)
    And the WebSocket connection remains open

  Scenario: returning from Predictions resumes Perps WS
    Given the user is on the Predictions tab
    When user taps Portfolio or Perpetuals
    Then Perps stream channels resume immediately

  Scenario: switching between Portfolio and Perpetuals
    Given the user is on the Portfolio tab
    When user taps the Perpetuals tab
    Then Perps stream channels are not paused or resumed
    And PerpsSection on Portfolio and PerpsHomeView both reflect current data

  Scenario: Perps data visible on Portfolio tab
    Given the hub tabs flag is enabled
    When the user views the Portfolio tab
    Then PerpsSection renders with live data (single provider instance, no double-mount)

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

Medium Risk
Medium risk because it changes Perps WebSocket stream emission behavior (new pause reference counting + global pause/resume) and restructures provider mounting in HomepageDiscoveryTabs, which could affect live Perps data updates and tab navigation edge cases.

Overview
Hoists PerpsConnectionProvider + PerpsStreamProvider to HomepageDiscoveryTabs so the Portfolio and Perpetuals tabs share a single Perps provider tree, and adds a perpsProvidersHoisted prop to Homepage to skip creating nested Perps providers.

Updates Perps streaming to support reference-counted pausing (pauseCount) and adds pauseAllChannels()/resumeAllChannels(); HomepageDiscoveryTabs now pauses all Perps stream channels when switching to tabs that don’t consume Perps WS data (e.g. Predictions) and resumes on return, with unmount cleanup guarded to avoid unmatched resumes.

Adds/extends unit tests covering pause reference counting, pause-all/resume-all behavior, and homepage/perps feature-flag rendering when providers are hoisted.

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

vinnyhoward and others added 29 commits April 22, 2026 09:40
- Add HomepageDiscoveryTabs component with Portfolio, Perpetuals, and Predictions tabs
- Wire A/B test gate in Wallet — treatment renders discovery tabs, control renders existing homepage
- Lazy-mount Perps and Predictions inline as tab content with hideHeader prop to suppress duplicate headers
- Extend TabsList/TabsBar/Tab to support per-tab icons using local icon system
- Register portfolio and predict custom SVG icons
- Add per-tab gradient overlay that bleeds into wallet header with color per tab
- Fix Perps safe area top inset when rendered as embedded tab
…underline, re-enable A/B variant gating, and add test coverage for keepMounted and new PerpsHomeView props
Co-authored-by: Cursor <cursoragent@cursor.com>
…ndexRef update order and prevent control variant layout regression from shared portfolioHeader margin
Adds Tab, TabsBar, and TabsList to components-temp with animated underline,
scrollable overflow detection, icon support, and height collapse animation.
Adds Candlestick, Portfolio, and Predict icons.
Introduces TabsIconTab, TabsIconBar, and TabsIconList as a new icon-only
tab variant alongside the existing Tabs family. Reverts all modifications
to the base Tabs components to avoid downstream regressions.
@github-actions

github-actions Bot commented May 5, 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.

…tmcu-591-homepage-hub-tabs-ui-perps-providers-hoist
@vinnyhoward vinnyhoward dismissed stale reviews from wachunei and geositta via 4db61f3 May 11, 2026 17:40
@vinnyhoward vinnyhoward enabled auto-merge May 11, 2026 18:45
@vinnyhoward vinnyhoward changed the title feat: hoist perps providers for homepage hub tabs UI feat: hoist perps providers for homepage hub tabs UI cp-7.77.0 May 11, 2026

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

Comment thread app/components/UI/Perps/providers/PerpsStreamManager.tsx
@vinnyhoward vinnyhoward changed the title feat: hoist perps providers for homepage hub tabs UI cp-7.77.0 feat: hoist perps providers for homepage hub tabs UI May 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The changes span three key areas:

  1. PerpsStreamManager.tsx - Refactored pause/resume from a boolean flag to a reference-counting system (pauseCount). Added pauseAllChannels() and resumeAllChannels() methods. This is a behavioral change to the WebSocket stream management that underpins all Perps data flows. If the reference counting is incorrect, Perps data could be blocked or incorrectly emitted.

  2. HomepageDiscoveryTabs.tsx - Major architectural change: PerpsConnectionProvider and PerpsStreamProvider are now hoisted to the parent level (wrapping all tabs) instead of being scoped to individual tabs. The Perpetuals tab changed from keepMounted={false} to always-mounted. Tab-switching logic now calls pauseAllChannels()/resumeAllChannels() when switching between Perps-consuming tabs (Portfolio, Perpetuals) and non-Perps tabs (Predictions). This directly affects how Perps streams behave across all discovery tabs.

  3. Homepage.tsx - Added perpsProvidersHoisted prop to conditionally skip rendering its own Perps providers when a parent already provides them. This prevents double-provider wrapping.

Tag Selection:

  • SmokePerps: Directly affected - the Perps WebSocket streaming infrastructure changed (pause/resume reference counting, provider hoisting). Perps add funds, positions, and trading flows all depend on correct stream behavior. Also required per SmokePerps description: select SmokeWalletPlatform (Trending section) and SmokeConfirmations.
  • SmokeWalletPlatform: The Homepage/HomepageDiscoveryTabs are the core wallet platform views. The Trending tab (Portfolio tab in discovery) is directly modified. Provider hoisting changes affect the Portfolio tab rendering.
  • SmokePredictions: The Predictions tab is directly involved in the tab-switching pause/resume logic. Switching to/from Predictions triggers pauseAllChannels/resumeAllChannels. The tab's keepMounted behavior may also have changed.
  • SmokeConfirmations: Required per SmokePerps tag description (Add Funds deposits are on-chain transactions).

The unit tests cover the new behavior well, but E2E tests are needed to validate the actual WebSocket stream behavior, provider hoisting, and tab-switching interactions in a real device environment.

Performance Test Selection:
The PerpsStreamManager changes affect WebSocket stream management with a new reference-counting pause/resume system. The HomepageDiscoveryTabs changes hoist providers and change tab mounting behavior (Perpetuals tab now always-mounted instead of keepMounted=false). These changes could impact Perps performance - specifically how quickly data loads when switching tabs and the overhead of always-mounted Perpetuals tab. @PerformancePreps covers perps market loading, position management, add funds flow, and order execution, which are all potentially affected by the streaming infrastructure changes.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@vinnyhoward vinnyhoward added this pull request to the merge queue May 13, 2026
Merged via the queue into main with commit e0a180e May 13, 2026
164 of 169 checks passed
@vinnyhoward vinnyhoward deleted the feat-tmcu-591-homepage-hub-tabs-ui-perps-providers-hoist branch May 13, 2026 01:16
@github-actions github-actions Bot locked and limited conversation to collaborators May 13, 2026
@vinnyhoward vinnyhoward changed the title feat: hoist perps providers for homepage hub tabs UI feat: hoist perps providers for homepage hub tabs UI cp-7.77.0 May 13, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants