[PR #756] [MERGED] Fix manual chat file deletion persistence #4762

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

📋 Pull Request Information

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

Base: main ← Head: fix/manual-chat-file-deletion


📝 Commits (2)

  • 151e1c4 Fix manual chat file deletion persistence
  • 19caa95 Address chat file deletion review feedback

📊 Changes

4 files changed (+99 additions, -19 deletions)

View changed files

📝 packages/client/src/components/chat/ChatFilesDrawer.tsx (+9 -6)
📝 packages/client/src/hooks/use-chats.ts (+38 -12)
📝 packages/server/src/db/file-backed-store.ts (+9 -1)
📝 packages/server/test/file-backed-store.test.ts (+43 -0)

📄 Description

Linked issue

Discord bug report: “Chat files not deleting with manual deletion” on Termux / Marinara 1.5.9. No GitHub issue exists yet.

Why this change

  • Users deleting chat files from Manage Chat Files could see the confirmation complete, but the deleted chat file would still be present after refreshing/restarting Marinara.
  • The reproduced root cause is in the v1.5.7+ file-native migration path: after a successful legacy SQLite import, the startup repair pass could treat an intentionally deleted imported chat as a missing legacy row and restore it from the old recovery database.

What changed

  • Mark successful legacy SQLite imports as already reconciled so later startup repair does not resurrect intentionally deleted imported rows.
  • Add a regression test proving a deleted imported chat stays deleted after reopening file-native storage with the legacy DB still present.
  • Make the Manage Chat Files delete path await the delete mutation, pass the known group ID for cache updates, refetch the group list, and show an error toast if deletion fails.

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

Manual verification notes

  • Automated repro before fix: imported two legacy chats, deleted one from file-native storage, reopened storage with the legacy DB still present, and observed the deleted chat return.
  • Automated repro after fix: same sequence leaves the deleted chat absent after reopening storage.
  • Ran pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/file-backed-store.test.ts.
  • Ran pnpm check.
  • Manual browser verification on this branch:
    • Built the current client bundle so the server served the updated Manage Chat Files drawer.
    • Started Marinara against an isolated file-native data directory seeded with a legacy SQLite database containing two grouped chat files.
    • Opened the real app UI, opened Manage Chat Files, deleted one branch, and confirmed the drawer refetched to one remaining chat file.
    • Restarted the server with the legacy database still present and confirmed the deleted branch stayed absent in both API data and the Manage Chat Files UI.
  • Manual Termux confirmation is still recommended because the original report came from a Discord user device.

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. The UI behavior is unchanged except for awaiting/refetching the existing delete action and surfacing delete failures.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed issue where deleted chats could reappear after restart when imported from legacy databases.
    • Improved error handling for chat deletion operations with on-screen notifications.
  • Improvements

    • Enhanced chat branch deletion with more reliable state management and recovery logic.

Review Change Stack


🔄 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/756 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/12/2026 **Status:** ✅ Merged **Merged:** 5/13/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `main` ← **Head:** `fix/manual-chat-file-deletion` --- ### 📝 Commits (2) - [`151e1c4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/151e1c4c8e421e4cda5294bd71b32c6c11c2914d) Fix manual chat file deletion persistence - [`19caa95`](https://github.com/Pasta-Devs/Marinara-Engine/commit/19caa95f608a44512f13b58181520beab4c2fb14) Address chat file deletion review feedback ### 📊 Changes **4 files changed** (+99 additions, -19 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/components/chat/ChatFilesDrawer.tsx` (+9 -6) 📝 `packages/client/src/hooks/use-chats.ts` (+38 -12) 📝 `packages/server/src/db/file-backed-store.ts` (+9 -1) 📝 `packages/server/test/file-backed-store.test.ts` (+43 -0) </details> ### 📄 Description ## Linked issue Discord bug report: “Chat files not deleting with manual deletion” on Termux / Marinara 1.5.9. No GitHub issue exists yet. ## Why this change - Users deleting chat files from Manage Chat Files could see the confirmation complete, but the deleted chat file would still be present after refreshing/restarting Marinara. - The reproduced root cause is in the v1.5.7+ file-native migration path: after a successful legacy SQLite import, the startup repair pass could treat an intentionally deleted imported chat as a missing legacy row and restore it from the old recovery database. ## What changed - Mark successful legacy SQLite imports as already reconciled so later startup repair does not resurrect intentionally deleted imported rows. - Add a regression test proving a deleted imported chat stays deleted after reopening file-native storage with the legacy DB still present. - Make the Manage Chat Files delete path await the delete mutation, pass the known group ID for cache updates, refetch the group list, and show an error toast if deletion fails. ## Validation - [x] `pnpm check` passes locally - [ ] 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 - Automated repro before fix: imported two legacy chats, deleted one from file-native storage, reopened storage with the legacy DB still present, and observed the deleted chat return. - Automated repro after fix: same sequence leaves the deleted chat absent after reopening storage. - Ran `pnpm --filter @marinara-engine/server exec tsx --import ./test/setup-env.ts --test test/file-backed-store.test.ts`. - Ran `pnpm check`. - Manual browser verification on this branch: - Built the current client bundle so the server served the updated Manage Chat Files drawer. - Started Marinara against an isolated file-native data directory seeded with a legacy SQLite database containing two grouped chat files. - Opened the real app UI, opened Manage Chat Files, deleted one branch, and confirmed the drawer refetched to one remaining chat file. - Restarted the server with the legacy database still present and confirmed the deleted branch stayed absent in both API data and the Manage Chat Files UI. - Manual Termux confirmation is still recommended because the original report came from a Discord user device. ## 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. The UI behavior is unchanged except for awaiting/refetching the existing delete action and surfacing delete failures. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Fixed issue where deleted chats could reappear after restart when imported from legacy databases. * Improved error handling for chat deletion operations with on-screen notifications. * **Improvements** * Enhanced chat branch deletion with more reliable state management and recovery logic. <!-- review_stack_entry_start --> [![Review Change Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/Pasta-Devs/Marinara-Engine/pull/756) <!-- review_stack_entry_end --> <!-- 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:10:26 +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#4762
No description provided.