[PR #2340] [MERGED] Fix connected chat disconnect cleanup #5543

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

📋 Pull Request Information

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

Base: refactor ← Head: fix/issue-2306


📝 Commits (1)

  • 3d6b6c3 Fix connected chat disconnect cleanup

📊 Changes

6 files changed (+441 additions, -15 deletions)

View changed files

📝 src-tauri/src/commands/storage/chats.rs (+355 -0)
📝 src-tauri/src/commands/storage/commands/chats.rs (+1 -4)
📝 src-tauri/src/http_dispatch.rs (+74 -6)
📝 src/features/catalog/chats/hooks/use-chats.ts (+7 -3)
📝 src/features/shell/plugins/components/CoreModulesSettings.tsx (+3 -1)
📝 src/features/shell/plugins/shell.ts (+1 -1)

📄 Description

Linked issue

Closes #2306

Why this change

Connected chat disconnect only cleared the requested chat in refactor. The partner chat could keep connectedChatId, and connected durable notes or pending influences could remain in notes, allowing stale conversation context to keep entering roleplay/game prompts after disconnect.

What changed

  • Moved disconnect behavior into a shared Rust storage helper used by both embedded Tauri commands and remote /api/invoke.
  • Disconnect now clears connectedChatId on both sides of the pair, including reverse-only stale links.
  • Disconnect removes pair-owned note and influence entries by sourceChatId / targetChatId while preserving ordinary memories and unrelated notes.
  • The disconnect response now returns affected chat ids, and the chat hook invalidates affected chat detail and note queries.
  • Added focused Rust tests for embedded storage behavior and remote dispatch parity.

Refactor impact

Primary owner:

Rust storage and remote runtime dispatch.

Impact areas reviewed:

  • Chat mode connected conversation lifecycle
  • Roleplay/game prompt context cleanup via connected notes/influences
  • Remote /api/invoke parity for chat_disconnect
  • React Query cache invalidation for affected chats and notes

Boundary notes:

The state transition lives in src-tauri storage ownership and is reused by the embedded command wrapper and http_dispatch.rs. Feature code continues using the existing shared API wrapper/hook path.

Pressure points touched:

  • src-tauri/src/commands/storage/chats.rs
  • src-tauri/src/commands/storage/commands/chats.rs
  • src-tauri/src/http_dispatch.rs
  • src/features/catalog/chats/hooks/use-chats.ts

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 disconnect_connected_chat
  • cargo test --manifest-path src-tauri/Cargo.toml dispatch_chat_disconnect_clears_partner_and_connected_notes
  • cargo check --manifest-path src-tauri/Cargo.toml
  • pnpm typecheck
  • pnpm check

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:

Bugfix only; no new user-discoverable feature or workflow.

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

No visible UI layout change. Query invalidation is covered by typecheck and command-level storage/remote tests.


🔄 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/2340 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 6/5/2026 **Status:** ✅ Merged **Merged:** 6/5/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `refactor` ← **Head:** `fix/issue-2306` --- ### 📝 Commits (1) - [`3d6b6c3`](https://github.com/Pasta-Devs/Marinara-Engine/commit/3d6b6c35383264cfd0057cbd4655106c63acd980) Fix connected chat disconnect cleanup ### 📊 Changes **6 files changed** (+441 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/src/commands/storage/chats.rs` (+355 -0) 📝 `src-tauri/src/commands/storage/commands/chats.rs` (+1 -4) 📝 `src-tauri/src/http_dispatch.rs` (+74 -6) 📝 `src/features/catalog/chats/hooks/use-chats.ts` (+7 -3) 📝 `src/features/shell/plugins/components/CoreModulesSettings.tsx` (+3 -1) 📝 `src/features/shell/plugins/shell.ts` (+1 -1) </details> ### 📄 Description ## Linked issue Closes #2306 ## Why this change Connected chat disconnect only cleared the requested chat in refactor. The partner chat could keep `connectedChatId`, and connected durable notes or pending influences could remain in `notes`, allowing stale conversation context to keep entering roleplay/game prompts after disconnect. ## What changed - Moved disconnect behavior into a shared Rust storage helper used by both embedded Tauri commands and remote `/api/invoke`. - Disconnect now clears `connectedChatId` on both sides of the pair, including reverse-only stale links. - Disconnect removes pair-owned `note` and `influence` entries by `sourceChatId` / `targetChatId` while preserving ordinary memories and unrelated notes. - The disconnect response now returns affected chat ids, and the chat hook invalidates affected chat detail and note queries. - Added focused Rust tests for embedded storage behavior and remote dispatch parity. ## Refactor impact Primary owner: Rust storage and remote runtime dispatch. Impact areas reviewed: - Chat mode connected conversation lifecycle - Roleplay/game prompt context cleanup via connected notes/influences - Remote `/api/invoke` parity for `chat_disconnect` - React Query cache invalidation for affected chats and notes Boundary notes: The state transition lives in `src-tauri` storage ownership and is reused by the embedded command wrapper and `http_dispatch.rs`. Feature code continues using the existing shared API wrapper/hook path. Pressure points touched: - `src-tauri/src/commands/storage/chats.rs` - `src-tauri/src/commands/storage/commands/chats.rs` - `src-tauri/src/http_dispatch.rs` - `src/features/catalog/chats/hooks/use-chats.ts` ## 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 disconnect_connected_chat` - `cargo test --manifest-path src-tauri/Cargo.toml dispatch_chat_disconnect_clears_partner_and_connected_notes` - `cargo check --manifest-path src-tauri/Cargo.toml` - `pnpm typecheck` - `pnpm check` ## 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: Bugfix only; no new user-discoverable feature or workflow. ## Docs and release impact - [x] 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 No visible UI layout change. Query invalidation is covered by typecheck and command-level storage/remote tests. --- <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:13 +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#5543
No description provided.