LibreChat/client/src/Providers
Danny Avila 5b75c79831
🫥 fix: Clear Hidden MCP Chat Selections (#14159)
* 🫥 fix: Clear Hidden MCP Chat Selections

A server hidden with `chatMenu: false` stayed active in chat when it had been
selected while still visible. The selection persists to localStorage, and the
guard that clears stale selections tested the *filtered* server list — which is
empty precisely when every configured server is hidden, so the guard could never
fire and the selection survived every reload.

Gate the prune on the unfiltered catalog instead. It is non-empty in exactly the
case the old guard missed, and it stays a guard rather than a load flag so an
empty catalog — still loading, or a degraded read — is never mistaken for "the
admin removed everything" and used to wipe a selection irrecoverably.

Clear the ephemeral agent alongside the atom: it is what carries the selection to
the server, so a hidden name has to leave it too, not just the dropdown's state.

Also label the dropdown badge from the servers the menu actually offers. It
counted the raw selection, so a hidden server rendered as "Server Four" or
"2 selected" above an empty menu — the symptom that reads as a server you cannot
turn off.

* 🔧 fix: Keep Spec-Assigned MCP Servers Out of the Hidden-Server Prune

A model spec may deliberately assign a server the chat menu hides, and
`applyModelSpecEphemeralAgent` seeds it straight into `ephemeralAgent.mcp`. The
prune could not tell that apart from a stale selection, so activating such a spec
dropped its server — and because the same function re-reads `LAST_MCP_` for
existing conversations, the loss persisted across navigation.

Exempt whatever the active spec pins. `chatMenu` hides a picker entry; it does
not override an admin's spec assignment.

* 🔒 fix: Confine the MCP Selection Prune to the Hook Instance That Owns It

`useMCPServerManager` has seven call sites, and only `BadgeRowContext` reads the
chat selection — the rest mount it for the catalog, the server actions, or the
status icons. Every instance keyed to the same conversation shares one atom and
one ephemeral agent, so those six were all running the prune too, and the
always-mounted `useSideNavLinks` has no spec context to exempt from: it would
rewrite the selection the picker's own instance was deliberately keeping.

Make managing the selection opt-in, off by default at both layers, and let the
badge row alone opt in. The six catalog consumers stop touching chat selection
state entirely, which is what they should have been doing all along.

Tests now state whether they own the selection rather than inheriting it from a
default, so each one exercises the same configuration as the instance it models.

* 🔁 fix: Mirror the MCP Selection Everywhere, Prune It Only in the Owner

Gating the whole ephemeral-agent sync on selection ownership was too broad. The
action paths — `initializeServer`'s OAuth success, the revoke handler — build
their next selection from `mcpValues` and write it back through `setMCPValues`,
which also rewrites the shared ephemeral agent. An unmirrored instance therefore
wrote a stale list: authenticating server B could drop an existing selection of
server A, leaving only B.

Mirroring and pruning are separate concerns. Every instance mirrors, so each one
builds on the current selection; only the owner prunes, because only it knows
which servers a spec pins.
2026-09-01 18:38:14 -04:00
..
__tests__ ☁️ fix: Enable Azure Agent Provider Uploads (#13045) 2026-05-10 17:47:05 -04:00
ActivePanelContext.tsx 🗂️ feat: Sidebar Icon Toggle & New Chat History Switch (#12642) 2026-04-13 09:46:38 -04:00
AddedChatContext.tsx ⏸ refactor: Improve UX for Parallel Streams (Multi-Convo) (#11096) 2025-12-25 01:43:54 -05:00
AgentPanelContext.tsx ⚡ perf: Warm Feature Catalogs in the Background After First Paint (#15047) 2026-08-21 20:33:29 -04:00
AgentsContext.tsx 🧹 chore: Sort Client Imports Left Behind by the Import Order Gate (#15139) 2026-08-23 15:18:05 -04:00
AgentsMapContext.tsx 🔁 fix: Re-Arm Soft Default When a Stored Agent No Longer Resolves (#14664) 2026-08-06 12:39:32 -04:00
AnnouncerContext.tsx
ArtifactContext.tsx 🧊 perf: Memoize Completed Markdown Blocks During Streaming (#13576) 2026-06-07 20:31:56 -04:00
ArtifactsContext.tsx 🧬 refactor: Derive Latest Message From Cache (#13294) 2026-05-24 16:20:27 -04:00
AssistantsContext.tsx 🧹 chore: Sort Client Imports Left Behind by the Import Order Gate (#15139) 2026-08-23 15:18:05 -04:00
AssistantsMapContext.tsx
BadgeRowContext.tsx 🫥 fix: Clear Hidden MCP Chat Selections (#14159) 2026-09-01 18:38:14 -04:00
BookmarkContext.tsx
ChatContext.tsx 🎨 refactor: Redesign Sidebar with Unified Icon Strip Layout (#12013) 2026-03-22 01:15:20 -04:00
ChatFormContext.tsx 🙋 feat: ask_user_question - agent-initiated questions with durable pause/resume (#14139) 2026-07-08 15:31:05 -04:00
CodeBlockContext.tsx 🧜 feat: Open Mermaid Diagrams as Artifacts with SVG/PNG Export (#14713) 2026-08-09 09:02:42 -04:00
CustomFormContext.tsx 🙋 feat: ask_user_question - agent-initiated questions with durable pause/resume (#14139) 2026-07-08 15:31:05 -04:00
DragDropContext.tsx ☁️ fix: Enable Azure Agent Provider Uploads (#13045) 2026-05-10 17:47:05 -04:00
EditorContext.tsx
FileMapContext.tsx
index.ts 🖼️ fix: Give a Phase's Files Their Own Media Row (#15435) 2026-08-31 22:05:27 -04:00
MediaContext.tsx 🖼️ fix: Give a Phase's Files Their Own Media Row (#15435) 2026-08-31 22:05:27 -04:00
MessageContext.tsx
MessagesViewContext.tsx 🧬 refactor: Derive Latest Message From Cache (#13294) 2026-05-24 16:20:27 -04:00
PromptGroupsContext.tsx ⚡ perf: Avoid Parallel Full and Paged Prompt Loading on Startup (#15031) 2026-08-25 21:21:17 -04:00
SearchContext.tsx
SetConvoContext.tsx
ShareContext.tsx 🔗 feat: Snapshot Files for Shared-Link Attachments (#13740) 2026-06-20 23:05:13 -04:00
ToolCallsMapContext.tsx
UploadModalContext.tsx 🫴 fix: Hand Composer Focus Back After Upload Dialogs (#15469) 2026-09-01 12:56:03 -04:00