Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/ui/src/components/star-count.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const getStarParts = (starCount: number) => {
};

export const StarCount = ({ className }: StarCountProps) => {
const { starCount, isLoading, error } = useStarCount();
const isHidden = !isLoading && !error && starCount <= 0;
const { starCount, isLoading } = useStarCount();
const isHidden = !isLoading && (!Number.isFinite(starCount) || starCount <= 0);
Comment on lines +20 to +21

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.

const { integer, decimal } = getStarParts(starCount);
const formattedValue = `${String(integer).padStart(2, "0")}.${decimal}K`;

Expand Down