[GH-ISSUE #2114] Storage commands: message/swipe/avatar deletion & projection correctness (Bunny findings from #1812 scan) #1036

Closed
opened 2026-10-21 05:25:25 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 4, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2114

Originally assigned to: @kolacheee on GitHub.

Summary

While Bunny Review re-scanned the full tree on PR #1812 (a frontend card-CSS / conversation-avatar feature), it flagged 4 findings in the Tauri storage command layer — src-tauri/src/commands/storage/*.rs. None are in #1812's diff (that PR touches no Rust files), and the files show no diff vs refactor; they're pre-existing on the refactor line and surfaced only because the reviewer scans the whole tree. Filing here so the storage owner can triage independently of #1812.

These are message / swipe / avatar deletion & projection correctness issues — most notably a HIGH where bulk delete can cross chat boundaries.

Findings

🔥 HIGH — Bulk delete admits foreign message IDs

src-tauri/src/commands/storage/chats.rs:612

A bulk-delete pre-scan feeds message ids to the sidecar deleter without confirming they belong to the target chat, so a caller could destroy children of a different parent.

Suggested fix: Filter the pre-scan by both message id and chatId before feeding ids to the sidecar deleter, so the children destroyed are the children this parent is allowed to lose.

⚠️ MEDIUM — Persona snapshot cleanup ignores avatarPath

src-tauri/src/commands/storage/avatars.rs:256

Snapshot avatar cleanup recognizes avatarUrl but not avatarPath, so some referenced avatar files aren't handled when a snapshot is cleaned up.

Suggested fix: Teach the scan to recognize every snapshot avatar URL field the contract emits — at minimum avatarPath alongside avatarUrl — and add the corresponding regression case.

⚠️ MEDIUM — Projected active-swipe fields lose their selector

src-tauri/src/commands/storage/commands/entities.rs:229

The read projection drops activeSwipeIndex while still returning active-swipe-derived fields (content, characterId, extra, swipe summaries), so the returned values can't be tied back to the active swipe.

Suggested fix: Restore activeSwipeIndex to the read projection whenever active-swipe-derived fields are requested.

⚠️ MEDIUM — Message swipe sidecars survive parent deletion

src-tauri/src/commands/storage/contracts.rs:396

Deleting a message doesn't clean up its message-swipes sidecar, orphaning swipe data.

Suggested fix: Add explicit message-swipes cleanup when a message is deleted, or make the sidecar write/delete path transactional with the parent message.

Context

  • Surfaced by Bunny Review on PR #1812 (head 20bebc9b); transcribed from its walkthrough "Isolated Defects" table + repair prompts (no inline threads were created because the lines are outside that PR's diff).
  • Not introduced by #1812 (frontend-only diff). Owner: storage / Rust capability layer.
Originally created by @kolacheee on GitHub (Jun 4, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2114 Originally assigned to: @kolacheee on GitHub. ### Summary While Bunny Review re-scanned the full tree on PR #1812 (a frontend card-CSS / conversation-avatar feature), it flagged 4 findings in the Tauri **storage command** layer — `src-tauri/src/commands/storage/*.rs`. None are in #1812's diff (that PR touches no Rust files), and the files show no diff vs `refactor`; they're pre-existing on the `refactor` line and surfaced only because the reviewer scans the whole tree. Filing here so the storage owner can triage independently of #1812. These are message / swipe / avatar **deletion & projection** correctness issues — most notably a HIGH where bulk delete can cross chat boundaries. ### Findings #### 🔥 HIGH — Bulk delete admits foreign message IDs `src-tauri/src/commands/storage/chats.rs:612` A bulk-delete pre-scan feeds message ids to the sidecar deleter without confirming they belong to the target chat, so a caller could destroy children of a different parent. **Suggested fix:** Filter the pre-scan by both message id *and* `chatId` before feeding ids to the sidecar deleter, so the children destroyed are the children this parent is allowed to lose. #### ⚠️ MEDIUM — Persona snapshot cleanup ignores avatarPath `src-tauri/src/commands/storage/avatars.rs:256` Snapshot avatar cleanup recognizes `avatarUrl` but not `avatarPath`, so some referenced avatar files aren't handled when a snapshot is cleaned up. **Suggested fix:** Teach the scan to recognize every snapshot avatar URL field the contract emits — at minimum `avatarPath` alongside `avatarUrl` — and add the corresponding regression case. #### ⚠️ MEDIUM — Projected active-swipe fields lose their selector `src-tauri/src/commands/storage/commands/entities.rs:229` The read projection drops `activeSwipeIndex` while still returning active-swipe-derived fields (`content`, `characterId`, `extra`, swipe summaries), so the returned values can't be tied back to the active swipe. **Suggested fix:** Restore `activeSwipeIndex` to the read projection whenever active-swipe-derived fields are requested. #### ⚠️ MEDIUM — Message swipe sidecars survive parent deletion `src-tauri/src/commands/storage/contracts.rs:396` Deleting a message doesn't clean up its `message-swipes` sidecar, orphaning swipe data. **Suggested fix:** Add explicit `message-swipes` cleanup when a message is deleted, or make the sidecar write/delete path transactional with the parent message. ### Context - Surfaced by Bunny Review on PR #1812 (head `20bebc9b`); transcribed from its walkthrough "Isolated Defects" table + repair prompts (no inline threads were created because the lines are outside that PR's diff). - Not introduced by #1812 (frontend-only diff). Owner: storage / Rust capability layer.
Author
Owner

@kolacheee commented on GitHub (Jun 4, 2026):

working on a pr for this btw

<!-- gh-comment-id:4618856686 --> @kolacheee commented on GitHub (Jun 4, 2026): working on a pr for this btw
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#1036
No description provided.