Uh oh!
There was an error while loading. Please reload this page.
perf(web): coalesce streaming Markdown renders - #4349
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit a46d860c61e47a8f6ad2ff9b7334ae213d5ae908. Configure here.
Uh oh!
There was an error while loading. Please reload this page.
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — The PR changes an existing assistant-message path by automatically suppressing Markdown parsing and DOM updates between 50 ms snapshots during streaming. Since this gate controls when substantial rendering work occurs without an operator choice, the runtime behavior merits human review. You can add or adjust custom eligibility rules. Learn more. |
6d2b488 to
26ebe2fCompareFinal refresh on current main: 325e1fe9a.
|
nateEc
commented
Aug 19, 2026
@juliusmarminge@mudit-loya — this is ready for human review and Linux reproduction validation on The current-main version coalesces streaming Markdown parsing to at most once every 50ms, while synchronously flushing the complete final response. It preserves current links, task lists, raw HTML, tables, and code-block behavior. The focused suite is 54/54, web typecheck and isolated browser streaming verification pass, and all CI/Bugbot/Macroscope checks are green (including Approvability and UI Consistency). For review, the main tradeoff is the 50ms intermediate-render cadence; final rendered output and stream-completion timing remain unchanged. A quick check against the original Linux high-CPU reproduction would be especially useful. |
mudit-loya
commented
Aug 19, 2026
@nateEc how can we test this fix? |
nateEc
commented
Aug 24, 2026
Thanks for offering to verify this. The useful comparison is the same one from #4074, using the same model and a response of roughly the same length:
The primary success signal is that long-thread streaming no longer scales sharply above the fresh-thread result (the original report was roughly 76%/65% versus 35%). The fresh-thread baseline may still be non-trivial; this PR specifically targets the per-token full reparse. Please include the T3 commit, Linux/desktop version, and the four peak samples when reporting back. |
26ebe2f to
325e1feComparenateEc
commented
Aug 24, 2026
@juliusmarminge Ready for another review on 325e1fe9a. Rebased onto current main; implementation range-diff is unchanged, 65/65 focused Markdown tests pass, and all 20 GitHub checks completed with 0 failures. Linux CPU/rendering repro instructions were sent to @mudit-loya. Mergeable state is clean. |
- 将高频 token 更新限制为每 50 毫秒最多触发一次 Markdown 解析。 - 流式结束时同步刷新完整文本,保留链接、任务列表与代码块行为。 - 最新主线上的 65 个定向测试通过,补丁经 range-diff 确认未漂移。 - Web 类型检查仅剩主线 electronPasskeys 测试中的两条既有错误。
325e1fe to
6497047CompareDismissing prior approval to re-evaluate 6497047
nateEc
commented
Sep 2, 2026
@juliusmarminge Rebased onto the latest main; the focused ChatMarkdown suite passes and the current CI is green. Could you take a human review when you have a moment? |

Closes#4074
Summary
Verification
vp test run apps/web/src/components/ChatMarkdown.logic.test.ts apps/web/src/components/markdown-list-indentation.test.tsx apps/web/src/components/markdown-links.test.ts(27 passed)vp run --filter @t3tools/web typechecktest-t3-app: streamed a live Codex response containing paragraphs, bullet/task lists, a table, and a fenced TypeScript block; all rendered after completionNote
Low Risk
UI-only throttling in chat markdown rendering with immediate flush when streaming stops; no auth, data, or API changes.
Overview
Coalesces assistant Markdown updates during streaming so
ChatMarkdownre-parses and re-renders at most once every 50ms, instead of on every token delta.Adds
useStreamingMarkdownTextand a smallstreamingMarkdownRenderDelayhelper (with unit tests). WhileisStreamingis true, visible source and derived work (link/meta extraction, task-list marker offsets) follow the throttledrenderedText; when streaming ends, the hook flushes immediately to the latesttext. TheReactMarkdowntree is also memoized onrenderedTextso component identity stays steadier between batched updates.Behavior: live output can lag the incoming stream by up to ~50ms; completed messages should match prior semantics.
Reviewed by Cursor Bugbot for commit 6497047. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Coalesce streaming Markdown renders in
ChatMarkdownto a 50ms intervaluseStreamingMarkdownTexthook in ChatMarkdown.tsx that throttles text updates during streaming to at most one render per 50ms, clearing superseded timers and recording render timestampsstreamingMarkdownRenderDelayutil in ChatMarkdown.logic.ts that computes the non-negative remaining delay since the last render, clamping elapsed time to zero when the clock moves backwardsChatMarkdownnow uses throttledrenderedTextfor file-link extraction, inline-code extraction, task-list markers, and the memoizedReactMarkdownoutput; non-streaming renders sync immediatelyChatMarkdownno longer re-parses and re-renders on every incoming text value; output updates at most every 50ms while streaming is activeMacroscope summarized 6497047.