fix(streamdown): render code blocks incrementally during streaming#474
Open
mvanhorn wants to merge 1 commit intovercel:mainfrom
Open
fix(streamdown): render code blocks incrementally during streaming#474mvanhorn wants to merge 1 commit intovercel:mainfrom
mvanhorn wants to merge 1 commit intovercel:mainfrom
Conversation
When using the `animated` prop, the animate plugin skipped all code/pre elements. This meant code block content appeared instantly while surrounding prose faded in word-by-word, creating a visual "buffering" effect where code seemed to dump all at once instead of streaming incrementally. The fix adds a `setAnimateCodeBlocks` method to the animate plugin. When a block has an incomplete (unclosed) code fence, the Block component tells the animate plugin to include code/pre elements in its animation pass. Once the code fence closes, animation reverts to the default behavior of skipping code blocks (since completed code gets syntax highlighting). Fixes vercel#473 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
|
@mvanhorn is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
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
setAnimateCodeBlocksmethod toAnimatePlugininterface so the Block component can toggle code animation per-blockProblem
When using
<Streamdown animated isAnimating>, prose text streams with word-by-word fade-in animation. But the animate plugin unconditionally skipped allcodeandpreelements (viaSKIP_TAGS), so code block content appeared instantly without any animation. This created a jarring visual discontinuity where code seemed to "buffer" and then dump all at once, while surrounding text streamed smoothly.Changes
packages/streamdown/lib/animate.ts: AddedSKIP_TAGS_WITHOUT_CODEset, madehasSkipAncestorstate-aware, addedanimateCodeBlocksflag to render state, exposedsetAnimateCodeBlockson the plugin APIpackages/streamdown/index.tsx: Block component callsanimatePluginProp.setAnimateCodeBlocks(isIncomplete)to enable code animation for blocks with unclosed fencesTest plan
Fixes #473
This contribution was developed with AI assistance (Claude Code).