[GH-ISSUE #5956] A GM turn can only keep one dice card — multiple rolls in a turn should all survive #3298

Closed
opened 2026-10-21 06:01:46 +07:00 by bsakaguchi · 1 comment
Owner

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

Originally assigned to: @SpicyMarinara on GitHub.

From #5924's known limitations: "A turn that rolls more than once keeps only the last card." The GM should be able to roll several times in one turn and have every roll survive — a fight round with an attack and a damage roll is the ordinary case, not an exotic one.

Where the seam is. The record is a single object, not a list:

// packages/shared/src/types/chat.ts:835
diceRollResult?: DiceRollResult | null;

The server holds one mutable slot for the whole generation (routes/generate.routes.ts:6383), overwrites it on every successful roll_dice (:6632), and writes that one value at the end of the turn (:7741, whose own comment says only the last roll is kept). It gets clobbered on two axes: several rolls returned in one response, and one roll per round across many rounds.

No number is wrong — this is display and durability only. Every roll goes back to the model as its own role: "tool" message, passed through verbatim on success (:6730-6735, tool-executor.ts:74). So the GM's narration is honest about all N rolls; only the card and the saved record collapse.

What a player sees today: card A appears, card B replaces it mid-turn with the 5-second dismiss timer restarting (GameDiceResult.tsx:17-28); when both rolls come back in the same round, A is overwritten before its entrance animation finishes, so it reads as a flicker. After the turn, the Game surface doesn't redraw cards from the saved record at all — the persisted value is currently written but never rendered there.

Most of the pipe is already plural. SSE emits one tool_result frame per roll, each carrying its own parsed card (:6638-6646). The collapse happens entirely in two consumers: the single store slot (stores/game-mode.store.ts:39) and the single message-extra field.

What a fix touches:

  • Server: the accumulator becomes a list (keep its per-attempt reset, so a regenerated swipe doesn't inherit).
  • Storage: add a plural field beside the existing one rather than repurposing it — /roll writes the singular field today and the Roleplay/Conversation renderers read it. It's a JSON blob so no migration, but the merge is shallow: a writer that sets only the new list must explicitly null the old field, or a re-rolled swipe keeps a stale card.
  • lib/dice-roll-result.ts is the single narrowing point for both the stored extra and the SSE frame — one companion that accepts either shape covers both readers.
  • Renderer: a queue or sequential presenter, so each roll gets its own beat instead of pre-empting the previous one. Watch shouldAnimateDiceRollMessage's 10-second window (AnimatedDiceRoll.tsx:46-51) — every card in a list shares one message createdAt, so a naive plural renderer would replay them all at once.
  • Swipes already own their own set (the write is per-swipe), so nothing new is needed there; but "swipe back and see that turn's rolls again" would be new behavior, not restored behavior.
  • These regressions pin the current lines by source text and must move in the same change: game-mode-dice-tool.regression.ts:434-442, dice-notation.regression.ts:573-598, spatial-only-message-visibility.regression.ts:36, and e2e/game-native-dice.e2e.ts:132,169 (its locator assumes exactly one card).

Not the same bug, but worth knowing while in here: #5923's server-rolled skill checks are fine — they're rewritten into the message content and re-parsed as an array, so three checks in a turn render as three log lines and survive reload (GameNarration.tsx:950-971). Their only single-slot limit is that just the first check gets the animated banner (GameSurface.tsx:4934-4937). That's first-wins on a transient overlay; this issue is last-wins on a durable record. Fixing one doesn't fix the other, but they'd sit naturally in the same pass.

Originally created by @kolacheee on GitHub (Sep 8, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/5956 Originally assigned to: @SpicyMarinara on GitHub. From #5924's known limitations: *"A turn that rolls more than once keeps only the last card."* The GM should be able to roll several times in one turn and have every roll survive — a fight round with an attack and a damage roll is the ordinary case, not an exotic one. **Where the seam is.** The record is a single object, not a list: ```ts // packages/shared/src/types/chat.ts:835 diceRollResult?: DiceRollResult | null; ``` The server holds one mutable slot for the whole generation (`routes/generate.routes.ts:6383`), overwrites it on every successful `roll_dice` (`:6632`), and writes that one value at the end of the turn (`:7741`, whose own comment says only the last roll is kept). It gets clobbered on two axes: several rolls returned in one response, and one roll per round across many rounds. **No number is wrong — this is display and durability only.** Every roll goes back to the model as its own `role: "tool"` message, passed through verbatim on success (`:6730-6735`, `tool-executor.ts:74`). So the GM's narration is honest about all N rolls; only the card and the saved record collapse. **What a player sees today:** card A appears, card B replaces it mid-turn with the 5-second dismiss timer restarting (`GameDiceResult.tsx:17-28`); when both rolls come back in the same round, A is overwritten before its entrance animation finishes, so it reads as a flicker. After the turn, the Game surface doesn't redraw cards from the saved record at all — the persisted value is currently written but never rendered there. **Most of the pipe is already plural.** SSE emits one `tool_result` frame per roll, each carrying its own parsed card (`:6638-6646`). The collapse happens entirely in two consumers: the single store slot (`stores/game-mode.store.ts:39`) and the single message-extra field. **What a fix touches:** - Server: the accumulator becomes a list (keep its per-attempt reset, so a regenerated swipe doesn't inherit). - Storage: add a plural field **beside** the existing one rather than repurposing it — `/roll` writes the singular field today and the Roleplay/Conversation renderers read it. It's a JSON blob so no migration, but the merge is shallow: a writer that sets only the new list must explicitly null the old field, or a re-rolled swipe keeps a stale card. - `lib/dice-roll-result.ts` is the single narrowing point for both the stored extra and the SSE frame — one companion that accepts either shape covers both readers. - Renderer: a queue or sequential presenter, so each roll gets its own beat instead of pre-empting the previous one. Watch `shouldAnimateDiceRollMessage`'s 10-second window (`AnimatedDiceRoll.tsx:46-51`) — every card in a list shares one message `createdAt`, so a naive plural renderer would replay them all at once. - Swipes already own their own set (the write is per-swipe), so nothing new is needed there; but "swipe back and see that turn's rolls again" would be new behavior, not restored behavior. - These regressions pin the current lines by source text and must move in the same change: `game-mode-dice-tool.regression.ts:434-442`, `dice-notation.regression.ts:573-598`, `spatial-only-message-visibility.regression.ts:36`, and `e2e/game-native-dice.e2e.ts:132,169` (its locator assumes exactly one card). **Not the same bug, but worth knowing while in here:** #5923's server-rolled skill checks are fine — they're rewritten into the message content and re-parsed as an array, so three checks in a turn render as three log lines and survive reload (`GameNarration.tsx:950-971`). Their only single-slot limit is that just the *first* check gets the animated banner (`GameSurface.tsx:4934-4937`). That's first-wins on a transient overlay; this issue is last-wins on a durable record. Fixing one doesn't fix the other, but they'd sit naturally in the same pass.
bsakaguchi 2026-10-21 06:01:46 +07:00
  • closed this issue
  • added the
    in-pr
    label
Author
Owner

@SpicyMarinara commented on GitHub (Sep 8, 2026):

Implementation is owned by @SpicyMarinara with Codex in draft #5979, as part of the authorized issue sweep. The work reuses the shared dice parser, existing cards, and per-swipe metadata.

<!-- gh-comment-id:5592957571 --> @SpicyMarinara commented on GitHub (Sep 8, 2026): Implementation is owned by @SpicyMarinara with Codex in draft #5979, as part of the authorized issue sweep. The work reuses the shared dice parser, existing cards, and per-swipe metadata.
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#3298
No description provided.