feat(comments): point an empty thread at the badge behind it - #40
Merged
Conversation
"No replies yet. Yours would be the first." is true and does nothing. The thread with nothing in it is the one place where telling somebody what a reply is worth might actually get one written, and the site already knows the answer: badge_progress holds the same counter the grant triggers read. So the empty line now carries it. Somebody with no comment badge is told a reply earns First Reply I. Somebody who has it is told how many threads they are off First Reply II, with the real number rather than a nudge in general terms. Nobody is offered a badge they already have, and a reader who is signed out or has finished the family gets the plain line back. The rule is the shelf's own next step narrowed to one family, so the badge named here and the plaque on the profile can never disagree. It only runs on an empty thread for a signed in reader, which keeps two extra queries off every thread that already has replies in it, and every failure path returns null: a nudge is a nicety and is never a reason for a thread to fail to load. Copy lives in thread.ts and the counter nouns in shelf.ts, both because the arithmetic and the plurals are the parts worth testing and both files already run under plain node. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5e5a689-2285-4421-b2b5-b348df97b055
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
An empty comment thread used to say "No replies yet. Yours would be the first." True, and it does nothing. Now it names the comment badge the reader is next in line for, with the real number attached.
Why
The thread with nothing in it is the one place where telling somebody what a reply is worth might actually get one written, and the site already knows the answer.
badge_progressholds the same counter the grant triggers read, so the number quoted here cannot drift from the one that hands the badge over.Nobody is told they are one reply off something they already have, which was the whole point of doing this against real progress rather than hardcoding a sentence about the badge.
How
nextStep(shelf, progress, family)is the shelf's own "next step" rule fromshapeShelf, narrowed to a single family. Same rule, so the badge named on a thread and the plaque on a profile can never disagree, including the numeral.Tier two counts distinct threads rather than raw replies, so
unitFormaps the counter names to nouns a reader would say and the copy says "threads" where it means threads.The lookup only runs on an empty thread for a signed in reader, which keeps two extra queries off every thread that already has replies. Every failure path returns null and the line falls back to the plain one: a nudge is a nicety and is never a reason for a thread to fail to load.
Files
src/lib/shelf.ts—nextStepandunitForsrc/lib/badges.ts(new) — the one family read, degrading to nullsrc/pages/api/comments.ts— GET returnsnudge, empty threads onlysrc/lib/thread.ts—emptyLine, where the copy and the plural livesrc/components/islands/CommentThread.tsx— renders itCopy and counter nouns sit in the libs rather than the island because the arithmetic and the plurals are the parts worth testing, and both files already run under plain node.
Testing
15 new cases across
tests/shelf.test.mjsandtests/thread.test.mjs. Full suite: 391 passing, 0 failing.astro checkcould not run locally because thesrc/contentsubmodule is empty in this worktree, so the touched TypeScript was type checked directly. CI has the submodule.