Skip to content

feat(statusline): show 5h/7d rate-limit usage with reset times#2550

Draft
tjcouch-sil wants to merge 2 commits into
mainfrom
feat/statusline-rate-limits
Draft

feat(statusline): show 5h/7d rate-limit usage with reset times#2550
tjcouch-sil wants to merge 2 commits into
mainfrom
feat/statusline-rate-limits

Conversation

@tjcouch-sil

@tjcouch-sil tjcouch-sil commented Jul 13, 2026

Copy link
Copy Markdown
Member

What

Augments the status line to show Claude.ai Pro/Max rate-limit usage to the right of the branch:

… | paranext-core | main | 5h 24% (1000) | 7d 41% (6 Feb 1000)
  • 5h N% (HHMM) — 5-hour rolling window, reset time in local 24-hour time.
  • 7d N% (D MMM HHMM) — weekly window, reset time as day / 3-char month / local 24-hour time.

How

  • Rate-limit parsing + local-time formatting done in the existing Node block (no jq, no date — portable, and Node handles the local time zone).
  • Appended after the branch, separated by |. True right-alignment isn't possible: Claude Code doesn't pass terminal width to the status line and stdout is a pipe (no tty), so $COLUMNS / tput cols are unreliable.
  • statusLine.refreshInterval set to 60 so the (HHMM) reset clocks tick while the session is idle.

⚠️ Reviewer note: touches .claude/settings.json

This PR edits .claude/settings.json (to add refreshInterval: 60), which this repo intentionally deny-lists for agent edits (Edit(.claude/settings.json) / Write(...)). That guardrail targets silent agent edits to permission/hook config; this is a reviewed, benign status-line change and doesn't alter permissions or hooks. Flagging it explicitly so the change gets a deliberate look. If you'd prefer to keep that file untouched, drop the one-line refreshInterval addition and the status line still works — the reset clocks just refresh on activity rather than every 60s.

Degradation (verified with mock input)

  • rate_limits absent (API-key auth, or before the first API response) → segment omitted; line ends at the branch.
  • One window missing / used_percentage null → only the available window shows.
  • No resets_at → percentage shown without the (…).

Note: rate_limits is only provided by Claude Code for Claude.ai Pro/Max subscribers, so contributors on API-key auth simply won't see the segment. Reset times render in each user's own local zone.

🤖 Generated with Claude Code


This change is Reviewable

Append Claude.ai Pro/Max rate-limit usage to the right of the branch in
the status line: "5h N% (HHMM) | 7d N% (D MMM HHMM)". Reset times render
in the machine's local time zone (24-hour). The segment degrades
gracefully when rate_limits is absent (API-key auth or before the first
API response) and per-window when a window or its percentage is missing.

Set statusLine.refreshInterval to 60 so the reset-time clocks update
while the session is idle. True right-alignment isn't possible: Claude
Code doesn't pass terminal width and stdout is a pipe (no tty), so
$COLUMNS / tput cols are unreliable.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@tjcouch-sil
tjcouch-sil marked this pull request as draft July 14, 2026 13:36
… WSL2)

Replace the per-session rate-limit read with a cross-session harvest:
every session writes the account-wide 5h/7d usage it observes to a shared
file and displays the freshest value across all sessions, so the figure
updates ~every minute (with refreshInterval) even while this session is
idle. Freshness is resolved by later resets_at, then higher percentage;
stale readings (>5 min) are flagged with "*".

The shared file resolves to the SAME physical file from native Windows
and WSL2 (Windows-side home via /mnt/c), and to the normal per-home file
on macOS and plain Linux. An optional CLAUDE_USAGE_SHARED_FILE env var
overrides the location.

Co-Authored-By: Claude Opus 4.8 (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