Skip to content

feat: add smooth prop to pace bursty streams - #625

Open
thedonmon wants to merge 4 commits into
vercel:mainfrom
thedonmon:feat/smooth-streaming
Open

thedonmon wants to merge 4 commits into
vercel:mainfrom
thedonmon:feat/smooth-streaming

Conversation

@thedonmon

@thedonmon thedonmon commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Some providers and relays send text in bursts, for example ~150 characters every ~550 ms. Rendered as it arrives, the text jumps and then pauses, and the caret jumps with it. smooth reveals each chunk a word at a time, at the rate chunks have been arriving.

<Streamdown smooth isAnimating={isStreaming}>
  {markdown}
</Streamdown>

Type of Change

  • New feature (non-breaking change which adds functionality)

Changes Made

  • New smooth prop, off by default. Only appended text is paced; any other change renders immediately.
  • A word split across two chunks is held until it's complete.
  • When isAnimating goes false, the rest appears within 250 ms. Streamdown stays in streaming mode until then, even if mode switches to "static".
  • With animated, stagger defaults to 0 under smooth, since pacing already spaces the words. An explicit stagger still applies.
  • Docs page and changeset.

Testing

Screendrop_2026-09-19-09-37-30_CB5B1E.mp4
  • All existing tests pass
  • Added new tests for the changes
  • Manually tested the changes

Replayed a captured stream (37 chunks, ~550 ms apart). The text now appears in ~700 steps of ~7 characters instead of 37 jumps of ~148. The cost is about one chunk interval of delay: median 583 ms before a chunk is fully shown.

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • New and existing unit tests pass locally with my changes
  • I have created a changeset (pnpm changeset)

🤖 Generated with Claude Code

@vercel

vercel Bot commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

@thedonmon is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@vasilich6107

vasilich6107 commented Sep 29, 2026 •

Copy link
Copy Markdown

Hi @farnabaz @haydenbleasel 👋 — a friendly +1 for this one.

We're hitting exactly the case in the description: our chat relays an agent's answer in ~500 ms chunks, so on 2.6.0 it renders as a jump followed by a pause.

thedonmon and others added 3 commits October 1, 2026 14:11
Some providers and relays deliver text in bursts (for example ~150
characters every ~500 ms), which renders as a jump followed by a pause,
with the caret jumping ahead. `smooth` measures the time between arrivals
and reveals each chunk a word at a time so it finishes about when the
next chunk is expected.

- Off by default; rendering is unchanged when off.
- Only appends are paced. Resets, edits and full-text replacements render
  immediately, as does content present on mount.
- Words split across chunks are held until complete. CJK characters are
  their own units.
- When `isAnimating` goes false the remainder drains within 250 ms, and
  Streamdown stays in streaming mode until then.
- Hidden tabs render immediately, since animation frames are paused there.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`smooth` already spaces words out as it reveals them. The animate
plugin's default 40 ms per-word stagger then queued them a second time,
so animated text trailed the reveal and left blank space (with the caret)
where scheduled words had not faded in yet. Under `smooth`, `stagger` now
defaults to 0; an explicit `stagger` is still honored.

Also narrow `animated` by type instead of comparing the memo key to
"true", since the key now includes `smooth`.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This repo reserves minor for marketing releases.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@thedonmon
thedonmon force-pushed the feat/smooth-streaming branch from bd68836 to 814dc00 Compare October 2, 2026 02:02

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants