Skip to content

Commit beeb1a0

Browse files
committed
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
1 parent c52fdc4 commit beeb1a0

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/core/webview/webviewMessageHandler.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -900,12 +900,20 @@ export const webviewMessageHandler = async (
900900
}
901901
case "mcpEnabled":
902902
const mcpEnabled = message.bool ?? true
903-
await updateGlobalState("mcpEnabled", mcpEnabled)
903+
const currentMcpEnabled = getGlobalState("mcpEnabled") ?? true
904904

905-
// Delegate MCP enable/disable logic to McpHub
906-
const mcpHubInstance = provider.getMcpHub()
907-
if (mcpHubInstance) {
908-
await mcpHubInstance.handleMcpEnabledChange(mcpEnabled)
905+
// Only update and refresh if the value actually changed
906+
if (currentMcpEnabled !== mcpEnabled) {
907+
await updateGlobalState("mcpEnabled", mcpEnabled)
908+
909+
// Delegate MCP enable/disable logic to McpHub
910+
const mcpHubInstance = provider.getMcpHub()
911+
if (mcpHubInstance) {
912+
await mcpHubInstance.handleMcpEnabledChange(mcpEnabled)
913+
}
914+
} else {
915+
// Just update the state without triggering refresh
916+
await updateGlobalState("mcpEnabled", mcpEnabled)
909917
}
910918

911919
await provider.postStateToWebview()

0 commit comments

Comments
 (0)