[GH-ISSUE #5474] Game Mode: narration choices do not repopulate after rewinding to a mid-log message #3036

Closed
opened 2026-10-21 05:59:02 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Aug 24, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5474

Originally assigned to: @SpicyMarinara on GitHub.

Game Mode: narration choices do not repopulate after rewinding to a mid-log message

Classification: ENGINE-SIDE. Not a Pixelforge defect — filed from a Pixelforge playtest only because that is where it was seen. Choice presentation is entirely Game Mode's; the package declares providesChoices: false and never touches it.

Repro

  1. Game Mode chat with an Experience surface active (Pixelforge), GM turns carrying [choices: ...].
  2. Rewind to the very first narration. Choices reappear — pick a different route, play forward. (The anchor rewind machinery itself works.)
  3. Rewind again, this time to a mid-log narration that had choices under it when it was live.
  4. No choices render. The narration is there; the cards are not.

Observed 2026-08-24, second playtest of Pixelforge 0.11 against Engine 2.4.3.

Why it is engine-side

Choices are not persisted anywhere. There is no gameChoices metadata key and no choices table — choice_blocks is unrelated prompt-preset machinery. They are ephemeral React state, re-derived from the message text each time the pipeline decides a turn is "new":

  • packages/client/src/components/game/GameSurface.tsx:2884 — const [activeChoices, setActiveChoices] = useState<string[] | null>(null);
  • :5070-5072 — the primary populate, inside processScene: if (!suppressInteractiveCommands && tags.choices) setActiveChoices(tags.choices);
  • :12290 — the render gate: const choicesVisible = Boolean(activeChoices && narrationDone);

Suspected mechanism (two candidates, both in the same file)

A. processScene is keyed on message id alone, so a rewind that lands on a message it has already processed never re-derives choices.

GameSurface.tsx:4921 — if (lastProcessedMsgRef.current === msg.id) return;

handleRetryTurn is the one flow that knows this and clears the ref explicitly (:6660, with setActiveChoices(null) at :6635). Any other timeline move onto an already-processed id returns early. Two aggravating facts:

  • processScene's reset block (:4931-4945) resets narrationDoneMsgId, partyDialogue, queuedQte, queuedEncounter, pendingSegmentEffects and more — but never setActiveChoices(null). So the state is neither refreshed nor cleared; whatever the last processed turn left is what stays.
  • The recovery path that would re-extract tags (:4502-4508, "Re-extract interactive tags … so they survive unmount/remount and page refresh") is one-shot per scope: if (sceneRestoredRef.current || …) return; (:4462), and the scope key is `${activeChatId}:${activeGameMetaId}` (:2413), which does not change on a rewind inside the same chat. So it never re-runs either.

B. gameNarrationMessageId carries no swipe index, so a restored cursor can be measured against a different swipe's segments — and out of bounds means "jump to the end".

  • GameSurface.tsx:4774 persists { index, messageId: latestAssistantMsg.id }; :4819 and :4831 compare ids only.
  • GameNarration.tsx:2840 — the narration reset key does include the swipe: `${latestAssistant.id}:${latestAssistant.activeSwipeIndex}`.
  • GameNarration.tsx:2890-2893 — when the restored index exceeds the new segment count it falls back to segments.length - 1, i.e. straight to the last segment, which immediately satisfies narrationComplete (:2298) and flips narrationDone true.

The two halves of the machine therefore disagree about what a "new turn" is: narration restarts on a swipe, choice derivation does not. A restore that lands past the end also silently skips every unpresented segment — which is a second, related bug worth noting in the same report.

A third, lower-confidence path: interruptedInteractiveCommandKeysRef (:2998) is consulted as suppressInteractiveCommands at both :4504 and :4967. Once a message id is in that set, choices for it are suppressed on every future re-derivation, including after rewinding back onto it. Only handleRetryTurn (:6657) removes an entry.

Also worth capturing while the area is open

  • Wheel-nav review freezes narrationDone. messageOffset > 0 suppresses both onSegmentChange (GameNarration.tsx:2941) and onNarrationComplete (:2398), so narrationDone holds its last value while the player reviews the past — and choicesVisible keeps rendering against that frozen value.
  • Branching copies the cursor verbatim. packages/server/src/routes/chats.routes.ts:3803-3821 — settingsToKeep deletes only summary keys, so gameNarrationIndex/gameNarrationMessageId are inherited into a branch whose messages get new ids. Benign today (the id will not match), but it is stale data carried into every branch, and it contrasts with the deliberate handling on the line beside it: settingsToKeep.gameWidgetState = restoreBranchHudLists(...).

Suggested direction

Key the narration cursor and the scene-processed marker on id:activeSwipeIndex rather than id, matching narrationKey in GameNarration.tsx:2840, and have processScene clear activeChoices in its reset block so a turn without a [choices:] tag cannot inherit the previous turn's cards.

Environment

Engine 2.4.3 (bb551bf921c006922edac7be06dbea8fe4c999b9), staging. Pixelforge 0.11.0, capability API 1.10. Line numbers are against the staging checkout on 2026-08-24 and were read directly, not inferred.

Originally created by @kolacheee on GitHub (Aug 24, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5474 Originally assigned to: @SpicyMarinara on GitHub. # Game Mode: narration choices do not repopulate after rewinding to a mid-log message **Classification: ENGINE-SIDE.** Not a Pixelforge defect — filed from a Pixelforge playtest only because that is where it was seen. Choice presentation is entirely Game Mode's; the package declares `providesChoices: false` and never touches it. ## Repro 1. Game Mode chat with an Experience surface active (Pixelforge), GM turns carrying `[choices: ...]`. 2. Rewind to the very first narration. **Choices reappear** — pick a different route, play forward. (The anchor rewind machinery itself works.) 3. Rewind again, this time to a **mid-log** narration that had choices under it when it was live. 4. **No choices render.** The narration is there; the cards are not. Observed 2026-08-24, second playtest of Pixelforge 0.11 against Engine 2.4.3. ## Why it is engine-side Choices are not persisted anywhere. There is no `gameChoices` metadata key and no choices table — `choice_blocks` is unrelated prompt-preset machinery. They are ephemeral React state, re-derived from the message text each time the pipeline decides a turn is "new": - `packages/client/src/components/game/GameSurface.tsx:2884` — `const [activeChoices, setActiveChoices] = useState<string[] | null>(null);` - `:5070-5072` — the primary populate, inside `processScene`: `if (!suppressInteractiveCommands && tags.choices) setActiveChoices(tags.choices);` - `:12290` — the render gate: `const choicesVisible = Boolean(activeChoices && narrationDone);` ## Suspected mechanism (two candidates, both in the same file) **A. `processScene` is keyed on message id alone, so a rewind that lands on a message it has already processed never re-derives choices.** `GameSurface.tsx:4921` — `if (lastProcessedMsgRef.current === msg.id) return;` `handleRetryTurn` is the one flow that knows this and clears the ref explicitly (`:6660`, with `setActiveChoices(null)` at `:6635`). Any other timeline move onto an already-processed id returns early. Two aggravating facts: - `processScene`'s reset block (`:4931-4945`) resets `narrationDoneMsgId`, `partyDialogue`, `queuedQte`, `queuedEncounter`, `pendingSegmentEffects` and more — but **never `setActiveChoices(null)`**. So the state is neither refreshed nor cleared; whatever the last processed turn left is what stays. - The recovery path that *would* re-extract tags (`:4502-4508`, "Re-extract interactive tags … so they survive unmount/remount and page refresh") is one-shot per scope: `if (sceneRestoredRef.current || …) return;` (`:4462`), and the scope key is `` `${activeChatId}:${activeGameMetaId}` `` (`:2413`), which **does not change on a rewind inside the same chat**. So it never re-runs either. **B. `gameNarrationMessageId` carries no swipe index, so a restored cursor can be measured against a different swipe's segments — and out of bounds means "jump to the end".** - `GameSurface.tsx:4774` persists `{ index, messageId: latestAssistantMsg.id }`; `:4819` and `:4831` compare **ids only**. - `GameNarration.tsx:2840` — the narration reset key **does** include the swipe: `` `${latestAssistant.id}:${latestAssistant.activeSwipeIndex}` ``. - `GameNarration.tsx:2890-2893` — when the restored index exceeds the new segment count it falls back to `segments.length - 1`, i.e. straight to the last segment, which immediately satisfies `narrationComplete` (`:2298`) and flips `narrationDone` true. The two halves of the machine therefore disagree about what a "new turn" is: narration restarts on a swipe, choice derivation does not. A restore that lands past the end also silently skips every unpresented segment — which is a second, related bug worth noting in the same report. A third, lower-confidence path: `interruptedInteractiveCommandKeysRef` (`:2998`) is consulted as `suppressInteractiveCommands` at both `:4504` and `:4967`. Once a message id is in that set, choices for it are suppressed on **every** future re-derivation, including after rewinding back onto it. Only `handleRetryTurn` (`:6657`) removes an entry. ## Also worth capturing while the area is open - **Wheel-nav review freezes `narrationDone`.** `messageOffset > 0` suppresses both `onSegmentChange` (`GameNarration.tsx:2941`) and `onNarrationComplete` (`:2398`), so `narrationDone` holds its last value while the player reviews the past — and `choicesVisible` keeps rendering against that frozen value. - **Branching copies the cursor verbatim.** `packages/server/src/routes/chats.routes.ts:3803-3821` — `settingsToKeep` deletes only summary keys, so `gameNarrationIndex`/`gameNarrationMessageId` are inherited into a branch whose messages get new ids. Benign today (the id will not match), but it is stale data carried into every branch, and it contrasts with the deliberate handling on the line beside it: `settingsToKeep.gameWidgetState = restoreBranchHudLists(...)`. ## Suggested direction Key the narration cursor and the scene-processed marker on `id:activeSwipeIndex` rather than `id`, matching `narrationKey` in `GameNarration.tsx:2840`, and have `processScene` clear `activeChoices` in its reset block so a turn without a `[choices:]` tag cannot inherit the previous turn's cards. ## Environment Engine 2.4.3 (`bb551bf921c006922edac7be06dbea8fe4c999b9`), staging. Pixelforge 0.11.0, capability API 1.10. Line numbers are against the `staging` checkout on 2026-08-24 and were read directly, not inferred.
bsakaguchi 2026-10-21 05:59:02 +07:00
Author
Owner

@SpicyMarinara commented on GitHub (Aug 25, 2026):

Completed and landed on staging in #5503.

<!-- gh-comment-id:5403779189 --> @SpicyMarinara commented on GitHub (Aug 25, 2026): Completed and landed on `staging` in #5503.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#3036
No description provided.