mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-10-13 03:58:14 +00:00
Problem: Closing auxiliary windows (e.g., from "open in editor") could prematurely dispose the shared singleton McpHub instance, shutting down MCP servers unexpectedly while other panels (like the sidebar) might still be active. Solution: Implemented reference counting directly within the McpHub class to manage its own lifecycle based on active clients (ClineProvider instances). - Added `refCount`, `registerClient()`, and `unregisterClient()` methods to McpHub. - McpHub now disposes itself only when the last registered client unregisters (`refCount` reaches 0). - ClineProvider instances now call `mcpHub.registerClient()` upon initialization and `mcpHub.unregisterClient()` upon disposal. - Removed the direct `mcpHub.dispose()` call from ClineProvider.dispose. Benefit: This ensures the shared McpHub instance remains active as long as at least one ClineProvider instance is using it. Cleanup now correctly occurs only when the last provider is closed or during full extension deactivation. This centralizes the resource's lifecycle logic within the resource class itself. Files Changed: - src/services/mcp/McpHub.ts - src/core/webview/ClineProvider.ts |
||
|---|---|---|
| .. | ||
| __mocks__ | ||
| __tests__ | ||
| activate | ||
| api | ||
| core | ||
| exports | ||
| i18n | ||
| integrations | ||
| schemas | ||
| services | ||
| shared | ||
| utils | ||
| extension.ts | ||