[PR #1856] [MERGED] Add Game Mode branching from turns and checkpoints #5316

Closed
opened 2026-10-22 04:15:11 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1856
Author: @cha1latte
Created: 6/1/2026
Status: ✅ Merged
Merged: 6/1/2026
Merged by: @cha1latte

Base: refactor ← Head: feat/issue-1850-game-branching


📝 Commits (2)

  • 35600a3 Add Game Mode branch actions
  • 6265e43 Address Game Mode branch review feedback

📊 Changes

7 files changed (+333 additions, -13 deletions)

View changed files

📝 src-tauri/src/commands/storage/chats.rs (+108 -0)
📝 src/features/modes/game/api/game-api.ts (+102 -8)
📝 src/features/modes/game/components/GameCheckpoints.tsx (+47 -2)
📝 src/features/modes/game/components/GameNarration.tsx (+28 -1)
📝 src/features/modes/game/components/GameSurface.tsx (+28 -0)
📝 src/features/modes/game/hooks/use-game.ts (+18 -0)
📝 src/features/shell/discovery/discovery-entries.json (+2 -2)

📄 Description

Linked issue

Closes #1850

Why this change

  • Game Mode could restore checkpoints in-place and retry the latest turn, but players could not create a separate alternate timeline from an older decision point the way Roleplay chats can.

What changed

  • Added a Branch from here action to Game Mode narration logs that creates a new chat branch up to the selected backing message and switches to it.
  • Added Branch from checkpoint in the Game Checkpoints panel.
  • Stored message anchors on newly created checkpoints so future checkpoint branches can copy the transcript up to the saved point, then restore the branch metadata/game state from the checkpoint snapshot.
  • Added a storage regression proving a Game Mode branch uses the selected tracker snapshot and excludes future transcript messages.
  • Updated Discover metadata for Game Checkpoints branching.

Refactor impact

Primary owner:

  • game mode

Impact areas reviewed:

  • Game Mode narration/log actions
  • Game Mode checkpoint panel and API
  • Shared chat branch command behavior for Game Mode tracker snapshots
  • Discover metadata

Boundary notes:

  • Feature UI stays in src/features/modes/game.
  • Branch creation reuses the existing shared chat command wrapper instead of adding raw Tauri calls to components.
  • Rust storage behavior is covered by a focused regression test; no storage schema migration or dependency changes.

Pressure points touched:

  • GameSurface
  • GameNarration
  • GameCheckpoints
  • Rust chat branching storage command

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • Codex ran cargo test --manifest-path src-tauri\Cargo.toml branch_chat_sets_game_state_to_selected_tracker_snapshot - passed.
  • Codex ran pnpm typecheck - passed.
  • Codex ran cargo check --manifest-path src-tauri\Cargo.toml - passed.
  • Codex ran pnpm check after the final diff - passed.
  • Browser/Tauri manual UI click-through was not run in this environment; please verify the new log and checkpoint branch buttons in the app before merging.
  • Legacy checkpoints saved before this PR do not have a message anchor; their Branch button is disabled with a legacy-anchor tooltip. Restoring an anchored checkpoint and saving immediately preserves the original anchor. Restoring an unanchored legacy checkpoint does not turn the restore marker into a branch anchor.
  • Review follow-up commit 6265e439 addressed the CodeRabbit checkpoint-anchor, legacy checkpoint button, and narration segment-granularity comments; Codex reran pnpm typecheck, the focused Rust regression, and pnpm check.

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • Game Checkpoints now includes branching/alternate timeline behavior.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence (if applicable)

No screenshots attached. The visible change is a small action button added to existing Game Mode log/checkpoint controls; Codex validation was command-based.

Summary by CodeRabbit

  • New Features
    • Branch game sessions from existing checkpoints to create alternate timelines while preserving game state.
    • Branch conversations from any message in the session log to explore alternative dialogue paths.
    • Added Branch buttons to checkpoint management and chat narration interfaces for convenient access.

🔄 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/1856 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 6/1/2026 **Status:** ✅ Merged **Merged:** 6/1/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `feat/issue-1850-game-branching` --- ### 📝 Commits (2) - [`35600a3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/35600a3817401f1df936d6fb962d8acc3d156805) Add Game Mode branch actions - [`6265e43`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6265e439ea5ca976e08241f7354f3aa6b57524aa) Address Game Mode branch review feedback ### 📊 Changes **7 files changed** (+333 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/chats.rs` (+108 -0) 📝 `src/features/modes/game/api/game-api.ts` (+102 -8) 📝 `src/features/modes/game/components/GameCheckpoints.tsx` (+47 -2) 📝 `src/features/modes/game/components/GameNarration.tsx` (+28 -1) 📝 `src/features/modes/game/components/GameSurface.tsx` (+28 -0) 📝 `src/features/modes/game/hooks/use-game.ts` (+18 -0) 📝 `src/features/shell/discovery/discovery-entries.json` (+2 -2) </details> ### 📄 Description ## Linked issue Closes #1850 ## Why this change - Game Mode could restore checkpoints in-place and retry the latest turn, but players could not create a separate alternate timeline from an older decision point the way Roleplay chats can. ## What changed - Added a Branch from here action to Game Mode narration logs that creates a new chat branch up to the selected backing message and switches to it. - Added Branch from checkpoint in the Game Checkpoints panel. - Stored message anchors on newly created checkpoints so future checkpoint branches can copy the transcript up to the saved point, then restore the branch metadata/game state from the checkpoint snapshot. - Added a storage regression proving a Game Mode branch uses the selected tracker snapshot and excludes future transcript messages. - Updated Discover metadata for Game Checkpoints branching. ## Refactor impact Primary owner: - game mode Impact areas reviewed: - Game Mode narration/log actions - Game Mode checkpoint panel and API - Shared chat branch command behavior for Game Mode tracker snapshots - Discover metadata Boundary notes: - Feature UI stays in `src/features/modes/game`. - Branch creation reuses the existing shared chat command wrapper instead of adding raw Tauri calls to components. - Rust storage behavior is covered by a focused regression test; no storage schema migration or dependency changes. Pressure points touched: - `GameSurface` - `GameNarration` - `GameCheckpoints` - Rust chat branching storage command ## Validation - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - Codex ran `cargo test --manifest-path src-tauri\Cargo.toml branch_chat_sets_game_state_to_selected_tracker_snapshot` - passed. - Codex ran `pnpm typecheck` - passed. - Codex ran `cargo check --manifest-path src-tauri\Cargo.toml` - passed. - Codex ran `pnpm check` after the final diff - passed. - Browser/Tauri manual UI click-through was not run in this environment; please verify the new log and checkpoint branch buttons in the app before merging. - Legacy checkpoints saved before this PR do not have a message anchor; their Branch button is disabled with a legacy-anchor tooltip. Restoring an anchored checkpoint and saving immediately preserves the original anchor. Restoring an unanchored legacy checkpoint does not turn the restore marker into a branch anchor. - Review follow-up commit `6265e439` addressed the CodeRabbit checkpoint-anchor, legacy checkpoint button, and narration segment-granularity comments; Codex reran `pnpm typecheck`, the focused Rust regression, and `pnpm check`. ## Feature Discoverability Check exactly one: - [x] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [ ] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - Game Checkpoints now includes branching/alternate timeline behavior. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [x] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence (if applicable) No screenshots attached. The visible change is a small action button added to existing Game Mode log/checkpoint controls; Codex validation was command-based. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Branch game sessions from existing checkpoints to create alternate timelines while preserving game state. * Branch conversations from any message in the session log to explore alternative dialogue paths. * Added Branch buttons to checkpoint management and chat narration interfaces for convenient access. <!-- 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-22 04:15:11 +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#5316
No description provided.