mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #321] [Issue]: Game Mode Start Game snaps back mid-stream and produces duplicate [Start the game] messages #135
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#135
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 (Apr 30, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/321
Summary
In Game Mode 1.5.6, clicking Start Game on a freshly-set-up game shows the intro typewriter, then snaps back to the Start Game screen mid-stream. The user clicks Start again and the chat ends up with two
[Start the game]user messages — the GM frames the second one as a session continuation and the game starts at "scene 2".Expected behavior
After clicking Start Game once on a new Game Mode chat, the intro typewriter plays through, the GM streams the opening scene, the Continue button replaces the Start screen, and the chat history contains exactly one
[Start the game]user message.Actual behavior
After clicking Start Game:
[Start the game]user messages and the GM treats the second one as a "session continuation" framing — the game effectively starts at "scene 2".Reproduces consistently across Opus, GPT, and DeepSeek as the GM model, so this is not a model-output issue.
Steps to reproduce
/game/setup(any genre / setting / tone — reproduced with Fantasy / Adventure / Smut / Harem / Heroic).[Start the game]user messages, and the GM is narrating "scene 2".Environment
Logs, screenshots, or video
Screen state when the bug fires (idle Start Game phase reappearing after the first click):
Additional context
Likely root cause (server-side race):
packages/server/src/routes/generate.routes.tscaptureschat.metadataonce at request start (~line 397) and writes the parsed copy back later viachats.updateMetadata.updateMetadatareplaces the metadata column wholesale (seepackages/server/src/services/storage/chats.storage.ts:105-110)./game/startflipsgameSessionStatusfrom"ready"→"active"while the[Start the game]generation is in flight.lastMapPosition, game-state-patchgameMapsync,chat_summary,mariContext) do NOT re-fetch metadata before merging, so they clobber the freshly-setgameSessionStatus: "active"back to"ready"when they fire mid-stream.generate.routes.ts:6361-6365already handles this correctly with a re-fetch-then-merge pattern.When the stale write lands first, the client's
chatMetarefetches"ready"again.GameSurface's clearing effect atpackages/client/src/components/game/GameSurface.tsx:5159-5164had already fired (it ran while status was briefly"active") and clearedstartGameRequested. WithsessionStatus === "ready"andintroPresented === false, the surface drops back to the idle Start Game phase — the visible bug.A previous attempt at this bug (3e13514, reverted by 518dc92 on a contributor's fork) tried to fix this client-side via query invalidation. That couldn't have worked because the actual race is server-side metadata clobbering.
PR with proposed fix: #320.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked: