Problem
Markdown obtained after copying and pasting a rendered assistant message has sometimes differed from the stored message source. In the investigated examples, stored $PCO_2$ appeared downstream as $PCO\_2$, along with HTML space entities and unusual emphasis markers. A blanket unescape would corrupt intentional TeX and Markdown, so the transformation must be located before changing behavior.
Verified diagnosis
- Read-only inspection of an authorized example confirmed that the stored response contains
$PCO_2$, with no escaped underscore.
- The same stored text existed in the parent and fork, excluding fork creation as the source of the change.
- The message-copy button does not itself add underscore escapes to the text passed to its clipboard writer.
Relevant paths:
apps/web/src/components/chat/MessageCopyButton.tsx
apps/web/src/hooks/useCopyToClipboard.ts
apps/web/src/markdown-clipboard.ts
- the receiving Markdown composer serialization path
Investigation required
For a synthetic message containing subscripts, intentional escaped underscores, emphasis, entities, and mixed Hebrew/English text, capture and compare:
- Stored message source.
- Text supplied to the copy action.
- Written
text/plain and text/html clipboard flavors.
- The receiving composer's parsed and serialized source.
Run the matrix for the message copy button and manual selection copy. Record the exact app version and receiving surface.
Desired behavior
The plain Markdown flavor should preserve authored syntax predictably, and paste handling should not introduce or remove escapes without a format-specific reason. Rich HTML and plain text may differ structurally, but each must have a defined contract.
Non-goals
- Do not globally replace
\_ with _.
- Do not infer the faulty component from screenshot text.
- Do not change stored messages while diagnosing clipboard behavior.
Validation
Cover intentional literal underscores, TeX subscripts, links, code, emphasis, HTML entities, Hebrew/English text, and copy/paste round trips. Verify native clipboard flavors and manual behavior before closure.
Problem
Markdown obtained after copying and pasting a rendered assistant message has sometimes differed from the stored message source. In the investigated examples, stored
$PCO_2$appeared downstream as$PCO\_2$, along with HTML space entities and unusual emphasis markers. A blanket unescape would corrupt intentional TeX and Markdown, so the transformation must be located before changing behavior.Verified diagnosis
$PCO_2$, with no escaped underscore.Relevant paths:
apps/web/src/components/chat/MessageCopyButton.tsxapps/web/src/hooks/useCopyToClipboard.tsapps/web/src/markdown-clipboard.tsInvestigation required
For a synthetic message containing subscripts, intentional escaped underscores, emphasis, entities, and mixed Hebrew/English text, capture and compare:
text/plainandtext/htmlclipboard flavors.Run the matrix for the message copy button and manual selection copy. Record the exact app version and receiving surface.
Desired behavior
The plain Markdown flavor should preserve authored syntax predictably, and paste handling should not introduce or remove escapes without a format-specific reason. Rich HTML and plain text may differ structurally, but each must have a defined contract.
Non-goals
\_with_.Validation
Cover intentional literal underscores, TeX subscripts, links, code, emphasis, HTML entities, Hebrew/English text, and copy/paste round trips. Verify native clipboard flavors and manual behavior before closure.