feat(tui): make Context and Token Usage sidebar sections collapsible#11986
feat(tui): make Context and Token Usage sidebar sections collapsible#11986IamCoder18 wants to merge 1 commit into
Conversation
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Re-verified against current HEAD ( Files Reviewed (2 files)
Previous Review Summaries (2 snapshots, latest commit 8c23c97)Current summary above is authoritative. Previous snapshots are kept for context only. 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: 26 · Output: 11.4K · Cached: 737.2K Review guidance: REVIEW.md from base branch |
e4ce4b7 to
8c23c97
Compare
The TUI session sidebar already lets Modified Files, LSP, MCP, Todo, and
Background Processes collapse on header click (▼/▶), but Context and the
three Token Usage sub-sections were always expanded. Match the existing
collapsible pattern so users can fold them away when they want a less
cluttered sidebar.
* packages/opencode/src/cli/cmd/tui/feature-plugins/sidebar/context.tsx
- add createSignal + Show; wrap the Context header in an onMouseDown
toggle that flips open() and shows ▼/▶ plus an inline summary
("(N tokens · X% used · $Y spent)") while collapsed
* packages/opencode/src/kilocode/plugins/sidebar-usage.tsx
- extract a local Collapsible helper (▼/▶ toggle + optional inline
collapsedLabel) so we don't duplicate the boilerplate three times
- wrap Token Usage, Terminal Bench 2.0, and Models with Collapsible;
each gets a one-line summary when collapsed so context is preserved
Balance (sidebar-footer.tsx) is intentionally untouched per request.
The non-Context sidebar plugins (LSP, MCP, Todo, Files, Background
Processes) already implemented the same onMouseDown toggle pattern, so
no shared helper was promoted into the upstream sidebar/ directory;
keeping the change inside the two Kilo-owned and the one shared
section we actually needed to touch keeps the upstream diff minimal.
8c23c97 to
0a6204a
Compare
|
Thanks @IamCoder18 - this LGTM but want to have another review first. |
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