Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Aug 6, 2025

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:

  1. SettingsView.tsx always sends the mcpEnabled message when saving settings
  2. webviewMessageHandler.ts unconditionally calls handleMcpEnabledChange when receiving the message
  3. McpHub.ts refreshes all MCP connections without checking if the value actually changed

Solution

Added a state comparison in webviewMessageHandler.ts before triggering MCP refresh:

  • Compare the new mcpEnabled value with the current state
  • Only call handleMcpEnabledChange when the value actually changes
  • Otherwise, just update the state without triggering refresh

Testing

  • ✅ All existing tests pass
  • ✅ Linting passes
  • ✅ Type checking passes

Acceptance Criteria

  • Saving non-MCP related settings does not trigger MCP refresh notifications
  • Toggling the "MCP Enabled" setting properly triggers MCP refresh
  • All other settings changes are persisted correctly

Fixes #6772


Important

Fixes unnecessary MCP server refresh notifications by adding state comparison for mcpEnabled in webviewMessageHandler.ts.

  • Behavior:
    • Prevents unnecessary MCP server refresh notifications when saving unrelated settings in webviewMessageHandler.ts.
    • Adds state comparison for mcpEnabled to trigger refresh only on actual changes.
  • Solution:
    • Compares new mcpEnabled value with current state before calling handleMcpEnabledChange.
    • Updates state without triggering refresh if value is unchanged.
  • Testing:
    • All existing tests, linting, and type checking pass.
    • Ensures non-MCP settings do not trigger refresh notifications.

This description was created by Ellipsis for beeb1a0. You can customize this summary. It will automatically update as commits are pushed.

- 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
@roomote roomote bot requested review from cte, jr and mrubens as code owners August 6, 2025 21:30
@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Aug 6, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Aug 6, 2025
Copy link
Contributor Author

@roomote roomote bot left a 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)
Copy link
Contributor Author

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) {
Copy link
Contributor Author

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.

@daniel-lxs
Copy link
Member

Closing in favor of #6779

@daniel-lxs daniel-lxs closed this Aug 7, 2025
@github-project-automation github-project-automation bot moved this from Triage to Done in Roo Code Roadmap Aug 7, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Aug 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. size:S This PR changes 10-29 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Bug: Settings save incorrectly triggers MCP server refresh notifications

4 participants