[Bug]: Rich text composer turns underscores in pasted URLs and paths into asterisks#25180
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/web
Steps to reproduce
- Leave the rich text composer on (the default).
- Paste this into the composer:
1 Read https://example.com/_handle_/status/1 and open src/__test__.tsx - Send it, or select all in the composer and copy.
Expected behavior
The agent receives exactly what was pasted:
| 1 | Read https://example.com/_handle_/status/1 and open src/__test__.tsx |
Actual behavior
The composer shows handle in italics and test in bold with the underscores hidden, and the agent receives:
| 1 | Read https://example.com/*handle*/status/1 and open src/**test**.tsx |
The link is broken and the path does not exist.
- The same happens whenever a draft is rebuilt from its stored Markdown: reload, thread switch, history recall, stash restore. A URL that was typed character by character, which #19186 keeps literal, is rewritten the next time the draft is rebuilt.
- Pasting into inline code splits the paste out of the span. Pasting
a_b_ **c**inside`xy`gives`x`a_b_ **c**`y`. - Pasting
see `**x**` nowsendssee **`x`** now.
Cause: parseInlineMarkdown in apps/web/src/composer-rich-text.ts has no notion of URLs, so /_handle_/ qualifies as emphasis, and appendInlineRuns in apps/web/src/composer-rich-text-doc.ts writes every italic as * and every bold as ** (RICH_TEXT_DELIMITERS), whatever produced it. Paste (handlePaste) and every draft rebuild (buildDocJson) go through that parser. The code span case comes from Tiptap's paste rules, which run again over text handlePaste already parsed; the composer's code mark does not exclude bold, so **x** inside the span becomes bold. The chat renders the same text correctly because GFM autolinks a URL before looking for emphasis.
Impact
Minor bug or occasional failure
Version or commit
main @ c58beff810
Environment
Linux (NixOS), web client via vp run dev in Chromium 155, pasting with Ctrl+V. First noticed in the desktop app.
Logs or stack traces
| 1 |
Screenshots, recordings, or supporting files
composer-underscores-before.png composer-underscores-after.png
Workaround
Paste into a fenced code block, escape the underscores (\_), or turn rich text off.
I have a fix with focused tests ready, and can open a PR if you agree with the direction.