🔐 refactor: Improve MCP Auth UX for Agent Panel (#9762)

* chore: Improve logging format for initial flow state creation

* refactor: MCP Tool Management with Improved Auth Handling and State Management

- Updated `CustomUserVarsSection` to include optional localization for placeholder text.
- Refactored `MCPToolSelectDialog` to streamline tool addition and management, including improved handling of authentication data.
- Introduced a new `addToolsToForm` function to encapsulate logic for adding tools to the form state.
- Enhanced `useRemoveMCPTool` hook to simplify tool removal logic and ensure proper state updates.
- Added loading state management for custom variable saving to improve user experience.

* refactor: Enhance MCP Tool Removal Logic and Integrate Toast Notifications

- Updated `MCPToolSelectDialog` to utilize the new `removeTool` function from the `useRemoveMCPTool` hook for improved tool removal handling.
- Refactored `useRemoveMCPTool` to accept options for toast notifications, allowing for more flexible user feedback during tool removal.
- Removed the previous inline tool removal logic to streamline the component's code and improve maintainability.

* refactor: Enhance user plugins mutation to invalidate MCP auth values on uninstall

* refactor: Replace refetchQueries with invalidateQueries for improved cache management

* chore: remove unused i18n key
This commit is contained in:
Danny Avila 2025-09-22 08:53:19 -04:00 committed by GitHub
parent ff8dac570f
commit a6bf2b6ce3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 111 additions and 114 deletions

View file

@ -320,6 +320,10 @@ export const useUpdateUserPluginsMutation = (
onSuccess: (...args) => {
queryClient.invalidateQueries([QueryKeys.user]);
onSuccess?.(...args);
if (args[1]?.action === 'uninstall' && args[1]?.pluginKey?.startsWith(Constants.mcp_prefix)) {
const serverName = args[1]?.pluginKey?.substring(Constants.mcp_prefix.length);
queryClient.invalidateQueries([QueryKeys.mcpAuthValues, serverName]);
}
},
});
};
@ -339,7 +343,7 @@ export const useReinitializeMCPServerMutation = (): UseMutationResult<
const queryClient = useQueryClient();
return useMutation((serverName: string) => dataService.reinitializeMCPServer(serverName), {
onSuccess: () => {
queryClient.refetchQueries([QueryKeys.mcpTools]);
queryClient.invalidateQueries([QueryKeys.mcpTools]);
},
});
};