[PR #2343] [MERGED] Fix branch chat bootstrap game state fallback #5544

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/2343
Author: @Xelvanis
Created: 6/5/2026
Status: ✅ Merged
Merged: 6/5/2026
Merged by: @Xelvanis

Base: refactor ← Head: fix/branch-chat-game-state-2323


📝 Commits (1)

  • cc95edd Fix branch chat bootstrap game state fallback

📊 Changes

1 file changed (+99 additions, -5 deletions)

View changed files

📝 src-tauri/src/commands/storage/chats.rs (+99 -5)

📄 Description

Linked issue

Closes #2323

Why this change

  • Partial branches from tracker-backed game/roleplay chats could wipe the new branch's visible gameState when the copied message range had no active assistant tracker snapshot. The bootstrap tracker snapshot existed, but branch_chat nulled the cloned message-bound state before trying the bootstrap fallback.

What changed

  • Reordered branch_chat tracker fallback handling so it copies the bootstrap tracker snapshot before nulling a stale message-bound gameState.
  • Added a Rust regression test for branching up to an early message that predates any copied per-message tracker snapshot.

Refactor impact

Primary owner:

Rust storage (src-tauri/src/commands/storage/chats.rs)

Impact areas reviewed:

  • Branch chat storage path
  • Tracker snapshot copy path
  • Game/roleplay world-state convenience field behavior

Boundary notes:

  • Rust-only storage fix; no React, TypeScript engine, shared API, command registration, or remote-runtime boundary changes.

Pressure points touched:

  • None of the listed pressure points; only existing Rust chat storage branching logic changed.

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

  • Reproduced before fix with cargo test --manifest-path src-tauri/Cargo.toml branch_chat_preserves_bootstrap_game_state_when_no_message_snapshot_is_copied --lib; failed with left: Null, right: "Camp".
  • After fix: cargo test --manifest-path src-tauri/Cargo.toml branch_chat_ --lib passed, 5 tests.
  • After fix: cargo check --manifest-path src-tauri/Cargo.toml passed.
  • Pre-PR gate: pnpm check passed.
  • Manual Tauri UI verification was not run; this is covered at the Rust storage behavior level.

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:

  • Bugfix to existing branch-chat storage behavior; no new user-discoverable feature or workflow.

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

N/A; Rust storage bugfix only, no visible UI surface changed.

Summary by CodeRabbit

  • Bug Fixes

    • Improved chat branching to properly preserve bootstrap tracker game state when creating conversation branches, ensuring consistent game context is maintained across branched conversations.
  • Tests

    • Added unit test coverage for bootstrap game state preservation during chat branching operations.

🔄 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/2343 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 6/5/2026 **Status:** ✅ Merged **Merged:** 6/5/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `fix/branch-chat-game-state-2323` --- ### 📝 Commits (1) - [`cc95edd`](https://github.com/Pasta-Devs/Marinara-Engine/commit/cc95edd9e1665f11add1868c900d664637856826) Fix branch chat bootstrap game state fallback ### 📊 Changes **1 file changed** (+99 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/chats.rs` (+99 -5) </details> ### 📄 Description ## Linked issue Closes #2323 ## Why this change - Partial branches from tracker-backed game/roleplay chats could wipe the new branch's visible `gameState` when the copied message range had no active assistant tracker snapshot. The bootstrap tracker snapshot existed, but `branch_chat` nulled the cloned message-bound state before trying the bootstrap fallback. ## What changed - Reordered `branch_chat` tracker fallback handling so it copies the bootstrap tracker snapshot before nulling a stale message-bound `gameState`. - Added a Rust regression test for branching up to an early message that predates any copied per-message tracker snapshot. ## Refactor impact Primary owner: Rust storage (`src-tauri/src/commands/storage/chats.rs`) Impact areas reviewed: - Branch chat storage path - Tracker snapshot copy path - Game/roleplay world-state convenience field behavior Boundary notes: - Rust-only storage fix; no React, TypeScript engine, shared API, command registration, or remote-runtime boundary changes. Pressure points touched: - None of the listed pressure points; only existing Rust chat storage branching logic changed. ## Validation - [x] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [x] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - Reproduced before fix with `cargo test --manifest-path src-tauri/Cargo.toml branch_chat_preserves_bootstrap_game_state_when_no_message_snapshot_is_copied --lib`; failed with `left: Null`, `right: "Camp"`. - After fix: `cargo test --manifest-path src-tauri/Cargo.toml branch_chat_ --lib` passed, 5 tests. - After fix: `cargo check --manifest-path src-tauri/Cargo.toml` passed. - Pre-PR gate: `pnpm check` passed. - Manual Tauri UI verification was not run; this is covered at the Rust storage behavior level. ## 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. - [x] 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: - Bugfix to existing branch-chat storage behavior; no new user-discoverable feature or workflow. ## 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 N/A; Rust storage bugfix only, no visible UI surface changed. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved chat branching to properly preserve bootstrap tracker game state when creating conversation branches, ensuring consistent game context is maintained across branched conversations. * **Tests** * Added unit test coverage for bootstrap game state preservation during chat branching operations. <!-- 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:17:13 +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#5544
No description provided.