Skip to content

fix(tui): gauge shows live window fill, not cumulative session tokens#9

Merged
jkyberneees merged 1 commit into
mainfrom
fix/tui-context-gauge
Jul 25, 2026
Merged

fix(tui): gauge shows live window fill, not cumulative session tokens#9
jkyberneees merged 1 commit into
mainfrom
fix/tui-context-gauge

Conversation

@jkyberneees

Copy link
Copy Markdown
Contributor

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 divided sessionContextTokens by maxContext — and odek reports that field as a cumulative sum (sessionInputTokens += contextTokens per turn in serve.go). The gauge could therefore only grow.

Fix

  • New winCtxTok tracks the last turn's contextTokens — the live window fill, which drops again after a trim.
  • The header gauge and the /stats context row now use winCtxTok.
  • The ∑ ⌂ footer summary keeps showing the cumulative session total, matching what the sigma denotes.
  • Comment on the client done event fields clarifies cumulative vs live semantics.

Tests

  • New regression test TestGaugeFollowsTurnFill: cumulative total at 50k while the gauge reads 90% from the turn fill, then drops to 30% after a trim.
  • Existing gauge/stats tests updated to drive via winCtxTok.

go build, go vet, and the full test suite pass.

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.
@jkyberneees
jkyberneees merged commit ab08612 into main Jul 25, 2026
4 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