Skip to content

refactor: merge new and recently added lists, add new pill to products#33302

Open
gambinish wants to merge 2 commits into
mainfrom
feat/perps-new-recently-added-consolidation
Open

refactor: merge new and recently added lists, add new pill to products#33302
gambinish wants to merge 2 commits into
mainfrom
feat/perps-new-recently-added-consolidation

Conversation

@gambinish

@gambinish gambinish commented Jul 14, 2026

Copy link
Copy Markdown
Member

Description

The Perps home "Recently Added" rail and the market list "New" pill used two different definitions of "new", which caused discrepancies (e.g. CASHCAT showing on the home rail but not under the "New" tab):

  • Recently Added rail: markets listed within the last 30 days (listedAt)
  • "New" pill: uncategorized HIP-3 markets (isNewMarket)
    This PR unifies both surfaces on the same "listed within the last 30 days" rule and surfaces "New" more prominently on the home page.

Changes

  • Added a shared isRecentlyListed(listedAt) helper in utils/time.ts so the home rail, the market-list filter, and the badge all use one definition.
  • Switched the 'new' filter and the new market count in usePerpsMarketListView, and the badge visibility in useHasNewMarkets, from isNewMarket to the 30-day listedAt rule.
  • Added a "New" pill to the home Products section, shown only when recent markets exist. Tapping it opens the market list filtered to "New" (reuses existing navigation + analytics).
  • Uncategorized markets older than 30 days remain reachable via the existing "All" pill (no change needed).
  • Kept the existing Recently Added rail; it's now consistent with the "New" tab it links to.

Out of scope

  • The weekly job to identify uncategorized markets (backend/Terminal side).
  • The controller's isNewMarket semantics are untouched — mobile just stops filtering on it.

Changelog

CHANGELOG entry: merge recently added and new filter logic for perps markets
CHANGELOG entry: add "new" pill to perps products

Related issues

Fixes:

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

Screen.Recording.2026-07-14.at.3.01.02.PM.mov

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
Changes user-visible market filtering and pill visibility across several Perps surfaces; logic is centralized but semantics shift away from isNewMarket.

Overview
Perps “New” is no longer driven by isNewMarket; home, market list, and badges now share isRecentlyListed(listedAt) (listed within the last 30 days).

utils/time.ts adds that helper and wires it into useHasNewMarkets, the new filter and marketCounts.new in usePerpsMarketListView, and the home Recently added rail in usePerpsHomeData. NEW_CATEGORY is exported from usePerpsCategories so category badges and products use the same id/label.

PerpsProducts prepends a New pill when recent listings exist (via useHasNewMarkets); tapping navigates to the market list with defaultMarketTypeFilter: 'new'. Tests cover the new time-based behavior and product pill visibility/navigation.

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

@metamask-ci metamask-ci Bot added the team-perps Perps team label Jul 14, 2026
@metamask-ci

metamask-ci Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Related issues section is empty. Add Fixes: #123 / Closes: <URL> / Refs: <Jira key>, or write a short rationale after the colon.
  • Manual testing steps still contain template content (the Gherkin example title or a [...] placeholder). Replace with real steps, or write N/A — <reason>.
  • Pre-merge author checklist has unchecked items (e.g. "I've tested on Android"). Every box must be consciously checked — see docs/readme/ready-for-review.md.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@gambinish gambinish marked this pull request as ready for review July 14, 2026 22:05
@gambinish gambinish requested a review from a team as a code owner July 14, 2026 22:05
@github-actions github-actions Bot added the risk:medium AI analysis: medium risk label Jul 14, 2026
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

🧪 Flaky unit test detection

Run history flaky detection

View recent run history

Historical failure rate is a hint, not proof — review each suggestion in context. See the flaky-test-detection skill for the full pattern reference and manual audit workflow.

Failures / runs sampled per window:

File 7d 15d 30d
app/components/UI/Perps/hooks/useHasNewMarkets.test.ts 0/91 0/179 0/365

AI-detected flaky patterns

app/components/UI/Perps/hooks/useHasNewMarkets.test.ts

  • J3 — Missing jest.clearAllMocks() / resetAllMocks() between tests (high)
    • beforeEach only mocks Date.now but omits jest.clearAllMocks(). Module mocks (usePerpsMarkets) and any call counts can therefore leak across tests, creating order-dependent behavior that matches the J3 shared-mock-state pattern. The second file already includes clearAllMocks in its beforeEach and contains no other J1-J10 matches (no waitFor, no fake-timers+waitFor, no mutable lets, no unstubbed Date.now, no arbitrary sleeps). History JSON showed zero failures for both files, so historicalHintUsed=false. No other concrete pattern matches found in either file.
    • Suggested fix in app/components/UI/Perps/hooks/useHasNewMarkets.test.ts:
      -  beforeEach(() => {
      -    jest.spyOn(Date, 'now').mockReturnValue(NOW);
      -  });
      +  beforeEach(() => {
      +    jest.clearAllMocks();
      +    jest.spyOn(Date, 'now').mockReturnValue(NOW);
      +  });

This check is informational only and does not block merging.

@github-actions github-actions Bot added risk:low AI analysis: low risk and removed risk:medium AI analysis: medium risk labels Jul 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
All 12 changed files are within the Perps UI component tree (app/components/UI/Perps/). The changes refactor how the "New" market category is determined:

  1. time.ts: New isRecentlyListed() utility wraps isWithinLast30Days() with an undefined guard, consolidating the 30-day criterion.
  2. useHasNewMarkets.ts: Switches from market.isNewMarket flag to isRecentlyListed(market.listedAt) - changes when the "New" badge appears.
  3. usePerpsCategories.ts: Exports NEW_CATEGORY constant (moved from PerpsMarketCategoryBadges) for shared use.
  4. usePerpsHomeData.ts: Uses isRecentlyListed instead of inline isWithinLast30Days with undefined check.
  5. usePerpsMarketListView.ts: Changes 'new' filter from market.isNewMarket to isRecentlyListed(market.listedAt), and updates market count logic.
  6. PerpsMarketCategoryBadges.tsx: Removes local NEW_CATEGORY definition, imports from shared hook.
  7. PerpsProducts.tsx: Adds useHasNewMarkets + NEW_CATEGORY to show "New" pill on home screen.

SmokePerps: Directly impacted - Perps market category filtering, "New" badge/pill visibility, and market list view filtering are all changed. The core logic for what constitutes a "new" market has changed from a boolean flag to a time-based calculation.

SmokeWalletPlatform: Per tag description, "changes to Perps views (headers, lists, full views, e.g. PerpsHomeView, PerpsMarketListView) affect Trending." The PerpsProducts component (home pills) and PerpsMarketListView hook are both changed.

SmokeConfirmations: Per SmokePerps tag description, "Add Funds deposits are on-chain transactions - when selecting SmokePerps, also select SmokeConfirmations."

Test files (.test.tsx/.test.ts) are also changed but these are unit tests, not E2E smoke specs - they don't affect tag selection directly.

Performance Test Selection:
The usePerpsMarketListView and usePerpsHomeData hooks are changed - these drive the Perps market loading and filtering logic. The @PerformancePreps tag covers 'perps market loading, position management, add funds flow, and order execution'. The change from isNewMarket flag to isRecentlyListed() time-based calculation in market filtering could affect rendering performance of the market list. This warrants a performance check to ensure the new time-based filtering doesn't introduce measurable overhead.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown
Contributor

⚡ Performance Test Results

ℹ️ Performance test results are currently non-blocking and will not block this PR.

All tests passed · 2 tests · 1 device

📱 Devices tested (1)

Android: Google Pixel 8 Pro (v14.0)

✅ Passed Tests (2)
Test Platform Device Duration Team Recording
Perps add funds Android Google Pixel 8 Pro (v14.0) 8.71s @mm-perps-engineering-team 📹 Watch
Perps open position and close it Android Google Pixel 8 Pro (v14.0) 14.51s @mm-perps-engineering-team 📹 Watch

Branch: feat/perps-new-recently-added-consolidation · Build: Normal · Commit: e22921a · View full run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low AI analysis: low risk size-M team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant