Commit graph dotfiles/claude
Author SHA1 Message Date
Jonny Barnes
f2dbe61276
Refresh the usage bars every 5 minutes, not every hour
The 5h/7d bars were served from a cache with a one-hour TTL, so a bar
could sit unchanged for most of a 5-hour window. The TTL is now a named
config setting next to GIT_CACHE_SECS at 300s: worst case 12 requests an
hour, shared across every session through /tmp/claude.

The section header claimed "cached 60s" — inherited from upstream and
never true here — which is what set the expectation the code did not
meet. It now names the setting instead of a number that can drift.

The refresh is gated on the same width-tier check as the bars, so a
render that shows them is a render that refreshes them: the new tests
pin that from full width down to WRAP_FLOOR, and pin that one column
below it, where the bars are dropped, no request is paid for either.
Those widths are given in usable columns, as in the sibling width test,
so the suite does not depend on the padding in the live settings.json.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-02 13:07:19 +01:00
Jonny Barnes
417542807b
Measure line one's branch budget instead of assuming 56 columns
In wrap mode the branch is truncated to whatever the rest of line one leaves,
and "the rest" was a flat 56 columns. It is not flat: the token counts and the
cost figure vary with the session, and with a four-digit cost the real width is
57, so line one came out exactly one column over and the renderer clipped it.
Reachable at COLUMNS 73-81 with padding 2 — a narrow split pane.

Add up the segments that follow the branch instead, from the same values that
render them, and count the ahead/behind markers too, which the constant also
ignored. That needs the cost formatted and the token bar width chosen before
the git segment is built, so both move up; neither depends on anything in
between.

The budget is now exact rather than approximate, so the branch also gets the
columns the old constant was over-reserving when the cost was short.

Tests: the large-cost sweep only used the short branch 'main', where the
overflow cannot show. Repeat it with the long branch, which fails on the old
budget at usable 68, 69, 70 and 75 by exactly one column.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 19:01:24 +01:00
Jonny Barnes
c88a291047
Wrap the status line rather than drop the per-model limit
The measured ladder tried every single-line variant before considering a
second line, so whenever line one plus the full group did not fit — from
around 92 usable columns upwards, depending on how long the branch, cwd and
model names are — it emitted rl_bare (5h and 7d only) and silently dropped
the per-model (Fable) bar that is the main reason the group is worth
rendering. On a 110-column laptop the limit was invisible.

Reorder so a second line beats losing that bar: one line rich/mid/lean, then
wrap, and rl_bare only when WRAP_NARROW is false. Reset times and
extra-usage credits are still given up rather than wrapped for, which makes
the rendered content non-monotone in width; the comment on the ladder spells
that out.

Also stop the tests writing fixtures to the caches the live status line
reads. ~/.claude/statusline.sh is a symlink to the script, so a test run was
visibly rendering fabricated usage — a Fable bar at 10%, extra-usage credits
of $1234.56/$2000.00 — in whatever session happened to be open, and a run
killed before its trap fired would have left that in place for an hour. The
cache directory is now $STATUSLINE_CACHE_DIR (default /tmp/claude) and each
suite points it at a temporary directory, which also removes the
backup/restore dance and the deletion of the live git-status cache.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 18:54:02 +01:00
Jonny Barnes
697ad5055f
Show the per-model usage limit, and size the status line by measurement
/usage reports a weekly limit scoped to a single model (Fable) that the
status line did not surface. It is absent from both the status line's stdin
JSON and the legacy seven_day_opus/seven_day_sonnet fields, which are always
null now; it lives in the usage API's .limits[] under kind "weekly_scoped".
Render it labelled by scope.model.display_name so it follows whichever model
the limit applies to, inside the 7d segment since both are weekly limits
sharing one reset time.

Fitting it exposed a problem with sizing by width tier. Tiers only know the
terminal width, so content that varies with session state — branch name, cwd,
model display name — could push a line past the edge and be clipped by the
renderer. Measure the assembled line instead (vis_len) and emit the richest of
four rate-limit variants that fits, on one line or two: with reset times, with
extra-usage credits, bars only, or bars without the per-model segment. Every
branch is fit-checked, including with wrapping disabled. Two lines render
correctly in the status line.

Cap the cwd basename as well: nothing else shortened line one, so a long
project directory could overflow it on its own.

Correct the usable width. Claude Code exports COLUMNS but applies the `padding`
setting on top of it rather than deducting it first, so a line sized to COLUMNS
is clipped; deduct padding on both sides plus a column of margin.

Sanitise payload data before rendering. printf %b interprets backslash escapes,
which is how the colour variables work, so a cwd or model name containing a
literal \n — or a real newline, which jq decodes from the JSON — would split
the line and break both the width measurement and the two-line guarantee.

Parse the usage payload in one jq pass rather than ten. The status line runs on
every redraw and per-field parsing had become the dominant cost; this brings a
render back to roughly what it was before (~155ms vs ~115ms parent), the
remainder being the reset times the tiered version did not show at this width.
Fields are read one per line rather than via @tsv: tab is IFS whitespace, so
`read` collapses runs of it and an empty field — no scoped limit, which is the
common case — silently shifted every later field along by one.

Tests cover the API payload shapes including malformed and hostile input, the
width invariants (never exceed the usable width, never more than two lines,
never wrap unnecessarily), and a sweep over widths, branch lengths, model
names, cwd lengths and extra-usage. They restore the live usage cache on exit,
and remove the fixture outright when there was no cache to restore — otherwise
a test run would leave fabricated usage figures live for an hour.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-27 18:25:20 +01:00
Jonny Barnes
d012a7f23e
Make the Claude Code statusline follow the terminal palette
The nine colours were hardcoded One Dark RGB via 38;2;R;G;B, so they did not
follow the light/dark switch. Measured against the tangere backgrounds they are
fine on dark (4.25-10.80:1) but collapse on light: orange 1.78, amber 1.70,
yellow 1.63, and 'white' — used for the token total — at 1.35:1, effectively
invisible.

Switched to palette indices, which resolve through the terminal's own palette and
so follow the ghostty tangere-light/tangere-dark swap with no detection and no
cost per render. 'white' becomes 39, default foreground, since it means primary
text. All seven colours actually used get distinct indices; blue and yellow are
unreferenced but converted too, so no RGB is left behind.

Contrast now clears WCAG AA in both modes: 5.77-14.26:1 on dark, 6.32-20.61:1 on
light.

Trade-off: tangere has no orange and its palette 2 is teal rather than green, so
'green' reads teal and the warm colours sit closer together than the One Dark
originals did.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-09 14:02:01 +01:00
Jonny Barnes
c7236f5a12
Switch Claude Code statusline to isaacaudet variant, show 7d usage
Add statusline.isaacaudet.sh and point the bootstrap symlink at it,
keeping the burnrate and original variants alongside.

The script already had a 7d rate-limit bar but gated it behind the
`full` width tier, so it only appeared at >=150 columns. Ungate it so it
renders wherever the 5h bar does, mirroring it exactly. The `full`-only
extra_usage bar is unchanged.

To pay for the ~14 columns that costs, the reset timestamps are now
`full`-only (the 5h one previously also showed at `wide`), and the model
name is shortened at `split` as well as `narrow` - with the 7d bar added
a `split` line came to 82 visible columns against a 76-column budget and
wrapped.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-08 11:54:05 +01:00
Jonny Barnes
8cc69aa6f3
Fix Opus statusline hue rendering as black in light theme
Hue 226 (#ffff00) has a contrast ratio of 1.05 against the tangere-light
background (#fdfdfa), below the minimum-contrast = 1.1 set in the ghostty
config. Ghostty then substitutes the foreground for whichever of black or
white has more contrast, so against a near-white background that letter of
the model name rendered black.

Swap 226 for 184 (#d7d700, ratio 1.51 light / 9.60 dark) in the Opus ramp
and the unknown-model fallback, the only two palettes that used it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-04 17:35:33 +01:00
Jonny Barnes
644c52d4b4
Switch Claude Code statusline to burnrate variant
Keep the previous statusline as statusline.original.sh and add
statusline.burnrate.sh from Gui-Gou/claude-statusline-burnrate, which
shows weekly/5h plan usage and a sustainable burn rate.

bootstrap.sh now links the burnrate script unconditionally - the old
`test -L` guard would have left an existing symlink pointing at the
previous script. jq is a hard dependency of the new script, so add it
to brew.sh.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-03 14:40:40 +01:00
Jonny Barnes
f9e4c65001
Add claude statusline to my dotfiles 2026-03-28 16:51:14 +00:00