fix(mcp): resolve sync-to-other-side functionality failure
This commit implements a three-layer fix to restore the "Sync to other side" feature when adding or editing MCP servers across Claude and Codex. Root Cause Analysis: 1. Frontend issue: New MCP entries had their `enabled` field deleted 2. Backend issue: Default value was `false` when `enabled` was missing 3. Core issue: MCP entries were never copied to the other app's servers Changes: Frontend (McpFormModal.tsx): - Set `enabled=true` by default for new MCP entries - Preserve existing `enabled` state when editing Backend (services/mcp.rs): - Change default value from `unwrap_or(false)` to `unwrap_or(true)` - Implement cross-app MCP replication when `sync_other_side=true` - Clone MCP entry to other app's servers before syncing to live files Impact: - "Sync to Codex" checkbox now correctly adds MCP to both Claude and Codex - "Sync to Claude" checkbox now correctly adds MCP to both Codex and Claude - Both config.json and live files (~/.claude.json, ~/.codex/config.toml) are updated - Fixes regression introduced during project restructure Tested: - TypeScript type checking passed - Rust clippy linting passed - Manual testing: MCP sync works bidirectionally
This commit is contained in:
@@ -365,10 +365,13 @@ const McpFormModal: React.FC<McpFormModalProps> = ({
|
||||
server: serverSpec,
|
||||
};
|
||||
|
||||
// 修复:新增 MCP 时默认启用(enabled=true)
|
||||
// 编辑模式下保留原有的 enabled 状态
|
||||
if (initialData?.enabled !== undefined) {
|
||||
entry.enabled = initialData.enabled;
|
||||
} else if (!initialData) {
|
||||
delete entry.enabled;
|
||||
} else {
|
||||
// 新增模式:默认启用
|
||||
entry.enabled = true;
|
||||
}
|
||||
|
||||
const nameTrimmed = (formName || trimmedId).trim();
|
||||
|
||||
Reference in New Issue
Block a user