Repository navigation
fix(chat): keep typed line breaks in user messages - #1015
Merged
Merged
Conversation
User messages are rendered as Markdown, and
`.markdown-user-message p { white-space: pre-wrap }` keeps single line
breaks inside paragraphs. Several cases still collapsed typed line
breaks into spaces:
- Lone `\r` line endings: Chrome renders `\r` as a space even under
pre-wrap, which merges pasted text into one paragraph exactly as
reported.
- Soft breaks inside tight list items (an exam question
`1. question\nA. option\nB. option`) and setext headings. Their text is
not inside a `<p>`, and adding pre-wrap to `li` turns the newlines
between block children into blank lines.
- Hard breaks (two trailing spaces or `\`) showed an extra blank line,
because remark-rehype emits `<br>` plus a "\n" that pre-wrap renders
again.
User messages now go through a small built-in remark plugin, selected by
a new `keepLineBreaks` prop on MarkdownBody, that turns every line ending
in text into a bare `<br>` and uses the same `<br>` for hard breaks.
Code, inline code, math and raw HTML keep their text. UserMessageView
also normalizes `\r\n`/`\r` so the plain-text paths (skill-command args,
the raw view of oversized messages) keep their breaks. Assistant
rendering is unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…680) A user message that mentions `<textarea>`, `<title>` or `<script>` without backticks opens a raw-text element in rehype-raw, and the <br> the line-break plugin placed after it ended that state: the lines were glued together or the rest of the paragraph disappeared. A paragraph, heading or table cell holding such a tag now renders as it did before, where the pre-wrap rule still shows its newlines. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
解开 agegr#981 的 DirectoryPicker 冲突后,这一段(390e70f..f52fd84)实测 0 冲突: - agegr#992 移动端输入框停在键盘上方并给打字更多空间 - agegr#997 限制每客户端 SSE 积压 - agegr#1001 可配置发送键(Enter / Ctrl+Enter) - agegr#1006 从 pi 的 provider catalog 解析 discovery endpoint - agegr#1017 空闲关闭被禁用时回收 Stop 无法解除的运行 - agegr#1016 Stop 结束输出被幸存进程持住的命令 - agegr#1015 保留用户消息里输入的换行 - agegr#1019 在 Safari / iOS 16.2 上可加载(新增 browserslist,无新依赖)
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 6, 2026
* fix(chat): keep typed line breaks in user messages (agegr#680) User messages are rendered as Markdown, and `.markdown-user-message p { white-space: pre-wrap }` keeps single line breaks inside paragraphs. Several cases still collapsed typed line breaks into spaces: - Lone `\r` line endings: Chrome renders `\r` as a space even under pre-wrap, which merges pasted text into one paragraph exactly as reported. - Soft breaks inside tight list items (an exam question `1. question\nA. option\nB. option`) and setext headings. Their text is not inside a `<p>`, and adding pre-wrap to `li` turns the newlines between block children into blank lines. - Hard breaks (two trailing spaces or `\`) showed an extra blank line, because remark-rehype emits `<br>` plus a "\n" that pre-wrap renders again. User messages now go through a small built-in remark plugin, selected by a new `keepLineBreaks` prop on MarkdownBody, that turns every line ending in text into a bare `<br>` and uses the same `<br>` for hard breaks. Code, inline code, math and raw HTML keep their text. UserMessageView also normalizes `\r\n`/`\r` so the plain-text paths (skill-command args, the raw view of oversized messages) keep their breaks. Assistant rendering is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(chat): leave blocks with raw-text tags to the default rendering (agegr#680) A user message that mentions `<textarea>`, `<title>` or `<script>` without backticks opens a raw-text element in rehype-raw, and the <br> the line-break plugin placed after it ended that state: the lines were glued together or the rest of the paragraph disappeared. A paragraph, heading or table cell holding such a tag now renders as it did before, where the pre-wrap rule still shows its newlines. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018
pushed a commit
to aiti-ai/aiti-ai
that referenced
this pull request
Nov 8, 2026
* fix(chat): keep typed line breaks in user messages (agegr#680) User messages are rendered as Markdown, and `.markdown-user-message p { white-space: pre-wrap }` keeps single line breaks inside paragraphs. Several cases still collapsed typed line breaks into spaces: - Lone `\r` line endings: Chrome renders `\r` as a space even under pre-wrap, which merges pasted text into one paragraph exactly as reported. - Soft breaks inside tight list items (an exam question `1. question\nA. option\nB. option`) and setext headings. Their text is not inside a `<p>`, and adding pre-wrap to `li` turns the newlines between block children into blank lines. - Hard breaks (two trailing spaces or `\`) showed an extra blank line, because remark-rehype emits `<br>` plus a "\n" that pre-wrap renders again. User messages now go through a small built-in remark plugin, selected by a new `keepLineBreaks` prop on MarkdownBody, that turns every line ending in text into a bare `<br>` and uses the same `<br>` for hard breaks. Code, inline code, math and raw HTML keep their text. UserMessageView also normalizes `\r\n`/`\r` so the plain-text paths (skill-command args, the raw view of oversized messages) keep their breaks. Assistant rendering is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(chat): leave blocks with raw-text tags to the default rendering (agegr#680) A user message that mentions `<textarea>`, `<title>` or `<script>` without backticks opens a raw-text element in rehype-raw, and the <br> the line-break plugin placed after it ended that state: the lines were glued together or the rest of the paragraph disappeared. A paragraph, heading or table cell holding such a tag now renders as it did before, where the pre-wrap rule still shows its newlines. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #680
Problem
User messages are rendered as Markdown.
.markdown-user-message p { white-space: pre-wrap }keeps single line breaks inside paragraphs, but several cases still collapsed typed line breaks into spaces:\rline endings: Chrome renders\ras a space even under pre-wrap, which merges pasted text into one paragraph exactly as reported.1. question\nA. option\nB. option, and setext headings. Their text is not inside a<p>, and adding pre-wrap toliturns the newlines between block children into blank lines.\) showed an extra blank line, because remark-rehype emits<br>plus a"\n"that pre-wrap renders again.Changes
MarkdownBodykeepLineBreaksprop, turns every line ending in text (\r\n,\r,\n) into a bare<br>viadata.hName, and uses the same<br>for hard breaks. Code, inline code, math and raw HTML keep their text.UserMessageViewnormalizes\r\n/\rso the plain-text paths (skill-command args and the raw view for oversized messages) also keep line breaks.Testing
components/MarkdownBody.test.mjsandcomponents/MessageView.test.mjs: LF/CRLF/CR, tight and nested lists, loose lists unchanged, setext heading, hard breaks, code and math untouched, assistant soft breaks unchanged, command args with\r. Six of them fail without the change.tsc --noEmitand eslint on the changed files pass.\r\nand with\r, plus an exam-style list: all render one line per typed line; before the fix the\rmessage merged into one paragraph and the list collapsed.🤖 Generated with Claude Code