refactor(mcp): complete form refactoring for unified MCP management

Complete the v3.7.0 MCP refactoring by updating the form layer to match
the unified architecture already implemented in data/service/API layers.

**Breaking Changes:**
- Remove confusing `appId` parameter from McpFormModal
- Replace with `defaultFormat` (json/toml) and `defaultEnabledApps` (array)

**Form Enhancements:**
- Add app enablement checkboxes (Claude/Codex/Gemini) directly in the form
- Smart defaults: new servers default to Claude enabled, editing preserves state
- Support "draft" mode: servers can be created without enabling any apps

**Architecture Improvements:**
- Eliminate semantic confusion: format selection separate from app targeting
- One-step workflow: configure and enable apps in single form submission
- Consistent with unified backend: `apps: { claude, codex, gemini }`

**Testing:**
- Update test mocks to use `useUpsertMcpServer` hook
- Add test case for creating servers with no apps enabled
- Fix parameter references from `appId` to `defaultFormat`

**i18n:**
- Add `mcp.form.enabledApps` translation (zh/en)
- Add `mcp.form.noAppsWarning` translation (zh/en)

This completes the MCP management refactoring, ensuring all layers
(data, service, API, UI) follow the same unified architecture pattern.
This commit is contained in:
Jason
2025-11-15 23:47:35 +08:00
parent 154ff4c819
commit 685a1138e4
5 changed files with 210 additions and 94 deletions

View File

@@ -191,12 +191,13 @@ const UnifiedMcpPanel: React.FC<UnifiedMcpPanelProps> = ({
{/* Form Modal */}
{isFormOpen && (
<McpFormModal
appId="claude" // Default to claude for unified panel
editingId={editingId || undefined}
initialData={
editingId && serversMap ? serversMap[editingId] : undefined
}
existingIds={serversMap ? Object.keys(serversMap) : []}
defaultFormat="json"
defaultEnabledApps={["claude"]} // 默认启用 Claude
onSave={async () => {
setIsFormOpen(false);
setEditingId(null);