fix: prevent unnecessary MCP server refresh on settings save

- Add state comparison before triggering MCP refresh
- Only call handleMcpEnabledChange when mcpEnabled value actually changes
- Fixes issue where saving any settings triggers MCP refresh notifications

Fixes #6772
This commit is contained in:
Roo Code 2025-08-06 21:28:55 +00:00
parent c52fdc4397
commit beeb1a0cf2

View file

@ -900,12 +900,20 @@ export const webviewMessageHandler = async (
}
case "mcpEnabled":
const mcpEnabled = message.bool ?? true
await updateGlobalState("mcpEnabled", mcpEnabled)
const currentMcpEnabled = getGlobalState("mcpEnabled") ?? true
// Delegate MCP enable/disable logic to McpHub
const mcpHubInstance = provider.getMcpHub()
if (mcpHubInstance) {
await mcpHubInstance.handleMcpEnabledChange(mcpEnabled)
// Only update and refresh if the value actually changed
if (currentMcpEnabled !== mcpEnabled) {
await updateGlobalState("mcpEnabled", mcpEnabled)
// Delegate MCP enable/disable logic to McpHub
const mcpHubInstance = provider.getMcpHub()
if (mcpHubInstance) {
await mcpHubInstance.handleMcpEnabledChange(mcpEnabled)
}
} else {
// Just update the state without triggering refresh
await updateGlobalState("mcpEnabled", mcpEnabled)
}
await provider.postStateToWebview()