The script now: runs the binary with --test after install to verify it
actually works, prints the statusLine JSON that was written to settings,
handles corrupt/invalid settings.json by backing up and writing fresh,
and emphasizes that Claude Code must be restarted to pick up the change.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Nightly toolchains with CARGO_BUILD_TARGET set (or .cargo/config.toml
[build] target) put the binary in target/<triple>/release/ instead of
target/release/. The installer now falls back to a find search across
all target subdirectories when the standard path doesn't exist.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cargo build --quiet swallowed compiler errors, and the subshell (...)
didn't reliably propagate exit codes across bash versions. The script
continued past a failed build, then ls/cp failed on the missing binary.
Now: removed --quiet so errors are visible, explicit exit-code check
with common-cause hints (build-essential, libc6-dev), and a secondary
check that the binary actually exists before attempting to install it.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
rust_prd.md (3,091 lines):
The Rust port PRD has been fully implemented — all beads closed,
all features delivered across 7 prior commits. Keeping the PRD
in-repo adds confusion about what's aspirational vs actual.
statusline.sh (2,245 lines):
The original bash implementation is fully superseded by the Rust
binary (claude-statusline). The bash script had fundamental
limitations: ~200ms render time, no caching, no gradient support,
no per-tool breakdown, and fragile process-tree width detection.
The Rust binary renders in <5ms with full feature parity and then
some. install.sh now targets the Rust binary exclusively.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The feature layer that builds on the new infrastructure modules. Adds
4 new environment-aware sections, rewrites the tools/beads/turns sections,
introduces gradient sparklines and block-style context bars, and wires
/clear detection into the main binary.
New sections (4):
cloud_profile — Shows active cloud provider profile from env vars
($AWS_PROFILE, $CLOUDSDK_CORE_PROJECT, $AZURE_SUBSCRIPTION_ID).
Provider-specific coloring (AWS orange, GCP blue, Azure blue).
k8s_context — Parses kubeconfig for current-context and namespace.
Minimal YAML scanning (no yaml dependency). 30s TTL cache.
Shows "context/namespace" with split coloring.
python_env — Detects active virtualenv ($VIRTUAL_ENV) or conda
($CONDA_DEFAULT_ENV, excluding "base"). Shows just the env name.
toolchain — Detects Rust (rust-toolchain.toml) and Node.js (.nvmrc,
.node-version) versions. Compares expected vs actual ($RUSTUP_TOOLCHAIN,
$NODE_VERSION) and highlights mismatches in yellow.
Tools section rewrite:
Progressive disclosure based on terminal width:
- Narrow: just the count ("245")
- Medium: count + last tool name ("245 tools (Bash)")
- Wide: per-tool color-coded breakdown ("245 tools (Bash: 84/Read: 35/...)")
Adaptive width budgeting: breakdown reduces tool count until it fits
within 1/3 of terminal width. Color palette priority: config > terminal
ANSI palette (via OSC 4) > built-in Dracula palette.
Beads section rewrite:
Switched from `br ready --json` to `br stats --json` to show all
statuses. Now renders multi-status breakdown: "3 ready 1 wip 2 open"
with per-status visibility toggles in config.
Turns section:
Falls back to transcript-derived turn count when cost.total_turns is
absent. Requires at least one data source to render (vanishes when
no session data exists at all).
Visual enhancements:
trend.rs:
- append_delta(): tracks rate-of-change (delta between cumulative
samples) so sparklines show burn intensity, not monotonic growth
- sparkline(): now renders exactly `width` chars with left-padding
for missing data. Baseline (space) vs flatline (lowest bar) chars.
- sparkline_colored(): per-character gradient coloring via colorgrad,
returns (raw, ansi) tuple for layout compatibility.
context_bar.rs:
- Block style: Unicode full-block fill + light-shade empty chars
- Per-character green->yellow->red gradient for block style
- Classic style preserved (= and - chars) with single threshold color
- Configurable fill_char/empty_char overrides
context_trend + cost_trend:
Switched to append_delta for rate-based sparklines. Gradient coloring
with green->yellow->red via sparkline_colored().
format.rs:
Background color support via resolve_background(). Accepts named
colors, hex, and palette refs. Applied as ANSI bg wrap around section
output, preserving foreground colors.
layout/mod.rs:
- Separator styles: text (default), powerline (Nerd Font), arrow
(Unicode), none (spaces). Powerline auto-falls-back to arrow when
glyphs disabled.
- Placeholder support: when an enabled section returns None (no data),
substitutes a configurable placeholder character (default: box-draw)
to maintain layout stability during justify/flex.
Section refinements:
cost, cost_velocity, token_velocity, duration, tokens_raw — now show
zero/baseline values instead of hiding entirely. This prevents layout
jumps when sessions start or after /clear.
context_usage — uses current_usage fields (input_tokens +
cache_creation + cache_read) for precise token counts instead of
percentage-derived estimates. Shows one decimal place on percentage.
metrics.rs — prefers total_api_duration_ms over total_duration_ms for
velocity calculations (active processing vs wall clock with idle time).
Cache efficiency now divides by total input (not just cache tokens).
Config additions (config.rs):
SeparatorStyle enum (text/powerline/arrow/none), BarStyle enum
(classic/block), gradient toggle on trends + context_bar, background
and placeholder on SectionBase, tools breakdown config (show_breakdown,
top_n, palette), 4 new section structs.
Main binary (/clear detection + wiring):
detect_clear() — watches for significant context usage drops (>15%
to <5%, >20pp drop) to identify /clear. On detection: saves transcript
offset so derived stats only count post-clear entries, flushes trend
caches for fresh sparklines.
resolve_transcript_stats() — cached transcript parsing with 5s TTL,
respects clear offset, skipped when cost already has tool counts.
resolve_terminal_palette() — cached palette detection with 1h TTL.
Debug: CLAUDE_STATUSLINE_DEBUG env var dumps raw input JSON to
/tmp/claude-statusline-input.json. dump-state now includes input data.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Infrastructure layer for the TUI visual overhaul. Introduces foundational
modules and capabilities that the section-level features build on:
colorgrad (0.7) dependency:
OKLab gradient interpolation for per-character color transitions in
sparklines and context bars. Adds ~100K to binary (929K -> 1.0M).
color.rs expansion:
- parse_hex(): #RRGGBB and #RGB -> (u8, u8, u8) conversion
- fg_rgb()/bg_rgb(): 24-bit true-color ANSI escape generation
- gradient_fg(): two-point interpolation via colorgrad
- make_gradient()/sample_fg(): multi-stop gradient construction and sampling
- resolve_color() now supports: hex (#FF6B35), bg:color, bg:#hex,
italic, underline, strikethrough, and palette refs (p:success)
- Named background constants (BG_RED through BG_WHITE)
transcript.rs (new module):
Parses Claude Code transcript JSONL files to derive tool use counts,
turn counts, and per-tool breakdowns. Claude Code doesn't include
total_tool_uses or total_turns in its JSON — we compute them by scanning
the transcript. Includes compact cache serialization format and
skip_lines support for /clear offset handling.
terminal.rs (new module):
Auto-detects the terminal's ANSI color palette for theme-aware tool
coloring. Priority chain: WezTerm config > Kitty config > Alacritty
config > OSC 4 escape sequence query. Parses Lua (WezTerm), key-value
(Kitty), and TOML/YAML (Alacritty) config formats. OSC 4 queries
use raw /dev/tty I/O with termios to avoid pipe interference. Includes
cache serialization helpers for 1-hour TTL caching.
input.rs updates:
- All structs now derive Serialize (for --dump-state diagnostics)
- New fields: transcript_path, session_id, cwd, vim.mode, agent.name,
exceeds_200k_tokens, cost.total_api_duration_ms
- CurrentUsage: added input_tokens and output_tokens fields
- #[serde(flatten)] extras on InputData and CostInfo for forward compat
cache.rs:
Added flush_prefix() for /clear detection — removes all cache entries
matching a key prefix (e.g., "trend_" to reset all sparkline history).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Config `width` was position #3 in the detection chain, overriding all
dynamic detection (ioctl, process tree, stty, etc). This meant the
statusline couldn't adapt to terminal/pane resizes.
Now config `width` serves two roles:
- Max cap on dynamically detected widths (prevents absurd widths)
- Fallback when all dynamic detection methods fail
Also adds:
- ioctl on stderr (works when stdout is piped)
- stdin JSON `terminal_width` field for Claude Code to pass width
- Distinct diagnostic sources: config_cap, config_fallback, stdin_json
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1. cache: record diagnostic miss before early-return on modified()/duration_since() failure
2. dump-state: resolve all cache_dir template vars ({cache_version}, {config_hash})
3. config: remove dead breakpoint_hysteresis field from GlobalConfig (breakpoints.hysteresis is used)
4. config: align Rust Default cache_dir with defaults.json template
5. vcs: apply branch truncation in render_stale_cache (--no-shell path)
6. vcs: fix jj prefetch retry on already-failed command (flatten→unwrap_or_else)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Revised bd-3uw, bd-ywx, bd-62g, bd-4b1, bd-1if, bd-3ax from
score 3/5 to 4+/5 with concrete approach steps, code snippets,
TDD loops, and edge cases sourced from rust_prd.md.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- justify: gate DIM/RESET separator coloring on color_enabled param;
previously leaked ANSI escapes when --color=never or NO_COLOR was set
- vcs: apply branch name truncation per config (truncate.enabled,
truncate.max, truncate.style) for both git and jj renderers;
previously ignored truncate config causing long branch names to
overflow and trigger unnecessary priority drops
- flex: account for prefix/suffix overhead when computing context_bar
flex expansion width; previously double-applied apply_formatting
causing line to overshoot term_width when prefix/suffix configured
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- output_style: use MAGENTA color per PRD (was incorrectly DIM)
- vcs: pass project dir to jj exec (was None, causing wrong cwd)
- tools: singular "tool" when count is 1 (was always "tools")
- layout: wire up apply_formatting() in render pipeline (prefix,
suffix, color override, pad, align were completely dead code)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>