Repository navigation
Render streamed Markdown incrementally unless it has a parsed HTML node - #7702
Merged
Merged
Conversation
3 tasks done
Messages with real HTML still render through the sanitized whole-document path, so resolving incremental pieces for them on every update doubled the work. The piece cache now remembers the body where HTML was found and skips piece parsing while the content keeps extending it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Human comments
What was wrong
MarkdownPreviewturned off incremental rendering whenallowHtmlwas set and the content contained<. Most<in agent output are not HTML (code fences,Array<T>,a < b). For those messages, each completed block caused a full parse of the settled message. That parse also ran rehype-raw and rehype-sanitize. #4343 states the intent "Plain Markdown retains incremental rendering". The<check was a cheap stand-in for "plain".What changed
markdown-incremental-pieces.ts: each piece summary records whether its mdast has anhtmlnode (checked only when the piece contains<).resolveMarkdownPiecesreturnshasHtml.markdown-preview.tsx: with incremental blocks on, the preview uses the sanitized whole-document path only if a piece has a realhtmlnode. Without incremental blocks, the old<check stays.<only in code now render like messages without<. One visible effect: footnote ids no longer get the seconduser-content-prefix from the sanitizer (see the comment on Markdown file preview: #fragment links open a new bb tab instead of scrolling to the target #6274).How you verified
markdown-incremental-pieces.test.ts:<in code spans, fences and prose giveshasHtml: false.<kbd>, a<details>block and an HTML comment givetrue.truewhile later pieces stream.pnpm exec turbo run typecheck --filter=@bb/appandtest --filter=@bb/app -- markdown Conversation: pass. This includes the incremental and cold-HTML differential tests.Fixes #7695