feat(widget): add api-backed activity filters by yield category#542
Conversation
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (12)
🚧 Files skipped from review as they are similar to previous changes (10)
📝 WalkthroughWalkthroughActivity filtering is moved from client-side ChangesAPI-driven activity filter refactor
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
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
packages/widget/src/hooks/api/use-activity-actions.ts (1)
340-374: 💤 Low valueConsider removing
useMemoper React Compiler guidelines.With React Compiler enabled, manual memoization for render-performance optimization is unnecessary. The
flatMapcomputation 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, orReact.memoonly 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
📒 Files selected for processing (12)
packages/widget/src/hooks/api/use-activity-actions.tspackages/widget/src/pages-dashboard/activity/activity.page.tsxpackages/widget/src/pages/details/activity-page/activity-filters.tspackages/widget/src/pages/details/activity-page/activity.page.tsxpackages/widget/src/pages/details/activity-page/hooks/use-activity-filters.tspackages/widget/src/pages/details/activity-page/hooks/use-activity-page.tsxpackages/widget/src/pages/details/activity-page/state/activity-page.context.tsxpackages/widget/src/pages/details/activity-page/state/types.tspackages/widget/src/providers/settings/index.tsxpackages/widget/src/providers/settings/types.tspackages/widget/tests/hooks/activity-actions.test.tspackages/widget/tests/use-cases/renders-initial-page.test.tsx
a55d805 to
3afdd03
Compare
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.
3afdd03 to
c5038bc
Compare
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