feat(tui): make Context and Token Usage sidebar sections collapsible - #11986
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge The incremental diff since the last review consists solely of splitting the arrow indicator into its own Files Reviewed (2 files)
Previous Review Summaries (4 snapshots, latest commit 7d16c5f)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 7d16c5f)Status: 1 Issue Found | Recommendation: Merge (optional cleanup) The branch was rebased/restructured since the last review — the diff now touches only The collapsible toggle added to Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous review (commit 0a6204a)Status: No Issues Found | Recommendation: Merge Re-verified against current HEAD ( Files Reviewed (2 files)
Previous review (commit 8c23c97)Status: No Issues Found | Recommendation: Merge The previous Files Reviewed (2 files)
Previous review (commit e4ce4b7)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)SUGGESTION
The collapsible pattern added to Note: this is a user-facing UI change (new collapsible sections) with no changeset in Fix these issues in Kilo Cloud Files Reviewed (2 files)
Reviewed by claude-sonnet-5 · Input: 14 · Output: 2.6K · Cached: 268.2K Review guidance: REVIEW.md from base branch |
8c23c97 to
0a6204a
Compare
|
Thanks @IamCoder18 - this LGTM but want to have another review first. |
|
Hey @IamCoder18, sorry for the late review. The change looks good. Since this PR was opened, Token Usage, Models, and Terminal Bench have already been made collapsible on Could you update the branch with the latest |
|
Yes, sure |
0a6204a to
7d16c5f
Compare
The TUI session sidebar already lets Token Usage, Models, and Terminal Bench 2.0 collapse on header click (▼/▶), but Context was always expanded. Match the existing collapsible pattern so users can fold it away when they want a less cluttered sidebar. When collapsed, the header shows a one-line summary of percent used and total cost.
7d16c5f to
ef694ab
Compare
|
@johnnyeric Done. The change now only makes Context collapsible, and shows a short summary of context percent and cost when collapsed.
|
|
Thanks for addressing it! Just merged. |
The TUI session sidebar already lets Token Usage, Models, and Terminal Bench 2.0 collapse on header click (▼/▶), but Context was always expanded. Match the existing collapsible pattern so users can fold it away when they want a less cluttered sidebar. When collapsed, the header shows a one-line summary of percent used and total cost.

Issue
Closes #11985
Context
The TUI session sidebar was inconsistent: Modified Files / LSP / MCP / Todo / Background Processes already collapsed on header click, but Context and the three Token Usage sub-sections (Token Usage, Terminal Bench 2.0, Models) were always expanded. This made the sidebar noisier than necessary on long sessions and forced users to scan past content they couldn't hide.
This change brings those sections in line with the existing collapsible pattern (header click toggles a indicator, content collapses, an inline one-line summary stays visible when folded) so the sidebar behaves predictably. The Balance section is intentionally left alone as it is not part of the scrollable sidebar (it's part of the footer).
Implementation
packages/opencode/src/cli/cmd/tui/feature-plugins/sidebar/context.tsxuses the samecreateSignal+Showtoggle pattern that's already infiles.tsx/lsp.tsx/mcp.tsx/todo.tsx. When folded, the header collapses to a singleContext (N tokens · X% used · $Y spent)summary so the user still sees the three numbers without the three rows of vertical space.packages/opencode/src/kilocode/plugins/sidebar-usage.tsxextracts a localCollapsiblehelper aboveView(theme + title + optionalcollapsedLabel+ children) so the boilerplate isn't duplicated three times. Each of the three sub-sections is wrapped:Cost $X · In N · Out M(usesusage()?.totals).terminalBenchmodel metadata.Models (N)already encodes the count in the title, matching what MCP does (MCP (N active[, M errors])).I deliberately did not promote
Collapsibleinto the sharedpackages/opencode/src/cli/cmd/tui/feature-plugins/sidebar/directory alongside the upstream-owned plugins. The other sidebar plugins already implement the same pattern inline withlength > 2guards; unifying them would touch shared upstream code (touching merge surface for very little user-visible benefit) without affecting any user-visible behavior.Balance(packages/opencode/src/kilocode/plugins/sidebar-footer.tsx) is intentionally not modified.Screenshots / Video
2026-07-06.16-53-18.mp4
How to Test
Manual/local verification
Reviewer test steps
▼ Contextheader — confirm it flips to▶and the body rows collapse into a one-line summary; click again to re-expand.Token Usage,Terminal Bench 2.0(visible when the current model hasterminalBenchmetadata), andModels. Each must toggle independently.Checklist
Get in Touch
Discord: @IamCoder18