fix(chat): don't apply hard-break newlines to AI-streamed messages#385
Open
FelipeRamos-neuro wants to merge 1 commit into
Open
fix(chat): don't apply hard-break newlines to AI-streamed messages#385FelipeRamos-neuro wants to merge 1 commit into
FelipeRamos-neuro wants to merge 1 commit into
Conversation
The blanket `.replace(/\n/gi, ' \n')` in the chat message renderer ran over every message, not just user input as the comment intended. Since it's a raw string transform applied before markdown parsing, it injected trailing double-spaces into every line of AI-streamed fenced code blocks, corrupting copy-pasted code with invisible trailing whitespace. Scope the hard-break transform to user messages only.
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.
Summary
Fixes #384
src/chat-sidebar.tsx:891) applied a blanket.replace(/\n/gi, ' \n')hard-break transform to every rendered message, not just user input as the adjacent comment intended.msg.from === 'user'only, matching the comment's stated intent. AI-streamed messages already contain well-formed markdown and don't need the hack.See #384 for the full root-cause writeup and reproduction.
Test plan
react-markdown@9.0.1+remark-gfm@4.0.0: AI-message code blocks no longer carry trailing whitespace on any line, while user-message hard breaks are preserved🤖 Generated with Claude Code