fix(tui): gauge shows live window fill, not cumulative session tokens#9
Merged
Conversation
The header gauge and /stats divided sessionContextTokens by maxContext, but odek reports that field as a cumulative sum (serve.go accumulates sessionInputTokens every turn). The gauge could only grow, pinning at 100%+ (e.g. 158.9k/131k) even though odek trims history to stay within budget. Track the last turn's contextTokens as winCtxTok — the live window fill — and drive the gauge and /stats ctx row from it, so the number drops back down after a trim. The ∑ ⌂ footer summary keeps the cumulative session total, which is what the sigma denotes.
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.
Problem
The header context gauge pinned at 100%+ (e.g.
158.9k/131k) and never recovered, suggesting the context window was exceeding its budget with no compaction.In reality odek trims history to stay within budget (emitting
context_trimmed), but bodek dividedsessionContextTokensbymaxContext— and odek reports that field as a cumulative sum (sessionInputTokens += contextTokensper turn inserve.go). The gauge could therefore only grow.Fix
winCtxToktracks the last turn'scontextTokens— the live window fill, which drops again after a trim./statscontext row now usewinCtxTok.∑ ⌂footer summary keeps showing the cumulative session total, matching what the sigma denotes.doneevent fields clarifies cumulative vs live semantics.Tests
TestGaugeFollowsTurnFill: cumulative total at 50k while the gauge reads 90% from the turn fill, then drops to 30% after a trim.statstests updated to drive viawinCtxTok.go build,go vet, and the full test suite pass.