Skip to content

Commit efb748a

Browse files
committed
Some roo-inspired feedback
1 parent c27b7ff commit efb748a

File tree

1 file changed

+20
-29
lines changed

1 file changed

+20
-29
lines changed

src/services/marketplace/MarketplaceManager.ts

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as path from "path"
44
import * as yaml from "yaml"
55
import { RemoteConfigLoader } from "./RemoteConfigLoader"
66
import { SimpleInstaller } from "./SimpleInstaller"
7-
import type { MarketplaceItem, MarketplaceItemType, McpMarketplaceItem } from "@roo-code/types"
7+
import type { MarketplaceItem, MarketplaceItemType, McpMarketplaceItem, OrganizationSettings } from "@roo-code/types"
88
import { GlobalFileNames } from "../../shared/globalFileNames"
99
import { ensureSettingsDirectoryExists } from "../../utils/globalContext"
1010
import { t } from "../../i18n"
@@ -32,48 +32,39 @@ export class MarketplaceManager {
3232

3333
async getMarketplaceItems(): Promise<MarketplaceItemsResponse> {
3434
try {
35-
let shouldHideMarketplaceMcps = false
36-
let orgSettings: ReturnType<typeof CloudService.instance.getOrganizationSettings> | null = null
35+
const errors: string[] = []
3736

38-
// Check organization settings first to determine if we should load MCPs
37+
let orgSettings: OrganizationSettings | undefined
3938
try {
4039
if (CloudService.hasInstance() && CloudService.instance.isAuthenticated()) {
4140
orgSettings = CloudService.instance.getOrganizationSettings()
42-
if (orgSettings?.hideMarketplaceMcps) {
43-
shouldHideMarketplaceMcps = true
44-
}
4541
}
4642
} catch (orgError) {
4743
console.warn("Failed to load organization settings:", orgError)
44+
const orgErrorMessage = orgError instanceof Error ? orgError.message : String(orgError)
45+
errors.push(`Organization settings: ${orgErrorMessage}`)
4846
}
4947

50-
const allMarketplaceItems = await this.configLoader.loadAllItems(shouldHideMarketplaceMcps)
48+
const allMarketplaceItems = await this.configLoader.loadAllItems(orgSettings?.hideMarketplaceMcps)
5149
let organizationMcps: MarketplaceItem[] = []
5250
let marketplaceItems = allMarketplaceItems
53-
const errors: string[] = []
5451

55-
try {
56-
if (orgSettings) {
57-
if (orgSettings.mcps && orgSettings.mcps.length > 0) {
58-
organizationMcps = orgSettings.mcps.map(
59-
(mcp: McpMarketplaceItem): MarketplaceItem => ({
60-
...mcp,
61-
type: "mcp" as const,
62-
}),
63-
)
64-
}
52+
if (orgSettings) {
53+
if (orgSettings.mcps && orgSettings.mcps.length > 0) {
54+
organizationMcps = orgSettings.mcps.map(
55+
(mcp: McpMarketplaceItem): MarketplaceItem => ({
56+
...mcp,
57+
type: "mcp" as const,
58+
}),
59+
)
60+
}
6561

66-
if (orgSettings.hiddenMcps && orgSettings.hiddenMcps.length > 0) {
67-
const hiddenMcpIds = new Set(orgSettings.hiddenMcps)
68-
marketplaceItems = allMarketplaceItems.filter(
69-
(item) => item.type !== "mcp" || !hiddenMcpIds.has(item.id),
70-
)
71-
}
62+
if (orgSettings.hiddenMcps && orgSettings.hiddenMcps.length > 0) {
63+
const hiddenMcpIds = new Set(orgSettings.hiddenMcps)
64+
marketplaceItems = allMarketplaceItems.filter(
65+
(item) => item.type !== "mcp" || !hiddenMcpIds.has(item.id),
66+
)
7267
}
73-
} catch (orgError) {
74-
console.warn("Failed to load organization settings:", orgError)
75-
const orgErrorMessage = orgError instanceof Error ? orgError.message : String(orgError)
76-
errors.push(`Organization settings: ${orgErrorMessage}`)
7768
}
7869

7970
return {

0 commit comments

Comments
 (0)