-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: prevent unnecessary MCP server refresh on settings save #6773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- 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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewing my own code is like debugging in a mirror - everything looks backwards but the bugs are still mine.
| } | ||
| } else { | ||
| // Just update the state without triggering refresh | ||
| await updateGlobalState("mcpEnabled", mcpEnabled) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this redundant state update intentional? Since the value hasn't changed, calling updateGlobalState("mcpEnabled", mcpEnabled) seems unnecessary. Could we simply skip this update entirely when the value is unchanged?
| if (mcpHubInstance) { | ||
| await mcpHubInstance.handleMcpEnabledChange(mcpEnabled) | ||
| // Only update and refresh if the value actually changed | ||
| if (currentMcpEnabled !== mcpEnabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding a comment here explaining why we check for value changes. Something like:
This would help future maintainers understand the performance optimization.
|
Closing in favor of #6779 |
Summary
This PR fixes an issue where saving any settings in the Roo Code VS Code extension incorrectly triggers MCP server refresh notifications, even when the changed settings are unrelated to MCP functionality.
Problem
When users save settings via the sprocket icon, the system displays "All MCP servers have been refreshed" notifications regardless of what settings were changed. This creates a confusing user experience and triggers unnecessary server refresh operations.
Root Cause
The issue occurs because:
SettingsView.tsxalways sends themcpEnabledmessage when saving settingswebviewMessageHandler.tsunconditionally callshandleMcpEnabledChangewhen receiving the messageMcpHub.tsrefreshes all MCP connections without checking if the value actually changedSolution
Added a state comparison in
webviewMessageHandler.tsbefore triggering MCP refresh:mcpEnabledvalue with the current statehandleMcpEnabledChangewhen the value actually changesTesting
Acceptance Criteria
Fixes #6772
Important
Fixes unnecessary MCP server refresh notifications by adding state comparison for
mcpEnabledinwebviewMessageHandler.ts.webviewMessageHandler.ts.mcpEnabledto trigger refresh only on actual changes.mcpEnabledvalue with current state before callinghandleMcpEnabledChange.This description was created by
for beeb1a0. You can customize this summary. It will automatically update as commits are pushed.