Skip to content

agent: Add expand_code_block setting - #64793

Open
cachebag wants to merge 2 commits into
zed-industries:mainfrom
cachebag:agent-collapse-tool-cards-by-default
Open

cachebag wants to merge 2 commits into
zed-industries:mainfrom
cachebag:agent-collapse-tool-cards-by-default

Conversation

@cachebag

@cachebag cachebag commented Sep 25, 2026 •

Copy link
Copy Markdown

Objective

Addresses #58333.

Long ACP agent turns are hard to scan because verbose blocks push the prose apart. Diff and terminal cards are already configurable via expand_edit_card / expand_terminal_card, but fenced code blocks inside agent messages had no collapse at all.

Code-heavy responses therefore dominated the thread with no settings-only workaround and this has been a really frustrating for many users, including me, as it makes a lot of the agent output borderline unreadable.

Solution

Adds agent.expand_code_block (this is defaulted to true).

When set to false, code blocks in agent messages render as a single row showing the language and line count (for example rust · 42 lines). Clicking the row expands the block, and the hover toolbar on an expanded block gains a collapse button next to the existing wrap and copy buttons. A block that contains the active in-thread search match stays open so navigating between matches never lands on hidden text.

  • markdown: new MarkdownElement::collapse_code_blocks option. Collapsed blocks skip content layout entirely and render a summary row instead. Per-block expanded state lives on the Markdown entity, keyed by source offset like the existing wrapped_code_blocks, so it survives re-renders and streaming appends.
  • settings_content / agent_settings / default.json / settings UI: the new setting, alongside expand_edit_card and expand_terminal_card.
  • agent_ui: applies the setting to assistant message content only. Tool output and compaction summaries are already collapsible as a whole and are left unchanged.

Testing

Ideally, some candidates from #58333 can also take a look and try it for themselves and post screenshots

Here are some code blocks with the setting on:
image

And with the setting disabled:
image

I wrote and tested this patch on macOS and tested on Linux but not on Windows

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 agent.expand_code_block setting to have code blocks in agent messages start collapsed, expandable individually.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Sep 25, 2026
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Sep 25, 2026
@SomeoneToIgnore SomeoneToIgnore added the area:ai/agent thread Feedback for Zed's Agent Thread label Sep 25, 2026
@cachebag
cachebag force-pushed the agent-collapse-tool-cards-by-default branch 2 times, most recently from b331c2b to dfa94c0 Compare September 26, 2026 15:28
Adds MarkdownElement::collapse_code_blocks. Collapsed blocks render as a
single row with the language and line count, expand on click, and get a
collapse button in the hover toolbar. A block containing the active
search match stays open so the match is never hidden.
When false, fenced code blocks in agent messages start collapsed and can
be expanded individually. Complements expand_edit_card and
expand_terminal_card. Tool output and compaction summaries are
unaffected.

Addresses zed-industries#58333
@cachebag
cachebag force-pushed the agent-collapse-tool-cards-by-default branch from dfa94c0 to b7be823 Compare September 27, 2026 00:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai/agent thread Feedback for Zed's Agent Thread cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants