Skip to content

markdown: Render soft breaks as line breaks in agent markdown - #57376

Merged
smitbarmase merged 2 commits into
zed-industries:mainfrom
tredondo:fix-markdown-emoji-newlines
Jun 16, 2026
Merged

markdown: Render soft breaks as line breaks in agent markdown#57376
smitbarmase merged 2 commits into
zed-industries:mainfrom
tredondo:fix-markdown-emoji-newlines

Conversation

@tredondo

Copy link
Copy Markdown
Contributor

Agents sometimes output status lists with bullets represented by emojis - see #57372. These currently get rendered on one line, as opposed to bullet items like - or *, because single newlines within a paragraph are collapsed into spaces - standard CommonMark soft-break behavior in prose contexts (e.g. README.md). But in comment/PR contexts, GitHub preserves these newlines:

✅ Did A
✅ Did B
✅ Did C

Users reasonably expect agent output to be rendered following the comment-style convention.

What this PR does

This PR adds a soft_break_as_hard_break: bool field on MarkdownStyle and enables it for MarkdownFont::Agent, so a single newline within a paragraph in agent output renders as a line break instead of a space. The field defaults to false to preserves CommonMark behavior everywhere else. In themed_with_overrides, sets it to true for MarkdownFont::Agent. The rendering switch in MarkdownElement::request_layout then emits "\n" instead of " " for MarkdownEvent::SoftBreak when the flag is set. This matches GitHub comments and Obsidian default behavior, and prevents emoji + trailing newline content from being collapsed onto a single line in agent responses.

Scoped strictly to MarkdownFont::Agent. Hover popovers, diagnostics, markdown preview, README rendering, etc. are all untouched.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior - visual tests completed:
image
  • Performance impact has been considered and is acceptable

Closes #57372

Release Notes:

  • Improved agent panel markdown rendering: single newlines within agent responses now render as line breaks, matching the convention used by GitHub comments and Obsidian.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 21, 2026
@tredondo
tredondo force-pushed the fix-markdown-emoji-newlines branch 2 times, most recently from 04ec4f9 to 314706e Compare May 21, 2026 10:54
@MrSubidubi MrSubidubi added the area:preview/markdown Feedback for Zed's Markdown preview label May 22, 2026
Adds a `soft_break_as_hard_break` field on `MarkdownStyle` and enables it for `MarkdownFont::Agent`, so a single newline within a paragraph in agent output renders as a line break instead of a space. Matches GitHub comments and Obsidian default behavior, and prevents emoji + trailing newline content from being collapsed onto a single line in agent responses.

@smitbarmase smitbarmase left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@smitbarmase
smitbarmase enabled auto-merge June 16, 2026 16:11
@smitbarmase
smitbarmase added this pull request to the merge queue Jun 16, 2026
Merged via the queue into zed-industries:main with commit fe22af1 Jun 16, 2026
32 checks passed
@tredondo
tredondo deleted the fix-markdown-emoji-newlines branch June 16, 2026 19:17
This was referenced Jun 18, 2026
liusuren123 pushed a commit to liusuren123/zed that referenced this pull request Jun 30, 2026
…dustries#57376)

Agents sometimes output status lists with bullets represented by emojis
- see zed-industries#57372. These currently get rendered on one line, as opposed to
bullet items like `-` or `*`, because single newlines within a paragraph
are collapsed into spaces - standard CommonMark soft-break behavior *in
prose* contexts (e.g. `README.md`). But in *comment/PR* contexts, GitHub
preserves these newlines:

✅ Did A
✅ Did B
✅ Did C

Users reasonably expect agent output to be rendered following the
comment-style convention.

## What this PR does

This PR adds a `soft_break_as_hard_break: bool` field on `MarkdownStyle`
and enables it for `MarkdownFont::Agent`, so a single newline within a
paragraph *in agent output* renders as a line break instead of a space.
The field defaults to `false` to preserves CommonMark behavior
everywhere else. In `themed_with_overrides`, sets it to `true` for
`MarkdownFont::Agent`. The rendering switch in
`MarkdownElement::request_layout` then emits `"\n"` instead of `" "` for
`MarkdownEvent::SoftBreak` when the flag is set. This matches GitHub
comments and Obsidian default behavior, and prevents emoji + trailing
newline content from being collapsed onto a single line in agent
responses.

Scoped strictly to `MarkdownFont::Agent`. Hover popovers, diagnostics,
markdown preview, README rendering, etc. are all untouched.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior - visual tests completed: 
<img width="892" height="632" alt="image"
src="https://github.com/user-attachments/assets/1aacb5da-edc8-49fd-bfe9-d37a22ae2d3f"
/>

- [x] Performance impact has been considered and is acceptable

Closes zed-industries#57372

Release Notes:

- Improved agent panel markdown rendering: single newlines within agent
responses now render as line breaks, matching the convention used by
GitHub comments and Obsidian.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…dustries#57376)

Agents sometimes output status lists with bullets represented by emojis
- see zed-industries#57372. These currently get rendered on one line, as opposed to
bullet items like `-` or `*`, because single newlines within a paragraph
are collapsed into spaces - standard CommonMark soft-break behavior *in
prose* contexts (e.g. `README.md`). But in *comment/PR* contexts, GitHub
preserves these newlines:

✅ Did A
✅ Did B
✅ Did C

Users reasonably expect agent output to be rendered following the
comment-style convention.

## What this PR does

This PR adds a `soft_break_as_hard_break: bool` field on `MarkdownStyle`
and enables it for `MarkdownFont::Agent`, so a single newline within a
paragraph *in agent output* renders as a line break instead of a space.
The field defaults to `false` to preserves CommonMark behavior
everywhere else. In `themed_with_overrides`, sets it to `true` for
`MarkdownFont::Agent`. The rendering switch in
`MarkdownElement::request_layout` then emits `"\n"` instead of `" "` for
`MarkdownEvent::SoftBreak` when the flag is set. This matches GitHub
comments and Obsidian default behavior, and prevents emoji + trailing
newline content from being collapsed onto a single line in agent
responses.

Scoped strictly to `MarkdownFont::Agent`. Hover popovers, diagnostics,
markdown preview, README rendering, etc. are all untouched.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior - visual tests completed: 
<img width="892" height="632" alt="image"
src="https://github.com/user-attachments/assets/1aacb5da-edc8-49fd-bfe9-d37a22ae2d3f"
/>

- [x] Performance impact has been considered and is acceptable

Closes zed-industries#57372

Release Notes:

- Improved agent panel markdown rendering: single newlines within agent
responses now render as line breaks, matching the convention used by
GitHub comments and Obsidian.

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:preview/markdown Feedback for Zed's Markdown preview cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Emoji bullets in agent-generated markdown don't generate newlines

3 participants