feat(tui): add focus view to collapse multi-step turns - #41264
Open
liush2yuxjtu wants to merge 3 commits into
Open
feat(tui): add focus view to collapse multi-step turns#41264liush2yuxjtu wants to merge 3 commits into
liush2yuxjtu wants to merge 3 commits into
Conversation
This was referenced Aug 8, 2026
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
fig2-toggle.webmfig3-flow.webmfig1-highlight.webm |
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.
Issue for this PR
Closes #37003
Type of change
What does this PR do?
Adds an opt-in TUI "focus view" toggle that collapses each multi-step assistant turn into one compact block: the turn's final text, a one-line summary of every tool call across the turn, and a hidden-message count. New messages update the block in place instead of appending more messages.
Why it works: a single prompt often produces several assistant messages (a tool-calls round, then a final text round), so the transcript floods with full tool output. Focus view groups messages by
parentIDinto turns and only renders the last message of each turn as a collapsed block while enabled.Toggle via command palette ("Enter/Exit focus view"), a
/focusslash command, or afocus_viewkeybind (default none, configurable intui.json). State persists across sessions. Disabled by default so existing behavior is unchanged.This is an implementation of the collapse behavior requested in #37003, delivered as opt-in rather than default-on.
Design
A turn is the set of assistant messages sharing the same
parentID(the user message). A multi-step reply emits a tool-calls round (finish="tool-calls") followed by a final text round (finish="stop").Demo 1 · Turn structure — click a message card to highlight its timeline row (interactive):
https://github.com/liush2yuxjtu/opencode/releases/download/focus-demo-v1/fig1-highlight.webm
Demo 2 · Focus OFF vs ON — click either side to toggle full/collapsed view (interactive):
https://github.com/liush2yuxjtu/opencode/releases/download/focus-demo-v1/fig2-toggle.webm
Demo 3 · Message flow — the display block updates in place as new messages arrive (interactive):
https://github.com/liush2yuxjtu/opencode/releases/download/focus-demo-v1/fig3-flow.webm
Render rule
How did you verify your code works?
bun run typecheck(packages/tui) passes.bun devsession and verified:↳ 1 write, 1 bash · 3 messages hidden+ final text, with a single turn footer (no duplicate▣lines from hidden intermediate messages).Screenshots / recordings
Focus ON (collapsed):
Focus OFF (full):
Checklist