When the MCP server was initialized before opening RooCode, disabled servers
would not appear in the settings UI. This was fixed by:
1. Using getAllServers() instead of getServers() in ClineProvider.ts for UI
state updates, ensuring all servers (including disabled ones) are shown
2. Maintaining getServers() for operational use (AI prompts, tool calls)
where disabled servers should be filtered out
The fix maintains clean separation between UI display and operational
server filtering.
Added thread-safe initialization to the McpServerManager singleton pattern to
prevent potential race conditions when getInstance is called concurrently.
The changes include:
1. Added initializationPromise to track ongoing initialization
2. Implemented double-checked locking pattern:
- First check: Return existing instance if available
- Second check: Wait for any ongoing initialization
- Third check: Double-check inside initialization block
3. Added proper cleanup in finally block to prevent deadlocks
This ensures that:
- Only one McpHub instance is ever created
- Concurrent calls wait for initialization to complete
- Resources are properly initialized and cleaned up
- No memory leaks from incomplete initialization
The fix maintains the existing functionality while making it safe for
concurrent access in VS Code's multi-window environment.
Problem:
- Multiple instances of the Roo Code application were launching separate MCP server instances
- This led to unnecessary resource consumption and potential conflicts between instances
Solution:
1. Created new McpServerManager singleton class to manage MCP server instances:
- Static getInstance() method ensures only one McpHub instance exists
- Tracks registered ClineProvider instances
- Handles cleanup on extension deactivation
2. Modified ClineProvider class:
- Changed mcpHub from private to protected
- Added getMcpHub() public getter method
- Updated initialization to use McpServerManager
- Added unregister logic in dispose()
3. Updated extension.ts to handle cleanup:
- Added McpServerManager cleanup in deactivate()
Technical Implementation:
- Uses WeakRef for provider tracking to allow proper garbage collection
- Maintains global state to track instance IDs
- Implements proper cleanup of resources on disposal
- Ensures backward compatibility with existing code
This change significantly improves resource usage and prevents potential conflicts
between multiple instances of the application while maintaining all existing
functionality.
One-line change to improve Roo-Cline's eyesight.
Aside: the above improves an AI's vision; the below works for people. My prescription has gone from -4.50 to -2.50 in a year, and I only do the exercises once a month or so, after the first few weeks of once a day:
https://www.youtube.com/watch?v=7TU7o5E3QuU
* Chore: Pretier for consistant formatting
- TODO: This PR needs to be updated by Saoud after he runs `npm install` & `npm format:fix` and commits the results of the prettier changes.
* Revert prettier config
* Run npm install
* Fix prettier config and ignore package lock
* Run format
---------
Co-authored-by: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com>