mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-01-26 20:26:13 +01:00
🧹 fix: MCP Panel Regressions after UI refactor (#11312)
* fix: Revoke OAuth and Vars. Config Regressions in MCP Panel - Introduced a new Trash2 icon button in MCPCardActions for revoking OAuth access on connected OAuth servers. - Updated MCPServerCard to handle the revoke action, allowing users to revoke OAuth for specific servers. - Enhanced user experience by ensuring the revoke option is available regardless of the server's connection state. * refactor: Reorganize Revoke Button Logic in MCPCardActions and Update Toast Messages - Moved the Revoke button for OAuth servers to a new position in MCPCardActions for improved visibility. - Updated the success message logic in useMCPServerManager to differentiate between uninstall and variable update actions, enhancing user feedback. * i18n: Add new translation for MCP server access revocation message * refactor: Centralize Deselection Logic in updateUserPluginsMutation - Updated the success handler in useUpdateUserPluginsMutation to manage deselection of MCP server values when revoking access, improving code clarity and reducing redundancy. - Simplified message assignment logic for user feedback during plugin updates.
This commit is contained in:
parent
fc6f127b21
commit
90521bfb4e
4 changed files with 48 additions and 9 deletions
|
|
@ -94,8 +94,20 @@ export function useMCPServerManager({ conversationId }: { conversationId?: strin
|
|||
const cancelOAuthMutation = useCancelMCPOAuthMutation();
|
||||
|
||||
const updateUserPluginsMutation = useUpdateUserPluginsMutation({
|
||||
onSuccess: async () => {
|
||||
showToast({ message: localize('com_nav_mcp_vars_updated'), status: 'success' });
|
||||
onSuccess: async (_data, variables) => {
|
||||
const isRevoke = variables.action === 'uninstall';
|
||||
const message = isRevoke
|
||||
? localize('com_nav_mcp_access_revoked')
|
||||
: localize('com_nav_mcp_vars_updated');
|
||||
showToast({ message, status: 'success' });
|
||||
|
||||
/** Deselect server from mcpValues when revoking access */
|
||||
if (isRevoke && variables.pluginKey?.startsWith(Constants.mcp_prefix)) {
|
||||
const serverName = variables.pluginKey.replace(Constants.mcp_prefix, '');
|
||||
const currentValues = mcpValuesRef.current ?? [];
|
||||
const filteredValues = currentValues.filter((name) => name !== serverName);
|
||||
setMCPValues(filteredValues);
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries([QueryKeys.mcpServers]),
|
||||
|
|
@ -491,13 +503,10 @@ export function useMCPServerManager({ conversationId }: { conversationId?: strin
|
|||
auth: {},
|
||||
};
|
||||
updateUserPluginsMutation.mutate(payload);
|
||||
|
||||
const currentValues = mcpValues ?? [];
|
||||
const filteredValues = currentValues.filter((name) => name !== targetName);
|
||||
setMCPValues(filteredValues);
|
||||
/** Deselection is now handled centrally in updateUserPluginsMutation.onSuccess */
|
||||
}
|
||||
},
|
||||
[selectedToolForConfig, updateUserPluginsMutation, mcpValues, setMCPValues],
|
||||
[selectedToolForConfig, updateUserPluginsMutation],
|
||||
);
|
||||
|
||||
/** Standalone revoke function for OAuth servers - doesn't require selectedToolForConfig */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue