Skip to content

feat(tui): make reasoning blocks collapsible in show mode - #59498

Open
ShiDikALexey wants to merge 3 commits into
anomalyco:devfrom
ShiDikALexey:thinking-collapse
Open

ShiDikALexey wants to merge 3 commits into
anomalyco:devfrom
ShiDikALexey:thinking-collapse

Conversation

@ShiDikALexey

@ShiDikALexey ShiDikALexey commented Oct 27, 2026 •

Copy link
Copy Markdown

Issue for this PR

Refs #51229 (reasoning blocks only).

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Reasoning blocks could only be collapsed by setting the session-wide Thinking option to hide. In show mode the block was always fully expanded and the header did not respond to clicks.

The reasoning header now toggles its block in both modes: expanded by default in show, collapsed by default in hide. Clicking the header flips the current state, selecting header text does not fold the block, and changing the session-wide default clears per-block overrides so the new default applies.

How did you verify your code works?

  • New packages/tui/test/cli/tui/reasoning-disclosure.test.tsx drives real mouse clicks and asserts the collapsed and expanded frames in both modes, including the reset after switching the session default.
  • bun --cwd packages/tui test: 1527 pass, 16 skip, 11 fail. Those 11 failures are pre-existing Windows-environment issues in this checkout (symlink EPERM, 5s timeouts, locale-specific 1 234 formatting); none are in the changed code or the new test.
  • bun --cwd packages/tui typecheck and root bun run typecheck: clean.
  • bun run lint: 0 errors.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" role="img" aria-label="Clicking a reasoning header collapses and expands the block">
  <g font-family="ui-monospace, SFMono-Regular, Menlo, monospace" font-size="10" fill="currentColor">
    <rect x="4" y="4" width="232" height="64" rx="6" fill="none" stroke="currentColor" stroke-opacity=".18"/>
    <g>
      <text x="14" y="24">+ Thought: Inspecting stability · 2s</text>
      <animate attributeName="opacity" values="1;1;0;0;1;1" keyTimes="0;.2;.24;.8;.84;1" dur="6s" repeatCount="indefinite"/>
    </g>
    <g opacity="0">
      <text x="14" y="24">- Thought: 2s</text>
      <text x="14" y="40" opacity=".65">Inspecting stability</text>
      <text x="14" y="54" opacity=".65">The reasoning body is visible.</text>
      <animate attributeName="opacity" values="0;0;1;1;0;0" keyTimes="0;.2;.24;.8;.84;1" dur="6s" repeatCount="indefinite"/>
    </g>
    <circle cx="10" cy="21" r="1" fill="none" stroke="currentColor">
      <animate attributeName="r" values="1;1;9;9" keyTimes="0;.16;.22;1" dur="6s" repeatCount="indefinite"/>
      <animate attributeName="opacity" values="0;0;1;0;0" keyTimes="0;.16;.18;.22;1" dur="6s" repeatCount="indefinite"/>
    </circle>
  </g>
</svg>

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Added by the opencode bot (AI-generated).

Related: #51229

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change works as described. I ran the TUI from source on the base and on this branch with session.thinking: "show" and clicked a reasoning header. On the base nothing happens. With this PR the block folds to + Thought: <title> · <duration> and unfolds again on the next click. The new test and the nearby TUI tests pass (430 pass, 0 fail). Type errors are the same on the base and the PR, and none are in the changed files.

Public API: unchanged. This only touches the TUI's internal reasoning component; there are no config, SDK, plugin or CLI changes.

No blocking concerns. The new guard that skips the toggle when header text is selected uses the same check found elsewhere in the TUI code. Resetting each block's open/closed state when the session-wide Thinking setting changes keeps the new default predictable. The fold state still isn't kept when a block is re-rendered from scratch, the same as hide mode on the base, so it isn't a regression.

Related: #51229

Before

After

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit only merges dev into the branch. The PR's own changes to the two files are byte-for-byte the same as in my last review, and the merge didn't touch packages/tui. I reran the TUI check at the new head with session.thinking: "show": clicking the reasoning header still folds the block. The nearby TUI tests still pass (430 pass, 0 fail).

Public API: unchanged.

No new concerns.

Before

After

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant