Skip to content

Commit 5d441dc

Browse files
committed
perf(McpHub/reloadMcpServers): ensure no multiple reloads are running, ensure one last update
1 parent 22eb274 commit 5d441dc

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

pnpm-lock.yaml

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@
381381
"i18next": "^24.2.2",
382382
"ignore": "^7.0.3",
383383
"isbinaryfile": "^5.0.2",
384+
"kontroll": "^1.0.5",
384385
"mammoth": "^1.8.0",
385386
"monaco-vscode-textmate-theme-converter": "^0.1.7",
386387
"node-cache": "^5.1.2",

src/services/mcp/McpHub.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import * as path from "path"
1717
import * as vscode from "vscode"
1818
import { z } from "zod"
1919
import { t } from "../../i18n"
20+
import { countdown } from "kontroll"
2021

2122
import { ClineProvider } from "../../core/webview/ClineProvider"
2223
import { GlobalFileNames } from "../../shared/globalFileNames"
@@ -354,6 +355,17 @@ export class McpHub {
354355
}
355356

356357
public async reloadMcpServers() {
358+
if (this.isConnecting) {
359+
countdown(
360+
2000,
361+
() => {
362+
this.reloadMcpServers()
363+
},
364+
{ key: "reloadMcpServers" },
365+
)
366+
return
367+
}
368+
357369
await this.initializeProjectMcpServers()
358370
await this.initializeGlobalMcpServers()
359371
}

0 commit comments

Comments
 (0)