opencode
opencode copied to clipboard
feat(tui): Dynamic Details - compact tool output with click-to-expand
Summary
Keeps tool output compact and accessible with click-to-expand functionality. Tool blocks with more than 15 lines collapse by default, showing a preview with a "+N" indicator. Click anywhere on the tool block to expand/collapse, making it easier to navigate long sessions without pages of output scrolling by.
Fixes #7450 Relates to #1816
Also helps with:
- #5358 - Collapsible outputs improve tool output visibility
- #5419 - Less scrolling through verbose output improves screen real estate usage
- #6240 - Same goal of reducing visual clutter
- #3521 - Diffs are collapsed by default
- #5277 - Collapsed outputs save space on small screens
Compliments commit: https://github.com/anomalyco/opencode/commit/b3a2f9fb4
Features
- Tool outputs collapse when exceeding configured line threshold
- Click anywhere on tool block to expand/collapse
- Shows "+N" indicator for hidden lines
- Configurable threshold via
tui.dynamic_details_max_lines(default: 15) - Configurable arrow indicators via
tui.dynamic_details_show_arrows(default: true) - Toggle via Ctrl+P -> "Enable/Disable dynamic details"
- Persisted preference in KV store (default: enabled)
Configuration
{
"tui": {
"dynamic_details_max_lines": 15,
"dynamic_details_show_arrows": true
}
}
Applies To
Block-container tools (bash, write, edit, patch) when:
- Output exceeds configured line threshold
- Tool has completed (not pending/running states)
TodoWrite is excluded (always expanded) for visibility.
Implementation
Enhances the existing BlockTool component with collapse/expand logic rather than introducing new abstractions. Uses:
- Data-based line counting for collapse decisions (stable, based on tool output)
- Visual line counting via
virtualLineCountfor accurate "+N" display -
maxHeight+overflow: hiddenfor clipping when collapsed
Changes
-
packages/opencode/src/cli/cmd/tui/routes/session/index.tsx- Add dynamicDetails context, toggle command, and collapse logic in BlockTool -
packages/opencode/src/config/config.ts- Add config options for max lines and arrow indicators