[GH-ISSUE #2306] [Issue]: 09-CHAT-RUNTIME-connected-chat-notes-influences disconnect leaves stale linked context #1142

Closed
opened 2026-10-21 05:27:44 +07:00 by bsakaguchi · 0 comments
Owner

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

Originally assigned to: @Promansis on GitHub.

Summary

09-CHAT-RUNTIME-connected-chat-notes-influences: refactor disconnects only the requested chat in a connected conversation/roleplay/game pair. The partner chat can keep connectedChatId, plus durable notes or unconsumed influences can remain active and continue entering linked roleplay/game prompts.

Expected behavior

Legacy behavior should be preserved: connected chats are bidirectionally linked, disconnect clears both sides of the link, and connected notes/influences associated with the disconnected chat are cleared so stale OOC context cannot keep steering later prompts.

Actual behavior

Refactor chat_disconnect clears connectedChatId only on the requested chat. It does not clear the partner chat's connectedChatId, and it does not clear embedded notes entries whose sourceChatId or targetChatId belongs to the disconnected pair.

Prompt/write/import behavior is otherwise mostly present: <note> and <influence> tags are parsed, stored on the linked roleplay/game chat's notes array, injected as <conversation_notes> and <ooc_influences>, and one-shot influences are consumed after prompt assembly.

Steps to reproduce

  1. Link a conversation chat to a roleplay or game chat.
  2. Save a connected <note> or unconsumed <influence> from the conversation into the linked roleplay/game chat.
  3. Disconnect from one side of the pair.
  4. Inspect the partner chat and generate in the linked roleplay/game chat.

Impact area

  • App shell, navigation, startup, or providers
  • Catalog resources
  • Chat mode
  • Roleplay mode
  • Game mode
  • Shared mode UI
  • Runtime systems: generation, world-state, visuals, tracker, or haptics
  • Professor Mari or shell tools
  • React-free engine behavior, contracts, agents, or capability ports
  • Shared API wrapper or remote runtime routing
  • Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime
  • Docs, contributor workflow, or templates

Environment

  • Branch or commit: refactor; source tracker #2268 used refactor@37585ab9
  • Run mode: Tauri desktop / remote runtime command parity path
  • OS + version: not verified
  • Node + pnpm versions: not verified
  • Rust version, if relevant: not verified
  • Remote Runtime URL configured? not relevant
  • Provider, model, or integration, if relevant: not relevant

Logs, screenshots, or video

Static parity trace only. No runtime logs, screenshots, or video.

Proof:

  • Legacy has sidecar ooc_influences and conversation_notes tables with source/target chat ids and consumed state: main:packages/server/src/db/schema/chats.ts:66.
  • Legacy links both chats and disconnect clears both linked rows: main:packages/server/src/services/storage/chats.storage.ts:940.
  • Legacy disconnect route deletes influences and notes for the disconnected chat: main:packages/server/src/routes/chats.routes.ts:756.
  • Refactor embedded chat_connect links both chats, but chat_disconnect only patches the requested chat to connectedChatId: null: src-tauri/src/commands/storage/commands/chats.rs:218.
  • Refactor remote /api/invoke dispatch has the same one-sided disconnect behavior: src-tauri/src/http_dispatch.rs:877.
  • Refactor connected commands store <note> / <influence> on the target roleplay/game chat notes array: src/engine/generation/connected-commands.ts:156 and src/engine/generation/connected-commands.ts:716.
  • Refactor prompt assembly injects unconsumed influences and durable notes from the target chat notes array: src/engine/generation/prompt-assembly.ts:1902.
  • Refactor consumes pending influences after prompt assembly: src/engine/generation/start-generation.ts:2893.
  • Refactor UI and hooks call the one-sided disconnect command: src/features/catalog/chats/hooks/use-chats.ts:1191 and src/features/modes/shared/chat-ui/components/ChatSettingsDrawer.tsx:3824.
  • Legacy sidecar imports intentionally normalize into target chat notes, so the storage-shape difference itself is not the gap: src-tauri/src/commands/storage/profile/legacy.rs:945.

Regression notes

Legacy behavior on main kept the connection lifecycle symmetric and cleared connected sidecar context on disconnect. Refactor moved connected notes/influences into chats.notes, which is an intentional shape change, but disconnect cleanup did not preserve the legacy lifecycle semantics.

Additional context

Surface: 09-CHAT-RUNTIME-connected-chat-notes-influences

Source tracker: #2268

Acceptance criteria:

  • Disconnecting either side of a connected conversation ↔ roleplay/game pair clears connectedChatId on both chats.
  • Disconnecting clears or otherwise deactivates connected note/influence entries associated with the disconnected pair so stale <conversation_notes> or <ooc_influences> cannot enter future roleplay/game prompts.
  • Embedded Tauri command and remote /api/invoke chat_disconnect have matching behavior.
  • Query invalidation/UI state refresh covers both affected chats.
  • Existing intentional behavior remains: legacy conversation_notes and ooc_influences imports continue landing on the target chat notes array, unconsumed influences inject once, and durable notes inject until explicitly cleared while the pair remains connected.

Follow-ups found but not chased in Batch 15:

  • Delete-chat cleanup for embedded notes entries by sourceChatId.
  • Broader roleplay/game prompt semantics remain owned by Targets 12 and 16.

Template check

Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked:

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Jun 5, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2306 Originally assigned to: @Promansis on GitHub. ## Summary `09-CHAT-RUNTIME-connected-chat-notes-influences`: refactor disconnects only the requested chat in a connected conversation/roleplay/game pair. The partner chat can keep `connectedChatId`, plus durable notes or unconsumed influences can remain active and continue entering linked roleplay/game prompts. ## Expected behavior Legacy behavior should be preserved: connected chats are bidirectionally linked, disconnect clears both sides of the link, and connected notes/influences associated with the disconnected chat are cleared so stale OOC context cannot keep steering later prompts. ## Actual behavior Refactor `chat_disconnect` clears `connectedChatId` only on the requested chat. It does not clear the partner chat's `connectedChatId`, and it does not clear embedded `notes` entries whose `sourceChatId` or `targetChatId` belongs to the disconnected pair. Prompt/write/import behavior is otherwise mostly present: `<note>` and `<influence>` tags are parsed, stored on the linked roleplay/game chat's `notes` array, injected as `<conversation_notes>` and `<ooc_influences>`, and one-shot influences are consumed after prompt assembly. ## Steps to reproduce 1. Link a conversation chat to a roleplay or game chat. 2. Save a connected `<note>` or unconsumed `<influence>` from the conversation into the linked roleplay/game chat. 3. Disconnect from one side of the pair. 4. Inspect the partner chat and generate in the linked roleplay/game chat. ## Impact area <!-- Check the areas you think are relevant. Leave uncertain items unchecked. --> - [ ] App shell, navigation, startup, or providers - [ ] Catalog resources - [x] Chat mode - [x] Roleplay mode - [x] Game mode - [x] Shared mode UI - [x] Runtime systems: generation, world-state, visuals, tracker, or haptics - [ ] Professor Mari or shell tools - [x] React-free engine behavior, contracts, agents, or capability ports - [x] Shared API wrapper or remote runtime routing - [x] Tauri/Rust storage, assets, LLM, integrations, security, imports, or HTTP runtime - [ ] Docs, contributor workflow, or templates ## Environment - Branch or commit: `refactor`; source tracker #2268 used `refactor@37585ab9` - Run mode: Tauri desktop / remote runtime command parity path - OS + version: not verified - Node + pnpm versions: not verified - Rust version, if relevant: not verified - Remote Runtime URL configured? not relevant - Provider, model, or integration, if relevant: not relevant ## Logs, screenshots, or video Static parity trace only. No runtime logs, screenshots, or video. Proof: - Legacy has sidecar `ooc_influences` and `conversation_notes` tables with source/target chat ids and consumed state: `main:packages/server/src/db/schema/chats.ts:66`. - Legacy links both chats and disconnect clears both linked rows: `main:packages/server/src/services/storage/chats.storage.ts:940`. - Legacy disconnect route deletes influences and notes for the disconnected chat: `main:packages/server/src/routes/chats.routes.ts:756`. - Refactor embedded `chat_connect` links both chats, but `chat_disconnect` only patches the requested chat to `connectedChatId: null`: `src-tauri/src/commands/storage/commands/chats.rs:218`. - Refactor remote `/api/invoke` dispatch has the same one-sided disconnect behavior: `src-tauri/src/http_dispatch.rs:877`. - Refactor connected commands store `<note>` / `<influence>` on the target roleplay/game chat notes array: `src/engine/generation/connected-commands.ts:156` and `src/engine/generation/connected-commands.ts:716`. - Refactor prompt assembly injects unconsumed influences and durable notes from the target chat notes array: `src/engine/generation/prompt-assembly.ts:1902`. - Refactor consumes pending influences after prompt assembly: `src/engine/generation/start-generation.ts:2893`. - Refactor UI and hooks call the one-sided disconnect command: `src/features/catalog/chats/hooks/use-chats.ts:1191` and `src/features/modes/shared/chat-ui/components/ChatSettingsDrawer.tsx:3824`. - Legacy sidecar imports intentionally normalize into target chat `notes`, so the storage-shape difference itself is not the gap: `src-tauri/src/commands/storage/profile/legacy.rs:945`. ## Regression notes Legacy behavior on `main` kept the connection lifecycle symmetric and cleared connected sidecar context on disconnect. Refactor moved connected notes/influences into `chats.notes`, which is an intentional shape change, but disconnect cleanup did not preserve the legacy lifecycle semantics. ## Additional context Surface: `09-CHAT-RUNTIME-connected-chat-notes-influences` Source tracker: #2268 Acceptance criteria: - Disconnecting either side of a connected conversation ↔ roleplay/game pair clears `connectedChatId` on both chats. - Disconnecting clears or otherwise deactivates connected note/influence entries associated with the disconnected pair so stale `<conversation_notes>` or `<ooc_influences>` cannot enter future roleplay/game prompts. - Embedded Tauri command and remote `/api/invoke` `chat_disconnect` have matching behavior. - Query invalidation/UI state refresh covers both affected chats. - Existing intentional behavior remains: legacy `conversation_notes` and `ooc_influences` imports continue landing on the target chat `notes` array, unconsumed influences inject once, and durable notes inject until explicitly cleared while the pair remains connected. Follow-ups found but not chased in Batch 15: - Delete-chat cleanup for embedded `notes` entries by `sourceChatId`. - Broader roleplay/game prompt semantics remain owned by Targets 12 and 16. ## Template check Please uncheck the box below before submitting so we know you read the template. It is intentionally pre-checked: - [ ] I DID NOT read this template and provide the requested details.
bsakaguchi 2026-10-21 05:27:44 +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#1142
No description provided.