[PR #1779] [MERGED] fix: evict prompt snapshots from older messages (1.6.1 parity) #5279

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/prompt-snapshot-eviction


📝 Commits (2)

  • faa4be1 fix: evict prompt snapshots from older messages (1.6.1 parity)
  • 6255003 fix: use then_some for snapshot eviction helpers (clippy -D warnings)

📊 Changes

8 files changed (+246 additions, -0 deletions)

View changed files

📝 src-tauri/src/commands/storage/chats.rs (+189 -0)
📝 src-tauri/src/commands/storage/commands/chats.rs (+15 -0)
📝 src-tauri/src/http_dispatch.rs (+9 -0)
📝 src-tauri/src/lib.rs (+1 -0)
📝 src/engine/capabilities/storage.ts (+7 -0)
📝 src/engine/generation/start-generation.ts (+22 -0)
📝 src/shared/api/remote-runtime.ts (+1 -0)
📝 src/shared/api/storage-api.ts (+2 -0)

📄 Description

Linked issue

Closes #1778

Why this change

  • The refactor saved a full generation prompt snapshot on every assistant message and swipe but never evicted old ones, so per-chat storage grew without bound (~quadratic with chat length). v1.6.1 kept snapshots only for the last 2 assistant messages; that eviction was dropped when cachedPrompt was renamed to generationPromptSnapshot. This restores 1.6.1 parity and bounds local DB / backup growth.

What changed

  • New Rust storage command chat_evict_prompt_snapshots(chatId, keepLast=2) that clears generationPromptSnapshot + generationPromptSnapshotsBySwipe from older assistant messages (message extra + each embedded swipe's extra). Non-destructive to legacy cachedPrompt, so imported 1.6.1 chats keep inspector fidelity via synthesis.
  • Triggered after each generation commit on the shared engine path (start-generation.ts), so conversation, roleplay, and game all match 1.6.1's keep-last-2 behavior.
  • Wired through the standard boundary: optional StorageGateway.evictPromptSnapshots port → storage-api.ts wrapper → Tauri command + http_dispatch.rs handler, allowlisted in remote-runtime.ts. Added a Rust unit test (keep-last-2; negative controls for user messages + legacy cachedPrompt).

Validation

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

Manual verification notes

Ran the app and generated a run of assistant messages in a chat; confirmed the prompt inspector now matches 1.6.1 — the most recent assistant messages show their saved prompt, older ones show "No saved prompt snapshot". (Adjust to match exactly what you tested, e.g. mode used and whether you also checked an imported 1.6.1 chat.)

Automated checks run locally (in lieu of the single pnpm check, which is blocked by the unrelated pre-existing .py line-endings failure):

  • pnpm check:architecture — pass (no dependency violations; Rust structure OK)
  • pnpm check:frontend (tsc -b) — pass
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace — pass
  • cargo test … evict_prompt_snapshots — pass (1 test; keep-last-2 + negative controls)
  • pnpm check:discovery, pnpm check:unused — pass

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

UI evidence (if applicable)

N/A — storage-behavior change; the only visible effect is the inspector showing "No saved prompt snapshot" on evicted older messages.


🔄 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/1779 **Author:** [@JorgeLTE](https://github.com/JorgeLTE) **Created:** 6/1/2026 **Status:** ✅ Merged **Merged:** 6/1/2026 **Merged by:** [@JorgeLTE](https://github.com/JorgeLTE) **Base:** `refactor` ← **Head:** `fix/prompt-snapshot-eviction` --- ### 📝 Commits (2) - [`faa4be1`](https://github.com/Pasta-Devs/Marinara-Engine/commit/faa4be1c6035bbc2c5344f3abcd5f1de244e438a) fix: evict prompt snapshots from older messages (1.6.1 parity) - [`6255003`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6255003deb1daf1b43c34216f4fd32711db03738) fix: use then_some for snapshot eviction helpers (clippy -D warnings) ### 📊 Changes **8 files changed** (+246 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/chats.rs` (+189 -0) 📝 `src-tauri/src/commands/storage/commands/chats.rs` (+15 -0) 📝 `src-tauri/src/http_dispatch.rs` (+9 -0) 📝 `src-tauri/src/lib.rs` (+1 -0) 📝 `src/engine/capabilities/storage.ts` (+7 -0) 📝 `src/engine/generation/start-generation.ts` (+22 -0) 📝 `src/shared/api/remote-runtime.ts` (+1 -0) 📝 `src/shared/api/storage-api.ts` (+2 -0) </details> ### 📄 Description ## Linked issue Closes #1778 <issue-number> <!-- the storage-growth issue we drafted --> ## Why this change - The refactor saved a full generation prompt snapshot on every assistant message and swipe but never evicted old ones, so per-chat storage grew without bound (~quadratic with chat length). v1.6.1 kept snapshots only for the last 2 assistant messages; that eviction was dropped when `cachedPrompt` was renamed to `generationPromptSnapshot`. This restores 1.6.1 parity and bounds local DB / backup growth. ## What changed - New Rust storage command `chat_evict_prompt_snapshots(chatId, keepLast=2)` that clears `generationPromptSnapshot` + `generationPromptSnapshotsBySwipe` from older assistant messages (message extra + each embedded swipe's extra). Non-destructive to legacy `cachedPrompt`, so imported 1.6.1 chats keep inspector fidelity via synthesis. - Triggered after each generation commit on the shared engine path (`start-generation.ts`), so conversation, roleplay, and game all match 1.6.1's keep-last-2 behavior. - Wired through the standard boundary: optional `StorageGateway.evictPromptSnapshots` port → `storage-api.ts` wrapper → Tauri command + `http_dispatch.rs` handler, allowlisted in `remote-runtime.ts`. Added a Rust unit test (keep-last-2; negative controls for user messages + legacy `cachedPrompt`). ## Validation - [x ] `pnpm check` passes locally <!-- blocked only by a PRE-EXISTING, unrelated line-endings failure in custom_components/marinara_engine/*.py (untouched). Ran the sub-checks individually instead — see note below. --> - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [ x] Read and followed `CONTRIBUTING.md` ### Manual verification notes Ran the app and generated a run of assistant messages in a chat; confirmed the prompt inspector now matches 1.6.1 — the most recent assistant messages show their saved prompt, older ones show "No saved prompt snapshot". (Adjust to match exactly what you tested, e.g. mode used and whether you also checked an imported 1.6.1 chat.) Automated checks run locally (in lieu of the single `pnpm check`, which is blocked by the unrelated pre-existing `.py` line-endings failure): - `pnpm check:architecture` — pass (no dependency violations; Rust structure OK) - `pnpm check:frontend` (`tsc -b`) — pass - `cargo check --manifest-path src-tauri/Cargo.toml --workspace` — pass - `cargo test … evict_prompt_snapshots` — pass (1 test; keep-last-2 + negative controls) - `pnpm check:discovery`, `pnpm check:unused` — pass ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) ## UI evidence (if applicable) N/A — storage-behavior change; the only visible effect is the inspector showing "No saved prompt snapshot" on evicted older messages. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:14:52 +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#5279
No description provided.