mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
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#4553
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/304
Author: @kevin-ho
Created: 4/29/2026
Status: ✅ Merged
Merged: 4/29/2026
Merged by: @SpicyMarinara
Base:
main← Head:fix/infinite-rerender-patchNpcAvatars📝 Commits (4)
1afcba2fix: prevent infinite re-render loop in Game Mode (React error #185)1a6c2a4chore: trigger CI re-run for template checkdf0a4adMerge branch 'main' into fix/infinite-rerender-patchNpcAvatars41bae44refactor: composite speaker dedupe key and fix useRef type annotation📊 Changes
2 files changed (+33 additions, -11 deletions)
View changed files
📝
packages/client/src/components/game/GameNarration.tsx(+21 -10)📝
packages/client/src/stores/game-mode.store.ts(+12 -1)📄 Description
Linked issue
Closes #305
Why this change
Opening any Game Mode chat session immediately crashes the UI with React error #185 (
Maximum update depth exceeded). The bug prevents all Game Mode gameplay — users cannot use GM chats at all.Root cause:
patchNpcAvatarsin the Zustand store uses.map()on thenpcsarray every time it's called, even when nothing was actually modified..map()always returns a new array reference, so Zustand sees "state changed" and notifies all subscribers. AuseEffectinGameSurfacecallspatchNpcAvatarsduring React's commit phase, which triggers a synchronous re-render viauseSyncExternalStore, re-fires the effect, callspatchNpcAvatarsagain — and the loop continues until React hits its 50-render depth limit.GM chats are specifically affected because they load additional state (NPCs, character library data via TanStack Query) that feeds into the
useEffectdependencies, guaranteeing the loop on first mount.What changed
packages/client/src/stores/game-mode.store.ts—patchNpcAvatarsnow tracks whether any NPC was actually modified. If nothing changed, it returns the same state reference (return s) instead of a new object. Zustand performs reference equality checking — when the reference is identical, it skips subscriber notification entirely, breaking the infinite loop.packages/client/src/components/game/GameNarration.tsx— Added auseRefguard to theonActiveSpeakerChangeuseEffect. The effect now tracks the last reported speaker name and bails out if it hasn't changed. This prevents the same class of bug (redundantsetActiveSpeakercalls) from a different code path where dependency references churn.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
pnpm --filter @marinara-engine/client build— clean build, no TypeScript errorsbackgrounds:generated:korriban-valley)Docs and release impact
UI evidence (if applicable)
Before: Opening any GM chat immediately shows the red React error overlay (error #185) and the tab becomes unresponsive.
After: GM chats load normally with full Game Mode UI rendering. No console errors.
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.