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