[PR #2386] [MERGED] Fix chat memory recall invalidation #5574

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-2305-memory-recall-invalidation


📝 Commits (2)

  • a91ce68 Fix chat memory recall invalidation
  • 18c46d9 Validate swipe read ownership

📊 Changes

2 files changed (+827 additions, -11 deletions)

View changed files

📝 src-tauri/src/commands/storage/chats.rs (+678 -8)
📝 src-tauri/src/commands/storage/commands/entities.rs (+149 -3)

📄 Description

Linked issue

Closes #2305

Why this change

  • Memory Recall chunks could keep stale visible message text after message edits, active swipe switches, active swipe additions, or active swipe deletions.
  • Manual and generation-triggered Memory Recall rebuilds also stored partial newest groups, while legacy only persisted complete 5-message chunks.

What changed

  • Added chat memory invalidation from a changed message boundary so chunks at or after the edited/swiped visible message are pruned.
  • Routed generic message content updates through the same invalidation behavior when the visible content actually changes.
  • Updated Memory Recall rebuild to store only complete 5-message chunks and leave incomplete newest groups pending.
  • Added focused Rust coverage for generic edits, conditional edits, active swipe changes, hidden-message filtering, and complete-only rebuild behavior.

Refactor impact

Primary owner:

Rust storage

Impact areas reviewed:

  • Chat mode Memory Recall persistence
  • Message edit and swipe mutation paths
  • Prompt recall downstream storage input
  • Embedded and remote command paths for existing Memory Recall list/delete/clear/rebuild

Boundary notes:

  • Kept behavior in src-tauri storage command owners.
  • No React, engine, shared API, or remote-runtime allowlist changes were needed because existing command routing remains intact.

Pressure points touched:

  • src-tauri/src/commands/storage/chats.rs
  • src-tauri/src/commands/storage/commands/entities.rs

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

  • cargo test --manifest-path src-tauri/Cargo.toml generic_message_content_update_prunes_stale_chat_memories -- --nocapture
  • cargo test --manifest-path src-tauri/Cargo.toml update_message_content_if_unchanged_prunes_stale_and_newer_memories -- --nocapture
  • cargo test --manifest-path src-tauri/Cargo.toml active_swipe_content_change_prunes_affected_chat_memories -- --nocapture
  • cargo test --manifest-path src-tauri/Cargo.toml refresh_chat_memories_stores_only_complete_five_message_chunks -- --nocapture
  • cargo test --manifest-path src-tauri/Cargo.toml refresh_chat_memories_skips_legacy_and_current_hidden_flags -- --nocapture
  • cargo test --manifest-path src-tauri/Cargo.toml chat_memory -- --nocapture
  • cargo test --manifest-path src-tauri/Cargo.toml refresh_chat_memories -- --nocapture
  • cargo check --manifest-path src-tauri/Cargo.toml
  • 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:

  • Bugfix for existing Memory Recall 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

  • Not applicable; storage behavior bugfix with Rust/local command proof.

Summary by CodeRabbit

  • Bug Fixes

    • Improved automatic cleanup of outdated chat memories when message content is edited or message versions are switched
    • Enhanced accuracy of chat context and memory management
  • Tests

    • Extended test coverage for message content updates and related memory scenarios

🔄 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/2386 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 6/6/2026 **Status:** ✅ Merged **Merged:** 6/6/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `refactor` ← **Head:** `fix/issue-2305-memory-recall-invalidation` --- ### 📝 Commits (2) - [`a91ce68`](https://github.com/Pasta-Devs/Marinara-Engine/commit/a91ce685666179d704cb66f1b8fc7ca945093e0e) Fix chat memory recall invalidation - [`18c46d9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/18c46d99c8d7e023cee1f310c7a7aa059c6b266b) Validate swipe read ownership ### 📊 Changes **2 files changed** (+827 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/chats.rs` (+678 -8) 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+149 -3) </details> ### 📄 Description ## Linked issue Closes #2305 ## Why this change - Memory Recall chunks could keep stale visible message text after message edits, active swipe switches, active swipe additions, or active swipe deletions. - Manual and generation-triggered Memory Recall rebuilds also stored partial newest groups, while legacy only persisted complete 5-message chunks. ## What changed - Added chat memory invalidation from a changed message boundary so chunks at or after the edited/swiped visible message are pruned. - Routed generic message content updates through the same invalidation behavior when the visible content actually changes. - Updated Memory Recall rebuild to store only complete 5-message chunks and leave incomplete newest groups pending. - Added focused Rust coverage for generic edits, conditional edits, active swipe changes, hidden-message filtering, and complete-only rebuild behavior. ## Refactor impact Primary owner: Rust storage Impact areas reviewed: - Chat mode Memory Recall persistence - Message edit and swipe mutation paths - Prompt recall downstream storage input - Embedded and remote command paths for existing Memory Recall list/delete/clear/rebuild Boundary notes: - Kept behavior in `src-tauri` storage command owners. - No React, engine, shared API, or remote-runtime allowlist changes were needed because existing command routing remains intact. Pressure points touched: - `src-tauri/src/commands/storage/chats.rs` - `src-tauri/src/commands/storage/commands/entities.rs` ## 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 - `cargo test --manifest-path src-tauri/Cargo.toml generic_message_content_update_prunes_stale_chat_memories -- --nocapture` - `cargo test --manifest-path src-tauri/Cargo.toml update_message_content_if_unchanged_prunes_stale_and_newer_memories -- --nocapture` - `cargo test --manifest-path src-tauri/Cargo.toml active_swipe_content_change_prunes_affected_chat_memories -- --nocapture` - `cargo test --manifest-path src-tauri/Cargo.toml refresh_chat_memories_stores_only_complete_five_message_chunks -- --nocapture` - `cargo test --manifest-path src-tauri/Cargo.toml refresh_chat_memories_skips_legacy_and_current_hidden_flags -- --nocapture` - `cargo test --manifest-path src-tauri/Cargo.toml chat_memory -- --nocapture` - `cargo test --manifest-path src-tauri/Cargo.toml refresh_chat_memories -- --nocapture` - `cargo check --manifest-path src-tauri/Cargo.toml` - `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. - [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 for existing Memory Recall 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 - Not applicable; storage behavior bugfix with Rust/local command proof. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved automatic cleanup of outdated chat memories when message content is edited or message versions are switched * Enhanced accuracy of chat context and memory management * **Tests** * Extended test coverage for message content updates and related memory scenarios <!-- 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:29 +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#5574
No description provided.