Skip to content

agent: Cap the height of large tool output and diff blocks#59242

Open
ebertn wants to merge 1 commit into
zed-industries:mainfrom
ebertn:agent-bound-tool-output-height
Open

agent: Cap the height of large tool output and diff blocks#59242
ebertn wants to merge 1 commit into
zed-industries:mainfrom
ebertn:agent-bound-tool-output-height

Conversation

@ebertn

@ebertn ebertn commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Tool output (including MCP/context server results), file diffs, and other text content blocks in the agent thread were rendered at full height. An accidentally huge buffer could lay out thousands of lines at once and cause serious UI/scrolling performance problems.

This caps each such block and reveals the rest behind an expand control.

Behavior:

  • Markdown/text output is capped at the new agent.tool_output_max_lines setting (default 10).
  • File diffs are sized proportionally to their length (3 + lines / 10), so small diffs show almost fully and large diffs grow slowly.
  • A centered, transparent chevron over a bottom vignette toggles each block between collapsed and expanded (2x the cap), and flips to reflect the state.
  • Expanded blocks are scrollable (and still capped); collapsed blocks are static previews. Scrolling chains out to the thread at the block's top/bottom edges.
  • agent.tool_output_max_lines = 0 disables capping entirely.

Implementation notes:

  • Generalizes the existing thinking-block constrain pattern into a reusable render_constrained_output_block helper, gated on the content's line count (short outputs render unchanged). The gating logic is a pure function with unit tests.
  • Scroll containment: the thread's list wheel handler only checks hit-test membership (not propagation), so the block is occluded to stop the thread from also scrolling, and we drive the block's scroll and hand off to list_state.scroll_by at the edges.
  • Terminal output is already bounded (fixed-height scroll region + output truncation), so it's left as-is.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Added an agent.tool_output_max_lines setting (default 10) that caps the height of large tool output and diff blocks in the agent panel behind an expandable, scrollable view, so an oversized buffer no longer degrades UI performance.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 13, 2026
@ebertn ebertn force-pushed the agent-bound-tool-output-height branch 2 times, most recently from ce4c405 to 5370dac Compare June 13, 2026 08:49
@ebertn ebertn marked this pull request as ready for review June 13, 2026 08:55
@ebertn ebertn force-pushed the agent-bound-tool-output-height branch 2 times, most recently from 0d695b9 to b90003f Compare June 14, 2026 00:46
ebertn added a commit to ebertn/zed that referenced this pull request Jun 14, 2026
Folds the updated terminal rendering from PR zed-industries#59242 into build: the inline embedded terminal now sizes its box to the actual output (growing up to the cap), keeps the trailing blank cursor line clipped just below the box, and shows an expand chevron beneath. The markdown/diff block capping and settings were already present on build.
Tool output (including MCP/context server results), file diffs, and other text content blocks in the agent thread were rendered at full height, so an accidentally huge buffer could lay out thousands of lines at once and cause serious UI/scrolling performance problems.

Cap each such block and reveal the rest behind an expand control:

- Markdown/text output is capped at agent.tool_output_max_lines (default 10).
- File diffs are sized proportionally to their length (3 + lines / 10).
- A centered, transparent chevron over a bottom vignette toggles each block between collapsed and expanded (2x the cap). The vignette band is reserved on top of the cap so the intended lines stay visible above it, the chrome is skipped entirely when the buffer already fits, and the fade only draws when content is actually clipped.
- Expanded blocks are scrollable and capped; collapsed blocks are static previews. Scrolling chains out to the thread at the block's top/bottom edges.
- agent.tool_output_max_lines = 0 disables capping entirely.

Terminal output is already bounded, so it's left as-is. The gating logic is covered by unit tests.
@ebertn ebertn force-pushed the agent-bound-tool-output-height branch from b90003f to 9b8e8e7 Compare June 14, 2026 19:50
ebertn added a commit to ebertn/zed that referenced this pull request Jun 14, 2026
A collapsed diff block was top-anchored, so it showed the leading context of the first hunk and the actual +/- changes were hidden below the fold. Anchor the collapsed preview to the first changed row (keeping one line of context above it) so the change is what's visible. From PR zed-industries#59242.
@ChristopherBiscardi ChristopherBiscardi added the area:ai Related to Agent Panel, Edit Prediction, Copilot, or other AI features label Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai Related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants