LibreChat/client/src/data-provider
Danny Avila 58647bc08b
🔖 fix: Decrement Bookmark Counts When Deleting Conversations (#13830)
* 🔖 fix: Decrement Bookmark Counts When Deleting Conversations

Deleting a bookmarked/tagged conversation removed the conversation but never decremented the affected ConversationTag counts, leaving stale bookmark counts in the UI.

- Add decrementTagCounts helper that atomically decrements tag counts (clamped at 0, deduped per conversation) in deleteConvos, covering single delete, clear-all, and account deletion.
- Invalidate the conversationTags query in the single-delete and clear-all client mutations so counts refetch.
- Add deleteConvos tag-count tests.

* 🔒 fix: Guard tag-count decrement on actual deletion and message-failure

Addresses Codex review findings:
- Guard the decrement on deleteConvoResult.deletedCount > 0 so a losing concurrent delete (double-click/two-tab) does not decrement counts for a conversation it did not actually remove.
- Move the count adjustment to run immediately after the conversation deletion, before message cleanup, so a deleteMessages failure cannot leave bookmark counts permanently stale.
- Add regression tests for both cases.

* 🔀 fix: Refresh project stats after message cleanup in deleteConvos

Addresses Codex finding: bundling refreshChatProjectStatsForUser into a Promise.all before deleteMessages let a stats-refresh error abort the function and orphan the deleted conversations' messages. Split the steps so the (best-effort) tag-count decrement still runs before message cleanup (counts reconciled even if messages fail), while project-stats refresh runs after, matching the original ordering.

*  test: Add e2e coverage for bookmark counts on conversation delete

Two mock-harness specs for the deleteConvos bookmark-count behavior:
- Deleting the only conversation carrying a bookmark drops its count to 0.
- Deleting one of two conversations that share a bookmark leaves the count at 1.
Both assert the persisted server count via GET /api/tags after the real delete round-trip.

* chore: import order
2026-06-18 08:37:08 -04:00
..
__tests__ 🧠 feat: User Memories for Conversational Context (#7760) 2025-06-07 18:52:22 -04:00
Agents 👷 ci: Type-check the Client Workspace (#13560) 2026-06-06 18:40:31 -04:00
Auth 👷 ci: Type-check the Client Workspace (#13560) 2026-06-06 18:40:31 -04:00
Endpoints 🪙 feat: SDK-Aligned Context-Usage Projection (gauge for window-switch & snapshot-less branches) (#13801) 2026-06-16 17:54:13 -04:00
Files 👷 ci: Type-check the Client Workspace (#13560) 2026-06-06 18:40:31 -04:00
MCP 👷 ci: Type-check the Client Workspace (#13560) 2026-06-06 18:40:31 -04:00
Memories 🧠 feat: User Memories for Conversational Context (#7760) 2025-06-07 18:52:22 -04:00
Messages 🧵 fix: Prevent Message Loading Race During Streaming (#13295) 2026-05-24 18:50:00 -04:00
Misc 💸 feat: Balance Tab in Settings Dialog (#6537) 2025-05-29 08:25:37 -04:00
Projects 👻 fix: Clear Project-Scoped Landing When the Selected Project Is Deleted (#13525) 2026-06-05 10:19:58 -04:00
Skills 🎚️ feat: Per-User Skill Active/Inactive Toggle with Ownership-Aware Defaults (#12692) 2026-04-25 04:02:00 -04:00
SSE feat: Immediate Conversation Title Generation (#13395) 2026-06-02 16:40:57 -04:00
Tools 🔌 feat: MCP Reinitialization and OAuth in UI (#8598) 2025-07-22 22:52:45 -04:00
connection.ts 🧩 feat: Web Search Config Validations & Clipboard Citation Processing (#7530) 2025-05-24 10:23:17 -04:00
Favorites.ts 📜 feat: Skills UI + Initial E2E CRUD / Sharing (#12580) 2026-04-25 04:02:00 -04:00
index.ts 🗂️ feat: Add Private Chat Projects (#13467) 2026-06-03 15:29:18 -04:00
mutations.ts 🔖 fix: Decrement Bookmark Counts When Deleting Conversations (#13830) 2026-06-18 08:37:08 -04:00
prompts.ts 📁 refactor: Prompts UI (#11570) 2026-03-22 16:56:22 -04:00
queries.ts 🗂️ feat: Add Private Chat Projects (#13467) 2026-06-03 15:29:18 -04:00
roles.ts 📜 feat: Skills UI + Initial E2E CRUD / Sharing (#12580) 2026-04-25 04:02:00 -04:00
tags.ts 🏷️ fix: Address Statefulness Issues for Bookmarks (#3590) 2024-08-08 21:25:10 -04:00