Skip to content

fix(ui): hide invalid GitHub star count#7988

Open
ShivanshTiwari01 wants to merge 1 commit into
prisma:mainfrom
ShivanshTiwari01:fix/7987-navbar-github-star-count
Open

fix(ui): hide invalid GitHub star count#7988
ShivanshTiwari01 wants to merge 1 commit into
prisma:mainfrom
ShivanshTiwari01:fix/7987-navbar-github-star-count

Conversation

@ShivanshTiwari01

@ShivanshTiwari01 ShivanshTiwari01 commented Jun 29, 2026

Copy link
Copy Markdown

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 as 00.0K.

The GitHub link now remains visible while the unavailable numeric count is hidden.

Closes #7987.

Testing

  • Ran the Prisma website locally.
  • Verified that a valid positive star count remains visible.
  • Verified that a rate-limited GitHub API response no longer renders 00.0K.
  • Verified that the GitHub icon and link remain available when the count is hidden.

Scope

This changes only packages/ui/src/components/star-count.tsx.

Summary by CodeRabbit

  • Bug Fixes
    • Improved star count display behavior so invalid values are hidden.
    • Star counts now stay hidden while loading and when the value is zero, negative, or non-finite.
    • Rendering and formatting otherwise remain unchanged.

@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

@ShivanshTiwari01 is attempting to deploy a commit to the Prisma Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

StarCount drops the error field from useStarCount and replaces the isHidden condition: previously it hid on error or starCount <= 0; now it hides when starCount is not finite (covers NaN/Infinity) or <= 0.

StarCount visibility fix

Layer / File(s) Summary
isHidden guard for non-finite values
packages/ui/src/components/star-count.tsx
Removes error from useStarCount destructuring and updates isHidden to !isFinite(starCount) || starCount <= 0, suppressing display of NaN/Infinity values like 00.0k.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 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 is concise and accurately describes the main change: hiding invalid GitHub star counts.
Linked Issues check ✅ Passed The change matches issue #7987 by hiding zero, negative, and invalid counts instead of rendering 00.0k.
Out of Scope Changes check ✅ Passed The diff is narrowly scoped to the star-count component and adds no unrelated behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

🤖 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

📥 Commits

Reviewing files that changed from the base of the PR and between 2b9e901 and c87ea88.

📒 Files selected for processing (1)
  • packages/ui/src/components/star-count.tsx

Comment on lines +20 to +21
const { starCount, isLoading } = useStarCount();
const isHidden = !isLoading && (!Number.isFinite(starCount) || starCount <= 0);

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.

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Navbar GitHub stars display shows 00.0k

1 participant