feat(tui): surface compaction-model context-limit cap in the TUI - #3811
Merged
Conversation
… model When an agent's dedicated compaction model has a smaller context window than the primary model, the effective context limit is silently capped with no indication of why. Surface the cap's source by adding CompactionModel, CompactionContextLimit and PrimaryContextLimit to ContextBreakdown, LiveSession and AgentInfoEvent, populated only when the compaction model actually caps the effective limit (strictly smaller than the primary window).
Render the compaction-model cap attribution added in the runtime: a dedicated warning-styled second header line in the /context dialog (shown only when capped, reading "compaction cap: <model> • <N> tokens"), a Q4 fallback that re-attributes the main meta line when only the compaction window is resolvable, and a short "⚠ capped" marker next to the sidebar context gauge. The /context header is the sole authority on the cap’s model and figure; Live-sessions rows and the sidebar marker intentionally stay silent on both to avoid repeating (and risking mis-attributing) that detail elsewhere. The header block’s height is now derived from its actual rendered content instead of a hardcoded constant, since the extra line makes it variable.
Note the /context dialog’s "compaction cap: <model> • <N> tokens" header line and the sidebar’s "⚠ capped" marker, and cross-reference them from the compaction guide’s context-window-mismatch callout. Live-sessions rows carry no cap wording of their own — the /context header is the sole authority on it.
…egment width The Token Usage section's click zone used to span the whole tab, including the "Token Usage" title line, so clicking the title opened the cost dialog just like clicking the reading below it. Replace the half-open usageZoneStart/usageZoneEnd range with usageReadingLine (the exact reading-line index) and usageSectionEnd (covering any budget lines below it), excluding the title line from the click zone. Also record usageContextSegWidth, the rendered width of the reading line's context segment (glyph, token count, and context %/compacting marker) — unused for now, but needed by the next commit to split the reading line's click target between the context and cost dialogs.
Split the Token Usage reading line's click target: an offset within usageContextSegWidth (the glyph, token count, and context %/compacting marker) now reports the new ClickUsageContext, while the rest of the line (cost figure, ⚠ capped marker, sub-session count) keeps reporting ClickUsage. Budget lines below the reading stay ClickUsage. Apply the same offset split in both the vertical branch and the collapsed band's shared-line/own-line branches of HandleClickType.
Add TargetSidebarUsageContext to the hit-test enum, map sidebar.ClickUsageContext to it, and open ShowContextDialogMsg on a left click, mirroring the existing ClickUsage -> ShowCostDialogMsg routing for the cost segment.
Update the sidebar usage-click description in the TUI feature doc and add a changelog entry for the new /context click target.
dgageot
previously approved these changes
Jul 24, 2026
feat(tui): open /context or /cost from the sidebar token-usage reading
trungutt
approved these changes
Jul 24, 2026
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.
Summary
When an agent configures a dedicated
compaction_modelwhose context window is smaller than the primary model's, the runtime silently caps the session's effective context limit to that smaller window. Until now the TUI attributed the reduced limit entirely to the primary model, with no indication that a different model imposed it — so users were misled about how much context they actually had before compaction was forced.This PR makes that cap explicit across the TUI, without changing any runtime capping behavior.
What changed
/contextdialog — when (and only when) the compaction model actually caps the limit, a dedicated second header line appears:compaction cap: <model> • <N> tokensIn the edge case where only the compaction window is resolvable (primary window unknown), the main limit line is re-attributed as
limit: <N> tokens (from compaction model).⚠ cappedmarker (no model name / figure) when capped; the/contextheader remains the authoritative source of the model and number.ContextBreakdown,LiveSession, andAgentInfoEventgained additive, cap-attribution fields (jsonomitempty); the effectiveContextLimitsemantics are unchanged so the usage bar, percentages, and free-space stay truthful.Notes
compaction_modelalready exists./contextdialog now derives the header height from the actually-rendered header (rather than a hardcoded line count) so the variable-height header does not break navigation.Validation
task build,task test,task lintall pass.main.Screenshots
Before
After