Skip to content

Commit e3147f8

Browse files
refactor: remove stale organizationMcps from MarketplaceManager and related components
- Remove organizationMcps field from MarketplaceManager class and all CRUD methods (add, get, remove, clear) - Remove organizationMcps from MarketplaceView interface and MarketplaceViewStateManager - Remove organizationMcps from vscode-extension-host ConfigurationRequest interface - Remove organization Mcps tab rendering from MarketplaceListView - Remove organizationMcps from useStateManager hook - Remove organization Mcps lifecycle from ClineProvider (onNewPrompt) - Clean up test files: remove obsolete organization Mcps tests Closes #62
1 parent ae27eea commit e3147f8

8 files changed

Lines changed: 22 additions & 119 deletions

File tree

packages/types/src/vscode-extension-host.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ export interface ExtensionMessage {
164164
organizationAllowList?: OrganizationAllowList
165165
tab?: string
166166
marketplaceItems?: MarketplaceItem[]
167-
organizationMcps?: MarketplaceItem[]
168167
marketplaceInstalledMetadata?: MarketplaceInstalledMetadata
169168
errors?: string[]
170169
visibility?: ShareVisibility

src/core/webview/ClineProvider.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,7 +1958,7 @@ export class ClineProvider
19581958
const [marketplaceResult, marketplaceInstalledMetadata] = await Promise.all([
19591959
this.marketplaceManager.getMarketplaceItems().catch((error) => {
19601960
console.error("Failed to fetch marketplace items:", error)
1961-
return { organizationMcps: [], marketplaceItems: [], errors: [error.message] }
1961+
return { marketplaceItems: [], errors: [error.message] }
19621962
}),
19631963
this.marketplaceManager.getInstallationMetadata().catch((error) => {
19641964
console.error("Failed to fetch installation metadata:", error)
@@ -1969,7 +1969,6 @@ export class ClineProvider
19691969
// Send marketplace data separately
19701970
this.postMessageToWebview({
19711971
type: "marketplaceData",
1972-
organizationMcps: marketplaceResult.organizationMcps || [],
19731972
marketplaceItems: marketplaceResult.marketplaceItems || [],
19741973
marketplaceInstalledMetadata: marketplaceInstalledMetadata || { project: {}, global: {} },
19751974
errors: marketplaceResult.errors,
@@ -1980,7 +1979,6 @@ export class ClineProvider
19801979
// Send empty data on error to prevent UI from hanging
19811980
this.postMessageToWebview({
19821981
type: "marketplaceData",
1983-
organizationMcps: [],
19841982
marketplaceItems: [],
19851983
marketplaceInstalledMetadata: { project: {}, global: {} },
19861984
errors: [error instanceof Error ? error.message : String(error)],

src/services/marketplace/MarketplaceManager.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import { ConfigLoader } from "./ConfigLoader"
1616
import { SimpleInstaller } from "./SimpleInstaller"
1717

1818
export interface MarketplaceItemsResponse {
19-
organizationMcps: MarketplaceItem[]
2019
marketplaceItems: MarketplaceItem[]
2120
errors?: string[]
2221
}
@@ -38,15 +37,13 @@ export class MarketplaceManager {
3837
const marketplaceItems = await this.configLoader.loadAllItems()
3938

4039
return {
41-
organizationMcps: [],
4240
marketplaceItems,
4341
}
4442
} catch (error) {
4543
const errorMessage = error instanceof Error ? error.message : String(error)
4644
console.error("Failed to load marketplace items:", error)
4745

4846
return {
49-
organizationMcps: [],
5047
marketplaceItems: [],
5148
errors: [errorMessage],
5249
}
@@ -55,7 +52,7 @@ export class MarketplaceManager {
5552

5653
async getCurrentItems(): Promise<MarketplaceItem[]> {
5754
const result = await this.getMarketplaceItems()
58-
return [...result.organizationMcps, ...result.marketplaceItems]
55+
return [...result.marketplaceItems]
5956
}
6057

6158
filterItems(

src/services/marketplace/__tests__/MarketplaceManager.spec.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ describe("MarketplaceManager", () => {
159159

160160
expect(result.marketplaceItems).toHaveLength(1)
161161
expect(result.marketplaceItems[0].name).toBe("Test Mode")
162-
expect(result.organizationMcps).toHaveLength(0)
163162
})
164163

165164
it("should handle bundled marketplace loading errors gracefully", async () => {
@@ -171,7 +170,6 @@ describe("MarketplaceManager", () => {
171170
const result = await manager.getMarketplaceItems()
172171

173172
expect(result.marketplaceItems).toHaveLength(0)
174-
expect(result.organizationMcps).toHaveLength(0)
175173
expect(result.errors).toEqual(["Marketplace asset load failed"])
176174
})
177175

@@ -191,7 +189,6 @@ describe("MarketplaceManager", () => {
191189

192190
const result = await manager.getMarketplaceItems()
193191

194-
expect(result.organizationMcps).toEqual([])
195192
expect(result.marketplaceItems).toHaveLength(1)
196193
expect(result.marketplaceItems[0].name).toBe("Test MCP")
197194
})
@@ -222,7 +219,6 @@ describe("MarketplaceManager", () => {
222219

223220
expect(result.marketplaceItems).toHaveLength(2)
224221
expect(result.marketplaceItems.map((item) => item.name)).toEqual(["Visible MCP", "Second MCP"])
225-
expect(result.organizationMcps).toHaveLength(0)
226222
})
227223
})
228224

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

Lines changed: 19 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@ export function MarketplaceListView({ stateManager, allTags, filteredTags, filte
2626
const [isTagPopoverOpen, setIsTagPopoverOpen] = React.useState(false)
2727
const [tagSearch, setTagSearch] = React.useState("")
2828
const allItems = state.displayItems || []
29-
const organizationMcps = state.displayOrganizationMcps || []
3029

3130
// NOTE: installed metadata is already synchronized into the state manager via handleMessage("state"/"marketplaceData")
3231
// in MarketplaceViewStateManager; avoid dispatching UPDATE_FILTERS here to prevent render loops.
3332

3433
// Filter items by type if specified
3534
const items = filterByType ? allItems.filter((item) => item.type === filterByType) : allItems
36-
const orgMcps = filterByType === "mcp" ? organizationMcps : []
3735

38-
const isEmpty = items.length === 0 && orgMcps.length === 0
36+
const isEmpty = items.length === 0
3937

4038
return (
4139
<>
@@ -220,69 +218,25 @@ export function MarketplaceListView({ stateManager, allTags, filteredTags, filte
220218

221219
{!state.isFetching && !isEmpty && (
222220
<div className="pb-3">
223-
{orgMcps.length > 0 && (
224-
<div className="mb-6">
225-
<div className="flex items-center gap-2 mb-3 px-1">
226-
<span className="codicon codicon-organization text-lg"></span>
227-
<h3 className="text-sm font-semibold text-vscode-foreground">
228-
{t("marketplace:sections.organizationMcps", {
229-
organization: cloudUserInfo?.organizationName,
230-
})}
231-
</h3>
232-
<div className="flex-1 h-px bg-vscode-input-border"></div>
233-
</div>
234-
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2 gap-3">
235-
{orgMcps.map((item) => (
236-
<MarketplaceItemCard
237-
key={`org-${item.id}`}
238-
item={item}
239-
filters={state.filters}
240-
setFilters={(filters) =>
241-
manager.transition({
242-
type: "UPDATE_FILTERS",
243-
payload: { filters },
244-
})
245-
}
246-
installed={{
247-
project: marketplaceInstalledMetadata?.project?.[item.id],
248-
global: marketplaceInstalledMetadata?.global?.[item.id],
249-
}}
250-
/>
251-
))}
252-
</div>
253-
</div>
254-
)}
255-
256221
{items.length > 0 && (
257-
<div>
258-
{orgMcps.length > 0 && (
259-
<div className="flex items-center gap-2 mb-3 px-1">
260-
<span className="codicon codicon-globe text-lg"></span>
261-
<h3 className="text-sm font-semibold text-vscode-foreground">
262-
{t("marketplace:sections.marketplace")}
263-
</h3>
264-
<div className="flex-1 h-px bg-vscode-input-border"></div>
265-
</div>
266-
)}
267-
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2 gap-3">
268-
{items.map((item) => (
269-
<MarketplaceItemCard
270-
key={item.id}
271-
item={item}
272-
filters={state.filters}
273-
setFilters={(filters) =>
274-
manager.transition({
275-
type: "UPDATE_FILTERS",
276-
payload: { filters },
277-
})
278-
}
279-
installed={{
280-
project: marketplaceInstalledMetadata?.project?.[item.id],
281-
global: marketplaceInstalledMetadata?.global?.[item.id],
282-
}}
283-
/>
284-
))}
285-
</div>
222+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2 gap-3">
223+
{items.map((item) => (
224+
<MarketplaceItemCard
225+
key={item.id}
226+
item={item}
227+
filters={state.filters}
228+
setFilters={(filters) =>
229+
manager.transition({
230+
type: "UPDATE_FILTERS",
231+
payload: { filters },
232+
})
233+
}
234+
installed={{
235+
project: marketplaceInstalledMetadata?.project?.[item.id],
236+
global: marketplaceInstalledMetadata?.global?.[item.id],
237+
}}
238+
/>
239+
))}
286240
</div>
287241
)}
288242
</div>

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

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import { WebviewMessage } from "../../../../src/shared/WebviewMessage"
1818

1919
export interface ViewState {
2020
allItems: MarketplaceItem[]
21-
organizationMcps: MarketplaceItem[]
2221
displayItems?: MarketplaceItem[] // Items currently being displayed (filtered or all)
23-
displayOrganizationMcps?: MarketplaceItem[] // Organization MCPs currently being displayed (filtered or all)
2422
isFetching: boolean
2523
activeTab: "mcp" | "mode"
2624
filters: {
@@ -59,9 +57,7 @@ export class MarketplaceViewStateManager {
5957
private getDefaultState(): ViewState {
6058
return {
6159
allItems: [],
62-
organizationMcps: [],
6360
displayItems: [], // Always initialize as empty array, not undefined
64-
displayOrganizationMcps: [], // Always initialize as empty array, not undefined
6561
isFetching: true, // Start with loading state for initial load
6662
activeTab: "mcp",
6763
filters: {
@@ -104,22 +100,16 @@ export class MarketplaceViewStateManager {
104100
public getState(): ViewState {
105101
// Only create new arrays if they exist and have items
106102
const allItems = this.state.allItems.length ? [...this.state.allItems] : []
107-
const organizationMcps = this.state.organizationMcps.length ? [...this.state.organizationMcps] : []
108103
// Ensure displayItems is always an array, never undefined
109104
// If displayItems is undefined or null, fall back to allItems
110105
const displayItems = this.state.displayItems ? [...this.state.displayItems] : [...allItems]
111-
const displayOrganizationMcps = this.state.displayOrganizationMcps
112-
? [...this.state.displayOrganizationMcps]
113-
: [...organizationMcps]
114106
const tags = this.state.filters.tags.length ? [...this.state.filters.tags] : []
115107

116108
// Create minimal new state object
117109
return {
118110
...this.state,
119111
allItems,
120-
organizationMcps,
121112
displayItems,
122-
displayOrganizationMcps,
123113
filters: {
124114
...this.state.filters,
125115
tags,
@@ -191,25 +181,18 @@ export class MarketplaceViewStateManager {
191181

192182
// Calculate display items based on current filters
193183
let newDisplayItems: MarketplaceItem[]
194-
let newDisplayOrganizationMcps: MarketplaceItem[]
195184
if (this.isFilterActive()) {
196185
newDisplayItems = this.filterItems([...items], this.state.installedMetadata)
197-
newDisplayOrganizationMcps = this.filterItems(
198-
[...this.state.organizationMcps],
199-
this.state.installedMetadata,
200-
)
201186
} else {
202187
// No filters active - show all items
203188
newDisplayItems = [...items]
204-
newDisplayOrganizationMcps = [...this.state.organizationMcps]
205189
}
206190

207191
// Update allItems as source of truth
208192
this.state = {
209193
...this.state,
210194
allItems: [...items],
211195
displayItems: newDisplayItems,
212-
displayOrganizationMcps: newDisplayOrganizationMcps,
213196
isFetching: false,
214197
}
215198

@@ -267,18 +250,13 @@ export class MarketplaceViewStateManager {
267250
filters: updatedFilters,
268251
}
269252

270-
// Apply filters to displayItems and displayOrganizationMcps with the updated filters
253+
// Apply filters to displayItems with the updated filters
271254
const newDisplayItems = this.filterItems(this.state.allItems, this.state.installedMetadata)
272-
const newDisplayOrganizationMcps = this.filterItems(
273-
this.state.organizationMcps,
274-
this.state.installedMetadata,
275-
)
276255

277256
// Update state with filtered items
278257
this.state = {
279258
...this.state,
280259
displayItems: newDisplayItems,
281-
displayOrganizationMcps: newDisplayOrganizationMcps,
282260
}
283261

284262
// Send filter message
@@ -385,17 +363,11 @@ export class MarketplaceViewStateManager {
385363
// If no filters are active, show all items
386364
// If filters are active, apply filtering
387365
let newDisplayItems: MarketplaceItem[]
388-
let newDisplayOrganizationMcps: MarketplaceItem[]
389366
if (this.isFilterActive()) {
390367
newDisplayItems = this.filterItems(items, this.state.installedMetadata)
391-
newDisplayOrganizationMcps = this.filterItems(
392-
this.state.organizationMcps,
393-
this.state.installedMetadata,
394-
)
395368
} else {
396369
// No filters active - show all items
397370
newDisplayItems = items
398-
newDisplayOrganizationMcps = this.state.organizationMcps
399371
}
400372

401373
// Update state in a single operation
@@ -404,7 +376,6 @@ export class MarketplaceViewStateManager {
404376
isFetching: false,
405377
allItems: items,
406378
displayItems: newDisplayItems,
407-
displayOrganizationMcps: newDisplayOrganizationMcps,
408379
installedMetadata: marketplaceInstalledMetadata || this.state.installedMetadata,
409380
}
410381
// Notification is handled below after all state parts are processed
@@ -446,14 +417,12 @@ export class MarketplaceViewStateManager {
446417
// Handle marketplace data updates (fetched on demand)
447418
if (message.type === "marketplaceData") {
448419
const marketplaceItems = message.marketplaceItems
449-
const organizationMcps = message.organizationMcps || []
450420
const marketplaceInstalledMetadata = message.marketplaceInstalledMetadata
451421

452422
if (marketplaceItems !== undefined) {
453423
// Always use the marketplace items from the extension when they're provided
454424
// This ensures fresh data is always displayed
455425
const items = [...marketplaceItems]
456-
const orgMcps = [...organizationMcps]
457426

458427
// Update installed metadata if provided
459428
if (marketplaceInstalledMetadata !== undefined) {
@@ -463,18 +432,13 @@ export class MarketplaceViewStateManager {
463432
const newDisplayItems = this.isFilterActive()
464433
? this.filterItems(items, this.state.installedMetadata)
465434
: items
466-
const newDisplayOrganizationMcps = this.isFilterActive()
467-
? this.filterItems(orgMcps, this.state.installedMetadata)
468-
: orgMcps
469435

470436
// Update state in a single operation
471437
this.state = {
472438
...this.state,
473439
isFetching: false,
474440
allItems: items,
475-
organizationMcps: orgMcps,
476441
displayItems: newDisplayItems,
477-
displayOrganizationMcps: newDisplayOrganizationMcps,
478442
installedMetadata: marketplaceInstalledMetadata || this.state.installedMetadata,
479443
}
480444
}

webview-ui/src/components/marketplace/__tests__/MarketplaceListView.spec.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ vi.mock("@/i18n/TranslationContext", () => ({
1818
const mockTransition = vi.fn()
1919
const mockState: ViewState = {
2020
allItems: [],
21-
organizationMcps: [],
2221
displayItems: [],
23-
displayOrganizationMcps: [],
2422
isFetching: false,
2523
activeTab: "mcp",
2624
filters: {

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ export function useStateManager(existingManager?: MarketplaceViewStateManager) {
1313
prevState.isFetching !== newState.isFetching ||
1414
prevState.activeTab !== newState.activeTab ||
1515
JSON.stringify(prevState.allItems) !== JSON.stringify(newState.allItems) ||
16-
JSON.stringify(prevState.organizationMcps) !== JSON.stringify(newState.organizationMcps) ||
1716
JSON.stringify(prevState.displayItems) !== JSON.stringify(newState.displayItems) ||
18-
JSON.stringify(prevState.displayOrganizationMcps) !==
19-
JSON.stringify(newState.displayOrganizationMcps) ||
2017
JSON.stringify(prevState.filters) !== JSON.stringify(newState.filters)
2118

2219
return hasChanged ? newState : prevState

0 commit comments

Comments
 (0)