Skip to content

feat(tui): show plugin and MCP tool input as a readable block - #54707

Closed
Nowaker wants to merge 1 commit into
anomalyco:v1from
Nowaker:tool-input-block
Closed

Nowaker wants to merge 1 commit into
anomalyco:v1from
Nowaker:tool-input-block

Conversation

@Nowaker

@Nowaker Nowaker commented Oct 12, 2026 •

Copy link
Copy Markdown

Note: I'm aware v1 is now the maintenance branch and new features go to v2 only. This PR is here for others to use, and I'll submit the v2 version once I've migrated my whole plugin system to it.

Issue for this PR

Closes #54703

Type of change

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

What does this PR do?

With syntax.tool_input: true in tui.json, a plugin or MCP tool's input that is all primitives and fits 80 characters keeps today's [key=value] line. Anything else becomes a block (util/tool-input.ts): one key per row, keys and values in different colors, values colored by type, strings unquoted with their newlines, tabs and quotes as themselves, nested objects indented under their key, and lists in compact YAML (- items at their key's indent). Until the block is clicked, every value takes exactly one row, cut with a muted … where it stops fitting, so the collapsed block shows keys and the start of each value; the width is the block's measured width, taken on layout and resize only. Clicking shows everything whole.

Keys and values never draw in red, which means a failed tool call in the transcript: the colors come from theme/tool-code.ts (shared with #54704), where every red or error-colored syntax slot takes a non-red alternative. Keys use the property color, falling back to the function color, then the type color.

When the generic output toggle is off, a call with a response still shows "Click to expand", and expanding draws the response under the input, so the block never leaves a stored response unreachable (toolOutputReach). Without syntax.tool_input the toggle stays in charge as today.

Off by default, so the transcript looks as it does now. Documented in tui.mdx.

How did you verify your code works?

  • bun typecheck; bun test test/util test/config.test.tsx test/cli/tui test/tool-code-theme.test.ts: 117 pass, including collapsed render frames at 40, 80 and 160 columns (one row per value, never wider than the block), the compact YAML layout, cutting by display width, and a check of every built-in theme for red slots.
  • A real TUI at 80 and 160 columns with an MCP call carrying nested input and a question list.
  • A real TUI at 40, 80 and 160 columns with the output toggle off and a stored Perplexity search response: the block shows "Click to expand", and a click through a real PTY client shows the response with "Click to collapse"; with syntax.tool_input off the inline row is unchanged.

Screenshots / recordings

Collapsed, at 80 columns:

# vibeterm_async_question
questions:
- header: Paste dialog v4
  question: Live as vt-233 on desktop and m4max (fork 00ea612cb9, PR #54…
  options:
  - label: Works
    description: Buttons, tab and hint behave as listed in the report ab…
  - label: Something's off
    description: Say what differs from the report, with the exact keys y…

Click to expand

Checklist

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

This PR is AI generated, but under direct supervision and on request of @Nowaker.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Nowaker added a commit to Nowaker/opencode that referenced this pull request Oct 12, 2026
Feature and session records for the bash, heredoc, file language and
tool input coloring (dfbf7f6..8a360b4), upstream PRs anomalyco#54704-anomalyco#54707
and the vt-238 install on desktop and m4max.

AI-Model: anthropic/claude-opus-5-5
AI-Variant: high
AI-Tool: opencode 1.19.0-vt-227-dfb56f76c7
AI-Platform: linux
AI-Harness: Vibeterm e8a9833
AI-Session-ID: ses_ed1e2b932ffe6tTqhsOiGuYXRE
Nowaker added a commit to Nowaker/opencode that referenced this pull request Oct 12, 2026
The colored bash command now lays out byte-identically to the plain one,
and tool-call code never draws in red (b236851, 91e33c5); upstream
branches amended, PRs anomalyco#54704, anomalyco#54705 and anomalyco#54707 updated, vt-241 on
desktop and m4max.

AI-Model: anthropic/claude-opus-5-5
AI-Variant: high
AI-Tool: opencode 1.19.0-vt-227-dfb56f76c7
AI-Platform: linux
AI-Harness: Vibeterm e6434eb
AI-Session-ID: ses_ed1e2b932ffe6tTqhsOiGuYXRE
Nowaker added a commit to Nowaker/opencode that referenced this pull request Oct 12, 2026
Session record for 2026-10-12: collapsed tool input shows every value on
one row, lists in compact YAML (84d27d0), PR anomalyco#54707 amended, vt-243
on desktop and m4max.

AI-Model: anthropic/claude-opus-5-5
AI-Variant: high
AI-Tool: opencode 1.19.0-vt-227-dfb56f76c7
AI-Platform: linux
AI-Harness: Vibeterm e6434eb
AI-Session-ID: ses_ed1e2b932ffe6tTqhsOiGuYXRE
A plugin or MCP tool's input is shown as `[key=value, ...]` on the
tool's line, and only its primitive values: an object or array argument
disappears, and a long or multi-line string runs on as one line with
its escapes. A tenth of these calls pass nested input and a tenth carry
multi-line text.

With `syntax.tool_input: true` in tui.json, input that is all primitives
and fits 80 characters keeps that one line. Anything else becomes a
block (packages/tui/src/util/tool-input.ts): one key per row, keys and
values in different colors and values colored by type, strings unquoted
with their newlines, tabs and quotes as themselves, a multi-line string
as indented lines under its key, nested objects indented under their
key, and lists in compact YAML: `- ` items at their key's indent, an
item's other keys aligned under its first. Until the block is clicked,
every value takes exactly one row, cut with a muted `…` where it stops
fitting; the width is the block's measured width, taken on layout and
on resize only. Clicking shows every value whole, together with the
output.

Keys and values never draw in red, which in the transcript means a
failed tool call: the colors come from packages/tui/src/theme/tool-code.ts,
where every syntax slot that is red, or the theme's error color, takes a
non-red alternative. Keys use the property color (syntaxVariable), which
falls back to the function color, then the type color, in themes where
it is red.

The setting defaults to false, so the transcript looks as it does now.

The generic output toggle hides a tool's response, and the block must
not lose it: when the toggle is off, a call with a response still shows
"Click to expand", and expanding draws the response under the input
(`toolOutputReach`); an input short enough for one line expands from
its row. Without `syntax.tool_input` the toggle stays in charge.
Nowaker added a commit to Nowaker/opencode that referenced this pull request Oct 13, 2026
Perplexity and other plugin/MCP responses were unreachable under the
tool input block with the generic output toggle off (4c00002); PR
anomalyco#54707 amended; vt-257 on desktop and m4max.

AI-Model: anthropic/claude-opus-5-5
AI-Variant: high
AI-Tool: opencode 1.19.0-vt-227-dfb56f76c7
AI-Platform: linux
AI-Harness: Vibeterm 41f09c2
AI-Session-ID: ses_ed1e2b932ffe6tTqhsOiGuYXRE
@Nowaker

Nowaker commented Nov 2, 2026

Copy link
Copy Markdown
Author

Closing: this targets the v1 TUI, which upstream now maintains for critical fixes only, so it is not going to be merged. The branch stays on Nowaker/opencode if anyone wants to pick it up.

@Nowaker Nowaker closed this Nov 2, 2026
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