mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #2878] [Issue]: Streaming responses cause GUI lag during generation (per-token markdown re-parse) #1461
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#1461
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Romuromylus on GitHub (Jun 25, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2878
Originally assigned to: @Romuromylus on GitHub.
Summary
With streaming responses enabled, the entire live message's markdown is re-parsed on every streamed token, which makes the UI lag and stutter while a response is generating — and gets worse the longer the message.
Expected behavior
Streaming a long response should stay responsive; the cost of rendering each token should not grow with the length of the message already received.
Actual behavior
While a streamed response is generating, the UI becomes laggy/unresponsive (input lag, scroll stutter). The effect is most noticeable on long multi-paragraph responses and on setups running the server and browser on the same machine.
Steps to reproduce
Environment
Logs, screenshots, or video
Reported as intermittent and hard to pin down ("the GUI is laggy/unresponsive can mean a lot of things"), but the streaming-token render path has a concrete, reproducible cost.
Additional context
Root cause: the live streaming message re-runs
renderMarkdownBlocksover the full accumulated buffer on every token. Each token triggers a re-render of the message content, and the markdown renderer re-parses the entire string (multiple regex passes line-by-line plus recursive inline parsing) from scratch each time, so the work grows roughly O(n²) with the message length. Memoizing the parsed markdown so it is only recomputed when the content actually changes removes the per-token re-parse. This is one identified, deterministic contributor to the reported streaming lag.Relevant files:
packages/client/src/components/chat/ConversationMessageShared.tsx(MessageContent/renderTextBlock),packages/client/src/lib/markdown.tsx(renderMarkdownBlocks),packages/client/src/stores/chat.store.ts(per-tokensetStreamBuffer).Template check