Skip to content

feat(home): surface FreshnessBadge + fail-closed staleness gate (F4)#3173

Open
0motionguy wants to merge 1 commit into
mainfrom
feat/F4-freshness-badge-plus-staleness-gate
Open

feat(home): surface FreshnessBadge + fail-closed staleness gate (F4)#3173
0motionguy wants to merge 1 commit into
mainfrom
feat/F4-freshness-badge-plus-staleness-gate

Conversation

@0motionguy

Copy link
Copy Markdown
Owner

Summary

  • Flip FreshnessBadge default from hidden to visible — readers can tell fresh from stale at a glance. Opt-out via NEXT_PUBLIC_HIDE_FRESHNESS_BADGES=true.
  • Add fail-closed staleness gate on the homepage LiveTopTable: when data is past MAX_PUBLIC_STALENESS_MIN (default 30min), render a "data refreshing" banner instead of the rankings. No publicly stale batches reach users.
  • Implements the user-added hard rule from the ULTRA improvement plan: stale batches do not get rendered as if they were live.

Files

  • src/lib/public-staleness.ts (new) — classifyPublicStaleness() helper returning { isFresh, ageMs, thresholdMs }.
  • src/components/shared/FreshnessBadge.tsx — flip default visibility.
  • src/components/home/LiveTopTable.tsx — guard rankings render on classifyPublicStaleness(); show banner when stale.

Why now

ULTRA improvement plan Phase 4.1 always-ship row F4. Independent of deep-crawl deltas — the FreshnessBadge component is already implemented behind an env flag, and the staleness gate is the user's "no publicly stale batches" rule.

Test plan

  • pnpm tsc --noEmit clean (existing .next/types errors unrelated)
  • Visit / after worker ticks — FreshnessBadge renders next to "showing X / Y" toolbar with current age label.
  • Force stale data (set NEXT_PUBLIC_MAX_PUBLIC_STALENESS_MIN=0 or pass a lastUpdatedAt more than 30min old) → rankings table is replaced by "Data refreshing." banner.
  • Verify the badge can still be hidden with NEXT_PUBLIC_HIDE_FRESHNESS_BADGES=true (opt-out kept).

Evidence

Phase 4.1 always-ship row from the ULTRA improvement plan. Companion to L1 PR #3172 (consensus stale-hide). Together they enforce: no stale row visible publicly anywhere on the homepage.

🤖 Generated with Claude Code

Flip the FreshnessBadge default from hidden to visible — readers
can now tell a 5-min-fresh batch from a 4h-stale one at a glance
without opening the route. The hide flag stays available via
`NEXT_PUBLIC_HIDE_FRESHNESS_BADGES=true`.

Add a fail-closed staleness gate on the homepage rankings card:
when `lastUpdatedAt` is older than `MAX_PUBLIC_STALENESS_MIN`
(default 30min, configurable via NEXT_PUBLIC_MAX_PUBLIC_STALENESS_MIN),
LiveTopTable renders a "data refreshing" banner instead of the
ranking rows. Rankings come back as soon as the next worker tick
lands and the data is fresh again.

This implements the user-added hard rule from the ULTRA improvement
plan: "no publicly stale batches across TrendingRepo." Stale
batches do not reach users.

Files:
- src/lib/public-staleness.ts (new) — classifyPublicStaleness()
  helper, returns { isFresh, ageMs, thresholdMs }.
- src/components/shared/FreshnessBadge.tsx — flip default visibility.
- src/components/home/LiveTopTable.tsx — guard rankings render on
  classifyPublicStaleness(); show banner when stale.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.

1 participant