From 1c720c97bc2901bb7c7fb6b3813d67658abd37a4 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Sat, 6 Sep 2025 01:20:45 -0700 Subject: [PATCH] done --- .../AssistantOption.tsx | 59 +- .../SelectedAssistantButton.tsx | 18 +- .../AssistantAndOrgListbox/index.tsx | 188 +++-- gui/src/components/Layout.tsx | 53 +- .../hooks/useSubmitOnboarding.ts | 3 - .../components/config/FatalErrorNotice.tsx | 11 +- gui/src/components/dialogs/AddDocsDialog.tsx | 2 +- gui/src/components/gui/Alert.tsx | 7 +- .../components/mainInput/Lump/LumpContext.tsx | 124 ---- .../LumpToolbar/BlockSettingsTopToolbar.tsx | 104 +-- gui/src/components/mainInput/Lump/index.tsx | 16 +- .../Lump/sections/BaseIconButton.tsx | 35 - .../Lump/sections/ContextSection.tsx | 3 - .../Lump/sections/ExploreBlocksButton.tsx | 41 -- .../Lump/sections/SelectedSection.tsx | 41 -- .../Lump/sections/errors/ErrorSection.tsx | 70 -- .../sections/errors/ErrorsSectionTooltip.tsx | 14 - .../Lump/sections/exploreBlocksLogic.ts | 47 -- gui/src/components/ui/EmptyState.tsx | 11 + gui/src/components/ui/index.ts | 2 + .../pages/config/components/ConfigSection.tsx | 17 + gui/src/pages/config/configTabs.tsx | 90 ++- .../features/indexing/IndexingProgress.tsx | 7 +- gui/src/pages/config/index.tsx | 4 +- .../pages/config/sections/AgentsSection.tsx | 86 +++ gui/src/pages/config/sections/DocsSection.tsx | 41 ++ gui/src/pages/config/sections/HelpSection.tsx | 3 +- .../sections/IndexingSettingsSection.tsx | 77 +- gui/src/pages/config/sections/McpSection.tsx | 379 +++++----- .../pages/config/sections/ModelsSection.tsx | 58 +- .../config/sections/OrganizationsSection.tsx | 104 +++ .../pages/config/sections/PromptsSection.tsx | 64 +- .../pages/config/sections/RulesSection.tsx | 275 ++++++- .../config/sections/ToolPoliciesSection.tsx | 206 +++--- .../pages/config/sections/ToolsSection.tsx | 682 ++++++++++++++++++ .../config/sections/UserSettingsSection.tsx | 3 +- .../sections/docs/DocsDetailsDialog.tsx | 6 +- .../sections/docs/DocsIndexingPeeks.tsx | 2 +- .../sections/docs/DocsIndexingStatus.test.tsx | 6 +- .../sections/docs/DocsIndexingStatus.tsx | 19 +- .../config}/sections/docs/DocsSection.tsx | 13 +- .../docs/IndexedPagesTooltip.test.tsx | 4 +- .../sections/docs/IndexedPagesTooltip.tsx | 6 +- .../config}/sections/docs/StatusIndicator.tsx | 2 +- gui/src/util/test/render.tsx | 7 +- 45 files changed, 2000 insertions(+), 1010 deletions(-) delete mode 100644 gui/src/components/mainInput/Lump/LumpContext.tsx delete mode 100644 gui/src/components/mainInput/Lump/sections/BaseIconButton.tsx delete mode 100644 gui/src/components/mainInput/Lump/sections/ContextSection.tsx delete mode 100644 gui/src/components/mainInput/Lump/sections/ExploreBlocksButton.tsx delete mode 100644 gui/src/components/mainInput/Lump/sections/SelectedSection.tsx delete mode 100644 gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx delete mode 100644 gui/src/components/mainInput/Lump/sections/errors/ErrorsSectionTooltip.tsx delete mode 100644 gui/src/components/mainInput/Lump/sections/exploreBlocksLogic.ts create mode 100644 gui/src/components/ui/EmptyState.tsx create mode 100644 gui/src/pages/config/components/ConfigSection.tsx create mode 100644 gui/src/pages/config/sections/AgentsSection.tsx create mode 100644 gui/src/pages/config/sections/DocsSection.tsx create mode 100644 gui/src/pages/config/sections/OrganizationsSection.tsx create mode 100644 gui/src/pages/config/sections/ToolsSection.tsx rename gui/src/{components/mainInput/Lump => pages/config}/sections/docs/DocsDetailsDialog.tsx (96%) rename gui/src/{components/mainInput/Lump => pages/config}/sections/docs/DocsIndexingPeeks.tsx (97%) rename gui/src/{components/mainInput/Lump => pages/config}/sections/docs/DocsIndexingStatus.test.tsx (97%) rename gui/src/{components/mainInput/Lump => pages/config}/sections/docs/DocsIndexingStatus.tsx (91%) rename gui/src/{components/mainInput/Lump => pages/config}/sections/docs/DocsSection.tsx (87%) rename gui/src/{components/mainInput/Lump => pages/config}/sections/docs/IndexedPagesTooltip.test.tsx (97%) rename gui/src/{components/mainInput/Lump => pages/config}/sections/docs/IndexedPagesTooltip.tsx (91%) rename gui/src/{components/mainInput/Lump => pages/config}/sections/docs/StatusIndicator.tsx (93%) diff --git a/gui/src/components/AssistantAndOrgListbox/AssistantOption.tsx b/gui/src/components/AssistantAndOrgListbox/AssistantOption.tsx index a7c84608c..183edd3ae 100644 --- a/gui/src/components/AssistantAndOrgListbox/AssistantOption.tsx +++ b/gui/src/components/AssistantAndOrgListbox/AssistantOption.tsx @@ -1,16 +1,15 @@ import { - Cog6ToothIcon, ExclamationTriangleIcon, } from "@heroicons/react/24/outline"; import { ProfileDescription } from "core/config/ProfileLifecycleManager"; import { useContext, useMemo } from "react"; import { useNavigate } from "react-router-dom"; +import { ToolTip } from "../gui/Tooltip"; import { IdeMessengerContext } from "../../context/IdeMessenger"; import { useAppDispatch } from "../../redux/hooks"; import { setSelectedProfile } from "../../redux/slices/profilesSlice"; import { isLocalProfile } from "../../util"; import { ROUTES } from "../../util/navigation"; -import { useLump } from "../mainInput/Lump/LumpContext"; import { ListboxOption, useFontSize } from "../ui"; import { AssistantIcon } from "./AssistantIcon"; @@ -27,7 +26,6 @@ export function AssistantOption({ }: AssistantOptionProps) { const tinyFont = useFontSize(-4); const navigate = useNavigate(); - const { setSelectedSection } = useLump(); const dispatch = useAppDispatch(); const ideMessenger = useContext(IdeMessengerContext); @@ -36,30 +34,24 @@ export function AssistantOption({ }, [profile.errors]); function handleOptionClick() { + // Always select the agent first (even if it has errors) // optimistic update dispatch(setSelectedProfile(profile.id)); // notify core which will handle actual update ideMessenger.post("didChangeSelectedProfile", { id: profile.id, }); - onClick(); - } - function handleConfigure() { - ideMessenger.post("config/openProfile", { profileId: profile.id }); - onClick(); - } - - function handleClickError() { - if (profile.id === "local") { - navigate(ROUTES.HOME); - setSelectedSection("error"); - } else { - ideMessenger.post("config/openProfile", { profileId: profile.id }); + // If the agent has errors, navigate to the agents config page + if (profile.errors && profile.errors.length > 0) { + navigate("/config?tab=agents"); } + onClick(); } + + return ( 0 ? "text-error" : ""}`} > {profile.title}
{profile.errors && profile.errors?.length > 0 && ( - { - e.preventDefault(); - e.stopPropagation(); - handleClickError(); - }} - /> - )} - {isLocalProfile(profile) ? ( - { - e.stopPropagation(); - e.preventDefault(); - handleConfigure(); - }} - /> - ) : ( - { - e.stopPropagation(); - e.preventDefault(); - handleConfigure(); - }} - /> + + + )}
diff --git a/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx b/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx index 66de275d4..2e02aeb0b 100644 --- a/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx +++ b/gui/src/components/AssistantAndOrgListbox/SelectedAssistantButton.tsx @@ -9,16 +9,16 @@ import { AssistantIcon } from "./AssistantIcon"; interface SelectedAssistantButtonProps { selectedProfile: ProfileDescription | null; - variant?: "small" | "large"; + variant?: "lump" | "sidebar"; } export function SelectedAssistantButton({ selectedProfile, - variant = "small", + variant, }: SelectedAssistantButtonProps) { const configLoading = useAppSelector((store) => store.config.loading); - const isLarge = variant === "large"; + const isLarge = variant === "sidebar"; const iconSize = isLarge ? "h-4 w-4" : "h-3 w-3"; const buttonPadding = isLarge ? "px-2 py-2" : "px-0 py-0"; const buttonStyle = isLarge ? {} : { fontSize: fontSize(-3) }; @@ -29,8 +29,10 @@ export function SelectedAssistantButton({ className={`text-description border-none bg-transparent hover:brightness-125 ${isLarge ? "w-full justify-start" : "gap-1.5"} ${buttonPadding}`} style={buttonStyle} > -
-
+
+
{selectedProfile === null ? ( "Create your first agent" ) : configLoading ? ( @@ -48,14 +50,16 @@ export function SelectedAssistantButton({
- + {selectedProfile.title} )}
diff --git a/gui/src/components/AssistantAndOrgListbox/index.tsx b/gui/src/components/AssistantAndOrgListbox/index.tsx index ebf952508..f789d1910 100644 --- a/gui/src/components/AssistantAndOrgListbox/index.tsx +++ b/gui/src/components/AssistantAndOrgListbox/index.tsx @@ -1,6 +1,13 @@ -import { ArrowPathIcon, PlusIcon } from "@heroicons/react/24/outline"; +import { + ArrowPathIcon, + Cog6ToothIcon, + PencilIcon, + PlusIcon, + WrenchScrewdriverIcon, +} from "@heroicons/react/24/outline"; import { isOnPremSession } from "core/control-plane/AuthTypes"; import { useContext, useEffect, useRef } from "react"; +import { useNavigate } from "react-router-dom"; import { useAuth } from "../../context/Auth"; import { IdeMessengerContext } from "../../context/IdeMessenger"; import { useAppDispatch, useAppSelector } from "../../redux/hooks"; @@ -11,8 +18,8 @@ import { import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util"; import { cn } from "../../util/cn"; import { + Button, Listbox, - ListboxOption, ListboxOptions, Transition, useFontSize, @@ -22,12 +29,15 @@ import { AssistantOptions } from "./AssistantOptions"; import { OrganizationOptions } from "./OrganizationOptions"; import { SelectedAssistantButton } from "./SelectedAssistantButton"; -interface AssistantAndOrgListboxProps { - variant?: "small" | "large"; +export interface AssistantAndOrgListboxProps { + variant: "lump" | "sidebar"; } -export function AssistantAndOrgListbox({ variant = "small" }: AssistantAndOrgListboxProps = {}) { +export function AssistantAndOrgListbox({ + variant = "sidebar", +}: AssistantAndOrgListboxProps) { const dispatch = useAppDispatch(); + const navigate = useNavigate(); const listboxRef = useRef(null); const currentOrg = useAppSelector(selectCurrentOrg); const ideMessenger = useContext(IdeMessengerContext); @@ -35,7 +45,6 @@ export function AssistantAndOrgListbox({ variant = "small" }: AssistantAndOrgLis profiles, selectedProfile, session, - login, logout, organizations, refreshProfiles, @@ -63,6 +72,33 @@ export function AssistantAndOrgListbox({ variant = "small" }: AssistantAndOrgLis close(); } + function onNewOrganization() { + void ideMessenger.request("controlPlane/openUrl", { + path: "/organizations/new", + }); + close(); + } + + function onAgentsConfig() { + navigate("/config?tab=agents"); + close(); + } + + function onOrganizationsConfig() { + navigate("/config?tab=organizations"); + close(); + } + + function onRulesConfig() { + navigate("/config?tab=rules"); + close(); + } + + function onToolsConfig() { + navigate("/config?tab=tools"); + close(); + } + function onLogout() { logout(); close(); @@ -112,16 +148,43 @@ export function AssistantAndOrgListbox({ variant = "small" }: AssistantAndOrgLis return (
- +
Agents +
+ + +
Organizations +
+ + +
@@ -144,45 +231,64 @@ export function AssistantAndOrgListbox({ variant = "small" }: AssistantAndOrgLis )} + {/* Settings Section */} + {variant !== "sidebar" && ( +
+ + + + +
+ )} + {/* Bottom Actions */}
- - - New Agent - - - - { - e.stopPropagation(); - refreshProfiles("Manual refresh from assistant list"); - }} - > - - - Reload agents - - - - -
{getMetaKeyLabel()} ⇧ ' to toggle agent +
diff --git a/gui/src/components/Layout.tsx b/gui/src/components/Layout.tsx index 05d21ba8c..049c363d5 100644 --- a/gui/src/components/Layout.tsx +++ b/gui/src/components/Layout.tsx @@ -18,7 +18,6 @@ import { incrementFreeTrialCount } from "../util/freeTrial"; import { ROUTES } from "../util/navigation"; import TextDialog from "./dialogs"; import { GenerateRuleDialog } from "./GenerateRuleDialog"; -import { LumpProvider } from "./mainInput/Lump/LumpContext"; import { useMainEditor } from "./mainInput/TipTapEditor"; import { isNewUserOnboarding, @@ -258,35 +257,33 @@ const Layout = () => { }} /> )} - - -
+
+ { + dispatch(setShowDialog(false)); }} - > - { - dispatch(setShowDialog(false)); - }} - onClose={() => { - dispatch(setShowDialog(false)); - }} - message={dialogMessage} - /> + onClose={() => { + dispatch(setShowDialog(false)); + }} + message={dialogMessage} + /> - - - - - -
-
- + + + + + +
+
diff --git a/gui/src/components/OnboardingCard/hooks/useSubmitOnboarding.ts b/gui/src/components/OnboardingCard/hooks/useSubmitOnboarding.ts index 259dd6392..da4c1953e 100644 --- a/gui/src/components/OnboardingCard/hooks/useSubmitOnboarding.ts +++ b/gui/src/components/OnboardingCard/hooks/useSubmitOnboarding.ts @@ -3,14 +3,12 @@ import { usePostHog } from "posthog-js/react"; import { useContext } from "react"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { getLocalStorage, setLocalStorage } from "../../../util/localStorage"; -import { useLump } from "../../mainInput/Lump/LumpContext"; import { useOnboardingCard } from "./useOnboardingCard"; export function useSubmitOnboarding(mode: OnboardingModes, isDialog = false) { const posthog = usePostHog(); const ideMessenger = useContext(IdeMessengerContext); const { close: closeOnboardingCard } = useOnboardingCard(); - const { setSelectedSection } = useLump(); function submitOnboarding(provider?: string, apiKey?: string) { const onboardingStatus = getLocalStorage("onboardingStatus"); @@ -39,7 +37,6 @@ export function useSubmitOnboarding(mode: OnboardingModes, isDialog = false) { } ideMessenger.post("config/openProfile", { profileId: undefined }); - setSelectedSection("models"); } return { diff --git a/gui/src/components/config/FatalErrorNotice.tsx b/gui/src/components/config/FatalErrorNotice.tsx index 3d528e810..95aad0f85 100644 --- a/gui/src/components/config/FatalErrorNotice.tsx +++ b/gui/src/components/config/FatalErrorNotice.tsx @@ -5,7 +5,6 @@ import { IdeMessengerContext } from "../../context/IdeMessenger"; import { useAppSelector } from "../../redux/hooks"; import { ROUTES } from "../../util/navigation"; import Alert from "../gui/Alert"; -import { useLump } from "../mainInput/Lump/LumpContext"; export const FatalErrorIndicator = () => { const { refreshProfiles } = useAuth(); @@ -18,12 +17,10 @@ export const FatalErrorIndicator = () => { return configError?.some((error) => error.fatal); }, [configError]); - const { setSelectedSection, selectedSection } = useLump(); const configLoading = useAppSelector((state) => state.config.loading); - const showLumpErrorSection = () => { - navigate(ROUTES.HOME); - setSelectedSection("error"); + const showConfigPage = () => { + navigate("/config?tab=agents"); }; const { selectedProfile } = useAuth(); @@ -68,8 +65,8 @@ export const FatalErrorIndicator = () => {
)}
View
diff --git a/gui/src/components/dialogs/AddDocsDialog.tsx b/gui/src/components/dialogs/AddDocsDialog.tsx index b2f229fc2..a6db802fa 100644 --- a/gui/src/components/dialogs/AddDocsDialog.tsx +++ b/gui/src/components/dialogs/AddDocsDialog.tsx @@ -9,7 +9,7 @@ import { useAppSelector } from "../../redux/hooks"; import { updateIndexingStatus } from "../../redux/slices/indexingSlice"; import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice"; import { ToolTip } from "../gui/Tooltip"; -import DocsIndexingPeeks from "../mainInput/Lump/sections/docs/DocsIndexingPeeks"; +import DocsIndexingPeeks from "../../pages/config/sections/docs/DocsIndexingPeeks"; function AddDocsDialog() { const posthog = usePostHog(); diff --git a/gui/src/components/gui/Alert.tsx b/gui/src/components/gui/Alert.tsx index a473ba141..108054a59 100644 --- a/gui/src/components/gui/Alert.tsx +++ b/gui/src/components/gui/Alert.tsx @@ -70,19 +70,20 @@ const spacingSizes = { lg: "ml-2", }; -function Alert({ type = "info", size = "lg", ...props }: AlertProps) { +function Alert({ type = "info", size = "lg", className, children, ...props }: AlertProps) { const { Icon, background, border, text, iconColor } = ALERT_CONFIGS[type]; return (
-
{props.children}
+
{children}
); diff --git a/gui/src/components/mainInput/Lump/LumpContext.tsx b/gui/src/components/mainInput/Lump/LumpContext.tsx deleted file mode 100644 index e2a7c17f8..000000000 --- a/gui/src/components/mainInput/Lump/LumpContext.tsx +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Provides context for controlling the Lump component's visibility state - */ -import { - createContext, - ReactNode, - useCallback, - useContext, - useEffect, - useState, -} from "react"; -import { useAppSelector } from "../../../redux/hooks"; - -interface LumpContextType { - isLumpVisible: boolean; - selectedSection: string | null; - displayedSection: string | null; - isToolbarExpanded: boolean; - hideLump: () => void; - setSelectedSection: (section: string | null) => void; - toggleToolbar: () => void; -} - -const LumpContext = createContext(undefined); - -interface LumpProviderProps { - children: ReactNode; -} - -/** - * Provider component that makes Lump state available to any child component - */ -export function LumpProvider({ children }: LumpProviderProps) { - const [selectedSection, setSelectedSection] = useState(null); - const [displayedSection, setDisplayedSection] = useState(null); - const [isVisible, setIsVisible] = useState(false); - const [isToolbarExpanded, setIsToolbarExpanded] = useState(true); - const isStreaming = useAppSelector((state) => state.session.isStreaming); - - const configError = useAppSelector((store) => store.config.configError); - - // Handle keyboard escape - const handleKeyDown = useCallback( - (event: KeyboardEvent) => { - if (event.key === "Escape" && selectedSection) { - setSelectedSection(null); - } - }, - [selectedSection], - ); - - // Function to hide the lump - const hideLump = useCallback(() => { - setSelectedSection(null); - }, []); - - // Function to toggle toolbar expanded state - const toggleToolbar = useCallback(() => { - setIsToolbarExpanded((prev) => !prev); - }, []); - - // Update displayedSection and visibility when selectedSection changes - useEffect(() => { - if (selectedSection) { - setDisplayedSection(selectedSection); - setIsVisible(true); - } else { - setIsVisible(false); - const timeout = setTimeout(() => { - setDisplayedSection(null); - }, 300); - return () => clearTimeout(timeout); - } - }, [selectedSection]); - - // Don't allow selection error section if there are no errors - useEffect(() => { - if (selectedSection === "error" && !configError) { - setSelectedSection(null); - } - }, [selectedSection, configError]); - - // Reset when streaming starts - useEffect(() => { - if (isStreaming && selectedSection) { - setSelectedSection(null); - } - }, [isStreaming, selectedSection]); - - // Set up keyboard listener - useEffect(() => { - if (selectedSection) { - document.addEventListener("keydown", handleKeyDown); - return () => document.removeEventListener("keydown", handleKeyDown); - } - }, [selectedSection, handleKeyDown]); - - return ( - - {children} - - ); -} - -/** - * Hook that lets any component access the Lump context - */ -export function useLump() { - const context = useContext(LumpContext); - if (context === undefined) { - throw new Error("useLump must be used within a LumpProvider"); - } - return context; -} diff --git a/gui/src/components/mainInput/Lump/LumpToolbar/BlockSettingsTopToolbar.tsx b/gui/src/components/mainInput/Lump/LumpToolbar/BlockSettingsTopToolbar.tsx index 61e368cda..644068c2e 100644 --- a/gui/src/components/mainInput/Lump/LumpToolbar/BlockSettingsTopToolbar.tsx +++ b/gui/src/components/mainInput/Lump/LumpToolbar/BlockSettingsTopToolbar.tsx @@ -1,13 +1,6 @@ -import { - ChatBubbleLeftIcon, - ChevronLeftIcon, - EllipsisHorizontalIcon, - ExclamationTriangleIcon, - PencilIcon, - Squares2X2Icon, - WrenchScrewdriverIcon, -} from "@heroicons/react/24/outline"; +import { ExclamationTriangleIcon } from "@heroicons/react/24/outline"; import { ReactNode, useContext, useEffect, useState } from "react"; +import { useNavigate } from "react-router-dom"; import { vscBadgeForeground } from "../../.."; import { IdeMessengerContext } from "../../../../context/IdeMessenger"; import { useAppSelector } from "../../../../redux/hooks"; @@ -15,8 +8,6 @@ import FreeTrialButton from "../../../FreeTrialButton"; import { ToolTip } from "../../../gui/Tooltip"; import { useFontSize } from "../../../ui/font"; import HoverItem from "../../InputToolbar/HoverItem"; -import { useLump } from "../LumpContext"; -import { ErrorsSectionTooltip } from "../sections/errors/ErrorsSectionTooltip"; import { usesFreeTrialApiKey } from "core/config/usesFreeTrialApiKey"; import type { FreeTrialStatus } from "core/control-plane/client"; @@ -41,29 +32,10 @@ interface Section { } const sections: Section[] = [ - { id: "rules", title: "Rules", tooltip: "Rules", icon: PencilIcon }, - { - id: "prompts", - title: "Prompts", - tooltip: "Prompts", - icon: ChatBubbleLeftIcon, - }, - { - id: "tools", - title: "Tools", - tooltip: "Tools", - icon: WrenchScrewdriverIcon, - }, - { - id: "mcp", - title: "MCP", - tooltip: "MCP Servers", - icon: Squares2X2Icon, - }, { id: "error", title: "Errors", - tooltip: , + tooltip: "View errors", icon: ExclamationTriangleIcon, }, ]; @@ -112,7 +84,7 @@ function BlockSettingsToolbarIcon( } export function BlockSettingsTopToolbar() { - const { selectedSection, setSelectedSection } = useLump(); + const navigate = useNavigate(); const configError = useAppSelector((store) => store.config.configError); const config = useAppSelector((state) => state.config.config); @@ -150,50 +122,36 @@ export function BlockSettingsTopToolbar() { }; }, [ideMessenger, isUsingFreeTrial]); - const visibleSections = sections.filter( - (section) => - section.id !== "error" || - (section.id === "error" && configError && configError?.length > 0), - ); + const errorSection = sections.find((section) => section.id === "error"); + const shouldShowError = configError && configError?.length > 0; return ( -
-
-
- {visibleSections.map((section) => ( - - setSelectedSection( - selectedSection === section.id ? null : section.id, - ) - } - /> - ))} -
-
-
- + {shouldShowError && errorSection && ( + navigate("/config?tab=agents")} + /> + )} + + - - {isUsingFreeTrial ? ( - - ) : ( - - )} - - -
+ {isUsingFreeTrial ? ( + + ) : ( + + )} + +
); } diff --git a/gui/src/components/mainInput/Lump/index.tsx b/gui/src/components/mainInput/Lump/index.tsx index a22ea7adb..d437c828a 100644 --- a/gui/src/components/mainInput/Lump/index.tsx +++ b/gui/src/components/mainInput/Lump/index.tsx @@ -1,27 +1,13 @@ -import { useLump } from "./LumpContext"; import { LumpToolbar } from "./LumpToolbar/LumpToolbar"; -import { SelectedSection } from "./sections/SelectedSection"; /** - * Internal component that consumes the LumpContext + * Simplified toolbar component that only shows the toolbar without expansion */ export function Lump() { - const { isLumpVisible, selectedSection } = useLump(); - return (
- -
- -
); diff --git a/gui/src/components/mainInput/Lump/sections/BaseIconButton.tsx b/gui/src/components/mainInput/Lump/sections/BaseIconButton.tsx deleted file mode 100644 index 00c4f99cd..000000000 --- a/gui/src/components/mainInput/Lump/sections/BaseIconButton.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { ComponentType, SVGProps } from "react"; -import { GhostButton } from "../../.."; -import { fontSize } from "../../../../util"; - -interface BaseIconButtonProps { - icon: ComponentType>; - text: string; - onClick: (e: React.MouseEvent) => void; - className?: string; - style?: React.CSSProperties; -} - -export function BaseIconButton({ - icon: Icon, - text, - onClick, - className = "w-full cursor-pointer rounded px-2 py-0.5 text-center", - style = { fontSize: fontSize(-3) }, -}: BaseIconButtonProps) { - return ( - { - e.preventDefault(); - onClick(e); - }} - > -
- - {text} -
-
- ); -} diff --git a/gui/src/components/mainInput/Lump/sections/ContextSection.tsx b/gui/src/components/mainInput/Lump/sections/ContextSection.tsx deleted file mode 100644 index 7524fd08d..000000000 --- a/gui/src/components/mainInput/Lump/sections/ContextSection.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export function ContextSection() { - return
Context content
; -} diff --git a/gui/src/components/mainInput/Lump/sections/ExploreBlocksButton.tsx b/gui/src/components/mainInput/Lump/sections/ExploreBlocksButton.tsx deleted file mode 100644 index 38fa4e8e4..000000000 --- a/gui/src/components/mainInput/Lump/sections/ExploreBlocksButton.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import { BlockType } from "@continuedev/config-yaml"; -import { useContext } from "react"; -import { useAuth } from "../../../../context/Auth"; -import { IdeMessengerContext } from "../../../../context/IdeMessenger"; -import { BaseIconButton } from "./BaseIconButton"; -import { getExploreBlocksConfig } from "./exploreBlocksLogic"; - -export function ExploreBlocksButton(props: { blockType: string }) { - const { selectedProfile } = useAuth(); - const ideMessenger = useContext(IdeMessengerContext); - - const isLocal = selectedProfile?.profileType === "local"; - - const handleLocalAdd = (blockType: BlockType) => { - void ideMessenger.request("config/addLocalWorkspaceBlock", { - blockType, - }); - }; - - const handleExplore = (blockType: string) => { - void ideMessenger.request("controlPlane/openUrl", { - path: `new?type=block&blockType=${blockType}`, - orgSlug: undefined, - }); - }; - - const config = getExploreBlocksConfig( - props.blockType, - isLocal, - handleLocalAdd, - handleExplore, - ); - - return ( - - ); -} diff --git a/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx b/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx deleted file mode 100644 index 2be1c90bc..000000000 --- a/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx +++ /dev/null @@ -1,41 +0,0 @@ -import { useNavigate } from "react-router-dom"; -import { useLump } from "../LumpContext"; -import { ContextSection } from "./ContextSection"; -import { ErrorSection } from "./errors/ErrorSection"; - -/** - * Renders the appropriate section based on the selected section in the Lump context - */ -export function SelectedSection() { - const { displayedSection, hideLump } = useLump(); - const navigate = useNavigate(); - - const handleConfigRedirect = (tabId: string) => { - hideLump(); - navigate(`/config?tab=${tabId}`); - }; - - switch (displayedSection) { - case "models": - handleConfigRedirect("models"); - return null; - case "rules": - handleConfigRedirect("rules"); - return null; - case "prompts": - handleConfigRedirect("prompts"); - return null; - case "tools": - handleConfigRedirect("tools"); - return null; - case "mcp": - handleConfigRedirect("mcp"); - return null; - case "context": - return ; - case "error": - return ; - default: - return null; - } -} diff --git a/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx b/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx deleted file mode 100644 index b9524ef78..000000000 --- a/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { - ExclamationCircleIcon, - ExclamationTriangleIcon, -} from "@heroicons/react/24/outline"; -import { useContext } from "react"; -import { useAuth } from "../../../../../context/Auth"; -import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; -import { useAppSelector } from "../../../../../redux/hooks"; - -export function ErrorSection() { - const configError = useAppSelector((state) => state.config.configError); - const configLoading = useAppSelector((state) => state.config.loading); - const ideMessenger = useContext(IdeMessengerContext); - - const { refreshProfiles } = useAuth(); - - const sortedErrors = configError - ? [...configError].sort((a, b) => (b.fatal ? 1 : 0) - (a.fatal ? 1 : 0)) - : []; - - return ( -
-
-
{ - refreshProfiles("Clicked reload in Error section"); - }} - > - Reload -
-
{ - ideMessenger.post( - "openUrl", - "https://docs.continue.dev/troubleshooting", - ); - }} - className="text-description cursor-pointer text-xs underline" - > - Help -
-
-
    - {sortedErrors.map((error, index) => ( -
  • - {error.fatal ? ( - - ) : ( - - )} -

    - {error.message} -

    -
  • - ))} -
-
- ); -} diff --git a/gui/src/components/mainInput/Lump/sections/errors/ErrorsSectionTooltip.tsx b/gui/src/components/mainInput/Lump/sections/errors/ErrorsSectionTooltip.tsx deleted file mode 100644 index 02a69d517..000000000 --- a/gui/src/components/mainInput/Lump/sections/errors/ErrorsSectionTooltip.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import { useAppSelector } from "../../../../../redux/hooks"; - -export const ErrorsSectionTooltip = () => { - const configError = useAppSelector((store) => store.config.configError); - - const numErrors = configError?.length ?? 0; - const plural = numErrors === 1 ? "" : "s"; - - return ( -
- {`${numErrors} Config Error${plural}`} -
- ); -}; diff --git a/gui/src/components/mainInput/Lump/sections/exploreBlocksLogic.ts b/gui/src/components/mainInput/Lump/sections/exploreBlocksLogic.ts deleted file mode 100644 index 18d9554bc..000000000 --- a/gui/src/components/mainInput/Lump/sections/exploreBlocksLogic.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { BlockType } from "@continuedev/config-yaml"; -import { - ArrowTopRightOnSquareIcon, - PlusIcon, -} from "@heroicons/react/24/outline"; -import { ComponentType, SVGProps } from "react"; - -export interface ExploreBlocksConfig { - icon: ComponentType>; - text: string; - action: () => void; -} - -export function getExploreBlocksConfig( - blockType: string, - isLocal: boolean, - onLocalAdd: (blockType: BlockType) => void, - onExplore: (blockType: string) => void, -): ExploreBlocksConfig { - const Icon = isLocal ? PlusIcon : ArrowTopRightOnSquareIcon; - - const text = `${isLocal ? "Add" : "Explore"} ${ - blockType === "mcpServers" - ? "MCP Servers" - : blockType.charAt(0).toUpperCase() + blockType.slice(1) - }`; - - const action = () => { - if (isLocal) { - onLocalAdd(blockType as BlockType); - } else { - onExplore(blockType); - } - }; - - return { - icon: Icon, - text, - action, - }; -} - -export function formatBlockTypeName(blockType: string): string { - return blockType === "mcpServers" - ? "MCP Servers" - : blockType.charAt(0).toUpperCase() + blockType.slice(1); -} diff --git a/gui/src/components/ui/EmptyState.tsx b/gui/src/components/ui/EmptyState.tsx new file mode 100644 index 000000000..07566f09d --- /dev/null +++ b/gui/src/components/ui/EmptyState.tsx @@ -0,0 +1,11 @@ +interface EmptyStateProps { + message: string; +} + +export function EmptyState({ message }: EmptyStateProps) { + return ( +
+ {message} +
+ ); +} \ No newline at end of file diff --git a/gui/src/components/ui/index.ts b/gui/src/components/ui/index.ts index 14766c3bf..1fa39d29f 100644 --- a/gui/src/components/ui/index.ts +++ b/gui/src/components/ui/index.ts @@ -1,5 +1,7 @@ export { Button } from "./Button"; export { Card } from "./Card"; +export { Divider } from "./Divider"; +export { EmptyState } from "./EmptyState"; export { useFontSize } from "./font"; export { Listbox, diff --git a/gui/src/pages/config/components/ConfigSection.tsx b/gui/src/pages/config/components/ConfigSection.tsx new file mode 100644 index 000000000..9e108d9e6 --- /dev/null +++ b/gui/src/pages/config/components/ConfigSection.tsx @@ -0,0 +1,17 @@ +import React from "react"; + +interface ConfigSectionProps { + children: React.ReactNode; + className?: string; +} + +export function ConfigSection({ + children, + className = "", +}: ConfigSectionProps) { + return ( +
+ {children} +
+ ); +} \ No newline at end of file diff --git a/gui/src/pages/config/configTabs.tsx b/gui/src/pages/config/configTabs.tsx index 21ab035ce..3e7ec1928 100644 --- a/gui/src/pages/config/configTabs.tsx +++ b/gui/src/pages/config/configTabs.tsx @@ -1,6 +1,6 @@ import { ArrowLeftIcon, - ChatBubbleLeftRightIcon, + BuildingOfficeIcon, CircleStackIcon, Cog6ToothIcon, CubeIcon, @@ -9,13 +9,15 @@ import { Squares2X2Icon, WrenchScrewdriverIcon, } from "@heroicons/react/24/outline"; +import { BotIcon } from "../../components/svg/BotIcon"; +import { ConfigSection } from "./components/ConfigSection"; +import { AgentsSection } from "./sections/AgentsSection"; import { HelpSection } from "./sections/HelpSection"; import { IndexingSettingsSection } from "./sections/IndexingSettingsSection"; -import { McpSection } from "./sections/McpSection"; import { ModelsSection } from "./sections/ModelsSection"; -import { PromptsSection } from "./sections/PromptsSection"; +import { OrganizationsSection } from "./sections/OrganizationsSection"; import { RulesSection } from "./sections/RulesSection"; -import { ToolPoliciesSection } from "./sections/ToolPoliciesSection"; +import { ToolsSection } from "./sections/ToolsSection"; import { UserSettingsSection } from "./sections/UserSettingsSection"; interface TabOption { @@ -55,9 +57,9 @@ export const topTabSections: TabSection[] = [ id: "models", label: "Models", component: ( -
+ -
+ ), icon: , }, @@ -65,39 +67,19 @@ export const topTabSections: TabSection[] = [ id: "rules", label: "Rules", component: ( -
+ -
+ ), icon: , }, - { - id: "prompts", - label: "Prompts", - component: ( -
- -
- ), - icon: ( - - ), - }, - { - id: "mcp", - label: "MCP", - component: , - icon: ( - - ), - }, { id: "tools", label: "Tools", component: ( -
- -
+ + + ), icon: ( @@ -105,6 +87,36 @@ export const topTabSections: TabSection[] = [ }, ], }, + { + id: "agents-orgs", + showTopDivider: true, + tabs: [ + { + id: "agents", + label: "Agents", + component: ( + + + + ), + icon: ( + + ), + }, + { + id: "organizations", + label: "Organizations", + component: ( + + + + ), + icon: ( + + ), + }, + ], + }, { id: "indexing", showTopDivider: true, @@ -112,7 +124,11 @@ export const topTabSections: TabSection[] = [ { id: "indexing", label: "Indexing", - component: , + component: ( + + + + ), icon: ( ), @@ -128,16 +144,20 @@ export const bottomTabSections: TabSection[] = [ { id: "settings", label: "Settings", - component: , + component: ( + + + + ), icon: , }, { id: "help", label: "Help", component: ( -
+ -
+ ), icon: ( diff --git a/gui/src/pages/config/features/indexing/IndexingProgress.tsx b/gui/src/pages/config/features/indexing/IndexingProgress.tsx index 6b0cb2069..f2564e087 100644 --- a/gui/src/pages/config/features/indexing/IndexingProgress.tsx +++ b/gui/src/pages/config/features/indexing/IndexingProgress.tsx @@ -6,7 +6,10 @@ import { useDispatch } from "react-redux"; import ConfirmationDialog from "../../../../components/dialogs/ConfirmationDialog"; import { IdeMessengerContext } from "../../../../context/IdeMessenger"; import { useWebviewListener } from "../../../../hooks/useWebviewListener"; -import { setDialogMessage, setShowDialog } from "../../../../redux/slices/uiSlice"; +import { + setDialogMessage, + setShowDialog, +} from "../../../../redux/slices/uiSlice"; import { isJetBrains } from "../../../../util"; import IndexingProgressBar from "./IndexingProgressBar"; import IndexingProgressErrorText from "./IndexingProgressErrorText"; @@ -108,7 +111,7 @@ function IndexingProgress() { } return ( -
+
{!["loading", "waiting"].includes(update.status) && ( diff --git a/gui/src/pages/config/index.tsx b/gui/src/pages/config/index.tsx index bc2581245..820f1d574 100644 --- a/gui/src/pages/config/index.tsx +++ b/gui/src/pages/config/index.tsx @@ -5,8 +5,8 @@ import { AssistantAndOrgListbox } from "../../components/AssistantAndOrgListbox" import { Divider } from "../../components/ui/Divider"; import { useAuth } from "../../context/Auth"; import { useNavigationListener } from "../../hooks/useNavigationListener"; -import { bottomTabSections, getAllTabs, topTabSections } from "./configTabs"; import { TabGroup } from "./components/ui/TabGroup"; +import { bottomTabSections, getAllTabs, topTabSections } from "./configTabs"; import { AccountDropdown } from "./features/account/AccountDropdown"; function ConfigPage() { @@ -56,7 +56,7 @@ function ConfigPage() { {index === 0 && shouldRenderOrgInfo && ( <> - + )} diff --git a/gui/src/pages/config/sections/AgentsSection.tsx b/gui/src/pages/config/sections/AgentsSection.tsx new file mode 100644 index 000000000..e6674db0a --- /dev/null +++ b/gui/src/pages/config/sections/AgentsSection.tsx @@ -0,0 +1,86 @@ +import { Cog6ToothIcon, PlusCircleIcon } from "@heroicons/react/24/outline"; +import { useContext } from "react"; +import { AssistantIcon } from "../../../components/AssistantAndOrgListbox/AssistantIcon"; +import { ToolTip } from "../../../components/gui/Tooltip"; +import { Button, Card, Divider, EmptyState } from "../../../components/ui"; +import { useAuth } from "../../../context/Auth"; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; + +export function AgentsSection() { + const { profiles } = useAuth(); + const ideMessenger = useContext(IdeMessengerContext); + + function handleAddAgent() { + ideMessenger.request("config/newAssistantFile", undefined); + } + + function handleConfigureAgent(profileId: string) { + ideMessenger.post("config/openProfile", { profileId }); + } + + return ( + <> +
+
+

Agents

+
+ +
+ + + {profiles && profiles.length > 0 ? ( + profiles.map((profile, index) => ( +
+
+
+
+ +
+
+

0 ? "text-error" : ""}`} + > + {profile.title} +

+ {profile.errors && profile.errors.length > 0 && ( +
+ {profile.errors.map((error, errorIndex) => ( +
+ {error.message} +
+ ))} +
+ )} +
+
+ + + +
+ {index < profiles.length - 1 && } +
+ )) + ) : ( + + )} +
+ + ); +} diff --git a/gui/src/pages/config/sections/DocsSection.tsx b/gui/src/pages/config/sections/DocsSection.tsx new file mode 100644 index 000000000..3bc1f4d61 --- /dev/null +++ b/gui/src/pages/config/sections/DocsSection.tsx @@ -0,0 +1,41 @@ +import { PlusCircleIcon } from "@heroicons/react/24/outline"; +import { useDispatch } from "react-redux"; +import { Button, Card } from "../../../components/ui"; +import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice"; +import AddDocsDialog from "../../../components/dialogs/AddDocsDialog"; +import DocsIndexingStatuses from "./docs/DocsSection"; + +export function DocsSection() { + const dispatch = useDispatch(); + + function handleAddDocs() { + dispatch(setShowDialog(true)); + dispatch( + setDialogMessage( + , + ), + ); + } + + return ( + <> +
+

Documentation

+ +
+ + +
+ +
+
+ + ); +} \ No newline at end of file diff --git a/gui/src/pages/config/sections/HelpSection.tsx b/gui/src/pages/config/sections/HelpSection.tsx index 494b03f89..a4492c4a2 100644 --- a/gui/src/pages/config/sections/HelpSection.tsx +++ b/gui/src/pages/config/sections/HelpSection.tsx @@ -172,9 +172,8 @@ export function HelpSection() { }; return ( -
+
-
{/* Resources */}
diff --git a/gui/src/pages/config/sections/IndexingSettingsSection.tsx b/gui/src/pages/config/sections/IndexingSettingsSection.tsx index 67017ba59..e56ae968e 100644 --- a/gui/src/pages/config/sections/IndexingSettingsSection.tsx +++ b/gui/src/pages/config/sections/IndexingSettingsSection.tsx @@ -1,49 +1,54 @@ -import DocsIndexingStatuses from "../../../components/mainInput/Lump/sections/docs/DocsSection"; import { Card } from "../../../components/ui"; import { useAppSelector } from "../../../redux/hooks"; -import { ConfigHeader } from "../ConfigHeader"; import IndexingProgress from "../features/indexing"; +import { DocsSection } from "./DocsSection"; -export function IndexingSettingsSection() { +function CodebaseSubSection() { const config = useAppSelector((state) => state.config.config); + return ( -
- +
+
+

@codebase index

+
-
-
-

@codebase index

- - Local embeddings of your codebase - - {config.disableIndexing ? ( -
-

- Indexing is disabled -

-

- Open settings and toggle Enable Indexing to - re-enable -

-
- ) : ( - - )} -
- -
-

@docs index

- - Local embeddings of your documentation sources - - -
+
+ {config.disableIndexing ? ( +
+

+ Indexing is disabled +

+

+ Open settings and toggle Enable Indexing to + re-enable +

+
+ ) : ( + + )}
); } + +export function IndexingSettingsSection() { + return ( + <> +
+
+

Indexing

+

+ Manage your codebase and documentation indexing +

+
+
+ +
+ + +
+ + ); +} diff --git a/gui/src/pages/config/sections/McpSection.tsx b/gui/src/pages/config/sections/McpSection.tsx index 6914f98c1..3c1b48c7d 100644 --- a/gui/src/pages/config/sections/McpSection.tsx +++ b/gui/src/pages/config/sections/McpSection.tsx @@ -1,16 +1,16 @@ import { ConfigYaml, parseConfigYaml } from "@continuedev/config-yaml"; import { ArrowPathIcon, + ChevronDownIcon, CircleStackIcon, CommandLineIcon, GlobeAltIcon, - InformationCircleIcon, - ShieldCheckIcon, - ShieldExclamationIcon, + PlusCircleIcon, + UserCircleIcon, WrenchScrewdriverIcon, } from "@heroicons/react/24/outline"; import { MCPServerStatus } from "core"; -import { Fragment, useContext, useMemo } from "react"; +import { Fragment, useContext, useMemo, useState } from "react"; import { useAuth } from "../../../context/Auth"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; @@ -18,16 +18,15 @@ import { updateConfig } from "../../../redux/slices/configSlice"; import { selectCurrentOrg } from "../../../redux/slices/profilesSlice"; import { fontSize } from "../../../util"; import { ToolTip } from "../../../components/gui/Tooltip"; -import { Button, Card } from "../../../components/ui"; +import { Button, Card, Divider } from "../../../components/ui"; import EditBlockButton from "../../../components/mainInput/Lump/EditBlockButton"; -import { ExploreBlocksButton } from "../../../components/mainInput/Lump/sections/ExploreBlocksButton"; -import { ConfigHeader } from "../ConfigHeader"; interface MCPServerStatusProps { server: MCPServerStatus; serverFromYaml?: NonNullable[number]; } -function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) { +function MCPServerCard({ server, serverFromYaml }: MCPServerStatusProps) { + const [isExpanded, setIsExpanded] = useState(false); const ideMessenger = useContext(IdeMessengerContext); const config = useAppSelector((store) => store.config.config); const dispatch = useAppDispatch(); @@ -66,33 +65,165 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) { }); }; - return ( -
-
- {/* Name and Status */} - {server.name} + const handleToggleExpanded = (e: React.MouseEvent) => { + // Don't expand if clicking on buttons + if ((e.target as HTMLElement).closest('button')) { + return; + } + setIsExpanded(!isExpanded); + }; - {/* Error indicator if any */} - {server.errors.length ? ( - error.length > 150) ? 1500 : 0 - } - className="flex flex-col gap-0.5" - content={server.errors.map((error, idx) => ( - -
+ return ( +
+
+
+ +
+

0 ? "text-error" : ""}`} + > + {server.name} +

+
+
+ +
+ {server.isProtectedResource && ( + + + + )} + + + + + + + +
+
+
+ + {isExpanded && ( +
+ {/* Tools, Prompts, Resources with counts */} +
+ + {server.tools.map((tool, idx) => ( + {tool.name} + ))} + {server.tools.length === 0 && ( + No tools + )} + + } + > +
+ + Tools: {server.tools.length} +
+
+ + + {server.prompts.map((prompt, idx) => ( + {prompt.name} + ))} + {server.prompts.length === 0 && ( + No prompts + )} + + } + > +
+ + Prompts: {server.prompts.length} +
+
+ + + {[...server.resources, ...server.resourceTemplates].map( + (resource, idx) => ( + {resource.name} + ), + )} + {server.resources.length === 0 && ( + No resources + )} + + } + > +
+ + Resources: {server.resources.length + server.resourceTemplates.length} +
+
+
+
+ )} + + {/* Error display below expandable section */} + {server.errors && server.errors.length > 0 && ( +
+ {server.errors.map((error, errorIndex) => ( +
+
+ {error.length > 150 ? error.substring(0, 150) + "..." : error} -
+ {error.length > 150 && ( )} - - ))} - > - - - ) : null} - - {/* Tools, Prompts, Resources with counts */} -
- - {server.tools.map((tool, idx) => ( - {tool.name} - ))} - {server.tools.length === 0 && ( - No tools - )} - - } - > -
- - {server.tools.length} +
- - - - {server.prompts.map((prompt, idx) => ( - {prompt.name} - ))} - {server.prompts.length === 0 && ( - No prompts - )} - - } - > -
- - {server.prompts.length} -
-
- - - {[...server.resources, ...server.resourceTemplates].map( - (resource, idx) => ( - {resource.name} - ), - )} - {server.resources.length === 0 && ( - No resources - )} - - } - > -
- - - {server.resources.length + server.resourceTemplates.length} - -
-
+ ))}
-
- -
- {server.isProtectedResource && ( - - )} - -
- -
- -
-
+ )}
); } @@ -233,7 +248,9 @@ function McpSection() { (store) => store.config.config.mcpServerStatuses, ); const { selectedProfile } = useAuth(); + const ideMessenger = useContext(IdeMessengerContext); const disableMcp = currentOrg?.policy?.allowMcpServers === false; + const isLocal = selectedProfile?.profileType === "local"; const mergedBlocks = useMemo(() => { const parsed = selectedProfile?.rawYaml @@ -245,6 +262,19 @@ function McpSection() { })); }, [servers, selectedProfile]); + const handleAddMcpServer = () => { + if (isLocal) { + void ideMessenger.request("config/addLocalWorkspaceBlock", { + blockType: "mcpServers", + }); + } else { + void ideMessenger.request("controlPlane/openUrl", { + path: "new?type=block&blockType=mcpServers", + orgSlug: undefined, + }); + } + }; + if (disableMcp) { return (
@@ -256,21 +286,42 @@ function McpSection() { } return ( -
- - - -
- {mergedBlocks.map(({ block, blockFromYaml }, idx) => ( - - ))} +
+
+
+

MCP Servers

- - + +
+ + {mergedBlocks && mergedBlocks.length > 0 ? ( + mergedBlocks.map(({ block, blockFromYaml }, index) => ( +
+ + + + {index < mergedBlocks.length - 1 &&
} +
+ )) + ) : ( + +
+ + No MCP servers configured. Click the + button to add your first server. + +
+
+ )}
); } diff --git a/gui/src/pages/config/sections/ModelsSection.tsx b/gui/src/pages/config/sections/ModelsSection.tsx index 6bea999fe..dad772d24 100644 --- a/gui/src/pages/config/sections/ModelsSection.tsx +++ b/gui/src/pages/config/sections/ModelsSection.tsx @@ -1,9 +1,9 @@ -import { Cog6ToothIcon } from "@heroicons/react/24/outline"; +import { Cog6ToothIcon, PlusCircleIcon } from "@heroicons/react/24/outline"; import { ModelRole } from "@continuedev/config-yaml"; import { ModelDescription } from "core"; import { useContext } from "react"; import { ToolTip } from "../../../components/gui/Tooltip"; -import { Card } from "../../../components/ui"; +import { Button, Card } from "../../../components/ui"; import { Divider } from "../../../components/ui/Divider"; import { useAuth } from "../../../context/Auth"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; @@ -12,7 +12,6 @@ import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice"; import { updateSelectedModelByRole } from "../../../redux/thunks/updateSelectedModelByRole"; import { isJetBrains } from "../../../util"; -import { ConfigHeader } from "../ConfigHeader"; import ModelRoleSelector from "../components/ModelRoleSelector"; export function ModelsSection() { @@ -49,27 +48,42 @@ export function ModelsSection() { } function handleAddModel() { - dispatch(setShowDialog(true)); - dispatch( - setDialogMessage( - { - dispatch(setShowDialog(false)); - }} - />, - ), - ); + const isLocal = selectedProfile?.profileType === "local"; + + if (isLocal) { + dispatch(setShowDialog(true)); + dispatch( + setDialogMessage( + { + dispatch(setShowDialog(false)); + }} + />, + ), + ); + } else { + void ideMessenger.request("controlPlane/openUrl", { + path: "?type=models", + orgSlug: undefined, + }); + } } return ( -
- + <> +
+
+

Models

+
+ +
@@ -269,6 +283,6 @@ export function ModelsSection() {
-
+ ); } diff --git a/gui/src/pages/config/sections/OrganizationsSection.tsx b/gui/src/pages/config/sections/OrganizationsSection.tsx new file mode 100644 index 000000000..39aa26bef --- /dev/null +++ b/gui/src/pages/config/sections/OrganizationsSection.tsx @@ -0,0 +1,104 @@ +import { Cog6ToothIcon, PlusCircleIcon } from "@heroicons/react/24/outline"; +import { BuildingOfficeIcon, UserIcon } from "@heroicons/react/24/solid"; +import { isOnPremSession } from "core/control-plane/AuthTypes"; +import { useContext } from "react"; +import { Button, Card, Divider } from "../../../components/ui"; +import { useAuth } from "../../../context/Auth"; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; + +function getOrgIcon(org: { name: string; iconUrl?: string | null }) { + if (org.iconUrl) { + return ( + + ); + } + + const IconComponent = org.name === "Personal" ? UserIcon : BuildingOfficeIcon; + return ; +} + +export function OrganizationsSection() { + const { organizations, session } = useAuth(); + const ideMessenger = useContext(IdeMessengerContext); + + const shouldRenderOrgInfo = + session && organizations.length > 1 && !isOnPremSession(session); + + function handleAddOrganization() { + ideMessenger.request("controlPlane/openUrl", { + path: "/organizations/new", + }); + } + + function handleConfigureOrganization(orgId: string) { + ideMessenger.request("controlPlane/openUrl", { + path: `/organizations/${orgId}/settings`, + }); + } + + if (!shouldRenderOrgInfo) { + return ( + <> +
+
+

Organizations

+
+
+ +
+ Organizations are only available with cloud accounts. Sign in to + manage organizations. +
+
+ + ); + } + + return ( + <> +
+
+

Organizations

+
+ +
+ + + {organizations.map((organization, index) => ( +
+
+
+
+ {getOrgIcon(organization)} +
+
+

{organization.name}

+
+
+ +
+ {index < organizations.length - 1 && } +
+ ))} +
+ + ); +} diff --git a/gui/src/pages/config/sections/PromptsSection.tsx b/gui/src/pages/config/sections/PromptsSection.tsx index 59ff484e4..58a3a307e 100644 --- a/gui/src/pages/config/sections/PromptsSection.tsx +++ b/gui/src/pages/config/sections/PromptsSection.tsx @@ -2,19 +2,19 @@ import { parseConfigYaml } from "@continuedev/config-yaml"; import { BookmarkIcon as BookmarkOutline, PencilIcon, + PlusCircleIcon, } from "@heroicons/react/24/outline"; import { BookmarkIcon as BookmarkSolid } from "@heroicons/react/24/solid"; import { SlashCommandDescWithSource } from "core"; import { useContext, useMemo } from "react"; -import { useLump } from "../../../components/mainInput/Lump/LumpContext"; -import { ExploreBlocksButton } from "../../../components/mainInput/Lump/sections/ExploreBlocksButton"; import { useMainEditor } from "../../../components/mainInput/TipTapEditor"; +import { ToolTip } from "../../../components/gui/Tooltip"; +import { Button, Card, EmptyState } from "../../../components/ui"; import { useAuth } from "../../../context/Auth"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; import { useBookmarkedSlashCommands } from "../../../hooks/useBookmarkedSlashCommands"; import { useAppSelector } from "../../../redux/hooks"; import { fontSize } from "../../../util"; -import { ConfigHeader } from "../ConfigHeader"; interface PromptCommandWithSlug extends SlashCommandDescWithSource { slug?: string; @@ -37,7 +37,6 @@ function PromptRow({ onEdit, }: PromptRowProps) { const { mainEditor } = useMainEditor(); - const { hideLump } = useLump(); const handlePromptClick = (e: React.MouseEvent) => { e.stopPropagation(); @@ -46,7 +45,6 @@ function PromptRow({ description: prompt.description, content: prompt.prompt, }); - hideLump(); }; const handleBookmarkClick = (e: React.MouseEvent) => { @@ -108,6 +106,7 @@ export function PromptsSection() { const { selectedProfile } = useAuth(); const { isCommandBookmarked, toggleBookmark } = useBookmarkedSlashCommands(); const ideMessenger = useContext(IdeMessengerContext); + const isLocal = selectedProfile?.profileType === "local"; const slashCommands = useAppSelector( (state) => state.config.config.slashCommands ?? [], @@ -131,6 +130,19 @@ export function PromptsSection() { } }; + const handleAddPrompt = () => { + if (isLocal) { + void ideMessenger.request("config/addLocalWorkspaceBlock", { + blockType: "prompts", + }); + } else { + void ideMessenger.request("controlPlane/openUrl", { + path: "new?type=block&blockType=prompts", + orgSlug: undefined, + }); + } + }; + const sortedCommands = useMemo(() => { const promptsWithSlug: PromptCommandWithSlug[] = structuredClone(slashCommands); @@ -166,17 +178,37 @@ export function PromptsSection() { return (
- - {sortedCommands.map((prompt) => ( - toggleBookmark(prompt)} - onEdit={() => handleEdit(prompt)} - /> - ))} - +
+
+

Prompts

+
+ +
+ + {sortedCommands.length > 0 ? ( +
+ {sortedCommands.map((prompt) => ( + toggleBookmark(prompt)} + onEdit={() => handleEdit(prompt)} + /> + ))} +
+ ) : ( + + + + )}
); } diff --git a/gui/src/pages/config/sections/RulesSection.tsx b/gui/src/pages/config/sections/RulesSection.tsx index 9108b5334..bb2e5d44c 100644 --- a/gui/src/pages/config/sections/RulesSection.tsx +++ b/gui/src/pages/config/sections/RulesSection.tsx @@ -1,18 +1,26 @@ import { parseConfigYaml } from "@continuedev/config-yaml"; import { ArrowsPointingOutIcon, + BookmarkIcon as BookmarkOutline, EyeIcon, PencilIcon, + PlusCircleIcon, } from "@heroicons/react/24/outline"; -import { RuleWithSource } from "core"; +import { BookmarkIcon as BookmarkSolid } from "@heroicons/react/24/solid"; +import { RuleWithSource, SlashCommandDescWithSource } from "core"; import { DEFAULT_AGENT_SYSTEM_MESSAGE, DEFAULT_CHAT_SYSTEM_MESSAGE, DEFAULT_SYSTEM_MESSAGES_URL, } from "core/llm/defaultSystemMessages"; import { useContext, useMemo } from "react"; +import HeaderButtonWithToolTip from "../../../components/gui/HeaderButtonWithToolTip"; +import Switch from "../../../components/gui/Switch"; +import { useMainEditor } from "../../../components/mainInput/TipTapEditor"; +import { Button, Card, EmptyState, useFontSize } from "../../../components/ui"; import { useAuth } from "../../../context/Auth"; import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { useBookmarkedSlashCommands } from "../../../hooks/useBookmarkedSlashCommands"; import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; import { DEFAULT_RULE_SETTING, @@ -20,11 +28,90 @@ import { setShowDialog, toggleRuleSetting, } from "../../../redux/slices/uiSlice"; -import HeaderButtonWithToolTip from "../../../components/gui/HeaderButtonWithToolTip"; -import Switch from "../../../components/gui/Switch"; -import { Card, useFontSize } from "../../../components/ui"; -import { ExploreBlocksButton } from "../../../components/mainInput/Lump/sections/ExploreBlocksButton"; -import { ConfigHeader } from "../ConfigHeader"; +import { fontSize } from "../../../util"; + +interface PromptCommandWithSlug extends SlashCommandDescWithSource { + slug?: string; +} + +interface PromptRowProps { + prompt: PromptCommandWithSlug; + isBookmarked: boolean; + setIsBookmarked: (isBookmarked: boolean) => void; + onEdit?: () => void; +} + +/** + * Displays a single prompt row with bookmark and edit controls + */ +function PromptRow({ + prompt, + isBookmarked, + setIsBookmarked, + onEdit, +}: PromptRowProps) { + const { mainEditor } = useMainEditor(); + + const handlePromptClick = (e: React.MouseEvent) => { + e.stopPropagation(); + mainEditor?.commands.insertPrompt({ + title: prompt.name, + description: prompt.description, + content: prompt.prompt, + }); + }; + + const handleBookmarkClick = (e: React.MouseEvent) => { + e.stopPropagation(); + setIsBookmarked(!isBookmarked); + }; + + const handleEditClick = (e: React.MouseEvent) => { + e.stopPropagation(); + if (onEdit) { + onEdit(); + } + }; + + const canEdit = + prompt.promptFile && !prompt.promptFile.startsWith("builtin:"); + + return ( +
+
+ + {prompt.name} + + + {prompt.description} + +
+
+ +
+ {isBookmarked ? ( + + ) : ( + + )} +
+
+
+ ); +} interface RuleCardProps { rule: RuleWithSource; @@ -181,10 +268,140 @@ const RuleCard: React.FC = ({ rule }) => { ); }; -export function RulesSection() { +/** + * Section that displays all available prompts with bookmarking functionality + */ +function PromptsSubSection() { + const { selectedProfile } = useAuth(); + const { isCommandBookmarked, toggleBookmark } = useBookmarkedSlashCommands(); + const ideMessenger = useContext(IdeMessengerContext); + const isLocal = selectedProfile?.profileType === "local"; + + const slashCommands = useAppSelector( + (state) => state.config.config.slashCommands ?? [], + ); + + const handleEdit = (prompt: PromptCommandWithSlug) => { + if (prompt.promptFile) { + ideMessenger.post("openFile", { + path: prompt.promptFile, + }); + } else if (prompt.slug) { + void ideMessenger.request("controlPlane/openUrl", { + path: `${prompt.slug}/new-version`, + orgSlug: undefined, + }); + } else { + ideMessenger.post("config/openProfile", { + profileId: undefined, + element: { sourceFile: (prompt as any).sourceFile }, + }); + } + }; + + const handleAddPrompt = () => { + if (isLocal) { + void ideMessenger.request("config/addLocalWorkspaceBlock", { + blockType: "prompts", + }); + } else { + void ideMessenger.request("controlPlane/openUrl", { + path: "?type=prompts", + orgSlug: undefined, + }); + } + }; + + const sortedCommands = useMemo(() => { + const promptsWithSlug: PromptCommandWithSlug[] = + structuredClone(slashCommands); + // get the slugs from rawYaml + if (selectedProfile?.rawYaml) { + const parsed = parseConfigYaml(selectedProfile.rawYaml); + const parsedPrompts = parsed.prompts ?? []; + + let index = 0; + for (const commandWithSlug of promptsWithSlug) { + // skip for local prompt files + if (commandWithSlug.promptFile) continue; + + const yamlPrompt = parsedPrompts[index]; + if (yamlPrompt) { + if ("uses" in yamlPrompt) { + commandWithSlug.slug = yamlPrompt.uses; + } else { + commandWithSlug.slug = `${selectedProfile?.fullSlug.ownerSlug}/${selectedProfile?.fullSlug.packageSlug}`; + } + } + index = index + 1; + } + } + return promptsWithSlug.sort((a, b) => { + const aBookmarked = isCommandBookmarked(a.name); + const bBookmarked = isCommandBookmarked(b.name); + if (aBookmarked && !bBookmarked) return -1; + if (!aBookmarked && bBookmarked) return 1; + return 0; + }); + }, [slashCommands, isCommandBookmarked, selectedProfile]); + + return ( +
+
+

Prompts

+ +
+ + {sortedCommands.length > 0 ? ( + +
+ {sortedCommands.map((prompt) => ( + toggleBookmark(prompt)} + onEdit={() => handleEdit(prompt)} + /> + ))} +
+
+ ) : ( + + + + )} +
+ ); +} + +function RulesSubSection() { const { selectedProfile } = useAuth(); const config = useAppSelector((store) => store.config.config); const mode = useAppSelector((store) => store.session.mode); + const ideMessenger = useContext(IdeMessengerContext); + const isLocal = selectedProfile?.profileType === "local"; + + const handleAddRule = () => { + if (isLocal) { + void ideMessenger.request("config/addLocalWorkspaceBlock", { + blockType: "rules", + }); + } else { + void ideMessenger.request("controlPlane/openUrl", { + path: "?type=rules", + orgSlug: undefined, + }); + } + }; + const sortedRules: RuleWithSource[] = useMemo(() => { const rules = [...config.rules.map((rule) => ({ ...rule }))]; @@ -265,16 +482,46 @@ export function RulesSection() { return (
- +
+

Rules

+ +
-
- {sortedRules.map((rule, index) => ( - - ))} - -
+ {sortedRules.length > 0 ? ( +
+ {sortedRules.map((rule, index) => ( + + ))} +
+ ) : ( + + )}
); } + +export function RulesSection() { + return ( + <> +
+
+

Rules

+
+
+ +
+ + +
+ + ); +} diff --git a/gui/src/pages/config/sections/ToolPoliciesSection.tsx b/gui/src/pages/config/sections/ToolPoliciesSection.tsx index ad25c92f0..417fd8d2c 100644 --- a/gui/src/pages/config/sections/ToolPoliciesSection.tsx +++ b/gui/src/pages/config/sections/ToolPoliciesSection.tsx @@ -1,4 +1,5 @@ import { + ChevronDownIcon, ChevronRightIcon, InformationCircleIcon, } from "@heroicons/react/24/outline"; @@ -10,7 +11,7 @@ import { Tooltip } from "react-tooltip"; import Alert from "../../../components/gui/Alert"; import ToggleSwitch from "../../../components/gui/Switch"; import { ToolTip } from "../../../components/gui/Tooltip"; -import { Card } from "../../../components/ui"; +import { Card, Listbox, ListboxButton, ListboxOption, ListboxOptions } from "../../../components/ui"; import { useFontSize } from "../../../components/ui/font"; import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; import { @@ -117,43 +118,46 @@ function ToolPolicyItem(props: ToolDropdownItemProps) {
-
{ - dispatch(toggleToolSetting(props.tool.function.name)); - e.stopPropagation(); - e.preventDefault(); - } - } - > - {disabled || policy === "disabled" ? ( - <> - Off - - Excluded - - - ) : policy === "allowedWithoutPermission" ? ( - <> - Auto - - Automatic - - - ) : ( - // allowedWithPermission - <> - Ask - - Ask First - - - )} +
+ { + if (!disabled && newPolicy !== policy) { + dispatch(toggleToolSetting(props.tool.function.name)); + } + }} + disabled={disabled} + > +
+ + + {disabled || policy === "disabled" + ? "Excluded" + : policy === "allowedWithoutPermission" + ? "Automatic" + : "Ask First"} + + + + {!disabled && ( + + + Automatic + + + Ask First + + + Excluded + + + )} +
+
{mode === "chat" @@ -193,6 +197,9 @@ export const ToolPoliciesSection = () => { (store) => store.ui.toolGroupSettings, ); const dispatch = useAppDispatch(); + const [expandedGroups, setExpandedGroups] = useState<{ + [key: string]: boolean; + }>({}); const toolsByGroup = useMemo(() => { const byGroup: Record = {}; @@ -235,59 +242,90 @@ export const ToolPoliciesSection = () => { const message = getMessage(mode); + const toggleGroup = (groupName: string) => { + setExpandedGroups((prev) => ({ + ...prev, + [groupName]: !prev[groupName], + })); + }; + return (
- - {(mode === "chat" || mode === "plan") && ( -
- - {message} - -
- )} - {toolsByGroup.length === 0 && ( + {(mode === "chat" || mode === "plan") && ( +
+ + {message} + +
+ )} + + {toolsByGroup.length === 0 ? ( + No tools available - )} - {toolsByGroup.map(([groupName, tools]) => { - const isGroupEnabled = - !allToolsOff && toolGroupSettings[groupName] !== "exclude"; - return ( -
-
-

- {groupName} -

- dispatch(toggleToolGroupSetting(groupName))} - text="" - size={10} - disabled={allToolsOff} - /> -
-
- {tools.map((tool) => ( - - ))} -
-
- ); - })} -
+
+ ) : ( +
+ {toolsByGroup.map(([groupName, tools]) => { + const isGroupEnabled = + !allToolsOff && toolGroupSettings[groupName] !== "exclude"; + const isExpanded = expandedGroups[groupName]; + + return ( + +
+
+
toggleGroup(groupName)} + > + +

+ {groupName} +

+
+ {tools.length} +
+
+ dispatch(toggleToolGroupSetting(groupName))} + text="" + size={10} + disabled={allToolsOff} + /> +
+ + {isExpanded && ( +
+ {tools.map((tool) => ( + + ))} +
+ )} +
+
+ ); + })} +
+ )}
); }; diff --git a/gui/src/pages/config/sections/ToolsSection.tsx b/gui/src/pages/config/sections/ToolsSection.tsx new file mode 100644 index 000000000..a91614c1d --- /dev/null +++ b/gui/src/pages/config/sections/ToolsSection.tsx @@ -0,0 +1,682 @@ +import { ConfigYaml, parseConfigYaml } from "@continuedev/config-yaml"; +import { + ArrowPathIcon, + ChevronDownIcon, + ChevronRightIcon, + CircleStackIcon, + CommandLineIcon, + GlobeAltIcon, + InformationCircleIcon, + PlusCircleIcon, + UserCircleIcon, + WrenchScrewdriverIcon, +} from "@heroicons/react/24/outline"; +import { MCPServerStatus, MessageModes, Tool } from "core"; +import { BUILT_IN_GROUP_NAME } from "core/tools/builtIn"; +import { useContext, useEffect, useMemo, useState } from "react"; +import { useDispatch } from "react-redux"; +import { Tooltip } from "react-tooltip"; +import Alert from "../../../components/gui/Alert"; +import ToggleSwitch from "../../../components/gui/Switch"; +import { ToolTip } from "../../../components/gui/Tooltip"; +import EditBlockButton from "../../../components/mainInput/Lump/EditBlockButton"; +import { Button, Card, EmptyState, Listbox, ListboxButton, ListboxOption, ListboxOptions } from "../../../components/ui"; +import { useFontSize } from "../../../components/ui/font"; +import { useAuth } from "../../../context/Auth"; +import { IdeMessengerContext } from "../../../context/IdeMessenger"; +import { useAppDispatch, useAppSelector } from "../../../redux/hooks"; +import { updateConfig } from "../../../redux/slices/configSlice"; +import { selectCurrentOrg } from "../../../redux/slices/profilesSlice"; +import { + addTool, + toggleToolGroupSetting, + toggleToolSetting, +} from "../../../redux/slices/uiSlice"; +import { fontSize } from "../../../util"; +import { ConfigHeader } from "../ConfigHeader"; + +interface MCPServerStatusProps { + server: MCPServerStatus; + serverFromYaml?: NonNullable[number]; +} + +function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) { + const [expandedSections, setExpandedSections] = useState<{ + [key: string]: boolean; + }>({}); + const ideMessenger = useContext(IdeMessengerContext); + const config = useAppSelector((store) => store.config.config); + const dispatch = useAppDispatch(); + + const updateMCPServerStatus = (status: MCPServerStatus["status"]) => { + // optimistic config update + dispatch( + updateConfig({ + ...config, + mcpServerStatuses: config.mcpServerStatuses.map((s) => + s.id === server.id + ? { + ...s, + status, + } + : s, + ), + }), + ); + }; + + const onAuthenticate = async () => { + updateMCPServerStatus("authenticating"); + await ideMessenger.request("mcp/startAuthentication", server); + }; + + const onRemoveAuth = async () => { + updateMCPServerStatus("authenticating"); + await ideMessenger.request("mcp/removeAuthentication", server); + }; + + const onRefresh = async () => { + updateMCPServerStatus("connecting"); + ideMessenger.post("mcp/reloadServer", { + id: server.id, + }); + }; + + const toggleSection = (section: string) => { + setExpandedSections((prev) => ({ + ...prev, + [section]: !prev[section], + })); + }; + + const ResourceRow = ({ + title, + items, + icon, + sectionKey, + }: { + title: string; + items: any[]; + icon: React.ReactNode; + sectionKey: string; + }) => { + const isExpanded = expandedSections[sectionKey]; + const hasItems = items.length > 0; + + return ( +
+
toggleSection(sectionKey)} + > +
+ +
+ {icon} + {title} +
+ {items.length} +
+
+
+
+ + {isExpanded && ( +
+ {hasItems ? ( +
+ {items.map((item, idx) => ( +
+ {item.name} + {item.description && ( +
+ {item.description} +
+ )} +
+ ))} +
+ ) : ( +
+ No {title.toLowerCase()} available +
+ )} +
+ )} +
+ ); + }; + + return ( +
+
+
+
+
+

{server.name}

+
+
+
+
+ +
+ {server.isProtectedResource && ( + + + + )} + + +
+ +
+
+ + + + +
+
+ + {/* Individual resource rows */} +
+ } + sectionKey={`${server.id}-tools`} + /> + + } + sectionKey={`${server.id}-prompts`} + /> + + } + sectionKey={`${server.id}-resources`} + /> +
+ + {/* Error display below expandable section */} + {server.errors && server.errors.length > 0 && ( +
+ {server.errors.map((error, errorIndex) => ( + + void ideMessenger.ide.showVirtualFile(server.name, error) + } + > + + {error.length > 150 ? error.substring(0, 150) + "..." : error} + + + ))} +
+ )} +
+ ); +} + +interface ToolDropdownItemProps { + tool: Tool; + duplicatesDetected: boolean; + isGroupEnabled: boolean; +} + +function ToolPolicyItem(props: ToolDropdownItemProps) { + const dispatch = useDispatch(); + const policy = useAppSelector( + (state) => state.ui.toolSettings[props.tool.function.name], + ); + const [isExpanded, setIsExpanded] = useState(false); + const mode = useAppSelector((state) => state.session.mode); + + useEffect(() => { + if (!policy) { + dispatch(addTool(props.tool)); + } + }, [props.tool.function.name, policy]); + + const parameters = useMemo(() => { + if (props.tool.function.parameters?.properties) { + return Object.entries(props.tool.function.parameters.properties).map( + ([name, schema]) => + [name, schema] as [string, { description: string; type: string }], + ); + } + return undefined; + }, [props.tool.function.parameters]); + + const fontSize = useFontSize(-2); + + const disabled = + !props.isGroupEnabled || + (mode === "plan" && + props.tool.group === BUILT_IN_GROUP_NAME && + !props.tool.readonly); + + if (!policy) { + return null; + } + const disabledTooltipId = `disabled-note-${props.tool.function.name}`; + + return ( +
+
+
+
setIsExpanded((val) => !val)} + > +
+ +
+ { + if (!disabled && newPolicy !== policy) { + dispatch(toggleToolSetting(props.tool.function.name)); + } + }} + disabled={disabled} + > +
+ + + {disabled || policy === "disabled" + ? "Excluded" + : policy === "allowedWithoutPermission" + ? "Automatic" + : "Ask First"} + + + + {!disabled && ( + + + Automatic + + + Ask First + + + Excluded + + + )} +
+
+
+
+ + {mode === "chat" + ? "Tool disabled in chat mode" + : !props.isGroupEnabled + ? "Group is turned off" + : "Tool disabled in plan mode"} + +
+
+ Description: + {props.tool.function.description} + {parameters ? ( + <> + Arguments: + {parameters.map((param, idx) => ( +
+ {param[0]} + {`(${param[1].type}):`} + {param[1].description} +
+ ))} + + ) : null} +
+
+
+ ); +} + +function McpSubsection() { + const currentOrg = useAppSelector(selectCurrentOrg); + const servers = useAppSelector( + (store) => store.config.config.mcpServerStatuses, + ); + const { selectedProfile } = useAuth(); + const ideMessenger = useContext(IdeMessengerContext); + const disableMcp = currentOrg?.policy?.allowMcpServers === false; + const isLocal = selectedProfile?.profileType === "local"; + + const mergedBlocks = useMemo(() => { + const parsed = selectedProfile?.rawYaml + ? parseConfigYaml(selectedProfile?.rawYaml ?? "") + : undefined; + return (servers ?? []).map((doc, index) => ({ + block: doc, + blockFromYaml: parsed?.mcpServers?.[index], + })); + }, [servers, selectedProfile]); + + const handleAddMcpServer = () => { + if (isLocal) { + void ideMessenger.request("config/addLocalWorkspaceBlock", { + blockType: "mcpServers", + }); + } else { + void ideMessenger.request("controlPlane/openUrl", { + path: "?type=mcpServers", + orgSlug: undefined, + }); + } + }; + + return ( +
+
+

MCP Servers

+ {!disableMcp && ( + + )} +
+ {disableMcp ? ( + + + + ) : mergedBlocks.length > 0 ? ( + mergedBlocks.map(({ block, blockFromYaml }, index) => ( +
+ + + + {index < mergedBlocks.length - 1 &&
} +
+ )) + ) : ( + + + + )} +
+ ); +} + +function ToolPoliciesSubsection() { + const mode = useAppSelector((state) => state.session.mode); + const availableTools = useAppSelector((state) => state.config.config.tools); + const toolGroupSettings = useAppSelector( + (store) => store.ui.toolGroupSettings, + ); + const dispatch = useAppDispatch(); + const [expandedGroups, setExpandedGroups] = useState<{ + [key: string]: boolean; + }>({}); + + const toolsByGroup = useMemo(() => { + const byGroup: Record = {}; + for (const tool of availableTools) { + if (!byGroup[tool.group]) { + byGroup[tool.group] = []; + } + byGroup[tool.group].push(tool); + } + return Object.entries(byGroup); + }, [availableTools]); + + // Detect duplicate tool names + const duplicateDetection = useMemo(() => { + const counts: Record = {}; + availableTools.forEach((tool) => { + if (counts[tool.function.name]) { + counts[tool.function.name] = counts[tool.function.name] + 1; + } else { + counts[tool.function.name] = 1; + } + }); + return Object.fromEntries( + Object.entries(counts).map(([k, v]) => [k, v > 1]), + ); + }, [availableTools]); + + const allToolsOff = mode === "chat"; + + const getMessage = (mode: MessageModes) => { + switch (mode) { + case "chat": + return "All tools disabled in Chat, switch to Plan or Agent mode to use tools"; + case "plan": + return "Read-only/MCP tools available in Plan mode"; + default: + return ""; + } + }; + + const message = getMessage(mode); + + const toggleGroup = (groupName: string) => { + setExpandedGroups((prev) => ({ + ...prev, + [groupName]: !prev[groupName], + })); + }; + + if (toolsByGroup.length === 0) { + return null; + } + + return ( +
+

Tool Policies

+ + {(mode === "chat" || mode === "plan") && ( +
+ + {message} + +
+ )} + +
+ {toolsByGroup.map(([groupName, tools]) => { + const isGroupEnabled = + !allToolsOff && toolGroupSettings[groupName] !== "exclude"; + const isExpanded = expandedGroups[groupName]; + + return ( + +
+
+
toggleGroup(groupName)} + > + +
+ {groupName} +
+ {tools.length} +
+
+
+ +
+ dispatch(toggleToolGroupSetting(groupName))} + text="" + size={10} + disabled={allToolsOff} + /> +
+
+
+ + {isExpanded && ( +
+ {tools.map((tool) => ( + + ))} +
+ )} +
+
+ ); + })} +
+
+ ); +} + +export function ToolsSection() { + const availableTools = useAppSelector((state) => state.config.config.tools); + + const hasTools = availableTools && availableTools.length > 0; + + return ( +
+ +
+ + {hasTools && } +
+
+ ); +} diff --git a/gui/src/pages/config/sections/UserSettingsSection.tsx b/gui/src/pages/config/sections/UserSettingsSection.tsx index b63b4dae7..33f23338d 100644 --- a/gui/src/pages/config/sections/UserSettingsSection.tsx +++ b/gui/src/pages/config/sections/UserSettingsSection.tsx @@ -125,9 +125,8 @@ export function UserSettingsSection() { return (
{hubEnabled ? ( -
+
-
{/* Chat Interface Settings */}
diff --git a/gui/src/components/mainInput/Lump/sections/docs/DocsDetailsDialog.tsx b/gui/src/pages/config/sections/docs/DocsDetailsDialog.tsx similarity index 96% rename from gui/src/components/mainInput/Lump/sections/docs/DocsDetailsDialog.tsx rename to gui/src/pages/config/sections/docs/DocsDetailsDialog.tsx index 4d5f27099..90d4c88f5 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/DocsDetailsDialog.tsx +++ b/gui/src/pages/config/sections/docs/DocsDetailsDialog.tsx @@ -2,12 +2,12 @@ import { DocsIndexingDetails } from "core"; import { useCallback, useContext, useEffect, useState } from "react"; import { useDispatch } from "react-redux"; import { Tooltip } from "react-tooltip"; -import { SecondaryButton } from "../../../.."; -import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; +import { SecondaryButton } from "../../../../components"; +import { IdeMessengerContext } from "../../../../context/IdeMessenger"; import { setDialogMessage, setShowDialog, -} from "../../../../../redux/slices/uiSlice"; +} from "../../../../redux/slices/uiSlice"; interface DocsDetailsDialogProps { startUrl: string; diff --git a/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingPeeks.tsx b/gui/src/pages/config/sections/docs/DocsIndexingPeeks.tsx similarity index 97% rename from gui/src/components/mainInput/Lump/sections/docs/DocsIndexingPeeks.tsx rename to gui/src/pages/config/sections/docs/DocsIndexingPeeks.tsx index 548cde046..eb5946923 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingPeeks.tsx +++ b/gui/src/pages/config/sections/docs/DocsIndexingPeeks.tsx @@ -5,7 +5,7 @@ import { useNavigate } from "react-router-dom"; import { setDialogMessage, setShowDialog, -} from "../../../../../redux/slices/uiSlice"; +} from "../../../../redux/slices/uiSlice"; export interface DocsIndexingPeekProps { status: IndexingStatus; diff --git a/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.test.tsx b/gui/src/pages/config/sections/docs/DocsIndexingStatus.test.tsx similarity index 97% rename from gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.test.tsx rename to gui/src/pages/config/sections/docs/DocsIndexingStatus.test.tsx index ab4524482..7657e4470 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.test.tsx +++ b/gui/src/pages/config/sections/docs/DocsIndexingStatus.test.tsx @@ -8,9 +8,9 @@ import { import { SiteIndexingConfig } from "core"; import { Provider } from "react-redux"; import { beforeEach, describe, expect, it, vi } from "vitest"; -import { AuthProvider } from "../../../../../context/Auth"; -import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; -import { createMockStore } from "../../../../../util/test/mockStore"; +import { AuthProvider } from "../../../../context/Auth"; +import { IdeMessengerContext } from "../../../../context/IdeMessenger"; +import { createMockStore } from "../../../../util/test/mockStore"; import DocsIndexingStatus from "./DocsIndexingStatus"; const mockLumpContext = { diff --git a/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx b/gui/src/pages/config/sections/docs/DocsIndexingStatus.tsx similarity index 91% rename from gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx rename to gui/src/pages/config/sections/docs/DocsIndexingStatus.tsx index ac7afe5d5..acd5775e5 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx +++ b/gui/src/pages/config/sections/docs/DocsIndexingStatus.tsx @@ -2,18 +2,17 @@ import { ConfigYaml } from "@continuedev/config-yaml"; import { ArrowPathIcon, StopIcon } from "@heroicons/react/24/outline"; import { SiteIndexingConfig } from "core"; import { useContext, useEffect, useMemo, useState } from "react"; -import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; -import { useAppDispatch, useAppSelector } from "../../../../../redux/hooks"; -import { updateIndexingStatus } from "../../../../../redux/slices/indexingSlice"; +import { IdeMessengerContext } from "../../../../context/IdeMessenger"; +import { useAppDispatch, useAppSelector } from "../../../../redux/hooks"; +import { updateIndexingStatus } from "../../../../redux/slices/indexingSlice"; import { setDialogMessage, setShowDialog, -} from "../../../../../redux/slices/uiSlice"; -import { fontSize } from "../../../../../util"; -import ConfirmationDialog from "../../../../dialogs/ConfirmationDialog"; -import { ToolTip } from "../../../../gui/Tooltip"; -import EditBlockButton from "../../EditBlockButton"; -import { useLump } from "../../LumpContext"; +} from "../../../../redux/slices/uiSlice"; +import { fontSize } from "../../../../util"; +import ConfirmationDialog from "../../../../components/dialogs/ConfirmationDialog"; +import { ToolTip } from "../../../../components/gui/Tooltip"; +import EditBlockButton from "../../../../components/mainInput/Lump/EditBlockButton"; import { IndexedPagesTooltip } from "./IndexedPagesTooltip"; import { StatusIndicator } from "./StatusIndicator"; @@ -28,7 +27,6 @@ function DocsIndexingStatus({ }: IndexingStatusViewerProps) { const ideMessenger = useContext(IdeMessengerContext); const dispatch = useAppDispatch(); - const { hideLump } = useLump(); const [indexedPages, setIndexedPages] = useState(null); const [showTooltip, setShowTooltip] = useState(false); @@ -127,7 +125,6 @@ function DocsIndexingStatus({ onClick={() => { if (status?.url) { ideMessenger.post("openUrl", status.url); - hideLump(); } }} > diff --git a/gui/src/components/mainInput/Lump/sections/docs/DocsSection.tsx b/gui/src/pages/config/sections/docs/DocsSection.tsx similarity index 87% rename from gui/src/components/mainInput/Lump/sections/docs/DocsSection.tsx rename to gui/src/pages/config/sections/docs/DocsSection.tsx index e7913d1ef..13526ecd0 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/DocsSection.tsx +++ b/gui/src/pages/config/sections/docs/DocsSection.tsx @@ -1,9 +1,9 @@ import { parseConfigYaml } from "@continuedev/config-yaml"; import { IndexingStatus } from "core"; import { useMemo } from "react"; -import { useAuth } from "../../../../../context/Auth"; -import { useAppSelector } from "../../../../../redux/hooks"; -import { ExploreBlocksButton } from "../ExploreBlocksButton"; +import { useAuth } from "../../../../context/Auth"; +import { useAppSelector } from "../../../../redux/hooks"; +import { EmptyState } from "../../../../components/ui"; import DocsIndexingStatus from "./DocsIndexingStatus"; function DocsIndexingStatuses() { @@ -48,6 +48,12 @@ function DocsIndexingStatuses() { return docs; }, [mergedDocs, indexingStatuses]); + if (sortedConfigDocs.length === 0) { + return ( + + ); + } + return (
@@ -67,7 +73,6 @@ function DocsIndexingStatuses() { ); })}
-
); } diff --git a/gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.test.tsx b/gui/src/pages/config/sections/docs/IndexedPagesTooltip.test.tsx similarity index 97% rename from gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.test.tsx rename to gui/src/pages/config/sections/docs/IndexedPagesTooltip.test.tsx index d585758eb..80a620a01 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.test.tsx +++ b/gui/src/pages/config/sections/docs/IndexedPagesTooltip.test.tsx @@ -1,8 +1,8 @@ import { fireEvent, render, screen } from "@testing-library/react"; import { Provider } from "react-redux"; import { beforeEach, describe, expect, it, vi } from "vitest"; -import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; -import { createMockStore } from "../../../../../util/test/mockStore"; +import { IdeMessengerContext } from "../../../../context/IdeMessenger"; +import { createMockStore } from "../../../../util/test/mockStore"; import { IndexedPagesTooltip } from "./IndexedPagesTooltip"; describe("IndexedPagesTooltip", () => { diff --git a/gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.tsx b/gui/src/pages/config/sections/docs/IndexedPagesTooltip.tsx similarity index 91% rename from gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.tsx rename to gui/src/pages/config/sections/docs/IndexedPagesTooltip.tsx index da3ffa3f7..5ef6f5fcc 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/IndexedPagesTooltip.tsx +++ b/gui/src/pages/config/sections/docs/IndexedPagesTooltip.tsx @@ -1,12 +1,12 @@ import { EyeIcon } from "@heroicons/react/24/outline"; import { useContext } from "react"; import { useDispatch } from "react-redux"; -import { IdeMessengerContext } from "../../../../../context/IdeMessenger"; +import { IdeMessengerContext } from "../../../../context/IdeMessenger"; import { setDialogMessage, setShowDialog, -} from "../../../../../redux/slices/uiSlice"; -import { fontSize } from "../../../../../util"; +} from "../../../../redux/slices/uiSlice"; +import { fontSize } from "../../../../util"; import DocsDetailsDialog from "./DocsDetailsDialog"; interface IndexedPagesTooltipProps { diff --git a/gui/src/components/mainInput/Lump/sections/docs/StatusIndicator.tsx b/gui/src/pages/config/sections/docs/StatusIndicator.tsx similarity index 93% rename from gui/src/components/mainInput/Lump/sections/docs/StatusIndicator.tsx rename to gui/src/pages/config/sections/docs/StatusIndicator.tsx index 8d118b0a3..97fcb0d40 100644 --- a/gui/src/components/mainInput/Lump/sections/docs/StatusIndicator.tsx +++ b/gui/src/pages/config/sections/docs/StatusIndicator.tsx @@ -1,5 +1,5 @@ import { IndexingStatus } from "core"; -import { ToolTip } from "../../../../gui/Tooltip"; +import { ToolTip } from "../../../../components/gui/Tooltip"; interface StatusIndicatorProps { status?: IndexingStatus["status"]; diff --git a/gui/src/util/test/render.tsx b/gui/src/util/test/render.tsx index 0ca3c7e3c..7a2838e4b 100644 --- a/gui/src/util/test/render.tsx +++ b/gui/src/util/test/render.tsx @@ -4,7 +4,6 @@ import userEvent from "@testing-library/user-event"; import { PropsWithChildren } from "react"; import { Provider } from "react-redux"; import { MemoryRouter, RouterProps } from "react-router-dom"; -import { LumpProvider } from "../../components/mainInput/Lump/LumpContext"; import { MainEditorProvider } from "../../components/mainInput/TipTapEditor"; import { AuthProvider } from "../../context/Auth"; import { IdeMessengerProvider } from "../../context/IdeMessenger"; @@ -52,10 +51,8 @@ export async function renderWithProviders( - - {children} - - + {children} +