Skip to content

Commit ceeb33f

Browse files
committed
Fix race condition where MCP servers were sent to webview before it was initialized
1 parent f938c40 commit ceeb33f

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,10 @@ export class ClineProvider implements vscode.WebviewViewProvider {
791791
}
792792
break
793793
}
794+
case "fetchLatestMcpServersFromHub": {
795+
this.mcpHub?.sendLatestMcpServers()
796+
break
797+
}
794798
case "searchCommits": {
795799
const cwd = vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath).at(0)
796800
if (cwd) {

src/services/mcp/McpHub.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,10 @@ export class McpHub {
472472
})
473473
}
474474

475+
async sendLatestMcpServers() {
476+
await this.notifyWebviewOfServerChanges()
477+
}
478+
475479
// Using server
476480

477481
// Public methods for server management

src/shared/WebviewMessage.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export interface WebviewMessage {
4848
| "silentlyRefreshMcpMarketplace"
4949
| "searchCommits"
5050
| "showMcpView"
51+
| "fetchLatestMcpServersFromHub"
5152
// | "relaunchChromeDebugMode"
5253
text?: string
5354
disabled?: boolean

webview-ui/src/components/mcp/McpView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const McpView = ({ onDone }: McpViewProps) => {
2323

2424
useEffect(() => {
2525
vscode.postMessage({ type: "silentlyRefreshMcpMarketplace" })
26+
vscode.postMessage({ type: "fetchLatestMcpServersFromHub" })
2627
}, [])
2728

2829
// const [servers, setServers] = useState<McpServer[]>([

0 commit comments

Comments
 (0)