[GH-ISSUE #6084] [Issue]: Deleting a character card leaves its id in Roleplay/Conversation chats; Chat Settings Characters count is one too high (#6021 covered Game only) #3372

Closed
opened 2026-10-21 06:02:26 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @ghost on GitHub (Sep 12, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6084

Originally assigned to: @SpicyMarinara on GitHub.

Summary

Deleting a character card leaves its id inside every Roleplay and Conversation chat it belonged to. Chat Settings → Characters then shows a count one higher than the number of rows (badge 2, one row). #6026 fixed this for Game party membership (#6021); the other two modes still have it.

Expected behavior

Deleting a card removes its id from every chat's characterIds, in all three modes — the same cleanup #6026 added to the deletion transaction for Game chats. The Characters badge in Chat Settings matches the rows listed under it.

Actual behavior

  • GET /api/chats/:id after the delete still returns both ids: ["Ho4U61zYmMks28sj0xgAL", "zQC0jHWKYWxyQXf5CdFFN"] (second one is the deleted card, GET /api/characters/zQC0… → 404).
  • Chat Settings → Characters: badge reads 2, one row is listed (the surviving card). With both cards deleted the badge would still read 2 above an empty container, since the empty-state text is gated on the same raw length.

Steps to reproduce

  1. Create two character cards, A and B.
  2. Create a Roleplay chat with A and B in it.
  3. In the Characters library, delete B.
  4. Open the chat → Chat Settings → Characters section.

Badge shows 2, one row. Same with a Conversation chat. A Game chat is clean (scrubbed by #6026).

Environment

  • Marinara Engine version: 2.4.5, staging @ 9bf5baaf0 (clean checkout, fresh worktree)
  • Install type: source
  • OS + version: macOS 26.6.2 (arm64)
  • Browser or app shell: Chromium 1400×900 (Playwright, for the readout); reproduced via the REST API first

Logs, screenshots, or video

POST /api/characters  {"data":{"name":"Probe A (kept)"}}     -> Ho4U61zYmMks28sj0xgAL
POST /api/characters  {"data":{"name":"Probe B (deleted)"}}  -> zQC0jHWKYWxyQXf5CdFFN
POST /api/chats       {"mode":"roleplay","characterIds":[A,B]} -> u83yYfyQIo4oLsCHQCBod
DELETE /api/characters/zQC0jHWKYWxyQXf5CdFFN                  -> 204
GET  /api/chats/u83yYfyQIo4oLsCHQCBod  .characterIds          -> ["Ho4U61zYmMks28sj0xgAL","zQC0jHWKYWxyQXf5CdFFN"]
Chat Settings → Characters: badge "2", rows 1 ["Probe A (kept)"]

Additional context

Where it comes from, read at 9bf5baaf0:

  • Server — packages/server/src/services/storage/characters.storage.ts, remove(): the chat scrub added in #6026 selects where(eq(chats.mode, "game")), so Roleplay and Conversation rows are never touched. Groups are scrubbed for all modes right below it.
  • Client — packages/client/src/components/chat/ChatSettingsDrawer.tsx, the Characters section (!isGame): count={chatCharIds.length} and the two chatCharIds.length === 0 empty-state checks use the raw id list, while the rows are characters.find(...) and skip anything unresolvable. The Game Party section already uses the resolved chatCharacters.length since #6026.

Fix I intend to open as a draft PR today, same shape as #6026: drop the mode filter in the deletion transaction so every chat is scrubbed (the Game metadata branch already no-ops when there is no gameSetupConfig), and count chatCharacters.length at the three Roleplay/Conversation sites so already-stale chats (imported, or deleted before this lands) also show the right number.

Template check

Please uncheck (untick) 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 @ghost on GitHub (Sep 12, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/6084 Originally assigned to: @SpicyMarinara on GitHub. ## Summary Deleting a character card leaves its id inside every **Roleplay** and **Conversation** chat it belonged to. Chat Settings → Characters then shows a count one higher than the number of rows (badge `2`, one row). #6026 fixed this for **Game** party membership (#6021); the other two modes still have it. ## Expected behavior Deleting a card removes its id from every chat's `characterIds`, in all three modes — the same cleanup #6026 added to the deletion transaction for Game chats. The Characters badge in Chat Settings matches the rows listed under it. ## Actual behavior - `GET /api/chats/:id` after the delete still returns both ids: `["Ho4U61zYmMks28sj0xgAL", "zQC0jHWKYWxyQXf5CdFFN"]` (second one is the deleted card, `GET /api/characters/zQC0…` → 404). - Chat Settings → Characters: badge reads **2**, one row is listed (the surviving card). With both cards deleted the badge would still read 2 above an empty container, since the empty-state text is gated on the same raw length. ## Steps to reproduce 1. Create two character cards, A and B. 2. Create a Roleplay chat with A and B in it. 3. In the Characters library, delete B. 4. Open the chat → Chat Settings → Characters section. Badge shows 2, one row. Same with a Conversation chat. A Game chat is clean (scrubbed by #6026). ## Environment - Marinara Engine version: 2.4.5, `staging` @ `9bf5baaf0` (clean checkout, fresh worktree) - Install type: source - OS + version: macOS 26.6.2 (arm64) - Browser or app shell: Chromium 1400×900 (Playwright, for the readout); reproduced via the REST API first ## Logs, screenshots, or video ```text POST /api/characters {"data":{"name":"Probe A (kept)"}} -> Ho4U61zYmMks28sj0xgAL POST /api/characters {"data":{"name":"Probe B (deleted)"}} -> zQC0jHWKYWxyQXf5CdFFN POST /api/chats {"mode":"roleplay","characterIds":[A,B]} -> u83yYfyQIo4oLsCHQCBod DELETE /api/characters/zQC0jHWKYWxyQXf5CdFFN -> 204 GET /api/chats/u83yYfyQIo4oLsCHQCBod .characterIds -> ["Ho4U61zYmMks28sj0xgAL","zQC0jHWKYWxyQXf5CdFFN"] Chat Settings → Characters: badge "2", rows 1 ["Probe A (kept)"] ``` ## Additional context Where it comes from, read at `9bf5baaf0`: - Server — `packages/server/src/services/storage/characters.storage.ts`, `remove()`: the chat scrub added in #6026 selects `where(eq(chats.mode, "game"))`, so Roleplay and Conversation rows are never touched. Groups are scrubbed for all modes right below it. - Client — `packages/client/src/components/chat/ChatSettingsDrawer.tsx`, the Characters section (`!isGame`): `count={chatCharIds.length}` and the two `chatCharIds.length === 0` empty-state checks use the raw id list, while the rows are `characters.find(...)` and skip anything unresolvable. The Game Party section already uses the resolved `chatCharacters.length` since #6026. Fix I intend to open as a draft PR today, same shape as #6026: drop the mode filter in the deletion transaction so every chat is scrubbed (the Game metadata branch already no-ops when there is no `gameSetupConfig`), and count `chatCharacters.length` at the three Roleplay/Conversation sites so already-stale chats (imported, or deleted before this lands) also show the right number. ## Template check Please **uncheck (untick)** 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 06:02:26 +07:00
Author
Owner

@ghost commented on GitHub (Sep 12, 2026):

Draft PR #6089 (server scrub for every chat mode + resolved count in the drawer + a regression that fails on staging at the Roleplay assertion). Before/after table in the PR.

<!-- gh-comment-id:5646801417 --> @ghost commented on GitHub (Sep 12, 2026): Draft PR #6089 (server scrub for every chat mode + resolved count in the drawer + a regression that fails on `staging` at the Roleplay assertion). Before/after table in the PR.
Author
Owner

@SpicyMarinara commented on GitHub (Sep 12, 2026):

Fixed on staging in #6095.

Deleting a character card now removes its membership from Roleplay, Conversation, and Game chats. Chat Settings counts resolved cards, while keeping the count stable during loading. Original patch from #6089 is preserved; deletion/history regressions pass.

<!-- gh-comment-id:5647848779 --> @SpicyMarinara commented on GitHub (Sep 12, 2026): Fixed on staging in #6095. Deleting a character card now removes its membership from Roleplay, Conversation, and Game chats. Chat Settings counts resolved cards, while keeping the count stable during loading. Original patch from #6089 is preserved; deletion/history regressions pass.
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#3372
No description provided.