mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #2539] [MERGED] fix(chat): memoize SplitMessageGroup to stop ~60x/sec re-renders during streaming #5641
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#5641
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2539
Author: @Romuromylus
Created: 6/9/2026
Status: ✅ Merged
Merged: 6/9/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/split-message-group-memo📝 Commits (3)
d35481dfix(chat): memoize SplitMessageGroup to stop ~60x/sec re-renders during streaming59843a5fix(chat): add a memo comparator so non-regenerating split groups actually baild377cf7Merge branch 'staging' into fix/split-message-group-memo📊 Changes
1 file changed (+73 additions, -21 deletions)
View changed files
📝
packages/client/src/components/chat/ConversationView.tsx(+73 -21)📄 Description
Linked issue
Closes #2531
Why this change
SplitMessageGroupwas a plain, non-memoized function component, unlike its siblingConversationMessage(which ismemo-wrapped).ConversationViewsubscribes to the per-tokenstreamBuffer/thinkingBufferZustand slices, and the typewriter loop inuse-generate.tsupdatesstreamBufferonce perrequestAnimationFrame(~60×/sec) during every generation. The single render site passed both buffers to every mountedSplitMessageGroup(up to 160), so all split groups received changing props each frame and re-executed their body (recomputingfullContent = items.map(...).join("\n")) for the whole duration of streaming — even though only the regenerating group actually consumes the buffers. The innerConversationMessagechildren still memo-bail, so this is a Low-severity render cleanup (parent-body work + reconciliation), not a correctness bug.What changed
packages/client/src/components/chat/ConversationView.tsx:memoimport and wrappedSplitMessageGroupinmemo()(mirroringConversationMessage.tsx:332).isRegenGroup = regenerateMessageId === groupItems[0].msg.idand pass livestreamBuffer/thinkingBufferonly to that group; every other group gets"", so its props are byte-stable across the ~60 updates/sec and thememo()bails.The regenerating group still receives live buffers and streams token-by-token. The non-regen branches never referenced the buffers, so passing
""is behavior-preserving.items(groupItems) is still rebuilt each parent render, so in the worst casememore-renders by reference — meaning the payoff is the issue's stated modest gain (matching Low severity), never a correctness risk; the change only ever removes prop churn.Not a regression: byte-identical on
main; shared-engine render characteristic.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
pnpm checkpasses locally (type-checks thememo()wrapper + the newisRegenGroupconst, lints unused-import/exhaustive-deps). There is no client test suite, sopnpm checkplus the live observation below is the canonical proof.Still to verify manually against the deploy (React DevTools Profiler):
SplitMessageGroupre-renders ~60×/sec; every other mounted split group renders 0 extra times.Docs and release impact
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.