perf(markdown): cache completed streaming blocks#7305
Closed
c121914yu wants to merge 2 commits into
Closed
Conversation
Collaborator
Author
|
Superseded by clean cache-only PR #7306 based on latest main. |
Coverage Report
File CoverageNo changed files found. |
|
✅ Admin Preview Image Ready! 🕒 Time: 2026-07-14 21:10:37 (UTC+8) |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves streaming Markdown rendering performance in the app by splitting the streamed Markdown into root-level blocks and memoizing completed blocks so only the actively-growing tail block re-renders (while preserving cross-block reference/footnote correctness via a full-document fallback).
Changes:
- Added a unified/remark-based
splitMarkdownBlockshelper to split Markdown by root node source ranges and detect reference/footnote cases that require full-document rendering. - Updated the Markdown renderer to render per-block
ReactMarkdowninstances via a memoizedMarkdownStreamBlock, applying the streaming tail animation only to the active (last) block. - Updated the stream-tail fade-in behavior and CSS fallback, and added unit tests covering splitting behavior and rendering equivalence.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| projects/app/test/components/Markdown/streamMarkdownBlocks.test.ts | Adds coverage for block splitting behavior, offsets, reference/footnote fallback, and render equivalence. |
| projects/app/src/components/Markdown/streamMarkdownBlocks.ts | Introduces root-level Markdown block splitting using unified + remark-parse (+ math/gfm) with safe fallbacks. |
| projects/app/src/components/Markdown/index.tsx | Switches streaming rendering to memoized per-block rendering; keeps tail-only animation on the last block. |
| projects/app/src/components/Markdown/index.module.scss | Adds CSS keyframes/props to provide a fade-in fallback for .stream-tail. |
| projects/app/package.json | Adds direct dependencies needed for block parsing (remark-parse, unified). |
| pnpm-lock.yaml | Locks newly added dependencies for the app workspace. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Verification
pnpm exec vitest run -c vitest.config.ts test/components/Markdown/streamMarkdownBlocks.test.ts test/components/Markdown/rehypeStreamAnimated.test.ts test/components/Markdown/utils.test.ts --run --coverage=falseNo documentation changes.