mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
Fix MCP hub lookup during view transition (#2829)
This commit is contained in:
parent
b6ea9d1465
commit
8b5d48013e
1 changed files with 12 additions and 4 deletions
|
|
@ -46,6 +46,7 @@ import { UrlContentFetcher } from "../services/browser/UrlContentFetcher"
|
|||
import { listFiles } from "../services/glob/list-files"
|
||||
import { BrowserSession } from "../services/browser/BrowserSession"
|
||||
import { McpHub } from "../services/mcp/McpHub"
|
||||
import { McpServerManager } from "../services/mcp/McpServerManager"
|
||||
import { telemetryService } from "../services/telemetry/TelemetryService"
|
||||
import { CheckpointServiceOptions, RepoPerTaskCheckpointService } from "../services/checkpoints"
|
||||
|
||||
|
|
@ -969,12 +970,19 @@ export class Cline extends EventEmitter<ClineEvents> {
|
|||
this.lastApiRequestTime = Date.now()
|
||||
|
||||
if (mcpEnabled ?? true) {
|
||||
mcpHub = this.providerRef.deref()?.getMcpHub()
|
||||
if (!mcpHub) {
|
||||
throw new Error("MCP hub not available")
|
||||
const provider = this.providerRef.deref()
|
||||
if (!provider) {
|
||||
throw new Error("Provider reference lost during view transition")
|
||||
}
|
||||
|
||||
// Wait for MCP hub initialization through McpServerManager
|
||||
mcpHub = await McpServerManager.getInstance(provider.context, provider)
|
||||
if (!mcpHub) {
|
||||
throw new Error("Failed to get MCP hub from server manager")
|
||||
}
|
||||
|
||||
// Wait for MCP servers to be connected before generating system prompt
|
||||
await pWaitFor(() => mcpHub!.isConnecting !== true, { timeout: 10_000 }).catch(() => {
|
||||
await pWaitFor(() => !mcpHub!.isConnecting, { timeout: 10_000 }).catch(() => {
|
||||
console.error("MCP servers failed to connect in time")
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue