@@ -18,9 +18,7 @@ import { WebviewMessage } from "../../../../src/shared/WebviewMessage"
1818
1919export 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 }
0 commit comments