From dde5c6de5c3ccaf0d241f3bbb10fbd16f3e8c36a Mon Sep 17 00:00:00 2001 From: haikdc Date: Sat, 18 Apr 2026 08:14:57 -0700 Subject: [PATCH] [Haik]: uncommented the mcpRegistrySlice to prevent crashes on actions page - still isnt implemented in backend tho --- frontend/src/shared/state/mcpRegistrySlice.ts | 142 +++++++++--------- frontend/src/shared/state/store.ts | 4 +- 2 files changed, 73 insertions(+), 73 deletions(-) diff --git a/frontend/src/shared/state/mcpRegistrySlice.ts b/frontend/src/shared/state/mcpRegistrySlice.ts index e06fbbeb..cbd8b6d6 100644 --- a/frontend/src/shared/state/mcpRegistrySlice.ts +++ b/frontend/src/shared/state/mcpRegistrySlice.ts @@ -4,8 +4,8 @@ // TODO: Re-implement the mcp registry (needs to also be implemented in the backend) -// import { createSlice, createAsyncThunk } from '@reduxjs/toolkit'; -import { createAsyncThunk } from '@reduxjs/toolkit'; +import { createSlice, createAsyncThunk } from '@reduxjs/toolkit'; +// import { createAsyncThunk } from '@reduxjs/toolkit'; // import { API_BASE } from '@/shared/config'; // const MCP_REGISTRY_API = `${API_BASE}/mcp-registry`; @@ -24,33 +24,33 @@ export interface McpServer { source: string; } -// interface McpServerDetail extends McpServer { -// environmentVariables: { name: string; description: string; default?: string; format?: string }[]; -// keywords: string[]; -// license: string; -// } +interface McpServerDetail extends McpServer { + environmentVariables: { name: string; description: string; default?: string; format?: string }[]; + keywords: string[]; + license: string; +} -// interface McpRegistryState { -// servers: McpServer[]; -// total: number; -// loading: boolean; -// query: string; -// offset: number; -// stats: { total: number; google: number; community: number; lastUpdated: number } | null; -// detail: McpServerDetail | null; -// detailLoading: boolean; -// } +interface McpRegistryState { + servers: McpServer[]; + total: number; + loading: boolean; + query: string; + offset: number; + stats: { total: number; google: number; community: number; lastUpdated: number } | null; + detail: McpServerDetail | null; + detailLoading: boolean; +} -// const initialState: McpRegistryState = { -// servers: [], -// total: 0, -// loading: false, -// query: '', -// offset: 0, -// stats: null, -// detail: null, -// detailLoading: false, -// }; +const initialState: McpRegistryState = { + servers: [], + total: 0, + loading: false, + query: '', + offset: 0, + stats: null, + detail: null, + detailLoading: false, +}; export const searchRegistry = createAsyncThunk( 'mcpRegistry/search', @@ -90,48 +90,48 @@ export const fetchServerDetail = createAsyncThunk( } ); -// const mcpRegistrySlice = createSlice({ -// name: 'mcpRegistry', -// initialState, -// reducers: { -// clearDetail(state) { -// state.detail = null; -// }, -// }, -// extraReducers: (builder) => { -// builder -// .addCase(searchRegistry.pending, (state, action) => { -// state.loading = true; -// state.query = action.meta.arg.q; -// state.offset = action.meta.arg.offset ?? 0; -// }) -// .addCase(searchRegistry.fulfilled, (state, action) => { -// state.loading = false; -// if (action.meta.arg.offset && action.meta.arg.offset > 0) { -// state.servers = [...state.servers, ...action.payload.servers]; -// } else { -// state.servers = action.payload.servers; -// } -// state.total = action.payload.total; -// }) -// .addCase(searchRegistry.rejected, (state) => { -// state.loading = false; -// }) -// .addCase(fetchRegistryStats.fulfilled, (state, action) => { -// state.stats = action.payload; -// }) -// .addCase(fetchServerDetail.pending, (state) => { -// state.detailLoading = true; -// }) -// .addCase(fetchServerDetail.fulfilled, (state, action) => { -// state.detailLoading = false; -// state.detail = action.payload; -// }) -// .addCase(fetchServerDetail.rejected, (state) => { -// state.detailLoading = false; -// }); -// }, -// }); +const mcpRegistrySlice = createSlice({ + name: 'mcpRegistry', + initialState, + reducers: { + clearDetail(state) { + state.detail = null; + }, + }, + extraReducers: (builder) => { + builder + .addCase(searchRegistry.pending, (state, action) => { + state.loading = true; + state.query = action.meta.arg.q; + state.offset = action.meta.arg.offset ?? 0; + }) + .addCase(searchRegistry.fulfilled, (state, action) => { + state.loading = false; + if (action.meta.arg.offset && action.meta.arg.offset > 0) { + state.servers = [...state.servers, ...action.payload.servers]; + } else { + state.servers = action.payload.servers; + } + state.total = action.payload.total; + }) + .addCase(searchRegistry.rejected, (state) => { + state.loading = false; + }) + .addCase(fetchRegistryStats.fulfilled, (state, action) => { + state.stats = action.payload; + }) + .addCase(fetchServerDetail.pending, (state) => { + state.detailLoading = true; + }) + .addCase(fetchServerDetail.fulfilled, (state, action) => { + state.detailLoading = false; + state.detail = action.payload; + }) + .addCase(fetchServerDetail.rejected, (state) => { + state.detailLoading = false; + }); + }, +}); -// export const { clearDetail } = mcpRegistrySlice.actions; -// export default mcpRegistrySlice.reducer; +export const { clearDetail } = mcpRegistrySlice.actions; +export default mcpRegistrySlice.reducer; diff --git a/frontend/src/shared/state/store.ts b/frontend/src/shared/state/store.ts index a31e07d1..0386e7ae 100644 --- a/frontend/src/shared/state/store.ts +++ b/frontend/src/shared/state/store.ts @@ -5,7 +5,7 @@ import skillsReducer from './skillsSlice'; import toolsReducer from './toolsSlice'; import modesReducer from './modesSlice'; import settingsReducer from './settingsSlice'; -// import mcpRegistryReducer from './mcpRegistrySlice'; +import mcpRegistryReducer from './mcpRegistrySlice'; import skillRegistryReducer from './skillRegistrySlice'; import dashboardLayoutReducer from './dashboardLayoutSlice'; import dashboardsReducer from './dashboardsSlice'; @@ -21,7 +21,7 @@ export const store = configureStore({ tools: toolsReducer, modes: modesReducer, settings: settingsReducer, - // mcpRegistry: mcpRegistryReducer, + mcpRegistry: mcpRegistryReducer, skillRegistry: skillRegistryReducer, dashboardLayout: dashboardLayoutReducer, dashboards: dashboardsReducer,