feat(tui): add warning/compacting states to the context-usage gauge#3537
Merged
Conversation
The always-on context gauge now escalates its color (normal -> warning -> critical) as usage approaches the agent's configured compaction threshold, and reads "compacting..." while a compaction runs, in both the main TUI sidebar and the lean TUI status line. TokenUsageEvent's Usage carries the agent's compaction_threshold so gauges color against the configured value rather than hardcoded percentages; the shared classification lives in pkg/tui/styles. Closes #3434
dgageot
approved these changes
Jul 8, 2026
pull Bot
pushed a commit
to TheTechOddBug/cagent
that referenced
this pull request
Jul 9, 2026
…ate for changes in docker#3537
Piyush0049
pushed a commit
to Piyush0049/docker-agent
that referenced
this pull request
Jul 15, 2026
…ate for changes in docker#3537
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.
Closes #3434
The always-on context gauge escalates its color (normal, warning, critical) as usage approaches the agent's configured compaction threshold, and reads "compacting..." while a compaction runs. Applies to both the main TUI sidebar and the lean TUI status line.
Issue expectations mapping
styles.ContextGaugeLevelFor(fill, threshold): warning at 75% of the threshold, critical at 95%; applied to the sidebar(N%), the per-agent roster percentages, and the lean TUI barruntime.Usagecarriescompaction_threshold, populated fromagent.CompactionThreshold()at everyTokenUsageEventemit siteSessionCompactionEventcompactingflag toggled by the started/completed pair; lean TUIStatusModel.Compactingpkg/tui/components/sidebar/sidebar.go,pkg/leantui/ui/status.goFlow
Behavior details
compaction_thresholdkeeps a proportional visual runway; thresholds outside (0, 1] fall back tocompaction.DefaultThreshold, mirroringcompaction.ShouldCompact.Usage.CompactionThresholdis 0 (omitted from JSON) when unknown, so events from older servers keep working; consumers fall back to the default.SessionUsagegains an optional variadic threshold parameter, following theAgentInfo(..., contextLimit ...int64)backward-compatibility precedent in the same file.Tests
pkg/tui/stylesSessionUsagecarries the optional thresholdValidation: build, golangci-lint plus repo lint cops,
go mod tidy --diffclean, full test suite green in touched packages (remaining repo failures are pre-existing sandbox network SSRF-guard tests, verified on a pristine checkout).