feat(agents): add score tier filter chips to agents page - #266
Conversation
|
@iBotayo Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAgentsPage now exposes score-tier filters and sends the selected tier to the agents API. The API filters before sorting and pagination. The page uses filtered totals, resets pagination on tier changes, separates empty states, and adds coverage for these flows. ChangesAgents score tier filter
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant AgentsPage
participant fetchAgents
participant AgentsAPI
User->>AgentsPage: Select a score tier
AgentsPage->>fetchAgents: Request page 0 with tier
fetchAgents->>AgentsAPI: GET /api/agents?tier
AgentsAPI->>AgentsAPI: Filter, sort, and paginate agents
AgentsAPI-->>AgentsPage: Return agents and filtered total
AgentsPage-->>User: Render filtered agents or empty state
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
frontend/__tests__/AgentsPage.test.tsx (1)
128-154: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover every advertised tier.
Despite the test name, it only selects
Trusted. Parameterize this case across New, Building, Established, Trusted, and Elite so each chip’s label, value, and filtering path is exercised.🤖 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 `@frontend/__tests__/AgentsPage.test.tsx` around lines 128 - 154, Parameterize the test case named “filters agents by each score tier” across New, Building, Established, Trusted, and Elite. For each tier, click its corresponding button, assert the expected label and score value, verify the matching agent remains visible, and verify agents from the other tiers are filtered out.
🤖 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 `@frontend/app/agents/page.tsx`:
- Around line 70-84: The agents view incorrectly filters, sorts, and paginates
only the server-provided page. Update the fetchAgents/API contract to accept
activeTier, include activeTier in the SWR key, and return agents plus a total
already filtered and sorted for that tier; then remove the client-side
filteredAgents, sortedAgents, and duplicate pagination logic while preserving
page clamping against the returned total. Add a regression case where total
exceeds agents.length and matching agents exist outside the first page.
---
Nitpick comments:
In `@frontend/__tests__/AgentsPage.test.tsx`:
- Around line 128-154: Parameterize the test case named “filters agents by each
score tier” across New, Building, Established, Trusted, and Elite. For each
tier, click its corresponding button, assert the expected label and score value,
verify the matching agent remains visible, and verify agents from the other
tiers are filtered out.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 1ee3b44a-f43f-43aa-a736-084808c35fba
⛔ Files ignored due to path filters (1)
frontend/package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (2)
frontend/__tests__/AgentsPage.test.tsxfrontend/app/agents/page.tsx
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
backend/src/routes/agents.js (1)
65-71: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winVerify parity with the existing
scoreTier()logic.This adds a separate threshold table instead of reusing the existing classifier described in the PR objective. If the boundaries diverge, the API filter can disagree with the tier labels shown by
frontend/app/agents/page.tsx. Verify boundary cases such as 299/300, 599/600, 899/900, and 999/1000, then centralize or test the mapping.🤖 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 `@backend/src/routes/agents.js` around lines 65 - 71, Update getAgentTier to reuse the existing scoreTier classifier rather than maintaining a separate threshold table, ensuring API filtering matches frontend tier labels at all boundaries. If direct reuse is unavailable, centralize the shared mapping and add coverage for 299/300, 599/600, 899/900, and 999/1000.
🤖 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 `@frontend/app/agents/page.tsx`:
- Line 61: Update the hasAnyAgents logic in the agent page to use data.total > 0
as the primary indicator that agents exist, so a missing or failed
fetchAgentStats() request cannot suppress the grid. Keep stats?.totalAgents only
for selecting the appropriate zero-result empty state after stats is available,
and preserve the existing rendering conditions around the agent grid.
---
Nitpick comments:
In `@backend/src/routes/agents.js`:
- Around line 65-71: Update getAgentTier to reuse the existing scoreTier
classifier rather than maintaining a separate threshold table, ensuring API
filtering matches frontend tier labels at all boundaries. If direct reuse is
unavailable, centralize the shared mapping and add coverage for 299/300,
599/600, 899/900, and 999/1000.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 86368b10-a22b-41e9-afad-5cdc2d185e0f
📒 Files selected for processing (4)
backend/src/routes/agents.jsfrontend/__tests__/AgentsPage.test.tsxfrontend/app/agents/page.tsxfrontend/lib/contract.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- frontend/tests/AgentsPage.test.tsx
|
Hi @iBotayo, This PR could not be merged because it has merge conflicts with the target branch. Please resolve the merge conflicts, push the updated changes, and the PR can be reviewed and merged. Thank you! |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
frontend/lib/contract.ts (1)
133-140: 🎯 Functional Correctness | 🔴 CriticalAdd
tierto thefetchAgentsparameter list.
fetchAgentsreadstieron line 138 but only declarespage,pageSize, andsort. Addtier: ScoreTier | 'all' = 'all'as the fourth parameter so theAgentsPagecall passes the selected tier and unchanged callers still work.[low Effort_and_high_reward]
🤖 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 `@frontend/lib/contract.ts` around lines 133 - 140, Add tier as the fourth parameter of fetchAgents, typed as ScoreTier | 'all' with a default of 'all', so the existing tierQuery logic uses the selected value while callers omitting it remain unchanged.
🤖 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.
Outside diff comments:
In `@frontend/lib/contract.ts`:
- Around line 133-140: Add tier as the fourth parameter of fetchAgents, typed as
ScoreTier | 'all' with a default of 'all', so the existing tierQuery logic uses
the selected value while callers omitting it remain unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 4512db41-9f05-4856-b837-c6658dca9e1c
📒 Files selected for processing (2)
backend/src/routes/agents.jsfrontend/lib/contract.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- backend/src/routes/agents.js
|
Hi @ritik4ever, |
Summary
Adds score tier filtering to the Agents page, allowing users to quickly narrow the list of agents by their computed score tier while preserving the existing sorting functionality.
Closes #34
Changes Made
Score Tier Filters
Added filter chips for:
Reused the existing
scoreTier()logic to determine each agent's tier.Preserved existing sorting options (
score,payments, andnewest) when filters are applied.User Experience
State Management
Tests
Added or updated automated tests covering:
Documentation
Updated documentation and related references where the new filtering behavior affects usage.
Files Updated
frontend/app/agents/page.tsxfrontend/components/AgentCard.tsxfrontend/lib/types.ts(if required)Acceptance Criteria
Notes
This implementation reuses the existing score tier calculation and integrates filtering into the current agent listing flow without modifying the underlying scoring algorithm or introducing unrelated changes.
Summary by CodeRabbit