[PR #1655] [MERGED] [codex] Clear chat activity on deleted chats #5186

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

📋 Pull Request Information

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

Base: refactor ← Head: cleanup/clear-chat-activity-on-delete


📝 Commits (4)

  • 046d9ab Clear chat activity on deleted chats
  • 8fce989 Handle missing chat group delete ids
  • 6b5516b Fix chat delete clippy warning
  • f77e3a5 Make chat group delete ids optional

📊 Changes

5 files changed (+309 additions, -12 deletions)

View changed files

📝 src-tauri/src/commands/storage/chats.rs (+88 -8)
📝 src-tauri/src/commands/storage/commands/entities.rs (+44 -2)
➕ src/features/catalog/chats/hooks/use-chats.test.tsx (+149 -0)
📝 src/features/catalog/chats/hooks/use-chats.ts (+22 -1)
📝 src/shared/api/chat-command-api.ts (+6 -1)

📄 Description

Linked issue

No linked issue. This is a local Knip unused-export triage cleanup slice.

Why this change

Chat deletion removed persisted chat records and cache state, but autonomous chat activity lived in an in-memory engine map keyed by chat id. Deleted chats, including cascade-deleted roleplay scene chats, could leave stale autonomous activity state behind until reload.

What changed

  • Return exact deletedChatIds from chat deletion commands, including scene-chat cascades.
  • Clear autonomous chat activity from backend-reported deleted ids after successful single-chat and group-chat deletion.
  • Keep group deletion tolerant of older or mixed-runtime responses that omit deletedChatIds.
  • Add focused React Query hook tests and Rust command tests for deletion id reporting and cleanup behavior.

Refactor impact

Primary owner:

Catalog chats, chat autonomous engine state, shared API chat command wrapper, and Rust storage chat deletion commands.

Impact areas reviewed:

  • Catalog chat deletion hooks and optimistic cache rollback.
  • Chat autonomous in-memory activity cleanup.
  • Rust storage_delete and chat_group_delete command response contracts.
  • Roleplay scene chat cascade deletion ids.
  • Shared API typing for the group-delete command.

Boundary notes:

  • Feature code still calls focused shared API/storage wrappers.
  • Engine code remains React-free and does not import shared API adapters.
  • Rust storage commands remain the source of truth for which chat ids were actually deleted.
  • chat_group_delete is already routed through the embedded Tauri command and remote /api/invoke allowlist/dispatch path; the response shape change is shared by both.

Pressure points touched:

  • None of the listed pressure points were touched: no ModeSurface, GameSurface, shared mode UI, src-tauri/src/lib.rs command registration, or import modules changed.

Validation

  • pnpm check passes locally
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Playwright, screenshot, or recording evidence added for UI changes
  • Remote runtime smoke checked when relevant

Manual verification notes

Commands run locally:

  • pnpm vitest run src/features/catalog/chats/hooks/use-chats.test.tsx passed.
  • cargo test --manifest-path src-tauri/Cargo.toml delete_chat_group_reports_exact_deleted_chat_ids_including_scene_children passed.
  • cargo test --manifest-path src-tauri/Cargo.toml deleting_chat_reports_cascade_deleted_chat_ids passed.
  • pnpm typecheck passed.
  • pnpm check:architecture passed.
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passed.
  • cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings passed after fixing the CI clippy finding.
  • pnpm exec eslint src/features/catalog/chats/hooks/use-chats.ts src/features/catalog/chats/hooks/use-chats.test.tsx src/shared/api/chat-command-api.ts passed.
  • pnpm build passed with the existing large chunk warning.
  • git diff --check passed.

Manual app/Tauri QA was not run. Remote runtime was not smoke checked separately.

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

No docs or release note files were changed. This checkout has no CHANGELOG.md, and the change is internal cleanup/bugfix behavior rather than a documented workflow change.

UI evidence

No visible UI changes; no screenshots or recordings added.

Summary by CodeRabbit

  • Bug Fixes

    • Improved accuracy of chat deletion reporting to track all affected chat records when deleting groups or related chats.
    • Enhanced cleanup of chat activity data during deletion operations to ensure all affected chats are properly cleared.
  • Tests

    • Added test coverage for multi-chat deletion and cascade delete scenarios.

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/1655 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 5/30/2026 **Status:** ✅ Merged **Merged:** 5/30/2026 **Merged by:** [@Xelvanis](https://github.com/Xelvanis) **Base:** `refactor` ← **Head:** `cleanup/clear-chat-activity-on-delete` --- ### 📝 Commits (4) - [`046d9ab`](https://github.com/Pasta-Devs/Marinara-Engine/commit/046d9ab5ad8457508b2acfcbcc09ce41682b934e) Clear chat activity on deleted chats - [`8fce989`](https://github.com/Pasta-Devs/Marinara-Engine/commit/8fce989ba17e20a2709576eb18e11df9689ed534) Handle missing chat group delete ids - [`6b5516b`](https://github.com/Pasta-Devs/Marinara-Engine/commit/6b5516b39e1f921cb7f94a6337d82847ab48193c) Fix chat delete clippy warning - [`f77e3a5`](https://github.com/Pasta-Devs/Marinara-Engine/commit/f77e3a5b6113b34491097b03563e18f0746266f5) Make chat group delete ids optional ### 📊 Changes **5 files changed** (+309 additions, -12 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/chats.rs` (+88 -8) 📝 `src-tauri/src/commands/storage/commands/entities.rs` (+44 -2) ➕ `src/features/catalog/chats/hooks/use-chats.test.tsx` (+149 -0) 📝 `src/features/catalog/chats/hooks/use-chats.ts` (+22 -1) 📝 `src/shared/api/chat-command-api.ts` (+6 -1) </details> ### 📄 Description ## Linked issue No linked issue. This is a local Knip unused-export triage cleanup slice. ## Why this change Chat deletion removed persisted chat records and cache state, but autonomous chat activity lived in an in-memory engine map keyed by chat id. Deleted chats, including cascade-deleted roleplay scene chats, could leave stale autonomous activity state behind until reload. ## What changed - Return exact `deletedChatIds` from chat deletion commands, including scene-chat cascades. - Clear autonomous chat activity from backend-reported deleted ids after successful single-chat and group-chat deletion. - Keep group deletion tolerant of older or mixed-runtime responses that omit `deletedChatIds`. - Add focused React Query hook tests and Rust command tests for deletion id reporting and cleanup behavior. ## Refactor impact Primary owner: Catalog chats, chat autonomous engine state, shared API chat command wrapper, and Rust storage chat deletion commands. Impact areas reviewed: - Catalog chat deletion hooks and optimistic cache rollback. - Chat autonomous in-memory activity cleanup. - Rust `storage_delete` and `chat_group_delete` command response contracts. - Roleplay scene chat cascade deletion ids. - Shared API typing for the group-delete command. Boundary notes: - Feature code still calls focused shared API/storage wrappers. - Engine code remains React-free and does not import shared API adapters. - Rust storage commands remain the source of truth for which chat ids were actually deleted. - `chat_group_delete` is already routed through the embedded Tauri command and remote `/api/invoke` allowlist/dispatch path; the response shape change is shared by both. Pressure points touched: - None of the listed pressure points were touched: no ModeSurface, GameSurface, shared mode UI, `src-tauri/src/lib.rs` command registration, or import modules changed. ## Validation - [ ] `pnpm check` passes locally - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Playwright, screenshot, or recording evidence added for UI changes - [ ] Remote runtime smoke checked when relevant ### Manual verification notes Commands run locally: - `pnpm vitest run src/features/catalog/chats/hooks/use-chats.test.tsx` passed. - `cargo test --manifest-path src-tauri/Cargo.toml delete_chat_group_reports_exact_deleted_chat_ids_including_scene_children` passed. - `cargo test --manifest-path src-tauri/Cargo.toml deleting_chat_reports_cascade_deleted_chat_ids` passed. - `pnpm typecheck` passed. - `pnpm check:architecture` passed. - `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passed. - `cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings` passed after fixing the CI clippy finding. - `pnpm exec eslint src/features/catalog/chats/hooks/use-chats.ts src/features/catalog/chats/hooks/use-chats.test.tsx src/shared/api/chat-command-api.ts` passed. - `pnpm build` passed with the existing large chunk warning. - `git diff --check` passed. Manual app/Tauri QA was not run. Remote runtime was not smoke checked separately. ## 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 No docs or release note files were changed. This checkout has no `CHANGELOG.md`, and the change is internal cleanup/bugfix behavior rather than a documented workflow change. ## UI evidence No visible UI changes; no screenshots or recordings added. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved accuracy of chat deletion reporting to track all affected chat records when deleting groups or related chats. * Enhanced cleanup of chat activity data during deletion operations to ensure all affected chats are properly cleared. * **Tests** * Added test coverage for multi-chat deletion and cascade delete scenarios. <!-- 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/1655?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack) <!-- 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:14:03 +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#5186
No description provided.