fix: persist agent run ratings and surface aggregate on agent cards - #769
fix: persist agent run ratings and surface aggregate on agent cards#769Quantumboy80 wants to merge 4 commits into
Conversation
|
@Quantumboy80 is attempting to deploy a commit to the aditthyass' projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Note
|
| Layer / File(s) | Summary |
|---|---|
Ratings persistence and synchronization src/lib/useAgentRatings.js |
Loads and saves per-agent ratings in localStorage, synchronizes hook instances through listeners, and exposes rating and aggregation functions. |
Rating submission wiring src/components/RunRating.jsx, src/components/AgentRunner.jsx, src/pages/WorkflowRunner.jsx |
RunRating persists ratings for its agentId; both runner call sites pass the relevant agent identifier. |
Rating display on cards src/components/AgentCard.jsx |
Computes aggregate ratings and conditionally renders a percentage badge with a total-count tooltip beside the provider badge. |
Estimated code review effort: 2 (Simple) | ~15 minutes
Sequence Diagram(s)
sequenceDiagram
participant User
participant RunRating
participant useAgentRatings
participant localStorage
participant AgentCard
User->>RunRating: click thumbs up/down
RunRating->>useAgentRatings: rateAgent(agentId, value)
useAgentRatings->>localStorage: save updated counts
useAgentRatings-->>AgentCard: synchronized rating state
AgentCard->>User: display percentage badge
Possibly related PRs
- AditthyaSS/iloveAgents#781: Updates the same rating persistence hook,
RunRatingagent association, and runner integrations.
Suggested labels: level:intermediate
Suggested reviewers: AditthyaSS
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title clearly summarizes the main change: persisted agent ratings and an aggregate badge on agent cards. |
| Linked Issues check | ✅ Passed | The changes satisfy #675 by persisting per-agent ratings, wiring agent IDs through both flows, and surfacing an aggregate rating on AgentCard. |
| Out of Scope Changes check | ✅ Passed | The modified files stay focused on the rating persistence and display work with no clear unrelated additions. |
| 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.
Comment @coderabbitai help to get the list of available commands.
|
Hey @Quantumboy80! 👋
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@src/lib/useAgentRatings.js`:
- Around line 15-17: The saveRatings helper currently writes directly to
localStorage via setItem, which can throw and break the rating flow. Update
saveRatings to catch write failures around the localStorage.setItem call and
handle them safely, keeping the rest of the useAgentRatings behavior intact.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 1ee61056-8f34-4fc7-b9e2-9b6369440aab
📒 Files selected for processing (5)
src/components/AgentCard.jsxsrc/components/AgentRunner.jsxsrc/components/RunRating.jsxsrc/lib/useAgentRatings.jssrc/pages/WorkflowRunner.jsx
There was a problem hiding this comment.
❌ Build is failing on this PR.
Please fix before merging:
- Run
npm run buildlocally - Fix any errors shown
- Push your fix — the check will re-run automatically
Most common issue: broken registry import.
Replace:
import agents from '../agents/registry'
With:
import { useAgents } from '../lib/useAgents'
const { agents } = useAgents()
See CONTRIBUTING.md for help. 🙏
|
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
…bit review feedback — setItem can throw in private browsing or when storage quota is exceeded.
What does this PR do?
RunRating (the 👍/👎 prompt shown after every agent run) collected feedback but never persisted it — the vote lived in local component state only and vanished the moment the component unmounted. Both call sites rendered with no props at all, so there was also no way to associate a rating with a specific agent even if it had been saved.
This PR wires it up properly:
Adds src/lib/useAgentRatings.js, a localStorage-backed hook mirroring the existing useFavorites.js pattern (same cross-component sync approach). Stores { [agentId]: { up, down } } under ila_ratings.
RunRating now accepts an agentId prop and calls rateAgent() on click instead of discarding the vote.
AgentRunner.jsx and WorkflowRunner.jsx now pass the relevant agentId through to RunRating.
AgentCard.jsx shows a 👍 XX% badge next to the provider badge, only once an agent has received at least one rating.
No new dependencies, no backend — fully consistent with the existing client-side/localStorage architecture already used for favorites and history.
Note: unrelated to the marketplace listing star-ratings (marketplace.js) that recently landed — that rates published listings; this rates individual run outputs, regardless of whether the agent is published.
Closes #675
Type of change
Checklist
npm run buildlocally and it passed ✅import agents from '../agents/registry'✅Screenshots (if UI change)
Rating badge on AgentCard (bottom-right, next to provider badge), only shown once an agent has ≥1 rating:
👍 100% — small pill, same style/sizing as the existing provider badge, light/dark theme aware.
Summary by CodeRabbit
New Features
Bug Fixes