[PR #2346] [MERGED] Clean agent bookkeeping on chat delete #5548

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/2296-agent-bookkeeping-cleanup


📝 Commits (5)

  • b03456b storage: clean agent bookkeeping on chat delete
  • 11deb95 storage: preserve legacy secret plot memory
  • 19733b8 storage: normalize legacy agent memory writes
  • 22681ad Merge origin/refactor into agent bookkeeping cleanup
  • e5b075b storage: normalize chat metadata inputs

📊 Changes

4 files changed (+735 additions, -81 deletions)

View changed files

📝 src-tauri/src/commands/storage/agents.rs (+312 -35)
📝 src-tauri/src/commands/storage/chats.rs (+156 -0)
📝 src-tauri/src/commands/storage/commands/entities.rs (+254 -43)
📝 src/shared/api/storage-api.ts (+13 -3)

📄 Description

Linked issue

Closes #2296

Why this change

Deleting a chat removed messages, swipes, tracker snapshots, scene memories, and gallery rows, but left that chat's agent bookkeeping in agent-runs and agent-memory. Deleted chats could accumulate inert per-chat agent state over time.

What changed

  • Added shared Rust storage cleanup for agent bookkeeping rows keyed to a chat.
  • Wired chat deletion to clear agent runs and memory for every chat in the delete scope, including owned scene chats.
  • Preserved the existing reset-world-state behavior that can restore the secret-plot overarching arc, including legacy agent_config_id / chat_id memory rows.
  • Added regression coverage for current chatId rows, legacy chat_id memory rows, scene-child cleanup, unrelated chat preservation, and legacy secret-plot arc preservation.
  • Switched the plugin shell public entrypoint from wildcard to named settings export so the Linux unused-export check can trace the existing settings usage.

Refactor impact

Primary owner:

Rust storage

Impact areas reviewed:

  • Chat delete cascade
  • Chat group delete caller through delete_chat_with_messages
  • Agent runs and agent memory storage rows
  • Scene child delete scope
  • Reset-world-state agent cleanup helper
  • Plugin shell public barrel export used by settings

Boundary notes:

  • Storage behavior stays in Rust storage modules; no React, engine, shared API, Tauri command shape, or remote runtime contract changes.
  • Existing storage command entrypoints continue to call the same chat delete helper.
  • Shell plugin barrel remains the public import boundary for settings; only the export style changed from wildcard to named export.

Pressure points touched:

  • None of the listed broad UI or command-registration pressure points were touched.

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 clear_agent_bookkeeping_preserves_legacy_secret_plot_arc passed.
  • cargo test --manifest-path src-tauri/Cargo.toml delete_chat_removes_agent_bookkeeping_for_deleted_chat_scope passed.
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passed.
  • pnpm check:architecture passed.
  • pnpm check:unused passed.
  • pnpm check passed.
  • Native app manual QA not run; storage-level Rust tests cover the owning delete/reset paths.

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:

  • Internal storage cleanup bugfix and public export maintenance; no new user-discoverable workflow or setting.

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; no visible UI behavior changed.


🔄 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/2346 **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/2296-agent-bookkeeping-cleanup` --- ### 📝 Commits (5) - [`b03456b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/b03456b8cdec01cded41cfd008a9c40e5da1c546) storage: clean agent bookkeeping on chat delete - [`11deb95`](https://github.com/Pasta-Devs/Marinara-Engine/commit/11deb9534fb3b697df7d73f6e2ea5d29e7979d9c) storage: preserve legacy secret plot memory - [`19733b8`](https://github.com/Pasta-Devs/Marinara-Engine/commit/19733b86710f8f6725c2f2aaae5d8082702759bd) storage: normalize legacy agent memory writes - [`22681ad`](https://github.com/Pasta-Devs/Marinara-Engine/commit/22681ad0191a22261efe60a5aaf1e9283159ae45) Merge origin/refactor into agent bookkeeping cleanup - [`e5b075b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/e5b075bb42a0c60a5d4bb9e18532594588cd00cb) storage: normalize chat metadata inputs ### 📊 Changes **4 files changed** (+735 additions, -81 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/agents.rs` (+312 -35) 📝 `src-tauri/src/commands/storage/chats.rs` (+156 -0) 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+254 -43) 📝 `src/shared/api/storage-api.ts` (+13 -3) </details> ### 📄 Description ## Linked issue Closes #2296 ## Why this change Deleting a chat removed messages, swipes, tracker snapshots, scene memories, and gallery rows, but left that chat's agent bookkeeping in `agent-runs` and `agent-memory`. Deleted chats could accumulate inert per-chat agent state over time. ## What changed - Added shared Rust storage cleanup for agent bookkeeping rows keyed to a chat. - Wired chat deletion to clear agent runs and memory for every chat in the delete scope, including owned scene chats. - Preserved the existing reset-world-state behavior that can restore the secret-plot overarching arc, including legacy `agent_config_id` / `chat_id` memory rows. - Added regression coverage for current `chatId` rows, legacy `chat_id` memory rows, scene-child cleanup, unrelated chat preservation, and legacy secret-plot arc preservation. - Switched the plugin shell public entrypoint from wildcard to named settings export so the Linux unused-export check can trace the existing settings usage. ## Refactor impact Primary owner: Rust storage Impact areas reviewed: - Chat delete cascade - Chat group delete caller through `delete_chat_with_messages` - Agent runs and agent memory storage rows - Scene child delete scope - Reset-world-state agent cleanup helper - Plugin shell public barrel export used by settings Boundary notes: - Storage behavior stays in Rust storage modules; no React, engine, shared API, Tauri command shape, or remote runtime contract changes. - Existing storage command entrypoints continue to call the same chat delete helper. - Shell plugin barrel remains the public import boundary for settings; only the export style changed from wildcard to named export. Pressure points touched: - None of the listed broad UI or command-registration pressure points were touched. ## 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 clear_agent_bookkeeping_preserves_legacy_secret_plot_arc` passed. - `cargo test --manifest-path src-tauri/Cargo.toml delete_chat_removes_agent_bookkeeping_for_deleted_chat_scope` passed. - `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passed. - `pnpm check:architecture` passed. - `pnpm check:unused` passed. - `pnpm check` passed. - Native app manual QA not run; storage-level Rust tests cover the owning delete/reset paths. ## 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: - Internal storage cleanup bugfix and public export maintenance; no new user-discoverable workflow or setting. ## 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; no visible UI behavior changed. --- <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:16 +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#5548
No description provided.