From effcaeaefeef2633bebef8dce101cf5ee6bac836 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 24 Apr 2025 16:21:44 -0700 Subject: [PATCH] rearrange/cleanup --- .../mainInput/Lump/sections/RulesSection.tsx | 4 - .../Lump/sections/SelectedSection.tsx | 2 +- .../Lump/sections/mcp/MCPSection.tsx | 190 +++++++++++++++++- gui/src/pages/config/MCPServersPreview.tsx | 189 ----------------- 4 files changed, 188 insertions(+), 197 deletions(-) delete mode 100644 gui/src/pages/config/MCPServersPreview.tsx diff --git a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx index d6129eef8..0fae7611e 100644 --- a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx @@ -209,7 +209,3 @@ export function RulesSection() { ); } - -export function RulesSectionToolTip() { - return "rules"; -} diff --git a/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx b/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx index f7fca7a35..ad07a86d6 100644 --- a/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx @@ -2,7 +2,7 @@ import { useLump } from "../LumpContext"; import { ContextSection } from "./ContextSection"; import DocsSection from "./docs/DocsSection"; import { ErrorSection } from "./errors/ErrorSection"; -import { MCPSection } from "./mcp/MCPSection"; +import MCPSection from "./mcp/MCPSection"; import { ModelsSection } from "./ModelsSection"; import { PromptsSection } from "./PromptsSection"; import { RulesSection } from "./RulesSection"; diff --git a/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx b/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx index 9c2f888eb..07ec23c56 100644 --- a/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx @@ -1,5 +1,189 @@ -import MCPServersPreview from "../../../../../pages/config/MCPServersPreview"; +import { ConfigYaml, parseConfigYaml } from "@continuedev/config-yaml"; +import { + ArrowPathIcon, + CircleStackIcon, + CommandLineIcon, + InformationCircleIcon, + WrenchScrewdriverIcon, +} from "@heroicons/react/24/outline"; +import { MCPServerStatus } from "core"; +import { useContext, useMemo } from "react"; +import { useAuth } from "../../../../../context/Auth"; +import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; +import { useAppDispatch, useAppSelector } from "../../../../../redux/hooks"; +import { updateConfig } from "../../../../../redux/slices/configSlice"; +import { fontSize } from "../../../../../util"; +import { ToolTip } from "../../../../gui/Tooltip"; +import EditBlockButton from "../../EditBlockButton"; +import { ExploreBlocksButton } from "../ExploreBlocksButton"; -export function MCPSection() { - return ; +interface MCPServerStatusProps { + server: MCPServerStatus; + serverFromYaml?: NonNullable[number]; } +function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) { + const ideMessenger = useContext(IdeMessengerContext); + const config = useAppSelector((store) => store.config.config); + const dispatch = useAppDispatch(); + const toolsTooltipId = `${server.id}-tools`; + const promptsTooltipId = `${server.id}-prompts`; + const resourcesTooltipId = `${server.id}-resources`; + const errorsTooltipId = `${server.id}-errors`; + + async function onRefresh() { + // optimistic config update + dispatch( + updateConfig({ + ...config, + mcpServerStatuses: config.mcpServerStatuses.map((s) => + s.id === server.id + ? { + ...s, + status: "connecting", + } + : s, + ), + }), + ); + ideMessenger.post("mcp/reloadServer", { + id: server.id, + }); + } + + return ( +
+
+ {/* Name and Status */} + {server.name} + + {/* Error indicator if any */} + {server.errors.length ? ( + <> + + + {server.errors.map((error, idx) => ( + {error} + ))} + + + ) : null} + + {/* Tools, Prompts, Resources with counts */} +
+
+ + {server.tools.length} + + {server.tools.map((tool, idx) => ( + {tool.name} + ))} + {server.tools.length === 0 && ( + No tools + )} + +
+
+ + {server.prompts.length} + + {server.prompts.map((prompt, idx) => ( + {prompt.name} + ))} + {server.prompts.length === 0 && ( + No prompts + )} + +
+
+ + {server.resources.length} + + {server.resources.map((resource, idx) => ( + {resource.name} + ))} + {server.resources.length === 0 && ( + No resources + )} + +
+
+
+ + {/* Refresh button */} +
+ +
+ +
+ +
+
+
+ ); +} + +function MCPSection() { + const servers = useAppSelector( + (store) => store.config.config.mcpServerStatuses, + ); + const { selectedProfile } = useAuth(); + + const mergedBlocks = useMemo(() => { + const parsed = selectedProfile?.rawYaml + ? parseConfigYaml(selectedProfile?.rawYaml ?? "") + : undefined; + return (servers ?? []).map((doc, index) => ({ + block: doc, + blockFromYaml: parsed?.mcpServers?.[index], + })); + }, [servers, selectedProfile]); + + return ( +
+
+ {mergedBlocks.map(({ block, blockFromYaml }, idx) => ( + + ))} +
+ +
+ ); +} + +export default MCPSection; diff --git a/gui/src/pages/config/MCPServersPreview.tsx b/gui/src/pages/config/MCPServersPreview.tsx deleted file mode 100644 index f1ca7b5af..000000000 --- a/gui/src/pages/config/MCPServersPreview.tsx +++ /dev/null @@ -1,189 +0,0 @@ -import { ConfigYaml, parseConfigYaml } from "@continuedev/config-yaml"; -import { - ArrowPathIcon, - CircleStackIcon, - CommandLineIcon, - InformationCircleIcon, - WrenchScrewdriverIcon, -} from "@heroicons/react/24/outline"; -import { MCPServerStatus } from "core"; -import { useContext, useMemo } from "react"; -import { ToolTip } from "../../components/gui/Tooltip"; -import EditBlockButton from "../../components/mainInput/Lump/EditBlockButton"; -import { ExploreBlocksButton } from "../../components/mainInput/Lump/sections/ExploreBlocksButton"; -import { useAuth } from "../../context/Auth"; -import { IdeMessengerContext } from "../../context/IdeMessenger"; -import { useAppDispatch, useAppSelector } from "../../redux/hooks"; -import { updateConfig } from "../../redux/slices/configSlice"; -import { fontSize } from "../../util"; - -interface MCPServerStatusProps { - server: MCPServerStatus; - serverFromYaml?: NonNullable[number]; -} -function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) { - const ideMessenger = useContext(IdeMessengerContext); - const config = useAppSelector((store) => store.config.config); - const dispatch = useAppDispatch(); - const toolsTooltipId = `${server.id}-tools`; - const promptsTooltipId = `${server.id}-prompts`; - const resourcesTooltipId = `${server.id}-resources`; - const errorsTooltipId = `${server.id}-errors`; - - async function onRefresh() { - // optimistic config update - dispatch( - updateConfig({ - ...config, - mcpServerStatuses: config.mcpServerStatuses.map((s) => - s.id === server.id - ? { - ...s, - status: "connecting", - } - : s, - ), - }), - ); - ideMessenger.post("mcp/reloadServer", { - id: server.id, - }); - } - - return ( -
-
- {/* Name and Status */} - {server.name} - - {/* Error indicator if any */} - {server.errors.length ? ( - <> - - - {server.errors.map((error, idx) => ( - {error} - ))} - - - ) : null} - - {/* Tools, Prompts, Resources with counts */} -
-
- - {server.tools.length} - - {server.tools.map((tool, idx) => ( - {tool.name} - ))} - {server.tools.length === 0 && ( - No tools - )} - -
-
- - {server.prompts.length} - - {server.prompts.map((prompt, idx) => ( - {prompt.name} - ))} - {server.prompts.length === 0 && ( - No prompts - )} - -
-
- - {server.resources.length} - - {server.resources.map((resource, idx) => ( - {resource.name} - ))} - {server.resources.length === 0 && ( - No resources - )} - -
-
-
- - {/* Refresh button */} -
- -
- -
- -
-
-
- ); -} - -function MCPServersPreview() { - const servers = useAppSelector( - (store) => store.config.config.mcpServerStatuses, - ); - const { selectedProfile } = useAuth(); - - const mergedBlocks = useMemo(() => { - const parsed = selectedProfile?.rawYaml - ? parseConfigYaml(selectedProfile?.rawYaml ?? "") - : undefined; - return (servers ?? []).map((doc, index) => ({ - block: doc, - blockFromYaml: parsed?.mcpServers?.[index], - })); - }, [servers, selectedProfile]); - - return ( -
-
- {mergedBlocks.map(({ block, blockFromYaml }, idx) => ( - - ))} -
- -
- ); -} - -export default MCPServersPreview;