Fix race condition where MCP servers were sent to webview before it was initialized

This commit is contained in:
Saoud Rizwan
2025-02-18 21:38:43 -08:00
parent f938c40539
commit ceeb33fdc5
4 changed files with 10 additions and 0 deletions
+4
View File
@@ -791,6 +791,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
}
break
}
case "fetchLatestMcpServersFromHub": {
this.mcpHub?.sendLatestMcpServers()
break
}
case "searchCommits": {
const cwd = vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0)
if (cwd) {
+4
View File
@@ -472,6 +472,10 @@ export class McpHub {
})
}
async sendLatestMcpServers() {
await this.notifyWebviewOfServerChanges()
}
// Using server
// Public methods for server management
+1
View File
@@ -48,6 +48,7 @@ export interface WebviewMessage {
| "silentlyRefreshMcpMarketplace"
| "searchCommits"
| "showMcpView"
| "fetchLatestMcpServersFromHub"
// | "relaunchChromeDebugMode"
text?: string
disabled?: boolean
@@ -23,6 +23,7 @@ const McpView = ({ onDone }: McpViewProps) => {
useEffect(() => {
vscode.postMessage({ type: "silentlyRefreshMcpMarketplace" })
vscode.postMessage({ type: "fetchLatestMcpServersFromHub" })
}, [])
// const [servers, setServers] = useState<McpServer[]>([