Skip to content

Show per-agent context size in tree (closes #16)#17

Merged
phiat merged 1 commit into
mainfrom
feat/context-size
May 2, 2026
Merged

Show per-agent context size in tree (closes #16)#17
phiat merged 1 commit into
mainfrom
feat/context-size

Conversation

@phiat
Copy link
Copy Markdown
Owner

@phiat phiat commented May 2, 2026

Summary

Closes #16 — thanks @halfbusy for the feature request!

Surfaces the current context size for Main and each subagent inline in the tree.

  • Tracks the latest input + cache_creation + cache_read per (session, agent) — overwrite, not sum, since context size is a rolling snapshot
  • Renders the percentage right-aligned on Main/Agent rows (e.g. Main 18%, Explore 9%)
  • Denominator is the model's max context window — NOT the user's autoCompactWindow setting. Resolved from per-message model via a per-family table:
    • claude-opus-4-7, claude-sonnet-4-6 → 1,000,000
    • claude-haiku-4-5 → 200,000
    • Update the table in parser.ContextWindowFor as new models ship
  • Subagents pick up their own model from per-message model field in the subagent JSONL — a haiku Explore under an opus Main shows /200k
  • Removed the redundant ☑/☐ checkbox prefix; disabled rows now mute the whole line so toggle state stays visible
  • README updated with a Features bullet noting the max-window denominator

Verified live

Tested with tui-use against multiple concurrent sessions, including a haiku-backed Explore subagent under an opus Main — Main row showed Main 18% (180k of 1M) while the haiku Explore showed Explore 9% (its own 200k denominator).

Test plan

  • go test ./... passes
  • Run claude-esp against a live session — verify XX% appears on the active Main row after the next assistant turn
  • Spawn an Explore subagent → verify its row shows a percentage scaled to the haiku 200k denominator
  • Trigger an auto-compaction → verify the displayed percentage drops sharply on the following turn
  • Toggle a row off with space — verify the muted styling is visible without a checkbox

🤖 Generated with Claude Code

Display each Main/subagent's current context as a percentage of the
model's max context window (e.g. `Main 18%`, `Explore 9%`).

Context size = latest assistant message's input + cache_creation +
cache_read tokens (a rolling snapshot, not a cumulative sum).

Denominator is the *model's max context window* — NOT the user's
autoCompactWindow setting. Hardcoded table:

  - claude-opus-4-7   → 1,000,000
  - claude-sonnet-4-6 → 1,000,000
  - claude-haiku-4-5  →   200,000

Per-subagent model is read from the per-message `model` field in
the subagent's JSONL, so a haiku subagent under an opus Main shows
its own (200k) denominator.

Also drops the redundant ☑/☐ checkbox column; disabled rows are now
indicated by muted styling on the existing emoji status icon.

Closes #16

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@phiat phiat force-pushed the feat/context-size branch from 82b13f9 to 72d90f0 Compare May 2, 2026 22:26
@phiat phiat merged commit 7200765 into main May 2, 2026
2 checks passed
@phiat phiat deleted the feat/context-size branch May 2, 2026 22:38
phiat added a commit that referenced this pull request May 2, 2026
Mirrors the tree-row checkbox removal from #17. Disabled toggles get a
leading mid-dot (·Thinking[t]); enabled toggles a leading space
( Thinking[t]) so the bar's column widths stay aligned.

Verified live with tui-use against an active session.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
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.

feat: show context size

1 participant