Skip to content

Commit 3e083fc

Browse files
committed
feat: enhance marketplace data handling with improved error logging and user notifications
1 parent 7de562e commit 3e083fc

File tree

5 files changed

+48
-20
lines changed

5 files changed

+48
-20
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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"
3738
import { findLast } from "../../shared/array"
3839
import { supportPrompt } from "../../shared/support-prompt"
3940
import { GlobalFileNames } from "../../shared/globalFileNames"
40-
import { ExtensionMessage } from "../../shared/ExtensionMessage"
41+
import { ExtensionMessage, MarketplaceInstalledMetadata } from "../../shared/ExtensionMessage"
4142
import { Mode, defaultModeSlug } from "../../shared/modes"
4243
import { experimentDefault, experiments, EXPERIMENT_IDS } from "../../shared/experiments"
4344
import { formatLanguage } from "../../shared/language"
@@ -1260,8 +1261,14 @@ export class ClineProvider
12601261
async fetchMarketplaceData() {
12611262
try {
12621263
const [marketplaceItems, marketplaceInstalledMetadata] = await Promise.all([
1263-
this.marketplaceManager.getCurrentItems().catch(() => []),
1264-
this.marketplaceManager.getInstallationMetadata().catch(() => ({ project: {}, global: {} })),
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+
}),
12651272
])
12661273

12671274
// Send marketplace data separately
@@ -1278,6 +1285,13 @@ export class ClineProvider
12781285
marketplaceItems: [],
12791286
marketplaceInstalledMetadata: { project: {}, global: {} },
12801287
})
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+
}
12811295
}
12821296
}
12831297

@@ -1369,18 +1383,12 @@ export class ClineProvider
13691383
const allowedCommands = vscode.workspace.getConfiguration(Package.name).get<string[]>("allowedCommands") || []
13701384
const cwd = this.cwd
13711385

1372-
// Initialize marketplace data as empty - will be fetched on demand
1373-
let marketplaceItems: any[] = []
1374-
let marketplaceInstalledMetadata: any = { project: {}, global: {} }
1375-
13761386
// Check if there's a system prompt override for the current mode
13771387
const currentMode = mode ?? defaultModeSlug
13781388
const hasSystemPromptOverride = await this.hasFileBasedSystemPromptOverride(currentMode)
13791389

13801390
return {
13811391
version: this.context.extension?.packageJSON?.version ?? "",
1382-
marketplaceItems,
1383-
marketplaceInstalledMetadata,
13841392
apiConfiguration,
13851393
customInstructions,
13861394
alwaysAllowReadOnly: alwaysAllowReadOnly ?? false,

src/shared/ExtensionMessage.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ import { Mode } from "./modes"
1818
import { RouterModels } from "./api"
1919
import type { MarketplaceItem } from "@roo-code/types"
2020

21+
// Type for marketplace installed metadata
22+
export interface MarketplaceInstalledMetadata {
23+
project: Record<string, { type: string }>
24+
global: Record<string, { type: string }>
25+
}
26+
2127
// Indexing status types
2228
export interface IndexingStatus {
2329
systemStatus: string
@@ -138,7 +144,7 @@ export interface ExtensionMessage {
138144
organizationAllowList?: OrganizationAllowList
139145
tab?: string
140146
marketplaceItems?: MarketplaceItem[]
141-
marketplaceInstalledMetadata?: { project: Record<string, any>; global: Record<string, any> }
147+
marketplaceInstalledMetadata?: MarketplaceInstalledMetadata
142148
}
143149

144150
export type ExtensionState = Pick<

webview-ui/src/components/marketplace/MarketplaceView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export function MarketplaceView({ stateManager, onDone }: MarketplaceViewProps)
3434
// send back the full state including all marketplace items.
3535
if (!hasReceivedInitialState && state.allItems.length === 0) {
3636
// Fetch marketplace data on demand
37+
// Note: isFetching is already true by default for initial load
3738
vscode.postMessage({
3839
type: "fetchMarketplaceData",
3940
})

webview-ui/src/components/marketplace/MarketplaceViewStateManager.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class MarketplaceViewStateManager {
5555
return {
5656
allItems: [],
5757
displayItems: [], // Always initialize as empty array, not undefined
58-
isFetching: false,
58+
isFetching: true, // Start with loading state for initial load
5959
activeTab: "mcp",
6060
filters: {
6161
type: "",
@@ -148,8 +148,12 @@ export class MarketplaceViewStateManager {
148148
public async transition(transition: ViewStateTransition): Promise<void> {
149149
switch (transition.type) {
150150
case "FETCH_ITEMS": {
151-
// Fetch functionality removed - data comes automatically from extension
152-
// No manual fetching needed since we removed caching
151+
// Set fetching state to show loading indicator
152+
this.state = {
153+
...this.state,
154+
isFetching: true,
155+
}
156+
this.notifyStateChange()
153157
break
154158
}
155159

@@ -225,12 +229,21 @@ export class MarketplaceViewStateManager {
225229
tags: filters.tags !== undefined ? filters.tags : this.state.filters.tags,
226230
}
227231

228-
// Update state
232+
// Update filters first
229233
this.state = {
230234
...this.state,
231235
filters: updatedFilters,
232236
}
233237

238+
// Apply filters to displayItems with the updated filters
239+
const newDisplayItems = this.filterItems(this.state.allItems)
240+
241+
// Update state with filtered items
242+
this.state = {
243+
...this.state,
244+
displayItems: newDisplayItems,
245+
}
246+
234247
// Send filter message
235248
vscode.postMessage({
236249
type: "filterMarketplaceItems",

webview-ui/src/context/ExtensionStateContext.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
ORGANIZATION_ALLOW_ALL,
1111
} from "@roo-code/types"
1212

13-
import { ExtensionMessage, ExtensionState } from "@roo/ExtensionMessage"
13+
import { ExtensionMessage, ExtensionState, MarketplaceInstalledMetadata } from "@roo/ExtensionMessage"
1414
import { findLastIndex } from "@roo/array"
1515
import { McpServer } from "@roo/mcp"
1616
import { checkExistKey } from "@roo/checkExistApiConfig"
@@ -43,7 +43,7 @@ export interface ExtensionStateContextType extends ExtensionState {
4343
customCondensingPrompt?: string
4444
setCustomCondensingPrompt: (value: string) => void
4545
marketplaceItems?: any[]
46-
marketplaceInstalledMetadata?: { project: Record<string, any>; global: Record<string, any> }
46+
marketplaceInstalledMetadata?: MarketplaceInstalledMetadata
4747
setApiConfiguration: (config: ProviderSettings) => void
4848
setCustomInstructions: (value?: string) => void
4949
setAlwaysAllowReadOnly: (value: boolean) => void
@@ -220,10 +220,10 @@ export const ExtensionStateContextProvider: React.FC<{ children: React.ReactNode
220220
const [currentCheckpoint, setCurrentCheckpoint] = useState<string>()
221221
const [extensionRouterModels, setExtensionRouterModels] = useState<RouterModels | undefined>(undefined)
222222
const [marketplaceItems, setMarketplaceItems] = useState<any[]>([])
223-
const [marketplaceInstalledMetadata, setMarketplaceInstalledMetadata] = useState<{
224-
project: Record<string, any>
225-
global: Record<string, any>
226-
}>({ project: {}, global: {} })
223+
const [marketplaceInstalledMetadata, setMarketplaceInstalledMetadata] = useState<MarketplaceInstalledMetadata>({
224+
project: {},
225+
global: {},
226+
})
227227

228228
const setListApiConfigMeta = useCallback(
229229
(value: ProviderSettingsEntry[]) => setState((prevState) => ({ ...prevState, listApiConfigMeta: value })),

0 commit comments

Comments
 (0)