mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #3223] Conversation mode: whole transcript re-renders every streaming frame (unmemoized emoji/sticker maps defeat message memo) #1733
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#1733
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 @kolacheee on GitHub (Jul 5, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/3223
Originally assigned to: @SpicyMarinara, @kolacheee on GitHub.
What happens
In conversation mode, every mounted message re-renders on every frame of a streaming reply (React DevTools "highlight updates" shows the whole transcript flashing per token frame). On long chats (100+ mounted messages, group chats with multi-speaker replies) this costs roughly 15–35ms per frame on a desktop — visible stutter during generation, worse on laptops or when a local model is saturating the same CPU.
Try it yourself
Why it happens
useConversationCustomEmojis()anduseConversationCustomStickers()(packages/client/src/hooks/use-conversation-custom-emojis.ts/use-conversation-custom-stickers.ts) build a freshlistarray and a freshMapon every render — there's no memoization, and theuseQueriesinputs churn identity per render anyway.ConversationViewpasses those Maps asemojiMap/stickerMapprops to everymemo(ConversationMessage), so the memo's shallow compare fails for all mounted messages on everyConversationViewrender — and ConversationView renders once per animation frame during any token stream. This is the same class as #3164/#3104 ("cheap per-message work × every mounted message × every render"): each message then re-runs its markdown/custom-emoji/mention pipeline per segment plus (since #3211) its per-segment reaction-button subtrees, measured at ~3.3ms of pure element work per pass for 100 messages × 4 segments before reconciliation.ChatAreaalready fixed the identical disease forchatCharacterRowsin #3166 with a ref-backed element-wise reuse (ChatArea.tsx ~750) — these two hooks are the remaining identity-breakers on the ConversationMessage prop surface (characterMap, personaInfo and the callbacks are already stable).Suggested fix
Apply the same row-stability pattern inside both hooks: compare the freshly-built list element-wise against a ref-cached previous one (all fields are primitives) and return the cached
{ list, map }object when unchanged.Found by a regression/perf sweep of the reaction PRs (#3211/#3221) — the bug predates them, but per-segment reactions multiplied the work living under the broken memo boundary.