[FEATURE]: Session context usage (similar to /context in Claude)
Feature hasn't been suggested before.
- [x] I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
I would like to implement a simple tool - TUI dialog - that displays a breakdown of the current session's context window usage, answering the question "what is eating my context window". A feature similar to /context command in Claude Code, but leveraging TUI dialog to avoid obstructing the chat log.
Its purpose is to optimize the context usage by understanding what exactly is consuming it.
I build a quick PoC, and while the real token usage is difficult to get, the estimations seem good enough to be useful.
Would you be interested in having such feature in the core?
Here's the PoC implement as a dialog:
How does it work?
- It exposes new server endpoint -
/session/:sessionID/contextthat it then loaded in TUI when<leader>ikey combo is pressed. - Token usage is estimated (4 characters per token) and then "calibrated" against the the actual total token usage reported by LLM provider. This is probably over-complicated, so I will play around with the methodology if this gets accepted.
It could be placed in the sidebar:
This issue might be a duplicate of existing issues. Please check:
- #1990: Add User Controls for Context Management - Proposes context management commands including a
/tokenscommand to display token usage breakdown - #2995: Feature: status command - Requests a
/statuscommand similar to Claude that would show used context breakdown - #4659: Sliding window context management for long-running sessions - Proposes an extensive context management system with a TUI context viewer that shows token usage breakdown
- #3759: More Detailed Subagent's Context - Requests ability to see context size, tool calls, token usage, and context size for optimization
Feel free to ignore if your specific case differs from these existing requests.
I was just about to raise a feature request for this and found yours, amazing :D
@thdxr seems there is some interest for this. Would you accept the PR?
We need this feature because some times the agent generates chunks of code that just breaks the context, for example taking a screenshot on a model that don't support vision, or reading a whole react site and using it as context. Being able to edit/update/modify context after this happens is a must.
Love this!!!