fix(ui): hide invalid GitHub star count#7988
Conversation
|
@ShivanshTiwari01 is attempting to deploy a commit to the Prisma Team on Vercel. A member of the Team first needs to authorize it. |
Walkthrough
StarCount visibility fix
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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
🤖 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/ui/src/components/star-count.tsx`:
- Around line 20-21: The visibility guard in star-count rendering is now relying
only on the numeric value from useStarCount, but useStarCount can retain the
previous starCount on a failed re-fetch and only set error. Update
star-count.tsx and the useStarCount hook so stale positive counts do not remain
visible after fetch failures, either by keeping error as part of isHidden or by
clearing starCount on fetch start/failure in use-star-count.ts so the
numeric-only check stays accurate.
🪄 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
Run ID: 9071c376-3ed6-43ef-9c32-cc8180d55318
📒 Files selected for processing (1)
packages/ui/src/components/star-count.tsx
| const { starCount, isLoading } = useStarCount(); | ||
| const isHidden = !isLoading && (!Number.isFinite(starCount) || starCount <= 0); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Don't drop the fetch error from the visibility guard yet.
packages/ui/src/hooks/use-star-count.ts:10-39 still leaves the previous starCount intact on fetch failure and only sets error. With this change, any failed re-fetch after a successful load will keep rendering a stale positive badge instead of hiding the unavailable count. Either keep error in isHidden, or clear starCount in the hook on fetch start/failure so this numeric-only check is actually sound.
🤖 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/ui/src/components/star-count.tsx` around lines 20 - 21, The
visibility guard in star-count rendering is now relying only on the numeric
value from useStarCount, but useStarCount can retain the previous starCount on a
failed re-fetch and only set error. Update star-count.tsx and the useStarCount
hook so stale positive counts do not remain visible after fetch failures, either
by keeping error as part of isHidden or by clearing starCount on fetch
start/failure in use-star-count.ts so the numeric-only check stays accurate.
What changed
Updates the navbar GitHub star count to hide the numeric value when the fetched count is zero, negative, or invalid.
Why
When the unauthenticated GitHub API request fails — for example, because of rate limiting — the star count remains
0. The component previously formatted that value as00.0K.The GitHub link now remains visible while the unavailable numeric count is hidden.
Closes #7987.
Testing
00.0K.Scope
This changes only
packages/ui/src/components/star-count.tsx.Summary by CodeRabbit