Repository navigation
Closed
Copy link
Labels
confirmed-reproBug reproduced again from a clean trusted checkout; see linked reportperfuiApp shell, sidebar, composer, rendering
Description
Summary
MarkdownPreview turns off incremental rendering when allowHtml is set and the content contains <. Then the whole settled part of an assistant message is parsed again with rehype-raw and rehype-sanitize each time a block completes. Most < characters in agent output are not HTML: they are in code fences (Map<string, number>), inline code (Array<T>) or prose (a < b, <-). For a long message this makes the cost grow with the number of blocks times the message length.
Versions and environment
mainat 1320c88e8a, run from source.- Linux 7.3.4 (CachyOS), Node 26.13.1.
- Found in a code survey for per-event and per-delta costs. The steps below are self-contained.
Steps to reproduce
- Render an assistant message that contains
`Array<T>`or a code fence with<, with incremental blocks on. - Append one paragraph at a time.
Expected vs actual
Expected: only the new blocks are parsed, as for a message without <.
Actual: every update renders the full message through LazyMarkdownHtml.
Evidence
- The check: markdown-preview.tsx#L1779-L1781. It came from Fix byte ranges for thread-storage videos #4343, which states the intent "Plain Markdown retains incremental rendering". The
includes("<")check is a cheap stand-in for "plain". - The incremental parser already builds the mdast of each piece, so it can tell whether a real
htmlnode exists. - Side effect: the sanitized path also adds a second
user-content-prefix to footnote ids (see the comment on Markdown file preview: #fragment links open a new bb tab instead of scrolling to the target #6274). Messages with<only in code get that path today.
What you ruled out
- Not a duplicate: perf(app): replace react-markdown with Streamdown (PoC) #1317 (Streamdown) is a different approach and is closed.
- Real HTML must still use the sanitized whole-document path: an HTML block can span several pieces (
<details>...</details>).
Suggested priority and effort
Low to medium effort. Impact: jank that grows with message length during streaming, for most coding answers. Not profiled.
Checks
- I reproduced this on
main, or I say above how. - I searched open and closed issues and pull requests for the same problem.
- If an agent wrote this, the body ends with
> AGENT GENERATED.
AGENT GENERATED
Metadata
Metadata
Assignees
Labels
confirmed-reproBug reproduced again from a clean trusted checkout; see linked reportperfuiApp shell, sidebar, composer, rendering
Activity
bb-slop-cop commentedon Nov 17, 2026
🚨 SLOP COP 🚨 ·
new-issue-autopilotui,perf. All were previously missing; no existing values were replaced.1320c88e8a) fails in four non-HTML cases in both clean checkouts: all eight appends reparse the settled prefix. Plain-text and genuine-HTML controls pass; 52 existing targeted tests also pass. Frame-time impact was not profiled.confirmed-repro.