Skip to content

fix(web): preserve XML-like tags in user messages#4133

Open
0utsights wants to merge 1 commit into
pingdotgg:mainfrom
0utsights:codex/issue-4059-rendering-repro
Open

fix(web): preserve XML-like tags in user messages#4133
0utsights wants to merge 1 commit into
pingdotgg:mainfrom
0utsights:codex/issue-4059-rendering-repro

Conversation

@0utsights

@0utsights 0utsights commented Jul 18, 2026

Copy link
Copy Markdown

Summary

  • display user-authored HTML/XML-like syntax literally in chat messages
  • preserve sanitized raw HTML rendering for assistant messages
  • add regression coverage for both behaviors

Root cause

ChatMarkdown always 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 typecheck

Note

Preserve XML-like tags as text in user messages

  • Adds a parseRawHtml prop (default true) to ChatMarkdown that controls whether HTML-like content is parsed into elements or rendered as inert source text.
  • Sets parseRawHtml={false} for all user message rendering in UserMessageBody, so XML-like tags and comparison operators in user input appear as escaped text rather than HTML.
  • Assistant messages continue to parse and sanitize raw HTML as before, supporting markup like <details>/<summary>.
  • Behavioral Change: user messages that previously rendered HTML tags as elements will now display them as literal text.

Macroscope summarized f0da0f7.


Note

Low Risk
Presentation-only change for user bubbles with stricter display of user HTML; assistant markdown path is unchanged and tests lock in XSS-safe user rendering.

Overview
Fixes user chat bubbles silently dropping XML-like text (e.g. <global-agent-instructions>) because ChatMarkdown always ran raw HTML parsing and sanitization.

Adds a parseRawHtml flag (default true) that toggles the rehype-raw / rehype-sanitize pipeline. When false, HTML-like input is shown as escaped source text instead of being parsed or stripped. User message rendering in MessagesTimeline opts out with parseRawHtml={false} on every ChatMarkdown path; assistant messages keep the default so supported markup (e.g. <details>) still renders after sanitization.

Regression tests cover literal XML/comparisons in user text, inert handling of malicious user HTML, and unchanged sanitized assistant HTML behavior.

Reviewed by Cursor Bugbot for commit f0da0f7. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2ceee19f-257f-43a4-ae05-45eec26b9064

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Jul 18, 2026
@0utsights
0utsights marked this pull request as ready for review July 19, 2026 00:50

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ 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.

Comment thread apps/web/src/components/ChatMarkdown.tsx
@macroscopeapp

macroscopeapp Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

Simple, well-tested bug fix that adds a boolean prop to preserve XML-like tags as literal text in user messages. The change is self-contained with comprehensive test coverage including XSS protection verification.

You can customize Macroscope's approvability policy. Learn more.

Render user-authored XML-like source as escaped text while retaining sanitized assistant HTML, with regression coverage for custom tags, code, comparisons, and unsafe input.

Co-authored-by: codex <codex@users.noreply.github.com>
@juliusmarminge
juliusmarminge force-pushed the codex/issue-4059-rendering-repro branch from 6fc3bad to f0da0f7 Compare July 20, 2026 17:33
@github-actions github-actions Bot added size:S 10-29 changed lines (additions + deletions). and removed size:XS 0-9 changed lines (additions + deletions). labels Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: XML-like tags get filtered/removed from the chat

1 participant