fix(statusline): compose with Claude prefix + bring back ctx bar (v0.7.1)#43
Merged
Conversation
Two issues with the v0.7.0 statusline:
1. **Overwriting Claude's default line.** Claude Code's `statusLine`
command replaces the entire bar; there's no built-in composition.
The CLI now parses the session JSON it gets on stdin and renders
a Claude-style prefix (model + cwd, colored), then `||`, then the
hew segment. NO_COLOR honored. New `--bare` flag for hew-only.
2. **Scope label was way too long.** When the current epic's title is
the full multi-clause description ("feat/treesitter-symbol-extract
— pure hew_core::treesitter module for diff-driven symbol
extraction (P3 foundation for future hew blast)"), the line
overflowed Claude Code's truncation point. `condense_title` now
splits on em-dash (same convention as the milestone body) and caps
at 28 chars with an ellipsis. Applied to both the epic title and
the milestone-derived label.
Tests:
- 5 new inline (claude_prefix render with/without colors, top-level
cwd fallback, empty-session None, shorten_path).
- 3 new inline for condense_title (em-dash strip, short pass-through,
ellipsis truncation).
- 2 new e2e (compose with session JSON on stdin, --bare flag skips
prefix even with session JSON).
Stale-on-clear note: not addressed in code — Claude Code reads
.claude/settings.json at session start and caches it for the
session's lifetime. The auto-migration writes the new config but a
session that loaded settings.json before the migration ran keeps the
old statusLine config until the next host restart. Inside our code
we re-query bd state on every invocation, so data freshness is fine
once the new config is active.
…oken count The bottom-bar metric users had before hew took over was Claude Code's context-window usage. Bring it back as its own clearly-labeled segment: ctx ▓▓▓░░░░░░░ 27% · 270K || hew feat/treesitter 0/4 (executing) Three changes: 1. Parse the transcript JSONL stdin-references to a `transcript_path`, walk backward to the most-recent `type=assistant` line with a `usage` block, and sum input_tokens + cache_creation + cache_read_input_tokens as "context used". Best-effort: any IO or parse failure → segment skipped, statusline keeps working. 2. Render `ctx <bar> <pct>% · <K/M>` with a color gradient: - green < 60% - yellow 60–84% - red ≥ 85% Context limit inferred from observed usage (200K standard, 1M extended). Token count humanized as `847` / `41K` / `1.2M`. 3. Drop the bar from the hew segment so the two graphs don't compete. Hew now renders `hew <label> N/M [(phase)]` — label-based, no bar. Each segment carries its own explicit prefix (`ctx` / `hew`) so nothing is ambiguous. Tests: - 5 new inline (humanize_tokens at each scale, infer_context_limit thresholds, TokenUsage::total). - 1 new e2e (ctx_segment_appears_when_transcript_has_usage) that writes a synthetic JSONL and verifies the `ctx`, `%`, and `41K` parts all land in stdout. - Existing e2e cases updated for the new shape (no `%` in the hew segment; phase parenthesised; --bare keeps the hew segment).
Patch release. Fixes statusline overwrite + composes with Claude Code's default prefix; brings back the context-usage bar with a green→yellow→red gradient and humanized token count. - Workspace version bump 0.7.0 → 0.7.1. - Every <!-- hew:version --> marker bumped across skills/ + commands/. - .claude/ mirror refreshed via hew init --runtime=claude. - CHANGELOG dated [0.7.1] section. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`checkout_new_branch_passes_from_base` (and any other RealGit test that writes+execs a stub) intermittently fails on Linux CI with `ExecutableFileBusy` (errno 26). Root cause: when sibling test threads each install their own stub via fs::rename + exec, the kernel's i_writecount on one thread's fresh inode can stay elevated transiently because another thread's in-flight `fork()` inherited that writable fd (O_CLOEXEC only fires on exec, not fork). The child closes it on its own exec but for a brief window the original thread's exec of its dest stub sees a writer still attached → ETXTBSY. Fix: wrap `RealGit::run` and `RealGit::run_to_file` spawn calls in `spawn_with_etxtbsy_retry`, which retries up to 5 times with exponential backoff (5/10/20/40/80ms, ~155ms worst case). Production spawns of /usr/bin/git aren't affected — no writers there — but the retry is harmless and absorbs the test-harness race.
5 tasks
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.
Summary
Three fixes for the v0.7.0 statusline:
statusLinein Claude Code replaces the entire bar with the command's stdout, no built-in composition. The CLI now parses the session JSON stdin and renders a Claude-style prefix (model + cwd, colored) ahead of the hew segment, separated by||. New--bareflag for hew-only output.NO_COLORhonored.condense_titlesplits epic/milestone titles on the first em-dash and truncates the head to 28 chars with an ellipsis. Stops 90-char epic descriptions from blowing past Claude Code's truncation point.ctx <bar> <pct>% · <used-tokens>segment with a green→yellow→red color gradient (<60%/60–84%/≥85%) and humanized token count (847/41K/1.2M). Parses the transcript JSONL for the last assistant message'susageblock.Live output
Three labeled segments, separated by
||:Commits
feb2e7a0e79fe3013ffb8Test plan
cargo fmt --all --checkcargo clippy --all-targets -- -D warningscargo test— 343+ tests, 11 new (8 inline + 3 e2e)v0.7.1after merge🤖 Generated with Claude Code