Repository navigation
feat(statusline): redesign with layouts, server cache state and cold-send hint - #442
Merged
Merged
Conversation
…send hint Status line now shows saved (estimate) next to spent (observed), the prompt-cache state with the proxy's own view overriding Claude Code's, context against the served window, and at most one actionable hint. Adds three layouts, per-element toggles, NO_COLOR and narrow-width degradation. Adds GET /api/cachestate (last cache-touching request, billed TTL tier, prefix tokens, rewrite price, served window) so the client does not have to guess. Drops the urllib and tempfile imports and memoises the routing gate: typical render 107 ms -> 45 ms median on the same box and stub. Signed-off-by: Osher-Elhadad <[email protected]>
Collaborator
Author
|
Reviewer: approved, with non-blocking notes. CI all pass; go test ./context-guru-plugin (406 s) and ./dash green; gofmt clean. Checked:
Test expectations (16): most are straight format updates and justified. Three are weaker than before:
|
This was referenced Oct 11, 2026
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.
Closes #436 (Workstream C). Design and mockups: see the issue comment.
What changes
context-guru-plugin/scripts/statusline.py: three layouts (--layout=minimal|balanced|detailed), per-element toggles (--hide=/--show=, envCG_STATUSLINE_*),NO_COLOR, width-aware degradation (readsCOLUMNS, which Claude Code exports), one hint at most.saved ≈$is the counterfactual estimate (vs the same request uncompacted, gateway prices, net of CG's own model spend and keep-alive pings);(spent $)is observed gateway-priced cost;day ≈$is the same estimate since local midnight. They are never added or divided.prompt_cachewhile fresh; Claude Code's is the fallback. Context uses the proxy's last forwarded prefix and its measured window when available.dash/cachestate.go: newGET /api/cachestate?session=(scopeTenant, numbers only): last cache-touching request (pings included), billed TTL tier (1h if the last write was billed at 1h), prefix tokens, price to rewrite it, served window./api/stats?lean=1did not expose any of this.urllib/tempfile/globimports (raw loopback socket), routing gate memoised 60 s, three reads in parallel under one 0.6 s deadline with disk caches (2 s session/cache, 60 s day). Typical render 45 ms median (p95 53) vs 107 ms (p95 123) before, same box, same stub proxy, loaded machine.Tests
Golden output for warm / expiring / cold / first-run x minimal / balanced / detailed x widths (
statusline_golden_test.go), proxy-down and colour.dash/cachestate_test.gocovers the endpoint. 16 existing statusline tests asserted the old strings (cache 4:12,$0.03 of $0.41 (-12k), cache hidden by default); I updated their expectations to the new format, plus the stubs that now see a second (since=) read.go test ./dash/ ./context-guru-plugin/passes.Real check (before = origin/main, after = this branch)
Real interactive Claude Code 2.1.296 in tmux, routed through a distinct-basename proxy built from this branch on :4120 (preset house, scratch data dir, killed by PID afterwards). "Before" is origin/main's script run on the identical stdin Claude Code produced at the same moment. Real, redacted (no session ids).
COLUMNSas noted.--cache)◌ no cache yet │ ········ 0/1.0M 0%········ 30.6k/1.0M 3% | $0.00 of $0.16 (-0) | proxy: 106ms · upstream: 10204mscache 4:01saved ≈$0.00 (spent $0.08) · day ≈$0.00 │ ● warm 4m │ ········ 30.6k/1.0M 3%········ 30.6k/1.0M 3% | $0.00 of $2.24 (-0) | ...... cache 4:01 ...saved ≈$0.00 (spent $1.12) · day ≈$0.00 │ ● warm 3m │ ██······ 237.2k/1.0M 24%cache 0:42... │ ◐ 42s left │ ██······ 237.2k/1.0M…(80 cols)cachehidden; bar 30.6kcache coldsaved ≈$0.00 (spent $1.12) · day ≈$0.00 │ ○ cold │ ██······ 237.2k/1.0M 24% │ ▸ cold on 237.2k: next send rewrites ≈$0.59 — /compact?saved ≈$0.00 │ ○ cold │ ctx 24% │ ▸ cold 237.2k: resend ≈$0.59 — /compact?cg!cg!cg!Findings from the run:
cost.total_cost_usd($2.24) is a list-price estimate, about 2x the gateway-priced spend ($1.12). The oldof $2.24mixed that with a gateway-priced saving.--cachewas passed, and then without any cost.house); the labelling, not the magnitude, is what this check shows.Not in this PR: a
/cg:configurewizard andcg doctor(separate issues). Not merged, per instructions.