You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: show the total stars a user received on their profile - #278
Shows the total stars a user's commits and replies received from other developers in the profile stats row, next to commits, following and followers.
It reads "1 star" or "N stars", and totals past a thousand are shortened with the shared formatCount from feat: short numbers where needed #410, like the sidebar and star buttons: 1.3k, 12.3k, 1.2m, 5b.
It updates as soon as someone stars or unstars one of the user's commits on the page, without a reload, the same way the pastéis received count does.
Why
Stars are the engagement action on /dev/null, but today they only show up per commit. The total gives a quick sense of how a developer's commits land with others, and the achievements already count it for XP and the Superstar badge without ever showing the number itself.
How it works
UserStarsCountQuery counts the stars on the user's commits that the viewer can see, from other developers only. Guests count approved commits only, and deleted commits are left out.
It is now the one place this number is counted. UserAchievementsQuery uses it for stars received, and UserController@show computes it once per request and shares it between the starsCount prop and the achievements, the same way it already shares the streaks. A test asserts the count query runs once.
starsCount is a lazy prop, so reloading the commit feed doesn't recompute it, and it stays out of loadCounts, which runs for the sidebar on every request.
Starring and unstarring now also return author: { id, stars_received }. The stars_received field is registered in commit-state.ts, so the profile's shared state picks up the new total like it does for pasteis_received.
The total is shown with formatCount from resources/js/lib/numbers.ts (feat: short numbers where needed #410), so it reads the same as the other short counts. Singular and plural follow the exact count.
The stats row now wraps (flex-wrap) instead of overflowing. With four stats it no longer fits on one line below about 380px, and on 320px and 360px screens the page used to scroll sideways.
PRODUCT.md describes the new count.
Not in this PR
The hover card, the public API, the link preview image and the profile's structured data still show only commits and followers. Adding stars there changes public output, so it is better as a follow-up if wanted.
The other stats (commits, following, followers) are still shown in full, as today.
formatCount rounds, so 999,999 reads 1m. Truncating instead (999.9k) would keep a count from reading higher than it is; that belongs in formatCount itself, for every count at once, so it is left for a separate PR.
The achievements shelf still updates on the next page load, not live, as before.
Screenshots
Profile
Light
Dark
Mobile, light
Mobile, dark
Live update
Starring a commit on the profile takes the total from 13 to 14 with no reload and no layout shift.
Before
After starring
Singular and plural
1 star
13 stars
Large totals
Rendered by the real page, with starsCount swapped in the browser instead of creating millions of stars in the database.
Total
Shown
999
1,000
1,250
1,999
12,345
999,999
1,234,567
5,000,000,000
Narrow screens
A wide total like 999.9k wraps to its own line instead of pushing the page sideways.
390px
360px
320px
Tests
UserStarsCountQueryTest: replies, visibility per viewer, deleted commits, self-stars.
CommitStarControllerTest: starring returns the author's new total; the existing exact-JSON assertions in CommitStarCountControllerTest and RateLimitTest include the new author field.
UserControllerTest: starsCount for signed-in users and guests, not computed when only commits reloads, and counted once for the stats and the achievements.
Verification
Pest with --coverage --exactly=100.0 (all 2,551 tests), the JS unit tests, test:types, Pint, Rector and bun run test:lint pass locally.
In Chromium: 1440×900, 1366×650, 390×844, 360×740 and 320×568, in light and dark. No horizontal overflow, and no layout shift on load or when starring and unstarring.
Compared with production at the same sizes: the stats row keeps its height, and only wraps to a second line on narrow phones.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Out-of-order star responses can overwrite a newer profile total with an older count.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Concurrent commit stars can overwrite the profile total out of order
resources/js/lib/commit-state.ts:9
Concurrent stars on two different commits by the same author can leave the profile total incorrect. createCommitStarMutations guards requests per commit, but collect and refreshSharedState apply this author-wide total unconditionally. If responses containing totals 14 and 15 arrive in reverse order, the profile ends at 14 even though both stars succeeded. Profile tab reloads omit starsCount, so switching tabs does not correct it. Serialize star mutations per author, or return and check an author-level revision before applying totals. Add a regression test that delivers the responses in reverse order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #434
Summary
Shows the total stars a user's commits and replies received from other developers in the profile stats row, next to commits, following and followers.
formatCountfrom feat: short numbers where needed #410, like the sidebar and star buttons: 1.3k, 12.3k, 1.2m, 5b.Why
Stars are the engagement action on /dev/null, but today they only show up per commit. The total gives a quick sense of how a developer's commits land with others, and the achievements already count it for XP and the Superstar badge without ever showing the number itself.
How it works
UserStarsCountQuerycounts the stars on the user's commits that the viewer can see, from other developers only. Guests count approved commits only, and deleted commits are left out.UserAchievementsQueryuses it for stars received, andUserController@showcomputes it once per request and shares it between thestarsCountprop and the achievements, the same way it already shares the streaks. A test asserts the count query runs once.starsCountis a lazy prop, so reloading the commit feed doesn't recompute it, and it stays out ofloadCounts, which runs for the sidebar on every request.author: { id, stars_received }. Thestars_receivedfield is registered incommit-state.ts, so the profile's shared state picks up the new total like it does forpasteis_received.formatCountfromresources/js/lib/numbers.ts(feat: short numbers where needed #410), so it reads the same as the other short counts. Singular and plural follow the exact count.flex-wrap) instead of overflowing. With four stats it no longer fits on one line below about 380px, and on 320px and 360px screens the page used to scroll sideways.PRODUCT.mddescribes the new count.Not in this PR
formatCountrounds, so 999,999 reads 1m. Truncating instead (999.9k) would keep a count from reading higher than it is; that belongs informatCountitself, for every count at once, so it is left for a separate PR.Screenshots
Profile
Live update
Starring a commit on the profile takes the total from 13 to 14 with no reload and no layout shift.
Singular and plural
Large totals
Rendered by the real page, with
starsCountswapped in the browser instead of creating millions of stars in the database.Narrow screens
A wide total like 999.9k wraps to its own line instead of pushing the page sideways.
Tests
UserStarsCountQueryTest: replies, visibility per viewer, deleted commits, self-stars.CommitStarControllerTest: starring returns the author's new total; the existing exact-JSON assertions inCommitStarCountControllerTestandRateLimitTestinclude the newauthorfield.UserControllerTest:starsCountfor signed-in users and guests, not computed when onlycommitsreloads, and counted once for the stats and the achievements.Verification
--coverage --exactly=100.0(all 2,551 tests), the JS unit tests,test:types, Pint, Rector andbun run test:lintpass locally.