fix(web): preserve XML-like tags in user messages#4133
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 6fc3bad. Configure here.
| lineBreaks ? CHAT_MARKDOWN_REMARK_PLUGINS_WITH_BREAKS : CHAT_MARKDOWN_REMARK_PLUGINS | ||
| } | ||
| rehypePlugins={CHAT_MARKDOWN_REHYPE_PLUGINS} | ||
| rehypePlugins={parseRawHtml ? CHAT_MARKDOWN_REHYPE_PLUGINS : undefined} |
There was a problem hiding this comment.
Raw HTML still dropped for users
High Severity
When parseRawHtml is false, XML-like tags (e.g., <global-agent-instructions>) disappear from rendered markdown. This happens because setting rehypePlugins to undefined removes the plugin needed to process these html nodes, causing them to be dropped from the output.
Reviewed by Cursor Bugbot for commit 6fc3bad. Configure here.
ApprovabilityVerdict: Needs human review An unresolved high-severity review comment identifies a potential bug where XML-like tags may be dropped rather than preserved, contradicting the PR's stated intent. Human review needed to verify correctness. You can customize Macroscope's approvability policy. Learn more. |


Summary
Root cause
ChatMarkdownalways enabled raw HTML parsing and sanitization. Unknown XML-like elements in user input, such as<global-agent-instructions>, were therefore interpreted as HTML and removed from the rendered message.User messages now opt out of raw HTML parsing, so their original text remains visible. Assistant messages keep the existing sanitized HTML behavior.
User impact
The rendered user message now matches what was typed instead of silently omitting XML-like tags. This only changes presentation; the message payload sent to the agent was already correct.
Fixes #4059.
Validation
pnpm exec vp test apps/web/src/components/chat/MessagesTimeline.test.tsx(14 tests passed)pnpm exec vp check(0 errors; 10 existing warnings)pnpm exec vp run typecheckNote
Preserve XML-like tags in user messages by disabling raw HTML parsing
parseRawHtmlprop toChatMarkdown(defaulttrue) that controls whether the rehype plugin pipeline runs.parseRawHtml={false}inUserMessageBodyso HTML-like tags in user text render as literal text instead of being parsed.Macroscope summarized 6fc3bad.
Note
Low Risk
Presentation-only change in chat markdown rendering with a narrow default-preserving API and targeted tests; no auth or data-path impact.
Overview
Fixes user chat bubbles silently dropping XML-like tags (e.g.
<global-agent-instructions>) because markdown always ran raw HTML parsing viarehype-raw+ sanitize.ChatMarkdowngains aparseRawHtmlflag (defaulttrue). Whenfalse, rehype raw-HTML plugins are skipped so angle-bracket text is shown as escaped literals instead of being stripped as unknown HTML.User message rendering in
MessagesTimelinesetsparseRawHtml={false}on everyChatMarkdownpath for user content. Assistant messages keep the default, so sanitized HTML such as<details>still renders.Regression tests cover escaped tags in user messages and continued HTML rendering for assistants.
Reviewed by Cursor Bugbot for commit 6fc3bad. Bugbot is set up for automated code reviews on this repo. Configure here.