Skip to content

fix(markdown-stream): incremental rendering to prevent browser freezing#166

Open
JamesHWade wants to merge 1 commit intoposit-dev:mainfrom
JamesHWade:feat/incremental-markdown-rendering
Open

fix(markdown-stream): incremental rendering to prevent browser freezing#166
JamesHWade wants to merge 1 commit intoposit-dev:mainfrom
JamesHWade:feat/incremental-markdown-rendering

Conversation

@JamesHWade
Copy link

Fixes #164

Summary

Fixes browser freezing when streaming long markdown responses by implementing incremental block-based rendering.

Problem

Markdown was re-parsed on every incoming chunk, creating slow parsing behavior. This is especially noticeable with tool calls where each result adds substantial content.

Solution

  • Split content into "committed" blocks (parsed once, cached) and a "pending" tail (re-parsed on updates)
  • Commit blocks at \n\n boundaries when outside code fences
  • Throttle pending updates based on buffer size (larger content = less frequent parsing)
  • At stream end, re-parse full content to fix any artifacts from block splitting

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.

Browser freezes when streaming (very) long markdown responses

1 participant