Skip to content

A '<' anywhere in a streamed message turns off incremental Markdown rendering #7695

Closed

Description

@lanjak

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

  • main at 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

  1. Render an assistant message that contains `Array<T>` or a code fence with <, with incremental blocks on.
  2. 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

What you ruled out

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

Activity

  1. added theissue type on Nov 17, 2026
  2. added
    ui
    confirmed-repro
    on Nov 17, 2026
  3. bb-slop-cop commented on Nov 17, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority Medium · Effort Low · ui, perf. All were previously missing; no existing values were replaced.
    • Report: Reproduction and root cause · REPRODUCED · high root-cause confidence.
    • Root cause: A literal less-than character selects the whole-document HTML renderer before Markdown parsing, bypassing the settled-piece cache even for code or plain text.
    • Evidence: The authored parser-input regression on trusted main (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.
    • Reproduction label: confirmed-repro.
    • No new PR: Open Render streamed Markdown incrementally unless it has a parsed HTML node #7702 already links this issue; a duplicate fix would be unnecessary. Its diff was reviewed statically, not executed.

    AGENT GENERATED

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-reproperfui

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions