Show when usage limits reset, as separate preferences - #108
Merged
Conversation
The Claude Code view's Session/Weekly meters only showed a reset time when the /usage probe happened to inherit one from an earlier Terminal statusLine snapshot in the same process — otherwise it stayed blank, even though a real epoch was already arriving on the CLI's rate_limit_event stream. That data was wired only to the transient usage-warning banner (controls.js), never to ClaudeStatusStore, the process-wide cache both views' status bars read from. ClaudeStatusStore now has a second producer, acceptRateLimitEvent, feeding just the reset epoch (never a percentage — the event's utilization field's unit is unverified) into the same per-window merge the CLI statusLine already uses. This required fixing mergeWindow, which previously discarded any window fragment lacking a percentage outright, dropping a reset-only update on the floor before its existing "inherit a missing reset from prev" logic ever ran. It now also inherits a missing *percentage* the same way, and keeps a reset-only fragment around (invisible until paired) instead of dropping it, so two rate-limit events landing before the next /usage probe don't erase each other's epoch. Terminal doesn't need this: its statusLine already carries resets_at directly and drives the bar without a proxy event. Mechanism differs, outcome converges on the shared ClaudeStatusStore/ClaudeStatusBar both views already use. Adds PREF_STATUSLINE_SHOW_RESETS (default on, shared — not view-scoped, since the store and bar widget are shared) as the "whether" the user asked for; "when" (e.g. only near reset, or above a usage threshold) is left for a follow-up since it's a separate design decision. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Session and Weekly already have independent "show this meter" prefs (PREF_STATUSLINE_SHOW_SESSION_5H / _WEEKLY); the reset-time toggle added in the previous commit was a single combined switch, which didn't match that existing granularity. Replaced it with PREF_STATUSLINE_SHOW_SESSION_5H_RESET and _WEEKLY_RESET (both default on), each listed on the preference page directly under its own meter's checkbox so the page order matches render order. buildSegments' width-reservation fallback (drop reset text before dropping whole segments when the bar is too narrow) still applies per-layout-attempt, now via a forceNoResets override rather than a single withResets flag, since each meter now decides independently whether it wants a reset shown in the first place. The on-hover tooltip is intentionally left alone: it still reports a meter's reset time even when its inline "(resets in ...)" text is hidden, since the preference is a space-saving toggle for the always-visible text, not a "never tell me this" switch. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Splits "show reset time" out as its own preference for each usage meter (5-hour session and weekly), shown next to the existing limit percentage.
Shows when each usage limit recovers, not just how full it is.