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#5805
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/3115
Author: @kolacheee
Created: 6/30/2026
Status: ✅ Merged
Merged: 7/2/2026
Merged by: @SpicyMarinara
Base:
staging← Head:fix/3104-game-narration-quadratic📝 Commits (2)
665451ffix(client): O(1) segment index lookup in game narration (#3104)372be04Merge branch 'staging' into fix/3104-game-narration-quadratic📊 Changes
1 file changed (+12 additions, -2 deletions)
View changed files
📝
packages/client/src/components/game/GameNarration.tsx(+12 -2)📄 Description
Linked issue
Partially addresses #3104 (the game-mode half). This does not close #3104 — the roleplay/conversation lag is a separate, still-open thread (different render path; this change does not touch it).
Why this change
A contributor confirmed the lag does not exist in v2.0.6, so #3104 is a regression. Bisecting the render-path diff (v2.0.6 → staging) surfaced one change that fits the instrumented signature (8–22s
render+commitscaling with chat length, game mode):In
GameNarration.tsx, the stacked-log narration renderer computes, at the top of each per-segment render:segmentsis the entire chat's flattened, uncapped segment array, andrenderStackedLogSegmentruns once per visible segment. So the cost isrendered × total= O(n²) in segment count, per render. On long agent-heavy chats (hundreds of messages → thousands of segments) that's thousands of full-array scans per render — matching the measured multi-second freeze, and scaling with chat length exactly as users report.In v2.0.6 this renderer was display-only and had no
findIndex. The eager lookup was added in v2.0.7, commite1e378b7e("Prepare v2.0.7 follow-up fixes"), when the segment renderer gained an inline action-button suite.GameNarrationis rendered solely byGameSurface, so this is game-mode only.What changed
Build an
id → indexMap once persegmentschange (auseMemokeyed onsegments) and look it up in O(1) at both call sites (the delete-navigation handler and the jump-to-segment row). This collapses the per-render cost from O(n²) to O(n) (one Map build) + O(1) lookups.Behavior-identical:
findIndexreturned-1when absent;Map.get(...) ?? -1returns the same. No visual or behavioral change — purely the cost of the index lookup.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
Done by the agent (not a substitute for human verification):
pnpm check→ exit 0 (TypeScript + ESLint + client build all clean).Still needs manual verification:
renderStackedLogSegment/findIndexself-time drops out (per #3104's "confirm perf fixes with a profile, don't trust code-reading alone").Docs and release impact
UI evidence (if applicable)
No UI change — this only changes how the per-segment index is computed (eager O(n²) scan → O(1) Map lookup).
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.