[PR #5137] [MERGED] fix: preserve turn-game state across conversation branches #6646

Closed
opened 2026-10-23 04:12:23 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5137
Author: @SpicyMarinara
Created: 8/16/2026
Status: ✅ Merged
Merged: 8/16/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/5131-conversation-turn-game-branch


📝 Commits (5)

  • 63dd533 fix: preserve conversation turn-game branches
  • 1b7944a fix: harden branch state copying
  • 8ed1d04 fix: preserve effective branch snapshots
  • a4f419b fix: clean up failed spatial branch copies
  • 97e3edd fix: restore failed branch grouping

📊 Changes

3 files changed (+187 additions, -65 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 packages/server/src/routes/chats.routes.ts (+82 -63)
📝 scripts/regressions/chat-branch-lineage.regression.ts (+104 -2)

📄 Description

Why

Conversation-mode turn games such as UNO and Chess persist their live state in the game-engine store. Branching copied that state only when the chat mode was Game, so a branch from Conversation silently lost or reset the active game.

Closes #5131.

What changed

  • Open the game-engine state store while branching Conversation chats as well as Game chats.
  • Reuse the existing per-message/per-swipe copy and rekeying path so every copied turn-game snapshot points at the new branch.
  • Extend the branch-lineage regression with a Conversation turn-game case and a Roleplay negative control.
  • Add the user-facing fix to the Unreleased changelog.

Validation evidence

  • pnpm check — passed.
  • Focused chat-branch-lineage regression — failed before the route fix with zero copied engine rows, then passed after it.
  • pnpm regression — 123/123 passed.
  • git diff --check — passed.

Manual verification

  • Start a Conversation chat with an active turn game, branch it, and verify play resumes from the copied state.
  • Branch a Roleplay chat and verify no unrelated game-engine state is copied.

Review checklist

  • Confirm the Conversation-only extension does not broaden game-engine copying to Roleplay.
  • Confirm copied state remains keyed to the branch's new message IDs and swipe indexes.

Notes

No client UI, localization, release metadata, or user-facing documentation changed. The server route is covered end-to-end through Fastify injection in the regression suite.

Summary by CodeRabbit

  • Bug Fixes
    • Conversation branches now preserve active turn-based game state when created from copied messages, swipe anchors, or initial setup points.
    • Branches retain the correct game type, saved state, message association, swipe position, and committed status instead of resetting or losing progress.
    • Game-state handling is now consistent across game and conversation chats, including chess and UNO sessions.
    • Branch creation now stops cleanly if required game-state data cannot be copied.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/5137 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 8/16/2026 **Status:** ✅ Merged **Merged:** 8/16/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/5131-conversation-turn-game-branch` --- ### 📝 Commits (5) - [`63dd533`](https://github.com/Pasta-Devs/Marinara-Engine/commit/63dd53360bd480ba2ba3e39cd62b16e8a5f46531) fix: preserve conversation turn-game branches - [`1b7944a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1b7944aeec5db4c7041f5dd7004210804bbb17f9) fix: harden branch state copying - [`8ed1d04`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8ed1d04ee2af59e4e5ece520b1c4352e800c28c5) fix: preserve effective branch snapshots - [`a4f419b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a4f419b0f21dc2f7e8b2cb026706d5bae61b92ca) fix: clean up failed spatial branch copies - [`97e3edd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/97e3eddd68e05052e9d7a27899e27f9a52ce8b80) fix: restore failed branch grouping ### 📊 Changes **3 files changed** (+187 additions, -65 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `packages/server/src/routes/chats.routes.ts` (+82 -63) 📝 `scripts/regressions/chat-branch-lineage.regression.ts` (+104 -2) </details> ### 📄 Description ## Why Conversation-mode turn games such as UNO and Chess persist their live state in the game-engine store. Branching copied that state only when the chat mode was Game, so a branch from Conversation silently lost or reset the active game. Closes #5131. ## What changed - Open the game-engine state store while branching Conversation chats as well as Game chats. - Reuse the existing per-message/per-swipe copy and rekeying path so every copied turn-game snapshot points at the new branch. - Extend the branch-lineage regression with a Conversation turn-game case and a Roleplay negative control. - Add the user-facing fix to the Unreleased changelog. ## Validation evidence - pnpm check — passed. - Focused chat-branch-lineage regression — failed before the route fix with zero copied engine rows, then passed after it. - pnpm regression — 123/123 passed. - git diff --check — passed. ## Manual verification - [ ] Start a Conversation chat with an active turn game, branch it, and verify play resumes from the copied state. - [ ] Branch a Roleplay chat and verify no unrelated game-engine state is copied. ## Review checklist - [ ] Confirm the Conversation-only extension does not broaden game-engine copying to Roleplay. - [ ] Confirm copied state remains keyed to the branch's new message IDs and swipe indexes. ## Notes No client UI, localization, release metadata, or user-facing documentation changed. The server route is covered end-to-end through Fastify injection in the regression suite. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Conversation branches now preserve active turn-based game state when created from copied messages, swipe anchors, or initial setup points. * Branches retain the correct game type, saved state, message association, swipe position, and committed status instead of resetting or losing progress. * Game-state handling is now consistent across game and conversation chats, including chess and UNO sessions. * Branch creation now stops cleanly if required game-state data cannot be copied. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:12:23 +07:00
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#6646
No description provided.