From e1a0e659be12d535e8f9ded586b998629be237ee Mon Sep 17 00:00:00 2001 From: NamesMT Date: Thu, 22 May 2025 12:17:19 +0000 Subject: [PATCH] chore(marketplace): invoke to reload modes and mcps --- src/core/config/CustomModesManager.ts | 2 +- src/core/webview/marketplaceMessageHandler.ts | 14 +++++++++++--- src/services/mcp/McpHub.ts | 5 +++++ 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/core/config/CustomModesManager.ts b/src/core/config/CustomModesManager.ts index f763ff0abb..880c1b075d 100644 --- a/src/core/config/CustomModesManager.ts +++ b/src/core/config/CustomModesManager.ts @@ -308,7 +308,7 @@ export class CustomModesManager { await fs.writeFile(filePath, yaml.stringify(settings), "utf-8") } - private async refreshMergedState(): Promise { + public async refreshMergedState(): Promise { const settingsPath = await this.getCustomModesFilePath() const roomodesPath = await this.getWorkspaceRoomodes() diff --git a/src/core/webview/marketplaceMessageHandler.ts b/src/core/webview/marketplaceMessageHandler.ts index 31b90d3d83..cad07f8051 100644 --- a/src/core/webview/marketplaceMessageHandler.ts +++ b/src/core/webview/marketplaceMessageHandler.ts @@ -242,7 +242,7 @@ export async function handleMarketplaceMessages( try { await marketplaceManager .installMarketplaceItem(message.mpItem, message.mpInstallOptions) - .then(async (r) => r === "$COMMIT" && (await provider.postStateToWebview())) + .then(async (r) => r === "$COMMIT" && (await _onCommit())) } catch (error) { vscode.window.showErrorMessage( `Failed to install item "${message.mpItem.name}":\n${error instanceof Error ? error.message : String(error)}`, @@ -263,7 +263,7 @@ export async function handleMarketplaceMessages( try { await marketplaceManager .installMarketplaceItem(item, { parameters }) - .then(async (r) => r === "$COMMIT" && (await provider.postStateToWebview())) + .then(async (r) => r === "$COMMIT" && (await _onCommit())) } catch (error) { console.error(`Error submitting marketplace parameters: ${error}`) vscode.window.showErrorMessage( @@ -287,7 +287,7 @@ export async function handleMarketplaceMessages( try { await marketplaceManager .removeInstalledMarketplaceItem(message.mpItem, message.mpInstallOptions) - .then(async (r) => r === "$COMMIT" && (await provider.postStateToWebview())) + .then(async (r) => r === "$COMMIT" && (await _onCommit())) } catch (error) { vscode.window.showErrorMessage( `Failed to remove item "${message.mpItem.name}":\n${error instanceof Error ? error.message : String(error)}`, @@ -302,4 +302,12 @@ export async function handleMarketplaceMessages( default: return false } + + async function _onCommit() { + await Promise.all([ + provider.getMcpHub()?.reloadMcpServers?.(), + provider.customModesManager?.refreshMergedState?.(), + provider.postStateToWebview(), + ]) + } } diff --git a/src/services/mcp/McpHub.ts b/src/services/mcp/McpHub.ts index e83f7afb9e..64b2991dca 100644 --- a/src/services/mcp/McpHub.ts +++ b/src/services/mcp/McpHub.ts @@ -353,6 +353,11 @@ export class McpHub { ) } + public async reloadMcpServers() { + await this.initializeProjectMcpServers() + await this.initializeGlobalMcpServers() + } + private async initializeMcpServers(source: "global" | "project"): Promise { try { const configPath =