Skip to content

feat(tui): auto-collapse reasoning blocks only when the reasoning phase ends - #82037

Closed
JElfferich wants to merge 1 commit into
NousResearch:mainfrom
JElfferich:feat/tui-reasoning-collapse-on-finish
Closed

feat(tui): auto-collapse reasoning blocks only when the reasoning phase ends#82037
JElfferich wants to merge 1 commit into
NousResearch:mainfrom
JElfferich:feat/tui-reasoning-collapse-on-finish

Conversation

@JElfferich

@JElfferich JElfferich commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • display.sections.thinking: collapsed now behaves as an auto preference: the TUI keeps the live reasoning panel open while reasoning streams, and collapses it the moment the reasoning phase ends (first tool call, final answer, or new turn)
  • Sealed reasoning segments from earlier phases in the same turn stay collapsed — only the currently-streaming block expands
  • expanded / hidden / MoA-reference panel semantics are unchanged

Motivation

With thinking: collapsed, the TUI collapsed every reasoning block — including the one currently being generated — so users couldn't watch reasoning stream while keeping finished blocks tidy. There was no mode for "expanded while live, collapsed when done". This PR makes collapsed that mode.

Changes

  • ui-tui/src/app/turnController.tssyncReasoningSegment() tags the open segment isLiveReasoning; endReasoningPhase() / closeReasoningSegment() seal the tag when reasoning ends
  • ui-tui/src/components/streamingAssistant.tsx — passes reasoningActive only to the live segment (block.msg.isLiveReasoning), not to every block
  • ui-tui/src/components/thinking.tsxToolTrail auto-opens while reasoningActive under collapsed mode; expanded/hidden/MoA references keep manual/current semantics
  • ui-tui/src/components/messageLine.tsx — threads reasoningActive through to ToolTrail
  • ui-tui/src/types.ts — new Msg.isLiveReasoning field
  • ui-tui/src/__tests__/thinkingLiveCollapse.test.tsx — new tests: open-on-stream, collapse-on-finish (incl. mid-turn rerender), expanded-mode no-op

Test Plan

  • npm run typecheck passes
  • npm run build passes
  • New thinkingLiveCollapse.test.tsx (4 tests) + existing details, messageLine, thinkingMoaReferenceVisibility, blockLayout, queueSubmission suites all pass
  • Full ui-tui suite: 0 new failures vs baseline (21 pre-existing failures in subscriptionOverlay/ink-backpressure/appChromeBlockedTimers — unrelated, A/B-verified on unpatched HEAD)
  • Manual: reasoning-heavy prompt in TUI — panel opens while streaming, collapses when reasoning ends, only current block expands

Notes for Reviewers

  • The isLiveReasoning flag approach was chosen over "last thinking segment" heuristics because the turn controller already tracks the open segment index precisely, and the flag survives segment merging (mergeToolShelfInto spreads the target msg).
  • Behavior is gated on the existing display.sections.thinking: collapsed config value — no new config keys.

Semantics change (reviewer note)

display.sections.thinking: collapsed previously meant "always collapsed". This PR redefines it as an auto preference: expanded while reasoning is live, collapsed when the reasoning phase ends. The strict "never expanded" behavior is still reachable via display.sections.thinking: hidden, and manual chevron clicks mid-stream still win (the auto-open only re-applies when the reasoning phase changes). Alternative considered: a new auto mode value leaving collapsed strict — rejected to avoid a second knob for the same concept; happy to split if maintainers prefer.

@alt-glitch alt-glitch added type/feature New feature or request comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have labels Aug 8, 2026
…se ends

Under display.sections.thinking: collapsed, the TUI now keeps the LIVE
reasoning panel open while reasoning streams and collapses it the moment
the reasoning phase ends (first tool call, final answer, or new turn).

Previously 'collapsed' meant the panel was always collapsed — including
the currently-streaming reasoning — and there was no way to get
'expanded while live, collapsed when done'. This makes 'collapsed' an
auto preference:

- turnController tags the open reasoning segment isLiveReasoning and
  seals the tag in endReasoningPhase/closeReasoningSegment
- streamingAssistant passes reasoningActive only to the live segment,
  so sealed reasoning segments from earlier phases stay collapsed
- ToolTrail auto-opens while reasoningActive under collapsed mode;
  expanded/hidden/MoA-reference semantics are unchanged

Adds thinkingLiveCollapse.test.tsx covering open-on-stream, close-on-
finish (including mid-turn rerender), and the expanded-mode no-op.
@teknium1

Copy link
Copy Markdown
Contributor

Thanks for this fix! It was salvaged into #86771 (cherry-picked onto current main with your authorship preserved in the commit history) and is now merged. Closing since the work has landed.

@teknium1 teknium1 closed this Aug 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants