[PR #7759] [MERGED] fix(chat): preserve Advanced Memory when branching roleplay history #7914

Closed
opened 2026-10-24 04:08:48 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7759
Author: @SpicyMarinara
Created: 10/17/2026
Status: ✅ Merged
Merged: 10/17/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/advanced-memory-branch-continuity


📝 Commits (2)

  • 09cbf4a fix: preserve Advanced Memory across chat branches
  • a718226 fix: retain explicit memory pauses in branched chats

📊 Changes

5 files changed (+731 additions, -44 deletions)

View changed files

📝 packages/server/src/routes/chats.routes.ts (+57 -27)
📝 packages/server/src/services/advanced-memory-transfer.ts (+28 -4)
📝 packages/server/src/services/advanced-memory.ts (+119 -0)
📝 packages/server/src/services/storage/chats.storage.ts (+14 -4)
📝 scripts/regressions/chat-branch-lineage.regression.ts (+513 -9)

📄 Description

Linked issue

Closes #7758

Why this change

Branching a prepared roleplay chat discards its memory processing state, making users prepare the entire retained history again even though the earlier scene archive survives. A missing saved entry for the selected swipe can additionally substitute an old reply and invalidate an earlier scene.

What changed

  • Prepared branches retain usable processing and classification checkpoints, automatic context starts, knowledge permissions, and normal scene-check cadence. Explicit pauses stay paused; stale fingerprint checkpoints are withheld. Deleted automatic Chat Summaries stay deleted during subsequent upkeep.
  • Historical forks reopen the containing scene, including forks exactly at its ending, and discard that scene's derived memories and records depending on omitted history. A clipped scene's timeframe is derived from retained messages. Complete earlier memories remain available for immediate recall.
  • Branching preserves the authoritative selected reply and its visibility even when its saved swipe entry is missing. Incomplete swipe histories are numbered consecutively; tracker/game snapshots, inventory tellings and interruption targets follow their copied swipes.
  • Transcript imports retain their existing conservative preparation behavior.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Tested code revision: a718226e5ca61e08a02bfd86a294b7600a9db1b5 (the committed tree is identical to the final locally reviewed and checked patch).

Completed on the final revision:

  • pnpm check: passed.
  • node scripts/run-regressions.mjs --filter chat-branch-lineage: passed 1/1. The pause regression failed before the correction and passes afterward, covering missing knowledge, empty archives, and actual recall from a prepared paused archive.
  • Final local CodeRabbit review of the two-file follow-up: completed with no further findings. Earlier local and hosted findings were traced and fixed; the review history was not finding-free.

Earlier evidence on 09cbf4a88a3bd1099c911576aa74ad8c1ad7e253: Advanced Memory Node lane 20/20; prompt, prompt-attachments and context-fit regressions; final server lint and formatting. Desktop shell smoke passed 7/7 before the handled-summary/timeframe follow-ups, whose affected branch and upkeep paths were rerun in the final branch regression. Those broader lanes were not rerun after the pause-only correction.

The branch regression also failed on unchanged staging with idle rather than ready. The actual branch endpoint passed against an isolated live-data snapshot: 1455 messages, 80 retained scene summaries, zero unprepared scenes, and an open fork scene.

Local CodeRabbit and independent review are complete. Verified findings about empty archives, sparse swipe numbering, checkpoint identity and explicit pauses were fixed. Prepared paused branches retain their archive and expose Resume. The proposed blanket reset on any copied source change was not adopted: saved scene boundaries remain reusable across edits, while exact checkpoint hashes still require verification. Regressions also cover deleted automatic Chat Summaries and clipped timeframes.

Manual verification notes

  • Read-only inspection confirmed the reported live branch lost its processing state while retaining earlier summaries and an open fork scene. It also exposed a selected-swipe mismatch behind one missing historical scene.
  • Manually verify a historical fork in the browser, send the next reply, and inspect recalled earlier scenes and the ongoing fork scene.
  • The existing live branch has not been modified. Containers and physical devices were not tested; no frontend layout was changed.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

No UI layout or copy changes. The behavioral proof exercises the real branch endpoint and recall service against isolated data.

Summary by CodeRabbit

  • Bug Fixes
    • Improved chat branching so copied swipe histories remain correctly navigable, including when the active swipe was missing from stored history.
    • Preserved associated interruption, game, and tracker state across branches, with references aligned to copied messages and swipes.
  • Improvements
    • Advanced Memory state now carries over appropriately when branching, including summaries, scene status, and paused state.
    • Branches that end within a scene reopen that scene without retaining later scene content.
    • Memory checkpoints and knowledge references are preserved when their related content is available in the branch.

🔄 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/7759 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/17/2026 **Status:** ✅ Merged **Merged:** 10/17/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/advanced-memory-branch-continuity` --- ### 📝 Commits (2) - [`09cbf4a`](https://github.com/Pasta-Devs/Marinara-Engine/commit/09cbf4a88a3bd1099c911576aa74ad8c1ad7e253) fix: preserve Advanced Memory across chat branches - [`a718226`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a718226e5ca61e08a02bfd86a294b7600a9db1b5) fix: retain explicit memory pauses in branched chats ### 📊 Changes **5 files changed** (+731 additions, -44 deletions) <details> <summary>View changed files</summary> 📝 `packages/server/src/routes/chats.routes.ts` (+57 -27) 📝 `packages/server/src/services/advanced-memory-transfer.ts` (+28 -4) 📝 `packages/server/src/services/advanced-memory.ts` (+119 -0) 📝 `packages/server/src/services/storage/chats.storage.ts` (+14 -4) 📝 `scripts/regressions/chat-branch-lineage.regression.ts` (+513 -9) </details> ### 📄 Description ## Linked issue Closes #7758 ## Why this change Branching a prepared roleplay chat discards its memory processing state, making users prepare the entire retained history again even though the earlier scene archive survives. A missing saved entry for the selected swipe can additionally substitute an old reply and invalidate an earlier scene. ## What changed - Prepared branches retain usable processing and classification checkpoints, automatic context starts, knowledge permissions, and normal scene-check cadence. Explicit pauses stay paused; stale fingerprint checkpoints are withheld. Deleted automatic Chat Summaries stay deleted during subsequent upkeep. - Historical forks reopen the containing scene, including forks exactly at its ending, and discard that scene's derived memories and records depending on omitted history. A clipped scene's timeframe is derived from retained messages. Complete earlier memories remain available for immediate recall. - Branching preserves the authoritative selected reply and its visibility even when its saved swipe entry is missing. Incomplete swipe histories are numbered consecutively; tracker/game snapshots, inventory tellings and interruption targets follow their copied swipes. - Transcript imports retain their existing conservative preparation behavior. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Tested code revision: `a718226e5ca61e08a02bfd86a294b7600a9db1b5` (the committed tree is identical to the final locally reviewed and checked patch). Completed on the final revision: - `pnpm check`: passed. - `node scripts/run-regressions.mjs --filter chat-branch-lineage`: passed 1/1. The pause regression failed before the correction and passes afterward, covering missing knowledge, empty archives, and actual recall from a prepared paused archive. - Final local CodeRabbit review of the two-file follow-up: completed with no further findings. Earlier local and hosted findings were traced and fixed; the review history was not finding-free. Earlier evidence on `09cbf4a88a3bd1099c911576aa74ad8c1ad7e253`: Advanced Memory Node lane 20/20; prompt, prompt-attachments and context-fit regressions; final server lint and formatting. Desktop shell smoke passed 7/7 before the handled-summary/timeframe follow-ups, whose affected branch and upkeep paths were rerun in the final branch regression. Those broader lanes were not rerun after the pause-only correction. The branch regression also failed on unchanged staging with idle rather than ready. The actual branch endpoint passed against an isolated live-data snapshot: 1455 messages, 80 retained scene summaries, zero unprepared scenes, and an open fork scene. Local CodeRabbit and independent review are complete. Verified findings about empty archives, sparse swipe numbering, checkpoint identity and explicit pauses were fixed. Prepared paused branches retain their archive and expose Resume. The proposed blanket reset on any copied source change was not adopted: saved scene boundaries remain reusable across edits, while exact checkpoint hashes still require verification. Regressions also cover deleted automatic Chat Summaries and clipped timeframes. ### Manual verification notes - Read-only inspection confirmed the reported live branch lost its processing state while retaining earlier summaries and an open fork scene. It also exposed a selected-swipe mismatch behind one missing historical scene. - Manually verify a historical fork in the browser, send the next reply, and inspect recalled earlier scenes and the ongoing fork scene. - The existing live branch has not been modified. Containers and physical devices were not tested; no frontend layout was changed. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) No UI layout or copy changes. The behavioral proof exercises the real branch endpoint and recall service against isolated data. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved chat branching so copied swipe histories remain correctly navigable, including when the active swipe was missing from stored history. * Preserved associated interruption, game, and tracker state across branches, with references aligned to copied messages and swipes. * **Improvements** * Advanced Memory state now carries over appropriately when branching, including summaries, scene status, and paused state. * Branches that end within a scene reopen that scene without retaining later scene content. * Memory checkpoints and knowledge references are preserved when their related content is available in the branch. <!-- 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-24 04:08:48 +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#7914
No description provided.