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>
This commit is contained in:
parent
697ad5055f
commit
c88a291047
5 changed files with 56 additions and 44 deletions
|
|
@ -31,7 +31,13 @@ EXTRA = {
|
|||
"on": '"extra_usage":{"is_enabled":true,"monthly_limit":200000,'
|
||||
'"used_credits":123456,"utilization":62.0}',
|
||||
}
|
||||
CACHE = "/tmp/claude/statusline-usage-cache.json"
|
||||
# Throwaway cache directory, inherited by every rendered subprocess: the live
|
||||
# cache belongs to the running status line (~/.claude/statusline.sh symlinks to
|
||||
# the script under test) and a fixture written there would be shown as real
|
||||
# usage until it expired.
|
||||
CACHE_DIR = tempfile.mkdtemp()
|
||||
os.environ["STATUSLINE_CACHE_DIR"] = CACHE_DIR
|
||||
CACHE = os.path.join(CACHE_DIR, "statusline-usage-cache.json")
|
||||
FIXTURE = ('{"five_hour":{"utilization":5.0,"resets_at":"2026-08-27T15:40:00+00:00"},'
|
||||
'"seven_day":{"utilization":7.0,"resets_at":"2026-08-28T02:00:00+00:00"},%s,'
|
||||
'"limits":[{"kind":"weekly_scoped","percent":10,'
|
||||
|
|
@ -46,12 +52,6 @@ def main():
|
|||
["jq", "-r", ".statusLine.padding // 0", os.path.expanduser("~/.claude/settings.json")],
|
||||
capture_output=True, text=True).stdout.strip() or 0)
|
||||
root = tempfile.mkdtemp()
|
||||
# Back up the live usage cache. If there wasn't one, remove the fixture at
|
||||
# the end rather than leaving it: the status line would treat it as a fresh
|
||||
# response for up to an hour and report fabricated usage.
|
||||
had_cache = os.path.exists(CACHE)
|
||||
saved = open(CACHE, "rb").read() if had_cache else None
|
||||
|
||||
fails, checked = [], 0
|
||||
try:
|
||||
for cwd_name, extra_name in itertools.product(CWDS, EXTRA):
|
||||
|
|
@ -64,9 +64,9 @@ def main():
|
|||
"commit", "-q", "--allow-empty", "-m", "i"], check=True)
|
||||
for br in BRANCHES:
|
||||
subprocess.run(["git", "-C", repo, "checkout", "-q", "-B", br], capture_output=True)
|
||||
for f in os.listdir("/tmp/claude"):
|
||||
for f in os.listdir(CACHE_DIR):
|
||||
if f.startswith("git-"):
|
||||
os.remove("/tmp/claude/" + f)
|
||||
os.remove(os.path.join(CACHE_DIR, f))
|
||||
for model, cols in itertools.product(MODELS, WIDTHS):
|
||||
stdin = ('{"model":{"display_name":"%s"},"cwd":"%s",'
|
||||
'"cost":{"total_cost_usd":8.31},"context_window":'
|
||||
|
|
@ -89,11 +89,7 @@ def main():
|
|||
fails.append(tag + (f"max {mx} > usable {usable}",))
|
||||
finally:
|
||||
shutil.rmtree(root, ignore_errors=True)
|
||||
if saved is not None:
|
||||
with open(CACHE, "wb") as fh:
|
||||
fh.write(saved)
|
||||
elif os.path.exists(CACHE):
|
||||
os.remove(CACHE)
|
||||
shutil.rmtree(CACHE_DIR, ignore_errors=True)
|
||||
|
||||
print(f"checked {checked} combinations "
|
||||
f"(widths {WIDTHS.start}-{WIDTHS.stop - 1}, {len(BRANCHES)} branches, "
|
||||
|
|
|
|||
Loading…
Reference in a new issue