@@ -23,6 +23,7 @@ import {
2323 type TerminalActionPromptType ,
2424 type HistoryItem ,
2525 type CloudUserInfo ,
26+ type MarketplaceItem ,
2627 requestyDefaultModelId ,
2728 openRouterDefaultModelId ,
2829 glamaDefaultModelId ,
@@ -37,7 +38,7 @@ import { Package } from "../../shared/package"
3738import { findLast } from "../../shared/array"
3839import { supportPrompt } from "../../shared/support-prompt"
3940import { GlobalFileNames } from "../../shared/globalFileNames"
40- import { ExtensionMessage } from "../../shared/ExtensionMessage"
41+ import { ExtensionMessage , MarketplaceInstalledMetadata } from "../../shared/ExtensionMessage"
4142import { Mode , defaultModeSlug } from "../../shared/modes"
4243import { experimentDefault , experiments , EXPERIMENT_IDS } from "../../shared/experiments"
4344import { formatLanguage } from "../../shared/language"
@@ -1254,6 +1255,46 @@ export class ClineProvider
12541255 }
12551256 }
12561257
1258+ /**
1259+ * Fetches marketplace data on demand to avoid blocking main state updates
1260+ */
1261+ async fetchMarketplaceData ( ) {
1262+ try {
1263+ const [ marketplaceItems , marketplaceInstalledMetadata ] = await Promise . all ( [
1264+ this . marketplaceManager . getCurrentItems ( ) . catch ( ( error ) => {
1265+ console . error ( "Failed to fetch marketplace items:" , error )
1266+ return [ ] as MarketplaceItem [ ]
1267+ } ) ,
1268+ this . marketplaceManager . getInstallationMetadata ( ) . catch ( ( error ) => {
1269+ console . error ( "Failed to fetch installation metadata:" , error )
1270+ return { project : { } , global : { } } as MarketplaceInstalledMetadata
1271+ } ) ,
1272+ ] )
1273+
1274+ // Send marketplace data separately
1275+ this . postMessageToWebview ( {
1276+ type : "marketplaceData" ,
1277+ marketplaceItems : marketplaceItems || [ ] ,
1278+ marketplaceInstalledMetadata : marketplaceInstalledMetadata || { project : { } , global : { } } ,
1279+ } )
1280+ } catch ( error ) {
1281+ console . error ( "Failed to fetch marketplace data:" , error )
1282+ // Send empty data on error to prevent UI from hanging
1283+ this . postMessageToWebview ( {
1284+ type : "marketplaceData" ,
1285+ marketplaceItems : [ ] ,
1286+ marketplaceInstalledMetadata : { project : { } , global : { } } ,
1287+ } )
1288+
1289+ // Show user-friendly error notification for network issues
1290+ if ( error instanceof Error && error . message . includes ( "timeout" ) ) {
1291+ vscode . window . showWarningMessage (
1292+ "Marketplace data could not be loaded due to network restrictions. Core functionality remains available." ,
1293+ )
1294+ }
1295+ }
1296+ }
1297+
12571298 /**
12581299 * Checks if there is a file-based system prompt override for the given mode
12591300 */
@@ -1342,21 +1383,12 @@ export class ClineProvider
13421383 const allowedCommands = vscode . workspace . getConfiguration ( Package . name ) . get < string [ ] > ( "allowedCommands" ) || [ ]
13431384 const cwd = this . cwd
13441385
1345- // Fetch marketplace data
1346- let marketplaceItems : any [ ] = [ ]
1347- let marketplaceInstalledMetadata : any = { project : { } , global : { } }
1348-
1349- marketplaceItems = ( await this . marketplaceManager . getCurrentItems ( ) ) || [ ]
1350- marketplaceInstalledMetadata = await this . marketplaceManager . getInstallationMetadata ( )
1351-
13521386 // Check if there's a system prompt override for the current mode
13531387 const currentMode = mode ?? defaultModeSlug
13541388 const hasSystemPromptOverride = await this . hasFileBasedSystemPromptOverride ( currentMode )
13551389
13561390 return {
13571391 version : this . context . extension ?. packageJSON ?. version ?? "" ,
1358- marketplaceItems,
1359- marketplaceInstalledMetadata,
13601392 apiConfiguration,
13611393 customInstructions,
13621394 alwaysAllowReadOnly : alwaysAllowReadOnly ?? false ,
0 commit comments