From fafca841cb16f8442be7f55c4c730ec36236a609 Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 14 Nov 2025 15:52:01 +0800 Subject: [PATCH] refactor(frontend): remove redundant 'Sync All' button from MCP panel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All MCP operations already auto-sync to live configs: - upsert_server() → sync_server_to_apps() - toggle_app() → sync_server_to_app() or remove_server_from_app() - delete_server() → remove_server_from_all_apps() The manual 'Sync All' button was redundant and could confuse users into thinking they need to manually sync after each change. Changes: - Remove 'Sync All' button from UnifiedMcpPanel header - Remove useSyncAllMcpServers hook - Remove handleSyncAll function and syncAllMutation state - Remove RefreshCw icon import - Remove sync-related i18n translations (en/zh) Note: Backend sync_all_mcp_servers command remains for potential future use (e.g., recovery tool), but is no longer exposed in UI. --- src/components/mcp/UnifiedMcpPanel.tsx | 39 ++++---------------------- src/hooks/useMcp.ts | 9 ------ src/i18n/locales/en.json | 2 -- src/i18n/locales/zh.json | 2 -- 4 files changed, 6 insertions(+), 46 deletions(-) diff --git a/src/components/mcp/UnifiedMcpPanel.tsx b/src/components/mcp/UnifiedMcpPanel.tsx index fed80ed..0de5483 100644 --- a/src/components/mcp/UnifiedMcpPanel.tsx +++ b/src/components/mcp/UnifiedMcpPanel.tsx @@ -1,6 +1,6 @@ import React, { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; -import { Plus, Server, Check, RefreshCw } from "lucide-react"; +import { Plus, Server, Check } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Dialog, @@ -10,7 +10,7 @@ import { DialogTitle, } from "@/components/ui/dialog"; import { Checkbox } from "@/components/ui/checkbox"; -import { useAllMcpServers, useToggleMcpApp, useSyncAllMcpServers } from "@/hooks/useMcp"; +import { useAllMcpServers, useToggleMcpApp } from "@/hooks/useMcp"; import type { McpServer } from "@/types"; import type { AppId } from "@/lib/api/types"; import McpFormModal from "./McpFormModal"; @@ -48,7 +48,6 @@ const UnifiedMcpPanel: React.FC = ({ const { data: serversMap, isLoading } = useAllMcpServers(); const toggleAppMutation = useToggleMcpApp(); const deleteServerMutation = useDeleteMcpServer(); - const syncAllMutation = useSyncAllMcpServers(); // Convert serversMap to array for easier rendering const serverEntries = useMemo((): Array<[string, McpServer]> => { @@ -110,17 +109,6 @@ const UnifiedMcpPanel: React.FC = ({ }); }; - const handleSyncAll = async () => { - try { - await syncAllMutation.mutateAsync(); - toast.success(t("mcp.unifiedPanel.syncAllSuccess")); - } catch (error) { - toast.error(t("common.error"), { - description: String(error), - }); - } - }; - const handleCloseForm = () => { setIsFormOpen(false); setEditingId(null); @@ -133,25 +121,10 @@ const UnifiedMcpPanel: React.FC = ({
{t("mcp.unifiedPanel.title")} -
- - -
+
diff --git a/src/hooks/useMcp.ts b/src/hooks/useMcp.ts index 781bad1..adc29f2 100644 --- a/src/hooks/useMcp.ts +++ b/src/hooks/useMcp.ts @@ -59,12 +59,3 @@ export function useDeleteMcpServer() { }, }); } - -/** - * 同步所有启用的 MCP 服务器到各应用的 live 配置 - */ -export function useSyncAllMcpServers() { - return useMutation({ - mutationFn: () => mcpApi.syncAllServers(), - }); -} diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json index 2d45987..72f7d3b 100644 --- a/src/i18n/locales/en.json +++ b/src/i18n/locales/en.json @@ -447,8 +447,6 @@ "editServer": "Edit Server", "deleteServer": "Delete Server", "deleteConfirm": "Are you sure you want to delete server \"{{id}}\"? This action cannot be undone.", - "syncAll": "Sync All", - "syncAllSuccess": "All enabled servers have been synced to application configs", "noServers": "No servers yet", "enabledApps": "Enabled Apps", "apps": { diff --git a/src/i18n/locales/zh.json b/src/i18n/locales/zh.json index 6156020..e0014ac 100644 --- a/src/i18n/locales/zh.json +++ b/src/i18n/locales/zh.json @@ -447,8 +447,6 @@ "editServer": "编辑服务器", "deleteServer": "删除服务器", "deleteConfirm": "确定要删除服务器 \"{{id}}\" 吗?此操作无法撤销。", - "syncAll": "同步全部", - "syncAllSuccess": "已同步所有启用的服务器到各应用配置", "noServers": "暂无服务器", "enabledApps": "启用的应用", "apps": {