Skip to content

feat(widget): add api-backed activity filters by yield category#542

Merged
Philippoes merged 1 commit into
mainfrom
feat/activity-api-filters
Jun 18, 2026
Merged

feat(widget): add api-backed activity filters by yield category#542
Philippoes merged 1 commit into
mainfrom
feat/activity-api-filters

Conversation

@petar-omni

@petar-omni petar-omni commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Fetch filter tabs and counts from the actions API using yieldTypes and SUCCESS/FAILED statuses. Prefetch filtered lists so tab switches feel instant in details and dashboard activity views.

Summary by CodeRabbit

  • New Features
    • Prefetches activity filter options to speed up switching between Stake, DeFi, and RWA.
  • Bug Fixes
    • Improved “no previous activity” empty-state rendering and more reliable activity list visibility.
    • Updated list rendering/count behavior to better match API results.
  • Refactor
    • Restructured activity filtering and how filter state is managed across the Activity page.
    • Updated activity action fetching to support the new filter categories.
  • Other
    • Adjusted default yield grouping behavior based on dashboard variant.

@changeset-bot

changeset-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: c5038bc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 662217dd-e4f4-4c1a-92c8-56cf3f7b4d27

📥 Commits

Reviewing files that changed from the base of the PR and between a55d805 and c5038bc.

📒 Files selected for processing (12)
  • packages/widget/src/hooks/api/use-activity-actions.ts
  • packages/widget/src/pages-dashboard/activity/activity.page.tsx
  • packages/widget/src/pages/details/activity-page/activity-filters.ts
  • packages/widget/src/pages/details/activity-page/activity.page.tsx
  • packages/widget/src/pages/details/activity-page/hooks/use-activity-filters.ts
  • packages/widget/src/pages/details/activity-page/hooks/use-activity-page.tsx
  • packages/widget/src/pages/details/activity-page/state/activity-page.context.tsx
  • packages/widget/src/pages/details/activity-page/state/types.ts
  • packages/widget/src/providers/settings/index.tsx
  • packages/widget/src/providers/settings/types.ts
  • packages/widget/tests/hooks/activity-actions.test.ts
  • packages/widget/tests/use-cases/renders-initial-page.test.tsx
🚧 Files skipped from review as they are similar to previous changes (10)
  • packages/widget/src/pages/details/activity-page/state/types.ts
  • packages/widget/src/pages/details/activity-page/activity.page.tsx
  • packages/widget/tests/hooks/activity-actions.test.ts
  • packages/widget/src/providers/settings/types.ts
  • packages/widget/src/pages/details/activity-page/state/activity-page.context.tsx
  • packages/widget/src/pages/details/activity-page/activity-filters.ts
  • packages/widget/src/pages-dashboard/activity/activity.page.tsx
  • packages/widget/src/pages/details/activity-page/hooks/use-activity-filters.ts
  • packages/widget/src/pages/details/activity-page/hooks/use-activity-page.tsx
  • packages/widget/src/hooks/api/use-activity-actions.ts

📝 Walkthrough

Walkthrough

Activity filtering is moved from client-side ActionYieldDto derivation to server-side API queries. New helpers (getActivityActionsQueryKey, getActivityActionsRequestParams, fetchActivityActionsPage, fetchActivityFilterOptions) are added. The context, hooks, and both activity page UI components are updated to use API-reported filter counts and three boolean show-flags (showActivityContent, showActivityControls, showActivityList). yieldGrouping default logic and two type exports in settings are also adjusted.

Changes

API-driven activity filter refactor

Layer / File(s) Summary
ActivityFilter type and yieldTypes helper
packages/widget/src/pages/details/activity-page/activity-filters.ts
Narrows ActivityFilter to "all" | DashboardYieldCategory, removes ActivityFilterCategory and getActivityFilterCategory, reduces activityFilterCategories to ["stake","defi","rwa"], and adds getActivityFilterYieldTypes to translate a filter to API yieldTypes.
Query-key, request-param, and page-fetch helpers
packages/widget/src/hooks/api/use-activity-actions.ts
Adds typed page shapes, getActivityActionsQueryKey, getActivityActionsRequestParams, fetchActivityActionsPage, and getNextActivityActionsPageParam as reusable building blocks keyed by address/filter/network/yieldTypes; introduces ACTIVITY_ACTION_STATUSES constant and pagination logic.
Filter-options fetcher and prefetch hooks
packages/widget/src/hooks/api/use-activity-actions.ts
Adds fetchActivityFilterOptions (fetches per-category counts, returns only nonzero categories plus conditional "all"), useActivityFilterOptions hook, and usePrefetchActivityActionFilters hook that prefetches infinite pages per filter option.
useActivityFilters refactored to accept precomputed options
packages/widget/src/pages/details/activity-page/hooks/use-activity-filters.ts
Removes derivation of options/filteredData/filteredCount from ActionYieldDto[]; hook now accepts { options: ActivityFilterOption[] } and returns only selectedFilter and setSelectedFilter.
ActivityPageContext updated with filter state
packages/widget/src/pages/details/activity-page/state/types.ts, packages/widget/src/pages/details/activity-page/state/activity-page.context.tsx
Extends ActivityPageContextType with filterOptions, selectedFilter, and setSelectedFilter; provider initializes filter options, prefetches, and passes selectedFilter to useActivityActions.
useActivityPage show-flags and result shape update
packages/widget/src/pages/details/activity-page/hooks/use-activity-page.tsx
Replaces filteredData/filteredCount with showActivityContent, showActivityControls, showActivityList flags; wires onFilterSelect to context setSelectedFilter; updates showingCount and total.
Activity page UI show-flag rendering and FallbackContent
packages/widget/src/pages/details/activity-page/activity.page.tsx, packages/widget/src/pages-dashboard/activity/activity.page.tsx
Both page components replace pending/length-gated renders with the three show-flags; show FallbackContent when the list is not visible; feed allData ?? [] to VirtualList.
Settings default yieldGrouping and type visibility
packages/widget/src/providers/settings/index.tsx, packages/widget/src/providers/settings/types.ts
Changes yieldGrouping fallback to "flat" when dashboardVariant is set; removes export from YieldGrouping and ResolvedSettingsProps.
Tests for helpers, filter options, and render assertions
packages/widget/tests/hooks/activity-actions.test.ts, packages/widget/tests/use-cases/renders-initial-page.test.tsx
New Vitest suite covers getActivityActionsRequestParams, getActivityActionsQueryKey, and fetchActivityFilterOptions with a mocked ApiClient; initial-page test updates tab absence assertion to use textContent.

Sequence Diagram(s)

sequenceDiagram
  rect rgba(100, 149, 237, 0.5)
    note over ActivityPageContextProvider: Context initialization
    ActivityPageContextProvider->>useActivityFilterOptions: fetch filter options (address, network)
    useActivityFilterOptions->>fetchActivityFilterOptions: parallel count queries per category
    fetchActivityFilterOptions-->>useActivityFilterOptions: nonzero categories + "all"
    useActivityFilterOptions-->>ActivityPageContextProvider: filterOptions[]
  end
  rect rgba(144, 238, 144, 0.5)
    note over ActivityPageContextProvider: Prefetch + main fetch
    ActivityPageContextProvider->>usePrefetchActivityActionFilters: prefetch per filterOption
    usePrefetchActivityActionFilters->>fetchActivityActionsPage: prefetch infinite pages per filter
    ActivityPageContextProvider->>useActivityActions: fetch with selectedFilter
    useActivityActions->>fetchActivityActionsPage: getActivityActionsRequestParams(filter)
    fetchActivityActionsPage-->>useActivityActions: typed page {data, total}
  end
  rect rgba(255, 165, 0, 0.5)
    note over useActivityPage: Derived flags
    useActivityPage->>ActivityPageContextProvider: read filterOptions, selectedFilter, activityActions
    useActivityPage-->>ActivityPageUI: showActivityContent, showActivityControls, showActivityList
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • stakekit/widget#527: Introduces getApiYieldTypesForDashboardCategory and the DashboardYieldCategory model that this PR's getActivityFilterYieldTypes and narrowed ActivityFilter type directly depend on.
  • stakekit/widget#525: Refactors the activity filter and actions code path, including activity-filters.ts and use-activity-actions.ts, with overlapping changes to the filter model and request shaping.
  • stakekit/widget#520: Modifies the activity actions pipeline to enrich actions with per-action validator data via getItemsWithValidators, which the main PR's fetchActivityActionsPage also uses.

Suggested reviewers

  • dnehl
  • Philippoes
  • xhakti

🐇 Hops past the old client-side filter stash,
Now the server counts what's staked, DeFi, or RWA flash.
Query keys are keyed, the prefetch is spry,
Show-flags replace the pending-length spy.
No borrow, no fuss — the bunny waves goodbye! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete. It lacks the required 'Added' and 'Changed' sections from the template, providing only a brief summary instead of structured sections. Reorganize the description using the template format with distinct 'Added' and 'Changed' sections that detail the new functionality and modifications made.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: adding API-backed activity filters organized by yield category to the widget.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/activity-api-filters

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

@aws-amplify-eu-central-1

Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-542.d2ribjy8evqo6h.amplifyapp.com

@aws-amplify-eu-central-1

Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-542.df4xyoi0xyeak.amplifyapp.com

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/widget/src/hooks/api/use-activity-actions.ts (1)

340-374: 💤 Low value

Consider removing useMemo per React Compiler guidelines.

With React Compiler enabled, manual memoization for render-performance optimization is unnecessary. The flatMap computation should be auto-memoized by the compiler. If semantic stability is required for downstream consumers (e.g., VirtualList's data prop identity), this could be an exception—but worth verifying if the memoization is truly needed or if the compiler handles it.

As per coding guidelines: "React Compiler is enabled. Do not add useMemo, useCallback, or React.memo only for render-performance optimization; prefer plain values/functions."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/widget/src/hooks/api/use-activity-actions.ts` around lines 340 -
374, The useActivityActions hook uses useMemo to memoize the flatMap computation
for allItems, but with React Compiler enabled, manual memoization for
render-performance optimization is unnecessary. Remove the useMemo wrapper
around the allItems variable definition and replace it with a direct computation
of the flattened data from query.data?.pages. However, first verify that
downstream consumers (such as VirtualList or other components using the allItems
prop) do not require memoization for semantic stability of the data prop
identity; if they do require it, document this as an exception to the guideline.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/widget/tests/use-cases/renders-initial-page.test.tsx`:
- Around line 170-175: The test is using optional chaining with a fallback to an
empty string when accessing the tabs section's text content, which allows the
test to pass even if the tabsSection element is missing from the DOM. Add an
explicit assertion immediately after querying the tabsSection element (after the
querySelector call) to ensure that tabsSection exists before attempting to
access its textContent property. This will prevent the test from silently
passing when the tabs container is not rendered.

---

Nitpick comments:
In `@packages/widget/src/hooks/api/use-activity-actions.ts`:
- Around line 340-374: The useActivityActions hook uses useMemo to memoize the
flatMap computation for allItems, but with React Compiler enabled, manual
memoization for render-performance optimization is unnecessary. Remove the
useMemo wrapper around the allItems variable definition and replace it with a
direct computation of the flattened data from query.data?.pages. However, first
verify that downstream consumers (such as VirtualList or other components using
the allItems prop) do not require memoization for semantic stability of the data
prop identity; if they do require it, document this as an exception to the
guideline.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5c4c0981-d0b8-4b66-9edc-16ddd21ddfb0

📥 Commits

Reviewing files that changed from the base of the PR and between c52d6b4 and a55d805.

📒 Files selected for processing (12)
  • packages/widget/src/hooks/api/use-activity-actions.ts
  • packages/widget/src/pages-dashboard/activity/activity.page.tsx
  • packages/widget/src/pages/details/activity-page/activity-filters.ts
  • packages/widget/src/pages/details/activity-page/activity.page.tsx
  • packages/widget/src/pages/details/activity-page/hooks/use-activity-filters.ts
  • packages/widget/src/pages/details/activity-page/hooks/use-activity-page.tsx
  • packages/widget/src/pages/details/activity-page/state/activity-page.context.tsx
  • packages/widget/src/pages/details/activity-page/state/types.ts
  • packages/widget/src/providers/settings/index.tsx
  • packages/widget/src/providers/settings/types.ts
  • packages/widget/tests/hooks/activity-actions.test.ts
  • packages/widget/tests/use-cases/renders-initial-page.test.tsx

Comment thread packages/widget/tests/use-cases/renders-initial-page.test.tsx Outdated
@petar-omni petar-omni force-pushed the feat/activity-api-filters branch from a55d805 to 3afdd03 Compare June 18, 2026 09:30
Fetch filter tabs and counts from the actions API using yieldTypes and
SUCCESS/FAILED statuses. Prefetch filtered lists so tab switches feel
instant in details and dashboard activity views.
@petar-omni petar-omni force-pushed the feat/activity-api-filters branch from 3afdd03 to c5038bc Compare June 18, 2026 09:37
@Philippoes Philippoes merged commit 5752e9f into main Jun 18, 2026
8 checks passed
@Philippoes Philippoes deleted the feat/activity-api-filters branch June 18, 2026 11:08
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.

3 participants