Skip to content

feat(agents): add score tier filter chips to agents page - #266

Open
iBotayo wants to merge 5 commits into
Stellar-Ecosystem:mainfrom
iBotayo:feature/agent-score-tier-filter
Open

feat(agents): add score tier filter chips to agents page#266
iBotayo wants to merge 5 commits into
Stellar-Ecosystem:mainfrom
iBotayo:feature/agent-score-tier-filter

Conversation

@iBotayo

@iBotayo iBotayo commented Jul 24, 2026

Copy link
Copy Markdown

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:

    • All
    • New
    • Building
    • Established
    • Trusted
    • Elite
  • Reused the existing scoreTier() logic to determine each agent's tier.

  • Preserved existing sorting options (score, payments, and newest) when filters are applied.

User Experience

  • Added a clear active state for the selected filter.
  • Ensured filters are fully keyboard accessible.
  • Preserved the existing page layout and styling.

State Management

  • Integrated filtering into the existing agent listing flow.
  • Avoided duplicating agent data.
  • Maintained sorting behavior after filtering.
  • Added support for resetting the filter using the All option.

Tests

Added or updated automated tests covering:

  • Default filter behavior
  • Filtering by each score tier
  • Filter and sort interaction
  • Empty result scenarios
  • Filter reset behavior

Documentation

Updated documentation and related references where the new filtering behavior affects usage.

Files Updated

  • frontend/app/agents/page.tsx
  • frontend/components/AgentCard.tsx
  • frontend/lib/types.ts (if required)
  • Related test files
  • Documentation (where applicable)

Acceptance Criteria

  • Score tier filter chips added
  • Existing sorting preserved
  • All supported score tiers available
  • Filter reset supported
  • Accessibility maintained
  • Tests updated
  • Documentation updated where applicable

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

  • New Features
    • Added interactive score-tier filters to the Agents page.
    • Filtering now keeps sorting, pagination, and result totals synchronized.
    • Added a quick way to return to “All” when no agents match a selected tier.
  • Bug Fixes
    • Improved empty states for unregistered agents and unmatched filters.
    • Agent results now remain visible when statistics loading fails.
  • Tests
    • Expanded coverage for filtering, pagination, sorting, empty states, and reset behavior.

@drips-wave

drips-wave Bot commented Jul 24, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 561b75f9-afe1-466a-b4ab-bf45340d2236

📥 Commits

Reviewing files that changed from the base of the PR and between c5c5293 and d39ff3a.

⛔ Files ignored due to path filters (1)
  • frontend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • frontend/lib/contract.ts

📝 Walkthrough

Walkthrough

AgentsPage 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.

Changes

Agents score tier filter

Layer / File(s) Summary
Tier filter API contract and backend processing
frontend/lib/contract.ts, backend/src/routes/agents.js
Adds the tier query to fetchAgents. The backend classifies, validates, filters, sorts, and paginates agents by tier.
Tier-filtered page flow and rendering
frontend/app/agents/page.tsx
Adds tier state and buttons, passes the tier through SWR requests, recalculates pagination from filtered totals, and renders tier-specific empty states.
Tier filter test coverage
frontend/__tests__/AgentsPage.test.tsx
Adds reusable fixtures and coverage for filtering, sorting, pagination totals, empty results, reset behavior, and rendering when stats loading fails.

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
Loading

Possibly related PRs

Suggested reviewers: ritik4ever

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The feature and frontend coverage meet the filtering objectives, but no automated coverage is shown for the changed backend route. Add or update backend route tests for the tier query parameter, filtering, sorting, pagination, and failure behavior.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly describes the main change: adding score tier filter chips to the Agents page.
Out of Scope Changes check ✅ Passed The changes are limited to score tier filtering, its API support, contract updates, and related frontend tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
frontend/__tests__/AgentsPage.test.tsx (1)

128-154: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover 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

📥 Commits

Reviewing files that changed from the base of the PR and between a3fd824 and d4171a8.

⛔ Files ignored due to path filters (1)
  • frontend/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • frontend/__tests__/AgentsPage.test.tsx
  • frontend/app/agents/page.tsx

Comment thread frontend/app/agents/page.tsx Outdated

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🧹 Nitpick comments (1)
backend/src/routes/agents.js (1)

65-71: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Verify 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

📥 Commits

Reviewing files that changed from the base of the PR and between d4171a8 and d045bf0.

📒 Files selected for processing (4)
  • backend/src/routes/agents.js
  • frontend/__tests__/AgentsPage.test.tsx
  • frontend/app/agents/page.tsx
  • frontend/lib/contract.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/tests/AgentsPage.test.tsx

Comment thread frontend/app/agents/page.tsx Outdated
@ritik4ever

Copy link
Copy Markdown
Collaborator

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!

@iBotayo
iBotayo requested a review from ritik4ever as a code owner August 2, 2026 17:48

@coderabbitai coderabbitai 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.

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 | 🔴 Critical

Add tier to the fetchAgents parameter list.

fetchAgents reads tier on line 138 but only declares page, pageSize, and sort. Add tier: ScoreTier | 'all' = 'all' as the fourth parameter so the AgentsPage call 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

📥 Commits

Reviewing files that changed from the base of the PR and between e79de27 and c5c5293.

📒 Files selected for processing (2)
  • backend/src/routes/agents.js
  • frontend/lib/contract.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • backend/src/routes/agents.js

@iBotayo

iBotayo commented Aug 3, 2026

Copy link
Copy Markdown
Author

Hi @ritik4ever,
Please, review PR and merge.

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

Labels

None yet

Projects

None yet

2 participants