🧹 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:
Danny Avila 2026-01-12 19:01:45 -05:00 committed by GitHub
parent fc6f127b21
commit 90521bfb4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 48 additions and 9 deletions

View file

@ -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 */