feat(billing): always-on Free sidebar bar with reset time#2350
Draft
k11kirky wants to merge 1 commit into
Draft
Conversation
Contributor
Author
This was referenced May 25, 2026
c79d047 to
a6fca1b
Compare
This was referenced May 25, 2026
Free users now see the usage bar with a reset-time line even while usage is still loading — the previous silent `return null` on `!usage` is what hid the bar from Free users in session replays. `useFreeUsage` exposes an `isLoading` flag so `SidebarUsageBar` can render a skeleton instead of disappearing. Reset time is rendered via a shared `formatResetTime` helper that prefers the new gateway `reset_at` ISO timestamp and falls back to `resets_in_seconds`, producing "Resets in 4h" / "Resets in 4h 30m" / "Resets May 30 at 12:00am PT" depending on the horizon. The duplicated formatter in `PlanUsageSettings` is replaced with the shared helper. Pro users still see nothing here — their notifications come via toasts in B2. Adds a `log.warn` on `fetchUsage` failures so we can see when the bar is silently hidden by a network/auth error. Generated-By: PostHog Code Task-Id: bac06178-1ab1-4000-9a56-1901215bd4af Generated-By: PostHog Code Task-Id: bac06178-1ab1-4000-9a56-1901215bd4af
a6fca1b to
211250e
Compare
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.

Problem
The sidebar usage bar showed no reset time context, and the existing reset countdown used a rolling
resets_in_secondsvalue that drifts between polls. Free-plan users also saw no loading state while usage data was being fetched — the bar simply didn't render.Changes
reset_at(absolute UTC timestamp) andbilling_period_endfields to the usage schema so the gateway's stable timestamp can be preferred over the driftingresets_in_secondscountdown.formatResetTimeinPlanUsageSettingswith a sharedformatResetTimeutility that accepts bothreset_atand a fallback seconds value. The function renders human-friendly labels (Resets in 30m,Resets in 4h 30m,Resets May 3 at 2:00 PM PDT, etc.) and prefers the absolute timestamp when available.SidebarUsageBarto show a skeleton loading state while usage data is in flight, rather than rendering nothing. The bar now also displays the reset time label below the progress bar.useFreeUsageto return{ usage, isLoading }so callers can distinguish between "not eligible" and "eligible but still loading."How did you test this?
Unit tests were added for
formatResetTimecovering: sub-hour countdowns, hour+minute formatting, hours-only when minutes round to zero, localized date formatting beyond 24 hours, preference ofreset_atover fallback seconds, and handling of already-pastreset_atvalues.Publish to changelog?
no