* Fetches marketplace data on demand to avoid blocking main state updates
()
| 2114 | * Fetches marketplace data on demand to avoid blocking main state updates |
| 2115 | */ |
| 2116 | async fetchMarketplaceData() { |
| 2117 | try { |
| 2118 | const [marketplaceResult, marketplaceInstalledMetadata] = await Promise.all([ |
| 2119 | this.marketplaceManager.getMarketplaceItems().catch((error) => { |
| 2120 | console.error("Failed to fetch marketplace items:", error) |
| 2121 | return { organizationMcps: [], marketplaceItems: [], errors: [error.message] } |
| 2122 | }), |
| 2123 | this.marketplaceManager.getInstallationMetadata().catch((error) => { |
| 2124 | console.error("Failed to fetch installation metadata:", error) |
| 2125 | return { project: {}, global: {} } as MarketplaceInstalledMetadata |
| 2126 | }), |
| 2127 | ]) |
| 2128 | |
| 2129 | // Send marketplace data separately |
| 2130 | this.postMessageToWebview({ |
| 2131 | type: "marketplaceData", |
| 2132 | organizationMcps: marketplaceResult.organizationMcps || [], |
| 2133 | marketplaceItems: marketplaceResult.marketplaceItems || [], |
| 2134 | marketplaceInstalledMetadata: marketplaceInstalledMetadata || { project: {}, global: {} }, |
| 2135 | errors: marketplaceResult.errors, |
| 2136 | }) |
| 2137 | } catch (error) { |
| 2138 | console.error("Failed to fetch marketplace data:", error) |
| 2139 | |
| 2140 | // Send empty data on error to prevent UI from hanging |
| 2141 | this.postMessageToWebview({ |
| 2142 | type: "marketplaceData", |
| 2143 | organizationMcps: [], |
| 2144 | marketplaceItems: [], |
| 2145 | marketplaceInstalledMetadata: { project: {}, global: {} }, |
| 2146 | errors: [error instanceof Error ? error.message : String(error)], |
| 2147 | }) |
| 2148 | |
| 2149 | // Show user-friendly error notification for network issues |
| 2150 | if (error instanceof Error && error.message.includes("timeout")) { |
| 2151 | vscode.window.showWarningMessage( |
| 2152 | "Marketplace data could not be loaded due to network restrictions. Core functionality remains available.", |
| 2153 | ) |
| 2154 | } |
| 2155 | } |
| 2156 | } |
| 2157 | |
| 2158 | /** |
| 2159 | * Merges allowed commands from global state and workspace configuration |
no test coverage detected