done
This commit is contained in:
parent
c7b3019b1c
commit
1c720c97bc
45 changed files with 2000 additions and 1010 deletions
|
|
@ -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 (
|
||||
<ListboxOption
|
||||
value={profile.id}
|
||||
|
|
@ -74,41 +66,18 @@ export function AssistantOption({
|
|||
<AssistantIcon assistant={profile} />
|
||||
</div>
|
||||
<span
|
||||
className={`line-clamp-1 flex-1 ${selected ? "font-semibold" : ""}`}
|
||||
className={`line-clamp-1 flex-1 ${selected ? "font-semibold" : ""} ${profile.errors && profile.errors.length > 0 ? "text-error" : ""}`}
|
||||
>
|
||||
{profile.title}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex flex-row items-center gap-1.5">
|
||||
{profile.errors && profile.errors?.length > 0 && (
|
||||
<ExclamationTriangleIcon
|
||||
data-tooltip-id={`${profile.id}-errors-tooltip`}
|
||||
className="text-error h-3.5 w-3.5 flex-shrink-0 cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
handleClickError();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{isLocalProfile(profile) ? (
|
||||
<Cog6ToothIcon
|
||||
className="text-description h-3.5 w-3.5 flex-shrink-0 cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
handleConfigure();
|
||||
}}
|
||||
/>
|
||||
) : (
|
||||
<Cog6ToothIcon
|
||||
className="text-description h-3.5 w-3.5 flex-shrink-0 cursor-pointer"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
handleConfigure();
|
||||
}}
|
||||
/>
|
||||
<ToolTip content="View errors">
|
||||
<ExclamationTriangleIcon
|
||||
className="text-error h-3.5 w-3.5 flex-shrink-0"
|
||||
/>
|
||||
</ToolTip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
>
|
||||
<div className={`flex flex-row items-center ${isLarge ? "justify-between w-full" : "gap-1.5"}`}>
|
||||
<div className="flex flex-row items-center gap-1.5">
|
||||
<div
|
||||
className={`flex flex-row items-center ${isLarge ? "w-full justify-between" : "gap-1.5"}`}
|
||||
>
|
||||
<div className="flex flex-row items-center gap-2">
|
||||
{selectedProfile === null ? (
|
||||
"Create your first agent"
|
||||
) : configLoading ? (
|
||||
|
|
@ -48,14 +50,16 @@ export function SelectedAssistantButton({
|
|||
<div className={`${iconSize} flex-shrink-0 select-none`}>
|
||||
<AssistantIcon assistant={selectedProfile} />
|
||||
</div>
|
||||
<span className={`${isLarge ? "hidden md:block" : "hidden md:block"} line-clamp-1 select-none break-all`}>
|
||||
<span
|
||||
className={`${isLarge ? "hidden md:block" : "hidden md:block"} select-none break-words`}
|
||||
>
|
||||
{selectedProfile.title}
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<ChevronDownIcon
|
||||
className={`${isLarge ? "h-3.5 w-3.5" : "h-2 w-2"} flex-shrink-0 select-none`}
|
||||
className={`text-description ${isLarge ? "h-3.5 w-3.5" : "h-2 w-2"} ${isLarge ? "ml-1.5" : "ml-0.5"} flex-shrink-0 select-none`}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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<HTMLDivElement>(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 (
|
||||
<Listbox>
|
||||
<div className="relative" ref={listboxRef}>
|
||||
<SelectedAssistantButton selectedProfile={selectedProfile} variant={variant} />
|
||||
<SelectedAssistantButton
|
||||
selectedProfile={selectedProfile}
|
||||
variant={variant}
|
||||
/>
|
||||
<Transition>
|
||||
<ListboxOptions
|
||||
className="-translate-x-1.5 pb-0 max-h-32 overflow-y-auto"
|
||||
className="max-h-32 -translate-x-1.5 overflow-y-auto pb-0"
|
||||
style={{ zIndex: 200 }}
|
||||
>
|
||||
<div className="flex items-center justify-between p-2">
|
||||
<span className="text-description text-xs font-medium">
|
||||
Agents
|
||||
</span>
|
||||
<div className="flex items-center gap-0.5">
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onNewAssistant();
|
||||
}}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-5 w-5 p-0"
|
||||
>
|
||||
<PlusIcon className="text-description h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onAgentsConfig();
|
||||
}}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-5 w-5 p-0"
|
||||
>
|
||||
<Cog6ToothIcon className="text-description h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<AssistantOptions
|
||||
|
|
@ -136,6 +199,30 @@ export function AssistantAndOrgListbox({ variant = "small" }: AssistantAndOrgLis
|
|||
<span className="text-description text-xs font-medium">
|
||||
Organizations
|
||||
</span>
|
||||
<div className="flex items-center gap-0.5">
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onNewOrganization();
|
||||
}}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-5 w-5 p-0"
|
||||
>
|
||||
<PlusIcon className="text-description h-3.5 w-3.5" />
|
||||
</Button>
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onOrganizationsConfig();
|
||||
}}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-5 w-5 p-0"
|
||||
>
|
||||
<Cog6ToothIcon className="text-description h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<OrganizationOptions onClose={close} />
|
||||
|
|
@ -144,45 +231,64 @@ export function AssistantAndOrgListbox({ variant = "small" }: AssistantAndOrgLis
|
|||
</>
|
||||
)}
|
||||
|
||||
{/* Settings Section */}
|
||||
{variant !== "sidebar" && (
|
||||
<div>
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onRulesConfig();
|
||||
}}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="text-description hover:bg-input my-0 w-full justify-start py-2 pl-1 text-left"
|
||||
>
|
||||
<div className="flex w-full items-center">
|
||||
<PencilIcon className="ml-1.5 mr-2 h-3.5 w-3.5 flex-shrink-0" />
|
||||
<span className="text-2xs">Rules</span>
|
||||
</div>
|
||||
</Button>
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
onToolsConfig();
|
||||
}}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="text-description hover:bg-input my-0 w-full justify-start py-2 pl-1 text-left"
|
||||
>
|
||||
<div className="flex w-full items-center">
|
||||
<WrenchScrewdriverIcon className="ml-1.5 mr-2 h-3.5 w-3.5 flex-shrink-0" />
|
||||
<span className="text-2xs">Tools</span>
|
||||
</div>
|
||||
</Button>
|
||||
|
||||
<Divider className="!mt-0" />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Bottom Actions */}
|
||||
<div>
|
||||
<ListboxOption
|
||||
value="new-assistant"
|
||||
fontSizeModifier={-2}
|
||||
className="border-border border-b px-2 py-2"
|
||||
onClick={onNewAssistant}
|
||||
>
|
||||
<span className="text-description text-2xs flex flex-row items-center">
|
||||
<PlusIcon className="mr-1.5 h-3.5 w-3.5" /> New Agent
|
||||
</span>
|
||||
</ListboxOption>
|
||||
|
||||
<ListboxOption
|
||||
value="reload-assistant"
|
||||
fontSizeModifier={-2}
|
||||
className="border-border border-b px-2 py-2"
|
||||
onClick={(e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
refreshProfiles("Manual refresh from assistant list");
|
||||
}}
|
||||
>
|
||||
<span className="text-description text-2xs flex flex-row items-center">
|
||||
<ArrowPathIcon
|
||||
className={cn(
|
||||
"mr-1.5 h-3.5 w-3.5",
|
||||
configLoading && "animate-spin-slow",
|
||||
)}
|
||||
/>
|
||||
Reload agents
|
||||
</span>
|
||||
</ListboxOption>
|
||||
|
||||
<Divider className="!my-0" />
|
||||
|
||||
<div className="text-description flex items-center justify-between gap-1.5 px-2 py-2">
|
||||
<span className="block" style={{ fontSize: tinyFont }}>
|
||||
<code>{getMetaKeyLabel()} ⇧ '</code> to toggle agent
|
||||
</span>
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
refreshProfiles("Manual refresh from assistant list");
|
||||
}}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-5 w-5 p-0"
|
||||
>
|
||||
<ArrowPathIcon
|
||||
className={cn(
|
||||
"text-description h-3.5 w-3.5",
|
||||
configLoading && "animate-spin-slow",
|
||||
)}
|
||||
/>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</ListboxOptions>
|
||||
|
|
|
|||
|
|
@ -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 = () => {
|
|||
}}
|
||||
/>
|
||||
)}
|
||||
<LumpProvider>
|
||||
<OSRContextMenu />
|
||||
<div
|
||||
style={{
|
||||
scrollbarGutter: "stable both-edges",
|
||||
minHeight: "100%",
|
||||
display: "grid",
|
||||
gridTemplateRows: "1fr auto",
|
||||
<OSRContextMenu />
|
||||
<div
|
||||
style={{
|
||||
scrollbarGutter: "stable both-edges",
|
||||
minHeight: "100%",
|
||||
display: "grid",
|
||||
gridTemplateRows: "1fr auto",
|
||||
}}
|
||||
>
|
||||
<TextDialog
|
||||
showDialog={showDialog}
|
||||
onEnter={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
>
|
||||
<TextDialog
|
||||
showDialog={showDialog}
|
||||
onEnter={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
onClose={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
message={dialogMessage}
|
||||
/>
|
||||
onClose={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
message={dialogMessage}
|
||||
/>
|
||||
|
||||
<GridDiv>
|
||||
<PostHogPageView />
|
||||
<Outlet />
|
||||
<FatalErrorIndicator />
|
||||
</GridDiv>
|
||||
</div>
|
||||
<div style={{ fontSize: fontSize(-4) }} id="tooltip-portal-div" />
|
||||
</LumpProvider>
|
||||
<GridDiv>
|
||||
<PostHogPageView />
|
||||
<Outlet />
|
||||
<FatalErrorIndicator />
|
||||
</GridDiv>
|
||||
</div>
|
||||
<div style={{ fontSize: fontSize(-4) }} id="tooltip-portal-div" />
|
||||
</LayoutTopDiv>
|
||||
</TelemetryProviders>
|
||||
</AuthProvider>
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 = () => {
|
|||
</div>
|
||||
)}
|
||||
<div
|
||||
onClick={showLumpErrorSection}
|
||||
className={`cursor-pointer underline transition-all ${selectedSection === "error" ? "opacity-0" : ""}`}
|
||||
onClick={showConfigPage}
|
||||
className="cursor-pointer underline"
|
||||
>
|
||||
View
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<div
|
||||
className={cn(
|
||||
`flex flex-row items-center ${background} border-[0.5px] ${border} border-solid shadow-sm ${alertSizes[size]}`,
|
||||
props.className,
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
<Icon className={`flex-shrink-0 ${iconColor} ${iconSizes[size]}`} />
|
||||
<div className="flex flex-1 flex-col">
|
||||
<div className={`${spacingSizes[size]} ${text}`}>{props.children}</div>
|
||||
<div className={`${spacingSizes[size]} ${text}`}>{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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<LumpContextType | undefined>(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<string | null>(null);
|
||||
const [displayedSection, setDisplayedSection] = useState<string | null>(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 (
|
||||
<LumpContext.Provider
|
||||
value={{
|
||||
isLumpVisible: isVisible,
|
||||
selectedSection,
|
||||
displayedSection,
|
||||
isToolbarExpanded,
|
||||
hideLump,
|
||||
setSelectedSection,
|
||||
toggleToolbar,
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</LumpContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
|
@ -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: <ErrorsSectionTooltip />,
|
||||
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 (
|
||||
<div className="flex flex-1 items-center justify-between gap-2">
|
||||
<div className="flex flex-row">
|
||||
<div className="flex items-center justify-center gap-0.5">
|
||||
{visibleSections.map((section) => (
|
||||
<BlockSettingsToolbarIcon
|
||||
key={section.id}
|
||||
sectionId={section.id}
|
||||
icon={section.icon}
|
||||
tooltip={section.tooltip}
|
||||
title={section.title}
|
||||
isSelected={selectedSection === section.id}
|
||||
onClick={() =>
|
||||
setSelectedSection(
|
||||
selectedSection === section.id ? null : section.id,
|
||||
)
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-0.5">
|
||||
<ToolTip
|
||||
place="top"
|
||||
content={isUsingFreeTrial ? "View free trial usage" : "Select Agent"}
|
||||
<div className="flex flex-1 items-center justify-end gap-1.5">
|
||||
{shouldShowError && errorSection && (
|
||||
<BlockSettingsToolbarIcon
|
||||
sectionId={errorSection.id}
|
||||
icon={errorSection.icon}
|
||||
tooltip={errorSection.tooltip}
|
||||
title={errorSection.title}
|
||||
isSelected={false}
|
||||
onClick={() => navigate("/config?tab=agents")}
|
||||
/>
|
||||
)}
|
||||
<ToolTip
|
||||
place="top"
|
||||
content={isUsingFreeTrial ? "View free trial usage" : "Select Agent"}
|
||||
>
|
||||
<HoverItem
|
||||
data-tooltip-id="assistant-select-tooltip"
|
||||
className="!m-0 !p-0"
|
||||
>
|
||||
<HoverItem
|
||||
data-tooltip-id="assistant-select-tooltip"
|
||||
className="!m-0 !p-0"
|
||||
>
|
||||
{isUsingFreeTrial ? (
|
||||
<FreeTrialButton freeTrialStatus={freeTrialStatus} />
|
||||
) : (
|
||||
<AssistantAndOrgListbox />
|
||||
)}
|
||||
</HoverItem>
|
||||
</ToolTip>
|
||||
</div>
|
||||
{isUsingFreeTrial ? (
|
||||
<FreeTrialButton freeTrialStatus={freeTrialStatus} />
|
||||
) : (
|
||||
<AssistantAndOrgListbox variant="lump" />
|
||||
)}
|
||||
</HoverItem>
|
||||
</ToolTip>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<div className="bg-input rounded-t-default border-command-border mx-1.5 border-l border-r border-t">
|
||||
<div className="xs:px-2 px-1 py-0.5">
|
||||
<LumpToolbar />
|
||||
|
||||
<div
|
||||
className={`no-scrollbar overflow-y-auto pr-0.5 transition-all duration-300 ease-in-out ${
|
||||
selectedSection
|
||||
? "my-1 max-h-[200px] opacity-100"
|
||||
: "my-0 max-h-0 opacity-0"
|
||||
} ${isLumpVisible ? "opacity-100" : "opacity-0"}`}
|
||||
>
|
||||
<SelectedSection />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
import { ComponentType, SVGProps } from "react";
|
||||
import { GhostButton } from "../../..";
|
||||
import { fontSize } from "../../../../util";
|
||||
|
||||
interface BaseIconButtonProps {
|
||||
icon: ComponentType<SVGProps<SVGSVGElement>>;
|
||||
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 (
|
||||
<GhostButton
|
||||
className={className}
|
||||
style={style}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
onClick(e);
|
||||
}}
|
||||
>
|
||||
<div className="flex items-center justify-center gap-1">
|
||||
<Icon className="h-3 w-3 pr-1" />
|
||||
<span className="text-[11px]">{text}</span>
|
||||
</div>
|
||||
</GhostButton>
|
||||
);
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
export function ContextSection() {
|
||||
return <div>Context content</div>;
|
||||
}
|
||||
|
|
@ -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 (
|
||||
<BaseIconButton
|
||||
icon={config.icon}
|
||||
text={config.text}
|
||||
onClick={config.action}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
@ -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 <ContextSection />;
|
||||
case "error":
|
||||
return <ErrorSection />;
|
||||
default:
|
||||
return 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 (
|
||||
<div className="flex flex-col gap-2 p-2">
|
||||
<div className="flex flex-row items-center justify-end gap-1.5">
|
||||
<div
|
||||
className={`text-description cursor-pointer text-xs underline transition-all ${configLoading ? "opacity-0" : ""}`}
|
||||
onClick={() => {
|
||||
refreshProfiles("Clicked reload in Error section");
|
||||
}}
|
||||
>
|
||||
Reload
|
||||
</div>
|
||||
<div
|
||||
onClick={() => {
|
||||
ideMessenger.post(
|
||||
"openUrl",
|
||||
"https://docs.continue.dev/troubleshooting",
|
||||
);
|
||||
}}
|
||||
className="text-description cursor-pointer text-xs underline"
|
||||
>
|
||||
Help
|
||||
</div>
|
||||
</div>
|
||||
<ul className="m-0 list-none space-y-4 p-0">
|
||||
{sortedErrors.map((error, index) => (
|
||||
<li
|
||||
key={index}
|
||||
className={`flex items-start rounded-md p-2 text-sm shadow-md ${
|
||||
error.fatal
|
||||
? "bg-red-100 text-red-800"
|
||||
: "bg-yellow-100 text-yellow-800"
|
||||
}`}
|
||||
>
|
||||
{error.fatal ? (
|
||||
<ExclamationCircleIcon className="mr-2 mt-1 h-3.5 w-3.5 shrink-0" />
|
||||
) : (
|
||||
<ExclamationTriangleIcon className="mr-2 mt-1 h-3.5 w-3.5 shrink-0" />
|
||||
)}
|
||||
<p
|
||||
className="m-0 whitespace-pre-wrap text-wrap"
|
||||
style={{ wordBreak: "break-word" }}
|
||||
>
|
||||
{error.message}
|
||||
</p>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -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 (
|
||||
<div>
|
||||
<span>{`${numErrors} Config Error${plural}`}</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
@ -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<SVGProps<SVGSVGElement>>;
|
||||
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);
|
||||
}
|
||||
11
gui/src/components/ui/EmptyState.tsx
Normal file
11
gui/src/components/ui/EmptyState.tsx
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
interface EmptyStateProps {
|
||||
message: string;
|
||||
}
|
||||
|
||||
export function EmptyState({ message }: EmptyStateProps) {
|
||||
return (
|
||||
<div className="flex flex-col items-center justify-center p-4">
|
||||
<span className="text-description text-sm">{message}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
17
gui/src/pages/config/components/ConfigSection.tsx
Normal file
17
gui/src/pages/config/components/ConfigSection.tsx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import React from "react";
|
||||
|
||||
interface ConfigSectionProps {
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function ConfigSection({
|
||||
children,
|
||||
className = "",
|
||||
}: ConfigSectionProps) {
|
||||
return (
|
||||
<div className={`py-4 ${className}`}>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -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: (
|
||||
<div className="mt-4">
|
||||
<ConfigSection>
|
||||
<ModelsSection />
|
||||
</div>
|
||||
</ConfigSection>
|
||||
),
|
||||
icon: <CubeIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />,
|
||||
},
|
||||
|
|
@ -65,39 +67,19 @@ export const topTabSections: TabSection[] = [
|
|||
id: "rules",
|
||||
label: "Rules",
|
||||
component: (
|
||||
<div className="mt-4">
|
||||
<ConfigSection>
|
||||
<RulesSection />
|
||||
</div>
|
||||
</ConfigSection>
|
||||
),
|
||||
icon: <PencilIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />,
|
||||
},
|
||||
{
|
||||
id: "prompts",
|
||||
label: "Prompts",
|
||||
component: (
|
||||
<div className="mt-4">
|
||||
<PromptsSection />
|
||||
</div>
|
||||
),
|
||||
icon: (
|
||||
<ChatBubbleLeftRightIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "mcp",
|
||||
label: "MCP",
|
||||
component: <McpSection />,
|
||||
icon: (
|
||||
<Squares2X2Icon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "tools",
|
||||
label: "Tools",
|
||||
component: (
|
||||
<div className="mt-4">
|
||||
<ToolPoliciesSection />
|
||||
</div>
|
||||
<ConfigSection>
|
||||
<ToolsSection />
|
||||
</ConfigSection>
|
||||
),
|
||||
icon: (
|
||||
<WrenchScrewdriverIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />
|
||||
|
|
@ -105,6 +87,36 @@ export const topTabSections: TabSection[] = [
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "agents-orgs",
|
||||
showTopDivider: true,
|
||||
tabs: [
|
||||
{
|
||||
id: "agents",
|
||||
label: "Agents",
|
||||
component: (
|
||||
<ConfigSection>
|
||||
<AgentsSection />
|
||||
</ConfigSection>
|
||||
),
|
||||
icon: (
|
||||
<BotIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" size={16} />
|
||||
),
|
||||
},
|
||||
{
|
||||
id: "organizations",
|
||||
label: "Organizations",
|
||||
component: (
|
||||
<ConfigSection>
|
||||
<OrganizationsSection />
|
||||
</ConfigSection>
|
||||
),
|
||||
icon: (
|
||||
<BuildingOfficeIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />
|
||||
),
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "indexing",
|
||||
showTopDivider: true,
|
||||
|
|
@ -112,7 +124,11 @@ export const topTabSections: TabSection[] = [
|
|||
{
|
||||
id: "indexing",
|
||||
label: "Indexing",
|
||||
component: <IndexingSettingsSection />,
|
||||
component: (
|
||||
<ConfigSection>
|
||||
<IndexingSettingsSection />
|
||||
</ConfigSection>
|
||||
),
|
||||
icon: (
|
||||
<CircleStackIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />
|
||||
),
|
||||
|
|
@ -128,16 +144,20 @@ export const bottomTabSections: TabSection[] = [
|
|||
{
|
||||
id: "settings",
|
||||
label: "Settings",
|
||||
component: <UserSettingsSection />,
|
||||
component: (
|
||||
<ConfigSection>
|
||||
<UserSettingsSection />
|
||||
</ConfigSection>
|
||||
),
|
||||
icon: <Cog6ToothIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />,
|
||||
},
|
||||
{
|
||||
id: "help",
|
||||
label: "Help",
|
||||
component: (
|
||||
<div className="mt-4">
|
||||
<ConfigSection>
|
||||
<HelpSection />
|
||||
</div>
|
||||
</ConfigSection>
|
||||
),
|
||||
icon: (
|
||||
<QuestionMarkCircleIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<div className="mt-4 flex flex-col">
|
||||
<div className="flex flex-col">
|
||||
<div className="mb-0 flex justify-between text-sm">
|
||||
<IndexingProgressTitleText update={update} />
|
||||
{!["loading", "waiting"].includes(update.status) && (
|
||||
|
|
|
|||
|
|
@ -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 && (
|
||||
<>
|
||||
<Divider />
|
||||
<AssistantAndOrgListbox variant="large" />
|
||||
<AssistantAndOrgListbox variant="sidebar" />
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
|
|
|
|||
86
gui/src/pages/config/sections/AgentsSection.tsx
Normal file
86
gui/src/pages/config/sections/AgentsSection.tsx
Normal file
|
|
@ -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 (
|
||||
<>
|
||||
<div className="mb-8 flex items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<h2 className="mb-0 text-xl font-semibold">Agents</h2>
|
||||
</div>
|
||||
<Button
|
||||
onClick={handleAddAgent}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
>
|
||||
<PlusCircleIcon className="text-description h-5 w-5" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
{profiles && profiles.length > 0 ? (
|
||||
profiles.map((profile, index) => (
|
||||
<div key={profile.id}>
|
||||
<div className="flex items-center justify-between py-1">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex h-6 w-6 flex-shrink-0 items-center justify-center">
|
||||
<AssistantIcon assistant={profile} />
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<h3
|
||||
className={`text-sm font-medium ${profile.errors && profile.errors.length > 0 ? "text-error" : ""}`}
|
||||
>
|
||||
{profile.title}
|
||||
</h3>
|
||||
{profile.errors && profile.errors.length > 0 && (
|
||||
<div className="mt-2 space-y-1">
|
||||
{profile.errors.map((error, errorIndex) => (
|
||||
<div
|
||||
key={errorIndex}
|
||||
className="text-error bg-error/10 rounded px-2 py-1 text-xs"
|
||||
>
|
||||
{error.message}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<ToolTip content="Configure agent">
|
||||
<Button
|
||||
onClick={() => handleConfigureAgent(profile.id)}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
>
|
||||
<Cog6ToothIcon className="text-description h-4 w-4" />
|
||||
</Button>
|
||||
</ToolTip>
|
||||
</div>
|
||||
{index < profiles.length - 1 && <Divider />}
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<EmptyState message="No agents configured. Click the + button to add your first agent." />
|
||||
)}
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
41
gui/src/pages/config/sections/DocsSection.tsx
Normal file
41
gui/src/pages/config/sections/DocsSection.tsx
Normal file
|
|
@ -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(
|
||||
<AddDocsDialog />,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-4 flex items-center justify-between">
|
||||
<h3 className="mb-0 text-sm font-semibold">Documentation</h3>
|
||||
<Button
|
||||
onClick={handleAddDocs}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
>
|
||||
<PlusCircleIcon className="text-description h-5 w-5" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<div className="py-6">
|
||||
<DocsIndexingStatuses />
|
||||
</div>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -172,9 +172,8 @@ export function HelpSection() {
|
|||
};
|
||||
|
||||
return (
|
||||
<div className="flex flex-col py-4">
|
||||
<div className="flex flex-col">
|
||||
<ConfigHeader title="Help Center" />
|
||||
|
||||
<div className="space-y-6">
|
||||
{/* Resources */}
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<div className="flex flex-col gap-4 py-5">
|
||||
<ConfigHeader
|
||||
title="Indexing"
|
||||
subtext="Manage your codebase and documentation indexing"
|
||||
/>
|
||||
<div>
|
||||
<div className="mb-4 flex items-center justify-between">
|
||||
<h3 className="mb-0 text-sm font-semibold">@codebase index</h3>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<div className="flex flex-col gap-6">
|
||||
<div>
|
||||
<h4 className="mb-2 text-base font-medium">@codebase index</h4>
|
||||
<span className="text-lightgray mb-3 block text-xs">
|
||||
Local embeddings of your codebase
|
||||
</span>
|
||||
{config.disableIndexing ? (
|
||||
<div className="pb-2 pt-2">
|
||||
<p className="py-1 text-center font-semibold">
|
||||
Indexing is disabled
|
||||
</p>
|
||||
<p className="text-lightgray cursor-pointer text-center text-xs">
|
||||
Open settings and toggle <code>Enable Indexing</code> to
|
||||
re-enable
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<IndexingProgress />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h4 className="mb-2 text-base font-medium">@docs index</h4>
|
||||
<span className="text-lightgray mb-3 block text-xs">
|
||||
Local embeddings of your documentation sources
|
||||
</span>
|
||||
<DocsIndexingStatuses />
|
||||
</div>
|
||||
<div className="py-2">
|
||||
{config.disableIndexing ? (
|
||||
<div className="pb-2 pt-2">
|
||||
<p className="py-1 text-center font-semibold">
|
||||
Indexing is disabled
|
||||
</p>
|
||||
<p className="text-lightgray cursor-pointer text-center text-xs">
|
||||
Open settings and toggle <code>Enable Indexing</code> to
|
||||
re-enable
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<IndexingProgress />
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function IndexingSettingsSection() {
|
||||
return (
|
||||
<>
|
||||
<div className="mb-8 flex items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<h2 className="mb-0 text-xl font-semibold">Indexing</h2>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
Manage your codebase and documentation indexing
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-10">
|
||||
<CodebaseSubSection />
|
||||
<DocsSection />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ConfigYaml["mcpServers"]>[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 (
|
||||
<div
|
||||
style={{
|
||||
fontSize: fontSize(-2),
|
||||
}}
|
||||
className={`flex flex-row items-center justify-between gap-3 ${server.status === "authenticating" ? "my-0.5" : ""}`}
|
||||
>
|
||||
<div className="flex flex-row items-center gap-3">
|
||||
{/* Name and Status */}
|
||||
<span className="m-0 font-semibold">{server.name}</span>
|
||||
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 ? (
|
||||
<ToolTip
|
||||
clickable
|
||||
delayHide={
|
||||
server.errors.some((error) => error.length > 150) ? 1500 : 0
|
||||
}
|
||||
className="flex flex-col gap-0.5"
|
||||
content={server.errors.map((error, idx) => (
|
||||
<Fragment key={idx}>
|
||||
<div>
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
className="flex items-center justify-between py-1 cursor-pointer"
|
||||
onClick={handleToggleExpanded}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<ChevronDownIcon
|
||||
className={`h-4 w-4 text-description transition-transform ${isExpanded ? 'rotate-180' : ''}`}
|
||||
/>
|
||||
<div className="flex-1">
|
||||
<h3
|
||||
className={`text-sm font-medium ${server.errors && server.errors.length > 0 ? "text-error" : ""}`}
|
||||
>
|
||||
{server.name}
|
||||
</h3>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{server.isProtectedResource && (
|
||||
<ToolTip
|
||||
content={server.status === "error" ? "Authenticate" : server.status === "authenticating" ? "Authenticating..." : "Remove authentication"}
|
||||
>
|
||||
<Button
|
||||
onClick={server.status === "error" ? onAuthenticate : server.status === "authenticating" ? undefined : onRemoveAuth}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
disabled={server.status === "authenticating"}
|
||||
>
|
||||
{server.status === "authenticating" ? (
|
||||
<GlobeAltIcon className="animate-spin-slow h-4 w-4 text-description" />
|
||||
) : (
|
||||
<UserCircleIcon className="h-4 w-4 text-description" />
|
||||
)}
|
||||
</Button>
|
||||
</ToolTip>
|
||||
)}
|
||||
|
||||
<EditBlockButton
|
||||
blockType={"mcpServers"}
|
||||
block={serverFromYaml}
|
||||
sourceFile={server.sourceFile}
|
||||
/>
|
||||
|
||||
<ToolTip content="Refresh server">
|
||||
<Button
|
||||
onClick={onRefresh}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
>
|
||||
<ArrowPathIcon className="h-4 w-4 text-description" />
|
||||
</Button>
|
||||
</ToolTip>
|
||||
|
||||
<div
|
||||
className="h-2 w-2 rounded-full flex-shrink-0"
|
||||
style={{
|
||||
backgroundColor:
|
||||
server.status === "connected"
|
||||
? "#22c55e" // green-500
|
||||
: server.status === "connecting"
|
||||
? "#eab308" // yellow-500
|
||||
: server.status === "not-connected"
|
||||
? "#78716c" // stone-500
|
||||
: "#ef4444", // red-500 for error
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{isExpanded && (
|
||||
<div className="mt-3 pl-7">
|
||||
{/* Tools, Prompts, Resources with counts */}
|
||||
<div className="flex flex-row items-center gap-6 mb-3">
|
||||
<ToolTip
|
||||
className="flex flex-col gap-0.5"
|
||||
content={
|
||||
<>
|
||||
{server.tools.map((tool, idx) => (
|
||||
<code key={idx}>{tool.name}</code>
|
||||
))}
|
||||
{server.tools.length === 0 && (
|
||||
<span className="text-lightgray">No tools</span>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
>
|
||||
<div className="flex cursor-zoom-in items-center gap-2 hover:opacity-80">
|
||||
<WrenchScrewdriverIcon className="h-4 w-4" />
|
||||
<span className="text-sm">Tools: {server.tools.length}</span>
|
||||
</div>
|
||||
</ToolTip>
|
||||
|
||||
<ToolTip
|
||||
className="flex flex-col gap-0.5"
|
||||
content={
|
||||
<>
|
||||
{server.prompts.map((prompt, idx) => (
|
||||
<code key={idx}>{prompt.name}</code>
|
||||
))}
|
||||
{server.prompts.length === 0 && (
|
||||
<span className="text-lightgray">No prompts</span>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
>
|
||||
<div className="flex cursor-zoom-in items-center gap-2 hover:opacity-80">
|
||||
<CommandLineIcon className="h-4 w-4" />
|
||||
<span className="text-sm">Prompts: {server.prompts.length}</span>
|
||||
</div>
|
||||
</ToolTip>
|
||||
|
||||
<ToolTip
|
||||
className="flex flex-col gap-0.5"
|
||||
content={
|
||||
<>
|
||||
{[...server.resources, ...server.resourceTemplates].map(
|
||||
(resource, idx) => (
|
||||
<code key={idx}>{resource.name}</code>
|
||||
),
|
||||
)}
|
||||
{server.resources.length === 0 && (
|
||||
<span className="text-lightgray">No resources</span>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
>
|
||||
<div className="flex cursor-zoom-in items-center gap-2 hover:opacity-80">
|
||||
<CircleStackIcon className="h-4 w-4" />
|
||||
<span className="text-sm">Resources: {server.resources.length + server.resourceTemplates.length}</span>
|
||||
</div>
|
||||
</ToolTip>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Error display below expandable section */}
|
||||
{server.errors && server.errors.length > 0 && (
|
||||
<div className="mt-2 space-y-1">
|
||||
{server.errors.map((error, errorIndex) => (
|
||||
<div key={errorIndex} className="text-error bg-error/10 rounded px-2 py-1 text-xs">
|
||||
<div className="flex items-start justify-between gap-2">
|
||||
<span className="flex-1">
|
||||
{error.length > 150 ? error.substring(0, 150) + "..." : error}
|
||||
</div>
|
||||
</span>
|
||||
{error.length > 150 && (
|
||||
<Button
|
||||
className="my-0"
|
||||
className="my-0 flex-shrink-0"
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={() =>
|
||||
|
|
@ -102,127 +233,11 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
|
|||
View full error
|
||||
</Button>
|
||||
)}
|
||||
</Fragment>
|
||||
))}
|
||||
>
|
||||
<InformationCircleIcon
|
||||
className={`h-3 w-3 ${server.status === "error" ? "text-red-500" : "text-yellow-500"}`}
|
||||
/>
|
||||
</ToolTip>
|
||||
) : null}
|
||||
|
||||
{/* Tools, Prompts, Resources with counts */}
|
||||
<div className="flex flex-row items-center gap-3">
|
||||
<ToolTip
|
||||
className="flex flex-col gap-0.5"
|
||||
content={
|
||||
<>
|
||||
{server.tools.map((tool, idx) => (
|
||||
<code key={idx}>{tool.name}</code>
|
||||
))}
|
||||
{server.tools.length === 0 && (
|
||||
<span className="text-lightgray">No tools</span>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
>
|
||||
<div className="flex cursor-zoom-in items-center gap-1 hover:opacity-80">
|
||||
<WrenchScrewdriverIcon className="h-3 w-3" />
|
||||
<span className="text-xs">{server.tools.length}</span>
|
||||
</div>
|
||||
</div>
|
||||
</ToolTip>
|
||||
|
||||
<ToolTip
|
||||
className="flex flex-col gap-0.5"
|
||||
content={
|
||||
<>
|
||||
{server.prompts.map((prompt, idx) => (
|
||||
<code key={idx}>{prompt.name}</code>
|
||||
))}
|
||||
{server.prompts.length === 0 && (
|
||||
<span className="text-lightgray">No prompts</span>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
>
|
||||
<div className="flex cursor-zoom-in items-center gap-1 hover:opacity-80">
|
||||
<CommandLineIcon className="h-3 w-3" />
|
||||
<span className="text-xs">{server.prompts.length}</span>
|
||||
</div>
|
||||
</ToolTip>
|
||||
|
||||
<ToolTip
|
||||
className="flex flex-col gap-0.5"
|
||||
content={
|
||||
<>
|
||||
{[...server.resources, ...server.resourceTemplates].map(
|
||||
(resource, idx) => (
|
||||
<code key={idx}>{resource.name}</code>
|
||||
),
|
||||
)}
|
||||
{server.resources.length === 0 && (
|
||||
<span className="text-lightgray">No resources</span>
|
||||
)}
|
||||
</>
|
||||
}
|
||||
>
|
||||
<div className="flex cursor-zoom-in items-center gap-1 hover:opacity-80">
|
||||
<CircleStackIcon className="h-3 w-3" />
|
||||
<span className="text-xs">
|
||||
{server.resources.length + server.resourceTemplates.length}
|
||||
</span>
|
||||
</div>
|
||||
</ToolTip>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
{server.isProtectedResource && (
|
||||
<ToolTip
|
||||
place="left"
|
||||
hidden={server.status === "authenticating"}
|
||||
content={server.status === "error" ? "Authenticate" : "Logout"}
|
||||
>
|
||||
<div className="text-lightgray flex cursor-pointer items-center hover:text-white hover:opacity-80">
|
||||
{server.status === "error" ? (
|
||||
<ShieldExclamationIcon
|
||||
className="h-3 w-3"
|
||||
onClick={onAuthenticate}
|
||||
/>
|
||||
) : server.status === "authenticating" ? (
|
||||
<GlobeAltIcon className="animate-spin-slow h-3 w-3" />
|
||||
) : (
|
||||
<ShieldCheckIcon className="h-3 w-3" onClick={onRemoveAuth} />
|
||||
)}
|
||||
</div>
|
||||
</ToolTip>
|
||||
)}
|
||||
<EditBlockButton
|
||||
blockType={"mcpServers"}
|
||||
block={serverFromYaml}
|
||||
sourceFile={server.sourceFile}
|
||||
/>
|
||||
<div
|
||||
className="text-lightgray flex cursor-pointer items-center hover:opacity-80"
|
||||
onClick={onRefresh}
|
||||
>
|
||||
<ArrowPathIcon className="h-3 w-3" />
|
||||
</div>
|
||||
|
||||
<div
|
||||
className="hidden h-2 w-2 rounded-full sm:flex"
|
||||
style={{
|
||||
backgroundColor:
|
||||
server.status === "connected"
|
||||
? "#22c55e" // green-500
|
||||
: server.status === "connecting"
|
||||
? "#eab308" // yellow-500
|
||||
: server.status === "not-connected"
|
||||
? "#78716c" // stone-500
|
||||
: "#ef4444", // red-500 for error
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -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 (
|
||||
<div className="flex flex-col items-center justify-center p-2">
|
||||
|
|
@ -256,21 +286,42 @@ function McpSection() {
|
|||
}
|
||||
|
||||
return (
|
||||
<div className="mt-4">
|
||||
<ConfigHeader title="MCP Servers" />
|
||||
|
||||
<Card>
|
||||
<div className="flex max-h-[170px] flex-col gap-1 overflow-y-auto overflow-x-hidden pr-2">
|
||||
{mergedBlocks.map(({ block, blockFromYaml }, idx) => (
|
||||
<MCPServerPreview
|
||||
key={idx}
|
||||
server={block}
|
||||
serverFromYaml={blockFromYaml}
|
||||
/>
|
||||
))}
|
||||
<div>
|
||||
<div className="mb-8 flex items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<h2 className="mb-0 text-xl font-semibold">MCP Servers</h2>
|
||||
</div>
|
||||
<ExploreBlocksButton blockType="mcpServers" />
|
||||
</Card>
|
||||
<Button
|
||||
onClick={handleAddMcpServer}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
>
|
||||
<PlusCircleIcon className="text-description h-5 w-5" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{mergedBlocks && mergedBlocks.length > 0 ? (
|
||||
mergedBlocks.map(({ block, blockFromYaml }, index) => (
|
||||
<div key={block.id}>
|
||||
<Card>
|
||||
<MCPServerCard
|
||||
server={block}
|
||||
serverFromYaml={blockFromYaml}
|
||||
/>
|
||||
</Card>
|
||||
{index < mergedBlocks.length - 1 && <div className="mb-4" />}
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<Card>
|
||||
<div className="flex flex-col items-center justify-center p-8 text-center">
|
||||
<span className="text-description">
|
||||
No MCP servers configured. Click the + button to add your first server.
|
||||
</span>
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
<AddModelForm
|
||||
onDone={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
const isLocal = selectedProfile?.profileType === "local";
|
||||
|
||||
if (isLocal) {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<AddModelForm
|
||||
onDone={() => {
|
||||
dispatch(setShowDialog(false));
|
||||
}}
|
||||
/>,
|
||||
),
|
||||
);
|
||||
} else {
|
||||
void ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "?type=models",
|
||||
orgSlug: undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<ConfigHeader
|
||||
title="Models"
|
||||
onAddClick={
|
||||
selectedProfile?.profileType === "local" ? handleAddModel : undefined
|
||||
}
|
||||
addButtonTooltip="Add a model"
|
||||
/>
|
||||
<>
|
||||
<div className="mb-8 flex items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<h2 className="mb-0 text-xl font-semibold">Models</h2>
|
||||
</div>
|
||||
<Button
|
||||
onClick={handleAddModel}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
>
|
||||
<PlusCircleIcon className="text-description h-5 w-5" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<div className="pb-6">
|
||||
|
|
@ -269,6 +283,6 @@ export function ModelsSection() {
|
|||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
104
gui/src/pages/config/sections/OrganizationsSection.tsx
Normal file
104
gui/src/pages/config/sections/OrganizationsSection.tsx
Normal file
|
|
@ -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 (
|
||||
<img
|
||||
src={org.iconUrl}
|
||||
alt=""
|
||||
className="h-5 w-5 flex-shrink-0 rounded-full"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const IconComponent = org.name === "Personal" ? UserIcon : BuildingOfficeIcon;
|
||||
return <IconComponent className="h-5 w-5 flex-shrink-0" />;
|
||||
}
|
||||
|
||||
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 (
|
||||
<>
|
||||
<div className="mb-8 flex items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<h2 className="mb-0 text-xl font-semibold">Organizations</h2>
|
||||
</div>
|
||||
</div>
|
||||
<Card>
|
||||
<div className="text-description py-8 text-center text-sm">
|
||||
Organizations are only available with cloud accounts. Sign in to
|
||||
manage organizations.
|
||||
</div>
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-8 flex items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<h2 className="mb-0 text-xl font-semibold">Organizations</h2>
|
||||
</div>
|
||||
<Button
|
||||
onClick={handleAddOrganization}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
>
|
||||
<PlusCircleIcon className="text-description h-5 w-5" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
{organizations.map((organization, index) => (
|
||||
<div key={organization.id}>
|
||||
<div className="flex items-center justify-between py-1">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex h-5 w-5 flex-shrink-0 items-center justify-center">
|
||||
{getOrgIcon(organization)}
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<h3 className="text-sm font-medium">{organization.name}</h3>
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
onClick={() => handleConfigureOrganization(organization.id)}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
>
|
||||
<Cog6ToothIcon className="text-description h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
{index < organizations.length - 1 && <Divider />}
|
||||
</div>
|
||||
))}
|
||||
</Card>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
@ -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 (
|
||||
<div className="flex flex-col">
|
||||
<ConfigHeader title="Prompts" />
|
||||
{sortedCommands.map((prompt) => (
|
||||
<PromptRow
|
||||
key={prompt.name}
|
||||
prompt={prompt}
|
||||
isBookmarked={isCommandBookmarked(prompt.name)}
|
||||
setIsBookmarked={() => toggleBookmark(prompt)}
|
||||
onEdit={() => handleEdit(prompt)}
|
||||
/>
|
||||
))}
|
||||
<ExploreBlocksButton blockType="prompts" />
|
||||
<div className="mb-8 flex items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<h2 className="mb-0 text-xl font-semibold">Prompts</h2>
|
||||
</div>
|
||||
<Button
|
||||
onClick={handleAddPrompt}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
>
|
||||
<PlusCircleIcon className="text-description h-5 w-5" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{sortedCommands.length > 0 ? (
|
||||
<div>
|
||||
{sortedCommands.map((prompt) => (
|
||||
<PromptRow
|
||||
key={prompt.name}
|
||||
prompt={prompt}
|
||||
isBookmarked={isCommandBookmarked(prompt.name)}
|
||||
setIsBookmarked={() => toggleBookmark(prompt)}
|
||||
onEdit={() => handleEdit(prompt)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<Card>
|
||||
<EmptyState message="No prompts configured. Click the + button to add your first prompt." />
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<div
|
||||
className="hover:bg-list-active hover:text-list-active-foreground flex items-center justify-between gap-3 rounded-md px-2 py-1 hover:cursor-pointer"
|
||||
onClick={handlePromptClick}
|
||||
style={{
|
||||
fontSize: fontSize(-3),
|
||||
}}
|
||||
>
|
||||
<div className="flex min-w-0 flex-col">
|
||||
<span className="text-vscForeground shrink-0 font-medium">
|
||||
{prompt.name}
|
||||
</span>
|
||||
<span className="line-clamp-2 text-[11px] text-gray-400">
|
||||
{prompt.description}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<PencilIcon
|
||||
className={`h-3 w-3 cursor-pointer text-gray-400 hover:brightness-125 ${!canEdit ? "pointer-events-none cursor-not-allowed opacity-50" : ""}`}
|
||||
onClick={canEdit ? handleEditClick : undefined}
|
||||
aria-disabled={!canEdit}
|
||||
/>
|
||||
<div
|
||||
onClick={handleBookmarkClick}
|
||||
className="cursor-pointer pt-0.5 text-gray-400 hover:brightness-125"
|
||||
>
|
||||
{isBookmarked ? (
|
||||
<BookmarkSolid className="h-3 w-3" />
|
||||
) : (
|
||||
<BookmarkOutline className="h-3 w-3" />
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
interface RuleCardProps {
|
||||
rule: RuleWithSource;
|
||||
|
|
@ -181,10 +268,140 @@ const RuleCard: React.FC<RuleCardProps> = ({ 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 (
|
||||
<div>
|
||||
<div className="mb-4 flex items-center justify-between">
|
||||
<h3 className="mb-0 text-sm font-semibold">Prompts</h3>
|
||||
<Button
|
||||
onClick={handleAddPrompt}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
>
|
||||
<PlusCircleIcon className="text-description h-5 w-5" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{sortedCommands.length > 0 ? (
|
||||
<Card>
|
||||
<div>
|
||||
{sortedCommands.map((prompt) => (
|
||||
<PromptRow
|
||||
key={prompt.name}
|
||||
prompt={prompt}
|
||||
isBookmarked={isCommandBookmarked(prompt.name)}
|
||||
setIsBookmarked={() => toggleBookmark(prompt)}
|
||||
onEdit={() => handleEdit(prompt)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
) : (
|
||||
<Card>
|
||||
<EmptyState message="No prompts configured. Click the + button to add your first prompt." />
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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 (
|
||||
<div>
|
||||
<ConfigHeader title="Rules" />
|
||||
<div className="mb-4 flex items-center justify-between">
|
||||
<h3 className="mb-0 text-sm font-semibold">Rules</h3>
|
||||
<Button
|
||||
onClick={handleAddRule}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
>
|
||||
<PlusCircleIcon className="text-description h-5 w-5" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<div className="flex flex-col gap-3">
|
||||
{sortedRules.map((rule, index) => (
|
||||
<RuleCard key={index} rule={rule} />
|
||||
))}
|
||||
<ExploreBlocksButton blockType="rules" />
|
||||
</div>
|
||||
{sortedRules.length > 0 ? (
|
||||
<div className="flex flex-col gap-3">
|
||||
{sortedRules.map((rule, index) => (
|
||||
<RuleCard key={index} rule={rule} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState message="No rules configured. Click the + button to add your first rule." />
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function RulesSection() {
|
||||
return (
|
||||
<>
|
||||
<div className="mb-8 flex items-center justify-between">
|
||||
<div className="flex flex-col">
|
||||
<h2 className="mb-0 text-xl font-semibold">Rules</h2>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="space-y-10">
|
||||
<RulesSubSection />
|
||||
<PromptsSubSection />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
className={`flex w-8 select-none flex-row items-center justify-end gap-2 px-2 py-0.5 sm:w-16 ${disabled ? "cursor-not-allowed" : "hover:text-list-active-foreground cursor-pointer hover:brightness-125"}`}
|
||||
data-testid={`tool-policy-item-${props.tool.function.name}`}
|
||||
data-tooltip-id={disabled ? disabledTooltipId : undefined}
|
||||
onClick={
|
||||
disabled
|
||||
? undefined
|
||||
: (e) => {
|
||||
dispatch(toggleToolSetting(props.tool.function.name));
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
}
|
||||
}
|
||||
>
|
||||
{disabled || policy === "disabled" ? (
|
||||
<>
|
||||
<span className="text-lightgray sm:hidden">Off</span>
|
||||
<span className="text-lightgray hidden sm:inline-block">
|
||||
Excluded
|
||||
</span>
|
||||
</>
|
||||
) : policy === "allowedWithoutPermission" ? (
|
||||
<>
|
||||
<span className="text-success sm:hidden">Auto</span>
|
||||
<span className="text-success hidden sm:inline-block">
|
||||
Automatic
|
||||
</span>
|
||||
</>
|
||||
) : (
|
||||
// allowedWithPermission
|
||||
<>
|
||||
<span className="text-warning sm:hidden">Ask</span>
|
||||
<span className="text-warning hidden sm:inline-block">
|
||||
Ask First
|
||||
</span>
|
||||
</>
|
||||
)}
|
||||
<div className="flex w-20 justify-end sm:w-24">
|
||||
<Listbox
|
||||
value={disabled || policy === "disabled" ? "disabled" : policy}
|
||||
onChange={(newPolicy) => {
|
||||
if (!disabled && newPolicy !== policy) {
|
||||
dispatch(toggleToolSetting(props.tool.function.name));
|
||||
}
|
||||
}}
|
||||
disabled={disabled}
|
||||
>
|
||||
<div className="relative">
|
||||
<ListboxButton
|
||||
className={`h-7 w-full justify-between ${disabled ? "cursor-not-allowed opacity-50" : ""}`}
|
||||
data-testid={`tool-policy-item-${props.tool.function.name}`}
|
||||
data-tooltip-id={disabled ? disabledTooltipId : undefined}
|
||||
>
|
||||
<span className="text-xs">
|
||||
{disabled || policy === "disabled"
|
||||
? "Excluded"
|
||||
: policy === "allowedWithoutPermission"
|
||||
? "Automatic"
|
||||
: "Ask First"}
|
||||
</span>
|
||||
<ChevronDownIcon className="h-3 w-3" />
|
||||
</ListboxButton>
|
||||
{!disabled && (
|
||||
<ListboxOptions>
|
||||
<ListboxOption value="allowedWithoutPermission">
|
||||
Automatic
|
||||
</ListboxOption>
|
||||
<ListboxOption value="allowedWithPermission">
|
||||
Ask First
|
||||
</ListboxOption>
|
||||
<ListboxOption value="disabled">
|
||||
Excluded
|
||||
</ListboxOption>
|
||||
</ListboxOptions>
|
||||
)}
|
||||
</div>
|
||||
</Listbox>
|
||||
</div>
|
||||
<Tooltip id={disabledTooltipId}>
|
||||
{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<string, Tool[]> = {};
|
||||
|
|
@ -235,59 +242,90 @@ export const ToolPoliciesSection = () => {
|
|||
|
||||
const message = getMessage(mode);
|
||||
|
||||
const toggleGroup = (groupName: string) => {
|
||||
setExpandedGroups((prev) => ({
|
||||
...prev,
|
||||
[groupName]: !prev[groupName],
|
||||
}));
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<ConfigHeader title="Tool Policies" />
|
||||
|
||||
<Card>
|
||||
{(mode === "chat" || mode === "plan") && (
|
||||
<div className="bg-background sticky top-0 z-10 my-1 mb-3">
|
||||
<Alert type="info" size="sm">
|
||||
<span className="text-2xs italic">{message}</span>
|
||||
</Alert>
|
||||
</div>
|
||||
)}
|
||||
{toolsByGroup.length === 0 && (
|
||||
{(mode === "chat" || mode === "plan") && (
|
||||
<div className="mb-4">
|
||||
<Alert type="info" size="sm">
|
||||
<span className="text-2xs italic">{message}</span>
|
||||
</Alert>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{toolsByGroup.length === 0 ? (
|
||||
<Card>
|
||||
<span className="text-description text-sm italic">
|
||||
No tools available
|
||||
</span>
|
||||
)}
|
||||
{toolsByGroup.map(([groupName, tools]) => {
|
||||
const isGroupEnabled =
|
||||
!allToolsOff && toolGroupSettings[groupName] !== "exclude";
|
||||
return (
|
||||
<div key={groupName} className="mt-2 flex flex-col pr-1">
|
||||
<div className="flex flex-row items-center justify-between px-1">
|
||||
<h3
|
||||
className="m-0 p-0 font-bold"
|
||||
style={{
|
||||
fontSize: fontSize(-2),
|
||||
}}
|
||||
>
|
||||
{groupName}
|
||||
</h3>
|
||||
<ToggleSwitch
|
||||
isToggled={isGroupEnabled}
|
||||
onToggle={() => dispatch(toggleToolGroupSetting(groupName))}
|
||||
text=""
|
||||
size={10}
|
||||
disabled={allToolsOff}
|
||||
/>
|
||||
</div>
|
||||
<div className={`relative flex flex-col p-1`}>
|
||||
{tools.map((tool) => (
|
||||
<ToolPolicyItem
|
||||
key={tool.uri + tool.function.name}
|
||||
tool={tool}
|
||||
duplicatesDetected={duplicateDetection[tool.function.name]}
|
||||
isGroupEnabled={isGroupEnabled}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</Card>
|
||||
</Card>
|
||||
) : (
|
||||
<div className="space-y-4">
|
||||
{toolsByGroup.map(([groupName, tools]) => {
|
||||
const isGroupEnabled =
|
||||
!allToolsOff && toolGroupSettings[groupName] !== "exclude";
|
||||
const isExpanded = expandedGroups[groupName];
|
||||
|
||||
return (
|
||||
<Card key={groupName}>
|
||||
<div className="flex flex-col">
|
||||
<div className="flex items-center justify-between">
|
||||
<div
|
||||
className="flex flex-1 cursor-pointer items-center gap-3 py-1"
|
||||
onClick={() => toggleGroup(groupName)}
|
||||
>
|
||||
<ChevronDownIcon
|
||||
className={`h-4 w-4 transition-transform ${
|
||||
isExpanded ? "rotate-180" : ""
|
||||
}`}
|
||||
/>
|
||||
<h3
|
||||
className="m-0 p-0 font-semibold"
|
||||
style={{
|
||||
fontSize: fontSize(-1),
|
||||
}}
|
||||
>
|
||||
{groupName}
|
||||
</h3>
|
||||
<div className="flex h-5 w-5 items-center justify-center rounded-full bg-gray-600 text-xs font-medium text-white">
|
||||
{tools.length}
|
||||
</div>
|
||||
</div>
|
||||
<ToggleSwitch
|
||||
isToggled={isGroupEnabled}
|
||||
onToggle={() => dispatch(toggleToolGroupSetting(groupName))}
|
||||
text=""
|
||||
size={10}
|
||||
disabled={allToolsOff}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{isExpanded && (
|
||||
<div className="mt-3 space-y-1">
|
||||
{tools.map((tool) => (
|
||||
<ToolPolicyItem
|
||||
key={tool.uri + tool.function.name}
|
||||
tool={tool}
|
||||
duplicatesDetected={duplicateDetection[tool.function.name]}
|
||||
isGroupEnabled={isGroupEnabled}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
682
gui/src/pages/config/sections/ToolsSection.tsx
Normal file
682
gui/src/pages/config/sections/ToolsSection.tsx
Normal file
|
|
@ -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<ConfigYaml["mcpServers"]>[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 (
|
||||
<div>
|
||||
<div
|
||||
className="-mx-2 flex cursor-pointer items-center justify-between rounded px-2 py-2 hover:bg-gray-50 hover:bg-opacity-5"
|
||||
onClick={() => toggleSection(sectionKey)}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<ChevronDownIcon
|
||||
className={`text-description h-3 w-3 transition-transform ${isExpanded ? "rotate-180" : ""}`}
|
||||
/>
|
||||
<div className="flex items-center gap-2">
|
||||
{icon}
|
||||
<span className="text-sm">{title}</span>
|
||||
<div className="flex h-5 w-5 items-center justify-center rounded-full bg-gray-600 text-xs font-medium text-white">
|
||||
{items.length}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{isExpanded && (
|
||||
<div className="mb-3 ml-6 mt-2">
|
||||
{hasItems ? (
|
||||
<div className="space-y-1">
|
||||
{items.map((item, idx) => (
|
||||
<div
|
||||
key={idx}
|
||||
className="text-description rounded bg-gray-50 bg-opacity-5 px-2 py-1 text-xs"
|
||||
>
|
||||
<code>{item.name}</code>
|
||||
{item.description && (
|
||||
<div className="mt-1 text-xs text-gray-500">
|
||||
{item.description}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div className="text-xs italic text-gray-500">
|
||||
No {title.toLowerCase()} available
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className="flex items-center justify-between py-1">
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex-1">
|
||||
<div className="flex items-center gap-3">
|
||||
<h3 className="my-0 text-sm font-medium">{server.name}</h3>
|
||||
<div
|
||||
className={`h-2 w-2 flex-shrink-0 rounded-full ${
|
||||
server.status === "connected"
|
||||
? "bg-success"
|
||||
: server.status === "connecting"
|
||||
? "bg-warning"
|
||||
: server.status === "not-connected"
|
||||
? "bg-description-muted"
|
||||
: "bg-error"
|
||||
}`}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="-mr-2.5 flex items-center gap-1">
|
||||
{server.isProtectedResource && (
|
||||
<ToolTip
|
||||
content={
|
||||
server.status === "error"
|
||||
? "Authenticate"
|
||||
: server.status === "authenticating"
|
||||
? "Authenticating..."
|
||||
: "Remove authentication"
|
||||
}
|
||||
>
|
||||
<Button
|
||||
onClick={
|
||||
server.status === "error"
|
||||
? onAuthenticate
|
||||
: server.status === "authenticating"
|
||||
? undefined
|
||||
: onRemoveAuth
|
||||
}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
disabled={server.status === "authenticating"}
|
||||
>
|
||||
{server.status === "authenticating" ? (
|
||||
<GlobeAltIcon className="animate-spin-slow text-description h-4 w-4" />
|
||||
) : (
|
||||
<UserCircleIcon className="text-description h-4 w-4" />
|
||||
)}
|
||||
</Button>
|
||||
</ToolTip>
|
||||
)}
|
||||
|
||||
<ToolTip content="Edit server configuration">
|
||||
<div>
|
||||
<EditBlockButton
|
||||
blockType={"mcpServers"}
|
||||
block={serverFromYaml}
|
||||
sourceFile={server.sourceFile}
|
||||
/>
|
||||
</div>
|
||||
</ToolTip>
|
||||
|
||||
<ToolTip content="Refresh server">
|
||||
<Button
|
||||
onClick={onRefresh}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
>
|
||||
<ArrowPathIcon className="text-description h-4 w-4" />
|
||||
</Button>
|
||||
</ToolTip>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Individual resource rows */}
|
||||
<div className="mt-1">
|
||||
<ResourceRow
|
||||
title="Tools"
|
||||
items={server.tools}
|
||||
icon={<WrenchScrewdriverIcon className="text-description h-4 w-4" />}
|
||||
sectionKey={`${server.id}-tools`}
|
||||
/>
|
||||
|
||||
<ResourceRow
|
||||
title="Prompts"
|
||||
items={server.prompts}
|
||||
icon={<CommandLineIcon className="text-description h-4 w-4" />}
|
||||
sectionKey={`${server.id}-prompts`}
|
||||
/>
|
||||
|
||||
<ResourceRow
|
||||
title="Resources"
|
||||
items={[...server.resources, ...server.resourceTemplates]}
|
||||
icon={<CircleStackIcon className="text-description h-4 w-4" />}
|
||||
sectionKey={`${server.id}-resources`}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Error display below expandable section */}
|
||||
{server.errors && server.errors.length > 0 && (
|
||||
<div className="mt-3 space-y-2">
|
||||
{server.errors.map((error, errorIndex) => (
|
||||
<Alert
|
||||
key={errorIndex}
|
||||
type="error"
|
||||
size="sm"
|
||||
className="cursor-pointer transition-all hover:underline"
|
||||
onClick={() =>
|
||||
void ideMessenger.ide.showVirtualFile(server.name, error)
|
||||
}
|
||||
>
|
||||
<span className="text-xs">
|
||||
{error.length > 150 ? error.substring(0, 150) + "..." : error}
|
||||
</span>
|
||||
</Alert>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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 (
|
||||
<div
|
||||
className="flex flex-col"
|
||||
style={{
|
||||
fontSize,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="-mx-2 flex flex-col rounded px-2 py-2 hover:bg-gray-50 hover:bg-opacity-5"
|
||||
>
|
||||
<div className="flex flex-row items-start justify-between">
|
||||
<div
|
||||
className="flex flex-1 cursor-pointer flex-row items-start gap-1"
|
||||
onClick={() => setIsExpanded((val) => !val)}
|
||||
>
|
||||
<ChevronRightIcon
|
||||
className={`mt-0.5 xs:flex hidden h-3 w-3 flex-shrink-0 transition-all duration-200 ${isExpanded ? "rotate-90" : ""}`}
|
||||
/>
|
||||
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex items-center gap-1">
|
||||
{props.duplicatesDetected ? (
|
||||
<ToolTip
|
||||
place="bottom"
|
||||
className="flex flex-wrap items-center"
|
||||
content={
|
||||
<p className="m-0 p-0">
|
||||
<span>Duplicate tool name</span>{" "}
|
||||
<code>{props.tool.function.name}</code>{" "}
|
||||
<span>
|
||||
detected. Permissions will conflict and usage may be
|
||||
unpredictable
|
||||
</span>
|
||||
</p>
|
||||
}
|
||||
>
|
||||
<InformationCircleIcon className="h-3 w-3 flex-shrink-0 cursor-help text-yellow-500" />
|
||||
</ToolTip>
|
||||
) : null}
|
||||
{props.tool.faviconUrl && (
|
||||
<img
|
||||
src={props.tool.faviconUrl}
|
||||
alt={props.tool.displayTitle}
|
||||
className="h-3 w-3 flex-shrink-0"
|
||||
/>
|
||||
)}
|
||||
<span
|
||||
className="line-clamp-1 break-all text-sm"
|
||||
>
|
||||
{props.tool.originalFunctionName ?? props.tool.function.name}
|
||||
</span>
|
||||
</div>
|
||||
<div className="text-sm text-description line-clamp-3">
|
||||
{props.tool.function.description}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex w-20 justify-end sm:w-24">
|
||||
<Listbox
|
||||
value={disabled || policy === "disabled" ? "disabled" : policy}
|
||||
onChange={(newPolicy) => {
|
||||
if (!disabled && newPolicy !== policy) {
|
||||
dispatch(toggleToolSetting(props.tool.function.name));
|
||||
}
|
||||
}}
|
||||
disabled={disabled}
|
||||
>
|
||||
<div className="relative">
|
||||
<ListboxButton
|
||||
className={`h-7 w-full justify-between px-3 ${disabled ? "cursor-not-allowed opacity-50" : ""}`}
|
||||
data-testid={`tool-policy-item-${props.tool.function.name}`}
|
||||
data-tooltip-id={disabled ? disabledTooltipId : undefined}
|
||||
>
|
||||
<span className="text-xs">
|
||||
{disabled || policy === "disabled"
|
||||
? "Excluded"
|
||||
: policy === "allowedWithoutPermission"
|
||||
? "Automatic"
|
||||
: "Ask First"}
|
||||
</span>
|
||||
<ChevronDownIcon className="h-3 w-3" />
|
||||
</ListboxButton>
|
||||
{!disabled && (
|
||||
<ListboxOptions className="min-w-0">
|
||||
<ListboxOption value="allowedWithoutPermission">
|
||||
Automatic
|
||||
</ListboxOption>
|
||||
<ListboxOption value="allowedWithPermission">
|
||||
Ask First
|
||||
</ListboxOption>
|
||||
<ListboxOption value="disabled">
|
||||
Excluded
|
||||
</ListboxOption>
|
||||
</ListboxOptions>
|
||||
)}
|
||||
</div>
|
||||
</Listbox>
|
||||
</div>
|
||||
</div>
|
||||
<Tooltip id={disabledTooltipId}>
|
||||
{mode === "chat"
|
||||
? "Tool disabled in chat mode"
|
||||
: !props.isGroupEnabled
|
||||
? "Group is turned off"
|
||||
: "Tool disabled in plan mode"}
|
||||
</Tooltip>
|
||||
</div>
|
||||
<div
|
||||
className={`flex flex-col overflow-hidden ${isExpanded ? "h-min" : "h-0 opacity-0"} gap-x-1 gap-y-2 pl-2 transition-all`}
|
||||
>
|
||||
<span className="mt-1.5 text-2xs font-bold">Description:</span>
|
||||
<span className="italic text-2xs">{props.tool.function.description}</span>
|
||||
{parameters ? (
|
||||
<>
|
||||
<span className="text-2xs font-bold">Arguments:</span>
|
||||
{parameters.map((param, idx) => (
|
||||
<div key={idx} className="block text-2xs">
|
||||
<code className="">{param[0]}</code>
|
||||
<span className="ml-1">{`(${param[1].type}):`}</span>
|
||||
<span className="ml-1 italic">{param[1].description}</span>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
) : null}
|
||||
<div className="h-1"></div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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 (
|
||||
<div>
|
||||
<div className="mb-2 flex items-center justify-between">
|
||||
<h3 className="text-sm font-semibold">MCP Servers</h3>
|
||||
{!disableMcp && (
|
||||
<Button
|
||||
onClick={handleAddMcpServer}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
>
|
||||
<PlusCircleIcon className="text-description h-5 w-5" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{disableMcp ? (
|
||||
<Card>
|
||||
<EmptyState message="MCP servers are disabled in your organization" />
|
||||
</Card>
|
||||
) : mergedBlocks.length > 0 ? (
|
||||
mergedBlocks.map(({ block, blockFromYaml }, index) => (
|
||||
<div key={block.id}>
|
||||
<Card>
|
||||
<MCPServerPreview server={block} serverFromYaml={blockFromYaml} />
|
||||
</Card>
|
||||
{index < mergedBlocks.length - 1 && <div className="mb-4" />}
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<Card>
|
||||
<EmptyState message="No MCP servers configured. Click the + button to add your first server." />
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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<string, Tool[]> = {};
|
||||
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<string, number> = {};
|
||||
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 (
|
||||
<div>
|
||||
<h3 className="mb-2 text-sm font-semibold">Tool Policies</h3>
|
||||
|
||||
{(mode === "chat" || mode === "plan") && (
|
||||
<div className="mb-4">
|
||||
<Alert type="info" size="sm">
|
||||
<span className="text-2xs italic">{message}</span>
|
||||
</Alert>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-4">
|
||||
{toolsByGroup.map(([groupName, tools]) => {
|
||||
const isGroupEnabled =
|
||||
!allToolsOff && toolGroupSettings[groupName] !== "exclude";
|
||||
const isExpanded = expandedGroups[groupName];
|
||||
|
||||
return (
|
||||
<Card key={groupName}>
|
||||
<div className="flex flex-col">
|
||||
<div className="flex items-center justify-between">
|
||||
<div
|
||||
className="-mx-2 flex flex-1 cursor-pointer items-center gap-3 rounded px-2 py-2 hover:bg-gray-50 hover:bg-opacity-5"
|
||||
onClick={() => toggleGroup(groupName)}
|
||||
>
|
||||
<ChevronDownIcon
|
||||
className={`text-description h-3 w-3 transition-transform ${
|
||||
isExpanded ? "rotate-180" : ""
|
||||
}`}
|
||||
/>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="text-sm font-semibold">{groupName}</span>
|
||||
<div className="flex h-5 w-5 items-center justify-center rounded-full bg-gray-600 text-xs font-medium text-white">
|
||||
{tools.length}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<ToolTip
|
||||
content={
|
||||
allToolsOff
|
||||
? "Tools disabled in current mode"
|
||||
: isGroupEnabled
|
||||
? `Disable all tools in ${groupName} group`
|
||||
: `Enable all tools in ${groupName} group`
|
||||
}
|
||||
>
|
||||
<div>
|
||||
<ToggleSwitch
|
||||
isToggled={isGroupEnabled}
|
||||
onToggle={() => dispatch(toggleToolGroupSetting(groupName))}
|
||||
text=""
|
||||
size={10}
|
||||
disabled={allToolsOff}
|
||||
/>
|
||||
</div>
|
||||
</ToolTip>
|
||||
</div>
|
||||
|
||||
{isExpanded && (
|
||||
<div className="mt-3 space-y-1">
|
||||
{tools.map((tool) => (
|
||||
<ToolPolicyItem
|
||||
key={tool.uri + tool.function.name}
|
||||
tool={tool}
|
||||
duplicatesDetected={duplicateDetection[tool.function.name]}
|
||||
isGroupEnabled={isGroupEnabled}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function ToolsSection() {
|
||||
const availableTools = useAppSelector((state) => state.config.config.tools);
|
||||
|
||||
const hasTools = availableTools && availableTools.length > 0;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<ConfigHeader title="Tools" />
|
||||
<div className="space-y-8">
|
||||
<McpSubsection />
|
||||
{hasTools && <ToolPoliciesSubsection />}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -125,9 +125,8 @@ export function UserSettingsSection() {
|
|||
return (
|
||||
<div>
|
||||
{hubEnabled ? (
|
||||
<div className="flex flex-col py-4">
|
||||
<div className="flex flex-col">
|
||||
<ConfigHeader title="User Settings" />
|
||||
|
||||
<div className="space-y-6">
|
||||
{/* Chat Interface Settings */}
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
|
|
@ -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 = {
|
||||
|
|
@ -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 | string[]>(null);
|
||||
const [showTooltip, setShowTooltip] = useState(false);
|
||||
|
||||
|
|
@ -127,7 +125,6 @@ function DocsIndexingStatus({
|
|||
onClick={() => {
|
||||
if (status?.url) {
|
||||
ideMessenger.post("openUrl", status.url);
|
||||
hideLump();
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
|
@ -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 (
|
||||
<EmptyState message="No documentation sources configured. Click the + button to add your first docs." />
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
<div className="flex flex-col overflow-y-auto overflow-x-hidden pr-2">
|
||||
|
|
@ -67,7 +73,6 @@ function DocsIndexingStatuses() {
|
|||
);
|
||||
})}
|
||||
</div>
|
||||
<ExploreBlocksButton blockType="docs" />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -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", () => {
|
||||
|
|
@ -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 {
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { IndexingStatus } from "core";
|
||||
import { ToolTip } from "../../../../gui/Tooltip";
|
||||
import { ToolTip } from "../../../../components/gui/Tooltip";
|
||||
|
||||
interface StatusIndicatorProps {
|
||||
status?: IndexingStatus["status"];
|
||||
|
|
@ -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(
|
|||
<Provider store={store}>
|
||||
<AuthProvider>
|
||||
<MainEditorProvider>
|
||||
<LumpProvider>
|
||||
{children}
|
||||
<ParallelListeners />
|
||||
</LumpProvider>
|
||||
{children}
|
||||
<ParallelListeners />
|
||||
</MainEditorProvider>
|
||||
</AuthProvider>
|
||||
</Provider>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue