Skip to content

fix(statusline): compose with Claude prefix + bring back ctx bar (v0.7.1)#43

Merged
droidnoob merged 4 commits into
mainfrom
fix/statusline-compose
May 25, 2026
Merged

fix(statusline): compose with Claude prefix + bring back ctx bar (v0.7.1)#43
droidnoob merged 4 commits into
mainfrom
fix/statusline-compose

Conversation

@droidnoob
Copy link
Copy Markdown
Owner

Summary

Three fixes for the v0.7.0 statusline:

  1. Overwriting Claude's default linestatusLine in 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 --bare flag for hew-only output. NO_COLOR honored.
  2. Scope label overflowcondense_title splits 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.
  3. Lost context-usage bar — The bar users saw before hew took over was Claude Code's context-window indicator. Brought back as its own 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's usage block.

Live output

Opus 4.7 | ~/Code/myoss/hew || ctx ██░░░░░░░░ 28% · 276K || hew feat/treesitter-symbol-extr… 0/4 (executing)

Three labeled segments, separated by ||:

  • Claude prefix — bold-cyan model · green cwd
  • ctx — color-gradient bar · pct · humanized used count
  • hew — magenta scope label · epic fraction · dim phase parenthetical (no bar — owns the label real-estate, ctx owns the bar)

Commits

Commit Scope
feb2e7a Compose with Claude prefix + condense scope label
0e79fe3 Context-usage segment with green→yellow→red bar + token count
013ffb8 Release 0.7.0 → 0.7.1

Test plan

  • cargo fmt --all --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test — 343+ tests, 11 new (8 inline + 3 e2e)
  • Live smoke test with real transcript path
  • CI green
  • Tag v0.7.1 after merge

🤖 Generated with Claude Code

droidnoob and others added 4 commits May 25, 2026 20:26
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.
@droidnoob droidnoob merged commit 58b384e into main May 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant