address feedback
This commit is contained in:
parent
1c720c97bc
commit
b9ed55546d
53 changed files with 1549 additions and 1501 deletions
|
|
@ -1,19 +1,5 @@
|
|||
import { ConfigYaml } from "@continuedev/config-yaml";
|
||||
|
||||
export const defaultContextProvidersVsCode: NonNullable<
|
||||
ConfigYaml["context"]
|
||||
>[number][] = [
|
||||
{ provider: "code" },
|
||||
{ provider: "docs" },
|
||||
{ provider: "diff" },
|
||||
{ provider: "terminal" },
|
||||
{ provider: "problems" },
|
||||
];
|
||||
|
||||
export const defaultContextProvidersJetBrains: NonNullable<
|
||||
ConfigYaml["context"]
|
||||
>[number][] = [{ provider: "diff" }];
|
||||
|
||||
export const defaultConfig: ConfigYaml = {
|
||||
name: "Local Agent",
|
||||
version: "1.0.0",
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ const router = createMemoryRouter([
|
|||
element: <History />,
|
||||
},
|
||||
{
|
||||
path: "/stats",
|
||||
path: ROUTES.STATS,
|
||||
element: <Stats />,
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,17 +5,24 @@ import { BotIcon } from "../svg/BotIcon";
|
|||
|
||||
export interface AssistantIconProps {
|
||||
assistant: ProfileDescription;
|
||||
size?: number;
|
||||
size?: string;
|
||||
}
|
||||
|
||||
export function AssistantIcon({ assistant }: AssistantIconProps) {
|
||||
export function AssistantIcon({
|
||||
assistant,
|
||||
size = "h-4 w-4",
|
||||
}: AssistantIconProps) {
|
||||
if (isLocalProfile(assistant)) {
|
||||
return <BotIcon className="text-foreground h-4 w-4" />;
|
||||
return <BotIcon className={`text-foreground ${size} flex-shrink-0`} />;
|
||||
} else if (assistant.iconUrl) {
|
||||
return (
|
||||
<img src={assistant.iconUrl} className="h-4 w-4 rounded-full" alt="" />
|
||||
<img
|
||||
src={assistant.iconUrl}
|
||||
className={`${size} flex-shrink-0 rounded-full`}
|
||||
alt=""
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
return <SparklesIcon className="h-4 w-4" />;
|
||||
return <SparklesIcon className={`${size} flex-shrink-0`} />;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,13 @@
|
|||
import {
|
||||
ExclamationTriangleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { 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 { ListboxOption, useFontSize } from "../ui";
|
||||
import { CONFIG_ROUTES } from "../../util/navigation";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
import { Button, ListboxOption, useFontSize } from "../ui";
|
||||
import { AssistantIcon } from "./AssistantIcon";
|
||||
|
||||
interface AssistantOptionProps {
|
||||
|
|
@ -42,16 +39,9 @@ export function AssistantOption({
|
|||
id: 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,9 +64,17 @@ export function AssistantOption({
|
|||
<div className="flex flex-row items-center gap-1.5">
|
||||
{profile.errors && profile.errors?.length > 0 && (
|
||||
<ToolTip content="View errors">
|
||||
<ExclamationTriangleIcon
|
||||
className="text-error h-3.5 w-3.5 flex-shrink-0"
|
||||
/>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="text-error hover:enabled:text-error my-0 h-4 w-4 p-0"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
navigate(CONFIG_ROUTES.AGENTS);
|
||||
}}
|
||||
>
|
||||
<ExclamationTriangleIcon className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</ToolTip>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
import { CheckIcon } from "@heroicons/react/24/outline";
|
||||
import { BuildingOfficeIcon, UserCircleIcon, UserIcon } from "@heroicons/react/24/solid";
|
||||
import {
|
||||
BuildingOfficeIcon,
|
||||
UserCircleIcon,
|
||||
UserIcon,
|
||||
} from "@heroicons/react/24/solid";
|
||||
import { useContext } from "react";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
||||
|
|
@ -74,11 +78,9 @@ export function OrganizationOption({
|
|||
</span>
|
||||
</div>
|
||||
<div className="flex flex-row items-center gap-1.5">
|
||||
{isSelected && (
|
||||
<CheckIcon className="h-3.5 w-3.5 flex-shrink-0" />
|
||||
)}
|
||||
{isSelected && <CheckIcon className="h-3.5 w-3.5 flex-shrink-0" />}
|
||||
</div>
|
||||
</div>
|
||||
</ListboxOption>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,12 +11,8 @@ export function OrganizationOptions({ onClose }: OrganizationOptionsProps) {
|
|||
return (
|
||||
<div className="thin-scrollbar flex max-h-24 flex-col overflow-y-auto">
|
||||
{organizations.map((org) => (
|
||||
<OrganizationOption
|
||||
key={org.id}
|
||||
organization={org}
|
||||
onClose={onClose}
|
||||
/>
|
||||
<OrganizationOption key={org.id} organization={org} onClose={onClose} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,19 +18,19 @@ export function SelectedAssistantButton({
|
|||
}: SelectedAssistantButtonProps) {
|
||||
const configLoading = useAppSelector((store) => store.config.loading);
|
||||
|
||||
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) };
|
||||
const isSidebar = variant === "sidebar";
|
||||
const iconSize = isSidebar ? "h-4 w-4" : "h-3 w-3";
|
||||
const buttonPadding = isSidebar ? "px-2 py-2" : "px-0 py-0";
|
||||
const buttonStyle = isSidebar ? {} : { fontSize: fontSize(-3) };
|
||||
|
||||
return (
|
||||
<ListboxButton
|
||||
data-testid="assistant-select-button"
|
||||
className={`text-description border-none bg-transparent hover:brightness-125 ${isLarge ? "w-full justify-start" : "gap-1.5"} ${buttonPadding}`}
|
||||
className={`text-description border-none bg-transparent !py-1.5 hover:brightness-125 ${isSidebar ? "w-full justify-start" : "gap-1.5"} ${buttonPadding}`}
|
||||
style={buttonStyle}
|
||||
>
|
||||
<div
|
||||
className={`flex flex-row items-center ${isLarge ? "w-full justify-between" : "gap-1.5"}`}
|
||||
className={`flex flex-row items-center ${isSidebar ? "w-full justify-between" : "gap-1.5"}`}
|
||||
>
|
||||
<div className="flex flex-row items-center gap-2">
|
||||
{selectedProfile === null ? (
|
||||
|
|
@ -47,11 +47,9 @@ export function SelectedAssistantButton({
|
|||
</span>
|
||||
) : (
|
||||
<>
|
||||
<div className={`${iconSize} flex-shrink-0 select-none`}>
|
||||
<AssistantIcon assistant={selectedProfile} />
|
||||
</div>
|
||||
<AssistantIcon assistant={selectedProfile} size={iconSize} />
|
||||
<span
|
||||
className={`${isLarge ? "hidden md:block" : "hidden md:block"} select-none break-words`}
|
||||
className={`${isSidebar ? "hidden md:block" : "hidden md:block"} select-none break-words`}
|
||||
>
|
||||
{selectedProfile.title}
|
||||
</span>
|
||||
|
|
@ -59,7 +57,7 @@ export function SelectedAssistantButton({
|
|||
)}
|
||||
</div>
|
||||
<ChevronDownIcon
|
||||
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`}
|
||||
className={`text-description ml-0.5 h-3 w-3 flex-shrink-0 select-none ${isSidebar && "hidden md:block"}`}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import {
|
|||
} from "../../redux/slices/profilesSlice";
|
||||
import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import { cn } from "../../util/cn";
|
||||
import { CONFIG_ROUTES } from "../../util/navigation";
|
||||
import {
|
||||
Button,
|
||||
Listbox,
|
||||
|
|
@ -80,27 +81,22 @@ export function AssistantAndOrgListbox({
|
|||
}
|
||||
|
||||
function onAgentsConfig() {
|
||||
navigate("/config?tab=agents");
|
||||
navigate(CONFIG_ROUTES.AGENTS);
|
||||
close();
|
||||
}
|
||||
|
||||
function onOrganizationsConfig() {
|
||||
navigate("/config?tab=organizations");
|
||||
navigate(CONFIG_ROUTES.ORGANIZATIONS);
|
||||
close();
|
||||
}
|
||||
|
||||
function onRulesConfig() {
|
||||
navigate("/config?tab=rules");
|
||||
navigate(CONFIG_ROUTES.RULES);
|
||||
close();
|
||||
}
|
||||
|
||||
function onToolsConfig() {
|
||||
navigate("/config?tab=tools");
|
||||
close();
|
||||
}
|
||||
|
||||
function onLogout() {
|
||||
logout();
|
||||
navigate(CONFIG_ROUTES.TOOLS);
|
||||
close();
|
||||
}
|
||||
|
||||
|
|
@ -241,7 +237,7 @@ export function AssistantAndOrgListbox({
|
|||
}}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="text-description hover:bg-input my-0 w-full justify-start py-2 pl-1 text-left"
|
||||
className="text-description hover:bg-input my-0 w-full justify-start py-1.5 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" />
|
||||
|
|
@ -255,13 +251,32 @@ export function AssistantAndOrgListbox({
|
|||
}}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="text-description hover:bg-input my-0 w-full justify-start py-2 pl-1 text-left"
|
||||
className="text-description hover:bg-input my-0 w-full justify-start py-1.5 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>
|
||||
<Button
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
void refreshProfiles("Manual refresh from assistant list");
|
||||
}}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="text-description hover:bg-input my-0 w-full justify-start py-1.5 pl-1 text-left"
|
||||
>
|
||||
<div className="flex w-full items-center">
|
||||
<ArrowPathIcon
|
||||
className={cn(
|
||||
"ml-1.5 mr-2 h-3.5 w-3.5 flex-shrink-0",
|
||||
configLoading && "animate-spin-slow",
|
||||
)}
|
||||
/>
|
||||
<span className="text-2xs">Reload config</span>
|
||||
</div>
|
||||
</Button>
|
||||
|
||||
<Divider className="!mt-0" />
|
||||
</div>
|
||||
|
|
@ -269,26 +284,10 @@ export function AssistantAndOrgListbox({
|
|||
|
||||
{/* Bottom Actions */}
|
||||
<div>
|
||||
<div className="text-description flex items-center justify-between gap-1.5 px-2 py-2">
|
||||
<div className="text-description flex items-center justify-start px-2 py-1">
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ export function HistoryTableRow({
|
|||
onMouseEnter={() => setHovered(true)}
|
||||
onMouseLeave={() => setHovered(false)}
|
||||
data-testid={`history-row-${index}`}
|
||||
className="border-border relative mb-2 box-border flex w-full cursor-pointer overflow-hidden rounded-lg border border-solid p-3"
|
||||
className="border-description-muted relative mb-2 box-border flex w-full cursor-pointer overflow-hidden rounded-lg border border-solid p-3"
|
||||
onClick={async () => {
|
||||
await dispatch(exitEdit({}));
|
||||
if (sessionMetadata.sessionId !== currentSessionId) {
|
||||
|
|
@ -117,7 +117,7 @@ export function HistoryTableRow({
|
|||
</td>
|
||||
|
||||
{hovered && !editing && (
|
||||
<td className="bg-badge absolute right-2 top-1/2 ml-auto flex -translate-y-1/2 transform items-center gap-x-1 rounded-full px-2 py-1 shadow-md">
|
||||
<td className="bg-input absolute right-2 top-1/2 ml-auto flex -translate-y-1/2 transform items-center gap-x-1 rounded-full px-2 py-1 shadow-md">
|
||||
<HeaderButtonWithToolTip
|
||||
text="Edit"
|
||||
onClick={async (e) => {
|
||||
|
|
|
|||
|
|
@ -3,6 +3,14 @@ import { ToolTip } from "./gui/Tooltip";
|
|||
|
||||
const DEFAULT_SIZE = "5";
|
||||
|
||||
const sizeMap = {
|
||||
"3": "h-3 w-3",
|
||||
"4": "h-4 w-4",
|
||||
"5": "h-5 w-5",
|
||||
"6": "h-6 w-6",
|
||||
"8": "h-8 w-8",
|
||||
} as const;
|
||||
|
||||
const InfoHover = ({
|
||||
msg,
|
||||
size,
|
||||
|
|
@ -12,11 +20,13 @@ const InfoHover = ({
|
|||
msg: string;
|
||||
size?: string;
|
||||
}) => {
|
||||
const sizeClasses =
|
||||
sizeMap[size as keyof typeof sizeMap] ||
|
||||
sizeMap[DEFAULT_SIZE as keyof typeof sizeMap];
|
||||
|
||||
return (
|
||||
<ToolTip content={msg} place="bottom">
|
||||
<InformationCircleIcon
|
||||
className={`h-${size ?? DEFAULT_SIZE} w-${size ?? DEFAULT_SIZE} text-gray-500`}
|
||||
/>
|
||||
<InformationCircleIcon className={`${sizeClasses} text-gray-500`} />
|
||||
</ToolTip>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,9 +6,15 @@ export interface PageHeaderProps {
|
|||
showBorder?: boolean;
|
||||
}
|
||||
|
||||
export function PageHeader({ onTitleClick, title }: PageHeaderProps) {
|
||||
export function PageHeader({
|
||||
onTitleClick,
|
||||
title,
|
||||
showBorder = true,
|
||||
}: PageHeaderProps) {
|
||||
return (
|
||||
<div className="border-border sticky top-0 z-20 m-0 flex items-center justify-between border border-x-0 border-b-2 border-t-0 border-solid bg-inherit py-3.5">
|
||||
<div
|
||||
className={`border-description-muted sticky top-0 z-20 m-0 flex items-center justify-between border border-x-0 ${showBorder ? "border-b" : "border-b-0"} border-t-0 border-solid bg-inherit py-3.5`}
|
||||
>
|
||||
<div
|
||||
className="flex cursor-pointer items-center transition-colors duration-200 hover:brightness-125"
|
||||
onClick={onTitleClick}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { useNavigate } from "react-router-dom";
|
|||
import { useAuth } from "../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { ROUTES } from "../../util/navigation";
|
||||
import { CONFIG_ROUTES } from "../../util/navigation";
|
||||
import Alert from "../gui/Alert";
|
||||
|
||||
export const FatalErrorIndicator = () => {
|
||||
|
|
@ -20,7 +20,7 @@ export const FatalErrorIndicator = () => {
|
|||
const configLoading = useAppSelector((state) => state.config.loading);
|
||||
|
||||
const showConfigPage = () => {
|
||||
navigate("/config?tab=agents");
|
||||
navigate(CONFIG_ROUTES.AGENTS);
|
||||
};
|
||||
|
||||
const { selectedProfile } = useAuth();
|
||||
|
|
@ -64,10 +64,7 @@ export const FatalErrorIndicator = () => {
|
|||
Reload
|
||||
</div>
|
||||
)}
|
||||
<div
|
||||
onClick={showConfigPage}
|
||||
className="cursor-pointer underline"
|
||||
>
|
||||
<div onClick={showConfigPage} className="cursor-pointer underline">
|
||||
View
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -70,7 +70,13 @@ const spacingSizes = {
|
|||
lg: "ml-2",
|
||||
};
|
||||
|
||||
function Alert({ type = "info", size = "lg", className, children, ...props }: AlertProps) {
|
||||
function Alert({
|
||||
type = "info",
|
||||
size = "lg",
|
||||
className,
|
||||
children,
|
||||
...props
|
||||
}: AlertProps) {
|
||||
const { Icon, background, border, text, iconColor } = ALERT_CONFIGS[type];
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ interface NumberInputProps {
|
|||
onChange: (value: number) => void;
|
||||
max: number;
|
||||
min: number;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
const NumberInput: React.FC<NumberInputProps> = ({
|
||||
|
|
@ -12,26 +13,26 @@ const NumberInput: React.FC<NumberInputProps> = ({
|
|||
onChange,
|
||||
max,
|
||||
min,
|
||||
disabled = false,
|
||||
}) => {
|
||||
const [inputValue, setInputValue] = useState(value.toString());
|
||||
|
||||
const handleIncrement = () => {
|
||||
if (value < max) {
|
||||
const newValue = value + 1;
|
||||
onChange(newValue);
|
||||
setInputValue(newValue.toString());
|
||||
}
|
||||
if (disabled || value >= max) return;
|
||||
const newValue = value + 1;
|
||||
onChange(newValue);
|
||||
setInputValue(newValue.toString());
|
||||
};
|
||||
|
||||
const handleDecrement = () => {
|
||||
if (value > min) {
|
||||
const newValue = value - 1;
|
||||
onChange(newValue);
|
||||
setInputValue(newValue.toString());
|
||||
}
|
||||
if (disabled || value <= min) return;
|
||||
const newValue = value - 1;
|
||||
onChange(newValue);
|
||||
setInputValue(newValue.toString());
|
||||
};
|
||||
|
||||
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (disabled) return;
|
||||
const newInputValue = e.target.value;
|
||||
setInputValue(newInputValue);
|
||||
|
||||
|
|
@ -51,13 +52,16 @@ const NumberInput: React.FC<NumberInputProps> = ({
|
|||
};
|
||||
|
||||
return (
|
||||
<div className="border-command-border bg-vsc-input-background flex flex-row overflow-hidden rounded-md border border-solid">
|
||||
<div
|
||||
className={`border-command-border bg-vsc-input-background flex flex-row overflow-hidden rounded-md border border-solid ${disabled ? "cursor-not-allowed opacity-50" : ""}`}
|
||||
>
|
||||
<input
|
||||
type="text"
|
||||
value={inputValue}
|
||||
onChange={handleInputChange}
|
||||
onBlur={handleBlur}
|
||||
className="text-vsc-foreground max-w-9 border-none bg-inherit pr-1.5 text-right outline-none ring-0 focus:border-none focus:outline-none focus:ring-0"
|
||||
disabled={disabled}
|
||||
className="text-vsc-foreground max-w-9 border-none bg-inherit pr-1.5 text-right outline-none ring-0 focus:border-none focus:outline-none focus:ring-0 disabled:cursor-not-allowed"
|
||||
style={{
|
||||
appearance: "none",
|
||||
WebkitAppearance: "none",
|
||||
|
|
@ -70,16 +74,16 @@ const NumberInput: React.FC<NumberInputProps> = ({
|
|||
<button
|
||||
style={{ fontSize: "9px" }}
|
||||
onClick={handleIncrement}
|
||||
disabled={value >= max}
|
||||
className="text-vsc-foreground m-0 mb-0.5 cursor-pointer border-none bg-inherit px-1.5 py-0 hover:opacity-80"
|
||||
disabled={disabled || value >= max}
|
||||
className="text-vsc-foreground m-0 mb-0.5 cursor-pointer border-none bg-inherit px-1.5 py-0 hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
>
|
||||
▲
|
||||
</button>
|
||||
<button
|
||||
style={{ fontSize: "9px" }}
|
||||
className="text-vsc-foreground m-0 mb-0.5 cursor-pointer border-none bg-inherit px-1.5 py-0 hover:opacity-80"
|
||||
className="text-vsc-foreground m-0 mb-0.5 cursor-pointer border-none bg-inherit px-1.5 py-0 hover:opacity-80 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
onClick={handleDecrement}
|
||||
disabled={value <= min}
|
||||
disabled={disabled || value <= min}
|
||||
>
|
||||
▼
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import {
|
|||
vscForeground,
|
||||
vscInputBackground,
|
||||
} from "..";
|
||||
import { cn } from "../../util/cn";
|
||||
|
||||
// appearance: none;
|
||||
// -webkit-appearance: none;
|
||||
|
|
@ -23,9 +24,9 @@ import {
|
|||
// // gui/src/components/gui/Select.tsx
|
||||
// import React from 'react';
|
||||
|
||||
export const Select: React.FC<React.SelectHTMLAttributes<HTMLSelectElement>> = (
|
||||
props,
|
||||
) => (
|
||||
export const Select: React.FC<
|
||||
React.SelectHTMLAttributes<HTMLSelectElement>
|
||||
> = ({ className, ...props }) => (
|
||||
<div
|
||||
style={{
|
||||
color: vscForeground,
|
||||
|
|
@ -33,7 +34,7 @@ export const Select: React.FC<React.SelectHTMLAttributes<HTMLSelectElement>> = (
|
|||
>
|
||||
<select
|
||||
{...props}
|
||||
className="rounded-default border px-3 py-1.5"
|
||||
className={cn("rounded-default border px-3 py-1.5", className)}
|
||||
style={{
|
||||
borderColor: vscCommandCenterInactiveBorder,
|
||||
backgroundColor: vscInputBackground,
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ export const Input = styled.input`
|
|||
box-sizing: border-box;
|
||||
margin: 4px 0px;
|
||||
border-radius: ${defaultBorderRadius};
|
||||
outline: 1px solid ${vscCommandCenterInactiveBorder};
|
||||
outline: 1px solid ${lightGray};
|
||||
border: none;
|
||||
background-color: ${vscBackground};
|
||||
color: ${vscForeground};
|
||||
|
|
|
|||
|
|
@ -163,9 +163,7 @@ function InputToolbar(props: InputToolbarProps) {
|
|||
>
|
||||
{!isInEdit && <ContextStatus />}
|
||||
{!props.toolbarOptions?.hideUseCodebase && !isInEdit && (
|
||||
<div
|
||||
className={`hover:underline" hidden transition-colors duration-200 md:flex`}
|
||||
>
|
||||
<div className="hidden transition-colors duration-200 hover:underline hover:brightness-125 md:flex">
|
||||
<HoverItem
|
||||
className={
|
||||
props.activeKey === "Meta" ||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import HoverItem from "../../InputToolbar/HoverItem";
|
|||
import { usesFreeTrialApiKey } from "core/config/usesFreeTrialApiKey";
|
||||
import type { FreeTrialStatus } from "core/control-plane/client";
|
||||
import { getLocalStorage } from "../../../../util/localStorage";
|
||||
import { CONFIG_ROUTES } from "../../../../util/navigation";
|
||||
import { AssistantAndOrgListbox } from "../../../AssistantAndOrgListbox";
|
||||
|
||||
interface BlockSettingsToolbarIcon {
|
||||
|
|
@ -134,7 +135,7 @@ export function BlockSettingsTopToolbar() {
|
|||
tooltip={errorSection.tooltip}
|
||||
title={errorSection.title}
|
||||
isSelected={false}
|
||||
onClick={() => navigate("/config?tab=agents")}
|
||||
onClick={() => navigate(CONFIG_ROUTES.AGENTS)}
|
||||
/>
|
||||
)}
|
||||
<ToolTip
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import { useAppDispatch, useAppSelector } from "../../redux/hooks";
|
|||
import { setDialogMessage, setShowDialog } from "../../redux/slices/uiSlice";
|
||||
import { updateSelectedModelByRole } from "../../redux/thunks/updateSelectedModelByRole";
|
||||
import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../../util";
|
||||
import { CONFIG_ROUTES } from "../../util/navigation";
|
||||
import {
|
||||
Listbox,
|
||||
ListboxButton,
|
||||
|
|
@ -211,7 +212,7 @@ function ModelSelect() {
|
|||
buttonRef.current.click();
|
||||
}
|
||||
|
||||
navigate("/config?tab=models");
|
||||
navigate(CONFIG_ROUTES.MODELS);
|
||||
}
|
||||
|
||||
const hasNoModels = allModels?.length === 0;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import * as React from "react";
|
||||
import { cn } from "../../util/cn";
|
||||
|
||||
type ButtonVariant = "ghost" | "primary" | "secondary" | "outline";
|
||||
type ButtonVariant = "ghost" | "primary" | "secondary" | "outline" | "icon";
|
||||
type ButtonSize = "sm" | "lg";
|
||||
|
||||
type ButtonProps = React.ComponentProps<"button"> & {
|
||||
|
|
@ -18,6 +18,7 @@ const buttonVariants = {
|
|||
"border border-solid border-description text-foreground bg-transparent hover:enabled:bg-input",
|
||||
ghost:
|
||||
"border-none text-foreground bg-inherit hover:enabled:brightness-125 hover:enabled:bg-input",
|
||||
icon: "border border-solid border-description text-description bg-transparent hover:enabled:text-foreground hover:enabled:bg-input hover:enabled:border-description rounded-full p-0",
|
||||
};
|
||||
|
||||
const buttonSizes = {
|
||||
|
|
@ -25,17 +26,25 @@ const buttonSizes = {
|
|||
lg: "px-2 py-1 text-sm",
|
||||
};
|
||||
|
||||
const iconButtonSizes = {
|
||||
sm: "h-4 w-4",
|
||||
lg: "h-6 w-6",
|
||||
};
|
||||
|
||||
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
||||
({ variant = "primary", size = "lg", className, ...props }, ref) => {
|
||||
const isIcon = variant === "icon";
|
||||
return (
|
||||
<button
|
||||
ref={ref}
|
||||
className={cn(
|
||||
"my-1.5 cursor-pointer rounded transition-all duration-200",
|
||||
"cursor-pointer transition-all duration-200",
|
||||
"hover:enabled:cursor-pointer",
|
||||
"disabled:text-description-muted disabled:pointer-events-none disabled:opacity-50",
|
||||
buttonVariants[variant],
|
||||
buttonSizes[size],
|
||||
isIcon
|
||||
? iconButtonSizes[size]
|
||||
: `my-1.5 rounded ${buttonSizes[size]}`,
|
||||
className,
|
||||
)}
|
||||
style={{
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
interface CardProps {
|
||||
interface CardProps extends React.ComponentProps<"div"> {
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function Card({ children, className = "" }: CardProps) {
|
||||
export function Card({ children, className = "", ...props }: CardProps) {
|
||||
return (
|
||||
<div
|
||||
className={`bg-vsc-editor-background space-y-0 rounded-lg p-4 ${className}`}
|
||||
className={`bg-editor rounded-default space-y-0 px-4 py-3 ${className}`}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -8,4 +8,4 @@ export function EmptyState({ message }: EmptyStateProps) {
|
|||
<span className="text-description text-sm">{message}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { ToolTip } from "../../../../components/gui/Tooltip";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
|
||||
interface TabButtonProps {
|
||||
id: string;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { Divider } from "../../../../components/ui/Divider";
|
||||
import { Divider } from "./Divider";
|
||||
import { TabButton } from "./TabButton";
|
||||
|
||||
interface TabOption {
|
||||
45
gui/src/components/ui/Toggle.tsx
Normal file
45
gui/src/components/ui/Toggle.tsx
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
import { ChevronRightIcon } from "@heroicons/react/24/outline";
|
||||
|
||||
interface ToggleProps {
|
||||
isOpen: boolean;
|
||||
onToggle: () => void;
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export function Toggle({
|
||||
isOpen,
|
||||
onToggle,
|
||||
title,
|
||||
subtitle,
|
||||
children,
|
||||
}: ToggleProps) {
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
className="flex cursor-pointer items-start gap-2 text-left text-sm font-semibold"
|
||||
onClick={onToggle}
|
||||
>
|
||||
<ChevronRightIcon
|
||||
className={`mt-0.5 h-4 w-4 transition-transform ${
|
||||
isOpen ? "rotate-90" : ""
|
||||
}`}
|
||||
/>
|
||||
<div>
|
||||
<span>{title}</span>
|
||||
{subtitle && (
|
||||
<p className="mt-1 text-xs font-normal text-gray-500">{subtitle}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className={`duration-400 overflow-hidden transition-all ease-in-out ${
|
||||
isOpen ? "mt-4 max-h-screen" : "max-h-0"
|
||||
}`}
|
||||
>
|
||||
<div className="pl-6">{children}</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -10,4 +10,5 @@ export {
|
|||
ListboxOptions,
|
||||
} from "./Listbox";
|
||||
export { Popover, PopoverButton, PopoverPanel } from "./Popover";
|
||||
export { Toggle } from "./Toggle";
|
||||
export { Transition } from "./Transition";
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { PlusIcon } from "@heroicons/react/24/outline";
|
||||
import { ToolTip } from "../../components/gui/Tooltip";
|
||||
import { Button } from "../../components/ui";
|
||||
import { ToolTip } from "../../../components/gui/Tooltip";
|
||||
import { Button } from "../../../components/ui";
|
||||
|
||||
interface ConfigHeaderProps {
|
||||
title: string;
|
||||
|
|
@ -8,6 +8,7 @@ interface ConfigHeaderProps {
|
|||
onAddClick?: () => void;
|
||||
addButtonTooltip?: string;
|
||||
className?: string;
|
||||
variant?: "default" | "sm";
|
||||
}
|
||||
|
||||
export function ConfigHeader({
|
||||
|
|
@ -16,21 +17,29 @@ export function ConfigHeader({
|
|||
onAddClick,
|
||||
addButtonTooltip = "Add item",
|
||||
className = "",
|
||||
variant = "default",
|
||||
}: ConfigHeaderProps) {
|
||||
const isSmall = variant === "sm";
|
||||
const marginBottom = isSmall ? "mb-4" : "mb-6";
|
||||
const titleSize = isSmall ? "text-sm font-semibold" : "text-xl font-semibold";
|
||||
const HeadingTag = isSmall ? "h3" : "h2";
|
||||
|
||||
return (
|
||||
<div className={`mb-8 flex items-center justify-between ${className}`}>
|
||||
<div
|
||||
className={`${marginBottom} flex items-center justify-between ${className}`}
|
||||
>
|
||||
<div className="flex flex-col">
|
||||
<h2 className="mb-0 text-xl font-semibold">{title}</h2>
|
||||
<HeadingTag className={`my-0 ${titleSize}`}>{title}</HeadingTag>
|
||||
{subtext && <p className="text-description mt-1 text-sm">{subtext}</p>}
|
||||
</div>
|
||||
{onAddClick && (
|
||||
<ToolTip content={addButtonTooltip}>
|
||||
<Button
|
||||
onClick={onAddClick}
|
||||
variant="outline"
|
||||
className="border-description h-6 w-6 rounded-full p-0"
|
||||
variant="icon"
|
||||
size={isSmall ? "sm" : undefined}
|
||||
>
|
||||
<PlusIcon className="h-3 w-3" />
|
||||
<PlusIcon className="h-3.5 w-3.5" />
|
||||
</Button>
|
||||
</ToolTip>
|
||||
)}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
import React from "react";
|
||||
import { Button } from "../../../components/ui/Button";
|
||||
|
||||
export interface ConfigRowProps {
|
||||
title: string;
|
||||
|
|
@ -19,31 +20,59 @@ export function ConfigRow({
|
|||
children,
|
||||
className = "",
|
||||
}: ConfigRowProps) {
|
||||
const baseClasses = `flex items-start justify-between rounded-md transition-colors ${className}`;
|
||||
const baseClasses = `flex items-start justify-between rounded-md transition-colors px-4 py-3 ${className}`;
|
||||
const interactiveClasses = onClick
|
||||
? "hover:bg-vsc-editor-background/50 cursor-pointer"
|
||||
? "hover:bg-list-hover cursor-pointer"
|
||||
: "";
|
||||
const disabledClasses = disabled ? "opacity-50 cursor-not-allowed" : "";
|
||||
|
||||
const handleClick = () => {
|
||||
const handleClick = (event: React.MouseEvent) => {
|
||||
if (!disabled && onClick) {
|
||||
onClick();
|
||||
const target = event.target as HTMLElement;
|
||||
const isInteractiveChild = target.closest(
|
||||
'button, input, textarea, select, [role="button"], [role="switch"]',
|
||||
);
|
||||
|
||||
if (
|
||||
!isInteractiveChild ||
|
||||
target.closest("[data-config-row]") === event.currentTarget
|
||||
) {
|
||||
onClick();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (onClick) {
|
||||
return (
|
||||
<Button
|
||||
variant="ghost"
|
||||
className={`${baseClasses} ${interactiveClasses} ${disabledClasses} !my-0 text-left`.trim()}
|
||||
onClick={handleClick}
|
||||
disabled={disabled}
|
||||
data-config-row
|
||||
>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm font-medium">{title}</span>
|
||||
<p className="mt-0.5 text-xs text-gray-500">{description}</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-4">
|
||||
{children}
|
||||
{Icon && <Icon className="h-5 w-5 flex-shrink-0 text-gray-400" />}
|
||||
</div>
|
||||
</Button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`${baseClasses} ${interactiveClasses} ${disabledClasses}`.trim()}
|
||||
onClick={handleClick}
|
||||
>
|
||||
<div className={`${baseClasses} ${disabledClasses}`.trim()} data-config-row>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm font-medium">{title}</span>
|
||||
<p className="mt-0.5 text-xs text-gray-500">{description}</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex items-center gap-4">
|
||||
{children}
|
||||
{Icon && <Icon className="h-5 w-5 flex-shrink-0 text-gray-400" />}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,22 @@
|
|||
import React from "react";
|
||||
|
||||
interface ConfigSectionProps {
|
||||
title?: string;
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
// ConfigSection for internal section organization within pages
|
||||
// Not used as page wrapper - that's handled by ConfigPageLayout
|
||||
export function ConfigSection({
|
||||
title,
|
||||
children,
|
||||
className = "",
|
||||
}: ConfigSectionProps) {
|
||||
return (
|
||||
<div className={`py-4 ${className}`}>
|
||||
<div className={className}>
|
||||
{title && <h3 className="mb-4 text-base font-semibold">{title}</h3>}
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
20
gui/src/pages/config/components/ConfigSubsection.tsx
Normal file
20
gui/src/pages/config/components/ConfigSubsection.tsx
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import React from "react";
|
||||
|
||||
interface ConfigSubsectionProps {
|
||||
title?: string;
|
||||
children: React.ReactNode;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function ConfigSubsection({
|
||||
title,
|
||||
children,
|
||||
className = "",
|
||||
}: ConfigSubsectionProps) {
|
||||
return (
|
||||
<div className={className}>
|
||||
{title && <h3 className="mb-2 text-sm font-semibold">{title}</h3>}
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ import {
|
|||
} from "@heroicons/react/24/outline";
|
||||
import { ModelDescription } from "core";
|
||||
import { LLMConfigurationStatuses } from "core/llm/constants";
|
||||
import { MouseEvent, useContext, useState } from "react";
|
||||
import { MouseEvent, useContext } from "react";
|
||||
import { defaultBorderRadius } from "../../../components";
|
||||
import InfoHover from "../../../components/InfoHover";
|
||||
import {
|
||||
|
|
@ -47,7 +47,6 @@ const ModelRoleSelector = ({
|
|||
onSelect(models.find((m) => m.title === title) ?? null);
|
||||
}
|
||||
|
||||
|
||||
function handleOptionClick(
|
||||
showMissingApiKeyMsg: boolean,
|
||||
e: MouseEvent<HTMLLIElement>,
|
||||
|
|
@ -72,7 +71,7 @@ const ModelRoleSelector = ({
|
|||
{models.length === 0 ? (
|
||||
<ListboxButton
|
||||
onClick={() => ideMessenger.post("openUrl", setupURL)}
|
||||
className="bg-input border-input-border hover:bg-list-active hover:text-list-active-foreground text-description w-full justify-between rounded border px-3 py-2 underline hover:underline"
|
||||
className="bg-input border-description-muted hover:bg-list-active hover:text-list-active-foreground text-description w-full justify-between rounded border px-3 py-2 underline hover:underline"
|
||||
>
|
||||
<span className="line-clamp-1" style={{ fontSize: fontSize(-1) }}>
|
||||
Setup {displayName} model
|
||||
|
|
@ -82,7 +81,7 @@ const ModelRoleSelector = ({
|
|||
<>
|
||||
<ListboxButton
|
||||
disabled={models.length === 0}
|
||||
className="bg-input border-input-border hover:bg-list-active hover:text-list-active-foreground w-full justify-between rounded border px-3 py-2"
|
||||
className="bg-input border-description-muted hover:bg-list-active hover:text-list-active-foreground w-full justify-between rounded border px-3 py-2"
|
||||
>
|
||||
{models.length === 0 || noConfiguredModels ? (
|
||||
<span className="text-lightgray line-clamp-1 italic">
|
||||
|
|
|
|||
60
gui/src/pages/config/components/ToolPolicies.tsx
Normal file
60
gui/src/pages/config/components/ToolPolicies.tsx
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
import Alert from "../../../components/gui/Alert";
|
||||
import { Card } from "../../../components/ui";
|
||||
import { useToolPolicies } from "../hooks/useToolPolicies";
|
||||
import { ToolPoliciesGroup } from "./ToolPoliciesGroup";
|
||||
|
||||
export function ToolPolicies() {
|
||||
const {
|
||||
mode,
|
||||
toolsByGroup,
|
||||
duplicateDetection,
|
||||
allToolsOff,
|
||||
message,
|
||||
expandedGroups,
|
||||
toggleGroup,
|
||||
toolGroupSettings,
|
||||
} = useToolPolicies();
|
||||
|
||||
if (toolsByGroup.length === 0) {
|
||||
return (
|
||||
<Card>
|
||||
<span className="text-description text-sm italic">
|
||||
No tools available
|
||||
</span>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{(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 (
|
||||
<ToolPoliciesGroup
|
||||
key={groupName}
|
||||
groupName={groupName}
|
||||
tools={tools}
|
||||
isGroupEnabled={isGroupEnabled}
|
||||
isExpanded={isExpanded}
|
||||
allToolsOff={allToolsOff}
|
||||
duplicateDetection={duplicateDetection}
|
||||
onToggleGroup={toggleGroup}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
93
gui/src/pages/config/components/ToolPoliciesGroup.tsx
Normal file
93
gui/src/pages/config/components/ToolPoliciesGroup.tsx
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
import { ChevronDownIcon } from "@heroicons/react/24/outline";
|
||||
import { Tool } from "core";
|
||||
import ToggleSwitch from "../../../components/gui/Switch";
|
||||
import { ToolTip } from "../../../components/gui/Tooltip";
|
||||
import { Card } from "../../../components/ui";
|
||||
import { useAppDispatch } from "../../../redux/hooks";
|
||||
import { toggleToolGroupSetting } from "../../../redux/slices/uiSlice";
|
||||
import { fontSize } from "../../../util";
|
||||
import { ToolPolicyItem } from "./ToolPolicyItem";
|
||||
|
||||
interface ToolPoliciesGroupProps {
|
||||
groupName: string;
|
||||
tools: Tool[];
|
||||
isGroupEnabled: boolean;
|
||||
isExpanded: boolean;
|
||||
allToolsOff: boolean;
|
||||
duplicateDetection: Record<string, boolean>;
|
||||
onToggleGroup: (groupName: string) => void;
|
||||
}
|
||||
|
||||
export function ToolPoliciesGroup({
|
||||
groupName,
|
||||
tools,
|
||||
isGroupEnabled,
|
||||
isExpanded,
|
||||
allToolsOff,
|
||||
duplicateDetection,
|
||||
onToggleGroup,
|
||||
}: ToolPoliciesGroupProps) {
|
||||
const dispatch = useAppDispatch();
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex flex-col">
|
||||
<div
|
||||
className="-mx-2 flex cursor-pointer items-center justify-between gap-3 rounded px-2 py-2 hover:bg-gray-50 hover:bg-opacity-5"
|
||||
onClick={() => onToggleGroup(groupName)}
|
||||
>
|
||||
<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">
|
||||
<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
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
dispatch(toggleToolGroupSetting(groupName));
|
||||
}}
|
||||
>
|
||||
<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>
|
||||
);
|
||||
}
|
||||
198
gui/src/pages/config/components/ToolPolicyItem.tsx
Normal file
198
gui/src/pages/config/components/ToolPolicyItem.tsx
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
import { ToolPolicy } from "@continuedev/terminal-security";
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
ChevronRightIcon,
|
||||
InformationCircleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { Tool } from "core";
|
||||
import { BUILT_IN_GROUP_NAME } from "core/tools/builtIn";
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Tooltip } from "react-tooltip";
|
||||
import { ToolTip } from "../../../components/gui/Tooltip";
|
||||
import {
|
||||
Listbox,
|
||||
ListboxButton,
|
||||
ListboxOption,
|
||||
ListboxOptions,
|
||||
} from "../../../components/ui";
|
||||
import { useFontSize } from "../../../components/ui/font";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import { addTool, setToolPolicy } from "../../../redux/slices/uiSlice";
|
||||
|
||||
interface ToolPolicyItemProps {
|
||||
tool: Tool;
|
||||
duplicatesDetected: boolean;
|
||||
isGroupEnabled: boolean;
|
||||
}
|
||||
|
||||
export function ToolPolicyItem(props: ToolPolicyItemProps) {
|
||||
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.group}-${props.tool.displayTitle}-${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={`xs:flex mt-0.5 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-description line-clamp-3 text-sm">
|
||||
{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(
|
||||
setToolPolicy({
|
||||
toolName: props.tool.function.name,
|
||||
policy: newPolicy as ToolPolicy,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}}
|
||||
disabled={disabled}
|
||||
>
|
||||
<div className="relative">
|
||||
<ListboxButton
|
||||
className={`border-description-muted 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="text-2xs mt-1.5 font-bold">Description:</span>
|
||||
<span className="text-2xs italic">
|
||||
{props.tool.function.description}
|
||||
</span>
|
||||
{parameters ? (
|
||||
<>
|
||||
<span className="text-2xs font-bold">Arguments:</span>
|
||||
{parameters.map((param, idx) => (
|
||||
<div key={idx} className="text-2xs block">
|
||||
<code className="">{param[0]}</code>
|
||||
<span className="ml-1">{`(${param[1].type ?? "unknown"}):`}</span>
|
||||
<span className="ml-1 italic">
|
||||
{param[1].description ?? "No description"}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</>
|
||||
) : null}
|
||||
<div className="h-1"></div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -2,12 +2,21 @@ import React from "react";
|
|||
import NumberInput from "../../../components/gui/NumberInput";
|
||||
import ToggleSwitch from "../../../components/gui/Switch";
|
||||
import { Input } from "../../../components";
|
||||
import { Listbox, ListboxButton, ListboxOption, ListboxOptions } from "../../../components/ui/Listbox";
|
||||
import { ChevronDownIcon, CheckIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import {
|
||||
Listbox,
|
||||
ListboxButton,
|
||||
ListboxOption,
|
||||
ListboxOptions,
|
||||
} from "../../../components/ui/Listbox";
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
CheckIcon,
|
||||
XMarkIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
|
||||
interface BaseUserSettingProps {
|
||||
title: string;
|
||||
description: string;
|
||||
description: React.ReactNode;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
|
|
@ -43,7 +52,11 @@ interface InputUserSettingProps extends BaseUserSettingProps {
|
|||
isValid?: boolean;
|
||||
}
|
||||
|
||||
type UserSettingProps = ToggleUserSettingProps | NumberUserSettingProps | SelectUserSettingProps | InputUserSettingProps;
|
||||
type UserSettingProps =
|
||||
| ToggleUserSettingProps
|
||||
| NumberUserSettingProps
|
||||
| SelectUserSettingProps
|
||||
| InputUserSettingProps;
|
||||
|
||||
export function UserSetting(props: UserSettingProps) {
|
||||
const { title, description, disabled = false } = props;
|
||||
|
|
@ -67,6 +80,7 @@ export function UserSetting(props: UserSettingProps) {
|
|||
onChange={props.onChange}
|
||||
min={props.min ?? 0}
|
||||
max={props.max ?? 100}
|
||||
disabled={disabled}
|
||||
/>
|
||||
);
|
||||
|
||||
|
|
@ -77,12 +91,13 @@ export function UserSetting(props: UserSettingProps) {
|
|||
onChange={props.onChange}
|
||||
disabled={disabled}
|
||||
>
|
||||
<ListboxButton className="px-3 py-2 justify-between">
|
||||
{props.options.find(opt => opt.value === props.value)?.label || props.value}
|
||||
<ListboxButton className="justify-between px-3 py-2">
|
||||
{props.options.find((opt) => opt.value === props.value)?.label ||
|
||||
props.value}
|
||||
<ChevronDownIcon className="h-4 w-4" />
|
||||
</ListboxButton>
|
||||
<ListboxOptions className="min-w-0">
|
||||
{props.options.map(option => (
|
||||
{props.options.map((option) => (
|
||||
<ListboxOption key={option.value} value={option.value}>
|
||||
{option.label}
|
||||
</ListboxOption>
|
||||
|
|
@ -106,8 +121,8 @@ export function UserSetting(props: UserSettingProps) {
|
|||
className={`max-w-[200px] ${
|
||||
props.isDirty
|
||||
? !props.isValid
|
||||
? "border-red-500"
|
||||
: "border-green-500"
|
||||
? "outline-red-500"
|
||||
: "outline-green-500"
|
||||
: ""
|
||||
}`}
|
||||
onChange={(e) => props.onChange(e.target.value)}
|
||||
|
|
@ -116,16 +131,10 @@ export function UserSetting(props: UserSettingProps) {
|
|||
<div className="flex h-full flex-col">
|
||||
{props.isDirty ? (
|
||||
<>
|
||||
<div
|
||||
onClick={props.onSubmit}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<div onClick={props.onSubmit} className="cursor-pointer">
|
||||
<CheckIcon className="h-4 w-4 text-green-500 hover:opacity-80" />
|
||||
</div>
|
||||
<div
|
||||
onClick={props.onCancel}
|
||||
className="cursor-pointer"
|
||||
>
|
||||
<div onClick={props.onCancel} className="cursor-pointer">
|
||||
<XMarkIcon className="h-4 w-4 text-red-500 hover:opacity-80" />
|
||||
</div>
|
||||
</>
|
||||
|
|
@ -154,12 +163,12 @@ export function UserSetting(props: UserSettingProps) {
|
|||
};
|
||||
|
||||
return (
|
||||
<div className="flex justify-between items-start">
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm font-medium">{title}</span>
|
||||
<p className="text-xs text-gray-500 mt-0.5">{description}</p>
|
||||
<div className="mt-0.5 text-xs text-gray-500">{description}</div>
|
||||
</div>
|
||||
{renderControl()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import {
|
|||
CubeIcon,
|
||||
PencilIcon,
|
||||
QuestionMarkCircleIcon,
|
||||
Squares2X2Icon,
|
||||
WrenchScrewdriverIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { BotIcon } from "../../components/svg/BotIcon";
|
||||
|
|
@ -30,7 +29,6 @@ interface TabOption {
|
|||
interface TabSection {
|
||||
id: string;
|
||||
tabs: TabOption[];
|
||||
label?: string;
|
||||
showTopDivider?: boolean;
|
||||
showBottomDivider?: boolean;
|
||||
className?: string;
|
||||
|
|
@ -50,7 +48,6 @@ export const topTabSections: TabSection[] = [
|
|||
},
|
||||
{
|
||||
id: "blocks",
|
||||
label: "Blocks",
|
||||
showTopDivider: true,
|
||||
tabs: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -97,9 +97,7 @@ export function AccountDropdown() {
|
|||
<>
|
||||
<ListboxButton
|
||||
className={`text-description w-full justify-start gap-1 border-none px-2 py-1.5 ${
|
||||
open
|
||||
? "bg-vsc-input-background"
|
||||
: "hover:bg-vsc-input-background bg-inherit"
|
||||
open ? "bg-input" : "hover:bg-input bg-inherit"
|
||||
}`}
|
||||
>
|
||||
<UserCircleIcon className="xs:h-4 xs:w-4 h-3 w-3 flex-shrink-0" />
|
||||
|
|
|
|||
74
gui/src/pages/config/hooks/useToolPolicies.ts
Normal file
74
gui/src/pages/config/hooks/useToolPolicies.ts
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
import { MessageModes, Tool } from "core";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
|
||||
export function useToolPolicies() {
|
||||
const mode = useAppSelector((state) => state.session.mode);
|
||||
const availableTools = useAppSelector((state) => state.config.config.tools);
|
||||
const toolGroupSettings = useAppSelector(
|
||||
(store) => store.ui.toolGroupSettings,
|
||||
);
|
||||
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],
|
||||
}));
|
||||
};
|
||||
|
||||
return {
|
||||
mode,
|
||||
availableTools,
|
||||
toolGroupSettings,
|
||||
toolsByGroup,
|
||||
duplicateDetection,
|
||||
allToolsOff,
|
||||
message,
|
||||
expandedGroups,
|
||||
toggleGroup,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
import { isOnPremSession } from "core/control-plane/AuthTypes";
|
||||
import { useEffect, useState } from "react";
|
||||
import React, { useEffect, useState } from "react";
|
||||
import { useNavigate, useSearchParams } from "react-router-dom";
|
||||
import { AssistantAndOrgListbox } from "../../components/AssistantAndOrgListbox";
|
||||
import Alert from "../../components/gui/Alert";
|
||||
import { Divider } from "../../components/ui/Divider";
|
||||
import { TabGroup } from "../../components/ui/TabGroup";
|
||||
import { useAuth } from "../../context/Auth";
|
||||
import { useNavigationListener } from "../../hooks/useNavigationListener";
|
||||
import { TabGroup } from "./components/ui/TabGroup";
|
||||
import { bottomTabSections, getAllTabs, topTabSections } from "./configTabs";
|
||||
import { AccountDropdown } from "./features/account/AccountDropdown";
|
||||
|
||||
|
|
@ -42,13 +43,11 @@ function ConfigPage() {
|
|||
<div className="bg-vsc-background flex w-12 flex-shrink-0 flex-col border-0 md:w-36">
|
||||
<div className="border-r-border flex flex-1 flex-col overflow-y-auto border-b-0 border-l-0 border-r-2 border-t-0 border-solid p-2">
|
||||
{topTabSections.map((section, index) => (
|
||||
<>
|
||||
<React.Fragment key={section.id}>
|
||||
<TabGroup
|
||||
key={section.id}
|
||||
tabs={section.tabs}
|
||||
activeTab={activeTab}
|
||||
onTabClick={handleTabClick}
|
||||
label={section.label}
|
||||
showTopDivider={section.showTopDivider}
|
||||
showBottomDivider={section.showBottomDivider}
|
||||
className={section.className}
|
||||
|
|
@ -59,7 +58,7 @@ function ConfigPage() {
|
|||
<AssistantAndOrgListbox variant="sidebar" />
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
</React.Fragment>
|
||||
))}
|
||||
|
||||
<div className="flex-1" />
|
||||
|
|
@ -70,7 +69,6 @@ function ConfigPage() {
|
|||
tabs={section.tabs}
|
||||
activeTab={activeTab}
|
||||
onTabClick={handleTabClick}
|
||||
label={section.label}
|
||||
showTopDivider={section.showTopDivider}
|
||||
showBottomDivider={section.showBottomDivider}
|
||||
className={section.className}
|
||||
|
|
@ -85,8 +83,21 @@ function ConfigPage() {
|
|||
|
||||
{/* Main content area */}
|
||||
<div className="flex min-h-0 flex-1 flex-col overflow-hidden">
|
||||
{/* Tab Content */}
|
||||
<div className="flex-1 overflow-y-auto px-4">
|
||||
{/* Alert for small screens (sm and below) */}
|
||||
<div className="block px-4 py-4 sm:hidden">
|
||||
<Alert type="warning" className="max-w-md">
|
||||
<div className="flex flex-col">
|
||||
<div className="font-medium">Screen width too small</div>
|
||||
<div className="text-description mt-1 text-sm">
|
||||
To view settings, please expand the sidebar by dragging the
|
||||
left/right border
|
||||
</div>
|
||||
</div>
|
||||
</Alert>
|
||||
</div>
|
||||
|
||||
{/* Tab Content for larger screens (md and above) */}
|
||||
<div className="hidden flex-1 space-y-6 overflow-y-auto px-4 py-4 sm:block">
|
||||
{allTabs.find((tab) => tab.id === activeTab)?.component}
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,17 +1,18 @@
|
|||
import { Cog6ToothIcon, PlusCircleIcon } from "@heroicons/react/24/outline";
|
||||
import { Cog6ToothIcon } 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";
|
||||
import { ConfigHeader } from "../components/ConfigHeader";
|
||||
|
||||
export function AgentsSection() {
|
||||
const { profiles } = useAuth();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
function handleAddAgent() {
|
||||
ideMessenger.request("config/newAssistantFile", undefined);
|
||||
void ideMessenger.request("config/newAssistantFile", undefined);
|
||||
}
|
||||
|
||||
function handleConfigureAgent(profileId: string) {
|
||||
|
|
@ -20,19 +21,11 @@ export function AgentsSection() {
|
|||
|
||||
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>
|
||||
<ConfigHeader
|
||||
title="Agents"
|
||||
onAddClick={handleAddAgent}
|
||||
addButtonTooltip="Add agent"
|
||||
/>
|
||||
|
||||
<Card>
|
||||
{profiles && profiles.length > 0 ? (
|
||||
|
|
@ -54,7 +47,7 @@ export function AgentsSection() {
|
|||
{profile.errors.map((error, errorIndex) => (
|
||||
<div
|
||||
key={errorIndex}
|
||||
className="text-error bg-error/10 rounded px-2 py-1 text-xs"
|
||||
className="text-error bg-error/10 rounded py-1 pr-2 text-xs"
|
||||
>
|
||||
{error.message}
|
||||
</div>
|
||||
|
|
@ -68,9 +61,9 @@ export function AgentsSection() {
|
|||
onClick={() => handleConfigureAgent(profile.id)}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
|
||||
>
|
||||
<Cog6ToothIcon className="text-description h-4 w-4" />
|
||||
<Cog6ToothIcon className="h-4 w-4 flex-shrink-0" />
|
||||
</Button>
|
||||
</ToolTip>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
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 { Card } from "../../../components/ui";
|
||||
import { setDialogMessage, setShowDialog } from "../../../redux/slices/uiSlice";
|
||||
import { ConfigHeader } from "../components/ConfigHeader";
|
||||
import DocsIndexingStatuses from "./docs/DocsSection";
|
||||
|
||||
export function DocsSection() {
|
||||
|
|
@ -10,32 +10,23 @@ export function DocsSection() {
|
|||
|
||||
function handleAddDocs() {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
setDialogMessage(
|
||||
<AddDocsDialog />,
|
||||
),
|
||||
);
|
||||
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>
|
||||
<div>
|
||||
<ConfigHeader
|
||||
title="Documentation"
|
||||
onAddClick={handleAddDocs}
|
||||
addButtonTooltip="Add documentation"
|
||||
variant="sm"
|
||||
/>
|
||||
|
||||
<Card>
|
||||
<div className="py-6">
|
||||
<DocsIndexingStatuses />
|
||||
</div>
|
||||
</Card>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import { setOnboardingCard } from "../../../redux/slices/uiSlice";
|
|||
import { saveCurrentSession } from "../../../redux/thunks/session";
|
||||
import { isJetBrains } from "../../../util";
|
||||
import { ROUTES } from "../../../util/navigation";
|
||||
import { ConfigHeader } from "../ConfigHeader";
|
||||
import { ConfigHeader } from "../components/ConfigHeader";
|
||||
import { ConfigRow } from "../components/ConfigRow";
|
||||
|
||||
interface KeyboardShortcutProps {
|
||||
|
|
@ -39,7 +39,6 @@ function KeyboardShortcut(props: KeyboardShortcutProps) {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
// Shortcut strings will be rendered correctly based on the platform by the Shortcut component
|
||||
const vscodeShortcuts: Omit<KeyboardShortcutProps, "isEven">[] = [
|
||||
{
|
||||
|
|
@ -178,8 +177,8 @@ export function HelpSection() {
|
|||
{/* Resources */}
|
||||
<div>
|
||||
<h3 className="mb-3 text-base font-medium">Resources</h3>
|
||||
<Card>
|
||||
<div className="flex flex-col gap-4">
|
||||
<Card className="!p-0">
|
||||
<div className="flex flex-col">
|
||||
<ConfigRow
|
||||
title="Continue Hub"
|
||||
description="Visit hub.continue.dev to explore custom agents and blocks"
|
||||
|
|
@ -225,13 +224,13 @@ export function HelpSection() {
|
|||
{/* Tools */}
|
||||
<div>
|
||||
<h3 className="mb-3 text-base font-medium">Tools</h3>
|
||||
<Card>
|
||||
<div className="flex flex-col gap-4">
|
||||
<Card className="!p-0">
|
||||
<div className="flex flex-col">
|
||||
<ConfigRow
|
||||
title="Token usage"
|
||||
description="Daily token usage across models"
|
||||
icon={TableCellsIcon}
|
||||
onClick={() => navigate("/stats")}
|
||||
onClick={() => navigate(ROUTES.STATS)}
|
||||
/>
|
||||
|
||||
{currentSession.history.length > 0 &&
|
||||
|
|
@ -284,7 +283,7 @@ export function HelpSection() {
|
|||
{/* Keyboard Shortcuts */}
|
||||
<div>
|
||||
<h3 className="mb-3 text-base font-medium">Keyboard Shortcuts</h3>
|
||||
<Card>
|
||||
<Card className="!p-0">
|
||||
<div className="overflow-hidden rounded-md border border-gray-600">
|
||||
{shortcuts.map((shortcut, i) => {
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -1,5 +1,16 @@
|
|||
import {
|
||||
SharedConfigSchema,
|
||||
modifyAnyConfigWithSharedConfig,
|
||||
} from "core/config/sharedConfig";
|
||||
import { useContext } from "react";
|
||||
import Alert from "../../../components/gui/Alert";
|
||||
import { Card } from "../../../components/ui";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import { updateConfig } from "../../../redux/slices/configSlice";
|
||||
import { selectCurrentOrg } from "../../../redux/slices/profilesSlice";
|
||||
import { ConfigHeader } from "../components/ConfigHeader";
|
||||
import { UserSetting } from "../components/UserSetting";
|
||||
import IndexingProgress from "../features/indexing";
|
||||
import { DocsSection } from "./DocsSection";
|
||||
|
||||
|
|
@ -33,19 +44,79 @@ function CodebaseSubSection() {
|
|||
);
|
||||
}
|
||||
|
||||
function EnableIndexingSetting() {
|
||||
const dispatch = useAppDispatch();
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const config = useAppSelector((state) => state.config.config);
|
||||
const currentOrg = useAppSelector(selectCurrentOrg);
|
||||
|
||||
function handleUpdate(sharedConfig: SharedConfigSchema) {
|
||||
const updatedConfig = modifyAnyConfigWithSharedConfig(config, sharedConfig);
|
||||
dispatch(updateConfig(updatedConfig));
|
||||
ideMessenger.post("config/updateSharedConfig", sharedConfig);
|
||||
}
|
||||
|
||||
const disableIndexing = config.disableIndexing ?? false;
|
||||
const disableIndexingToggle =
|
||||
currentOrg?.policy?.allowCodebaseIndexing === false;
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex flex-col gap-4">
|
||||
<UserSetting
|
||||
title="Enable indexing"
|
||||
type="toggle"
|
||||
description={
|
||||
<>
|
||||
Allows indexing of your codebase for search and context
|
||||
understanding.
|
||||
<br />
|
||||
<br />
|
||||
Note that indexing can consume significant system resources,
|
||||
especially on larger codebases.
|
||||
</>
|
||||
}
|
||||
value={!disableIndexing}
|
||||
disabled={disableIndexingToggle}
|
||||
onChange={(value) => handleUpdate({ disableIndexing: !value })}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
export function IndexingSettingsSection() {
|
||||
const config = useAppSelector((state) => state.config.config);
|
||||
const disableIndexing = config.disableIndexing ?? false;
|
||||
|
||||
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>
|
||||
<ConfigHeader title="Indexing" />
|
||||
|
||||
<Alert type="warning" className="mb-6">
|
||||
<div>
|
||||
<div className="text-sm font-medium">
|
||||
Indexing has been deprecated
|
||||
</div>
|
||||
<div className="mt-1">
|
||||
Learn more about{" "}
|
||||
<a
|
||||
href="https://docs.continue.dev/guides/codebase-documentation-awareness"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="text-inherit underline hover:brightness-125"
|
||||
>
|
||||
making your agent aware of your codebase and documentation
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</Alert>
|
||||
|
||||
<div className="mb-6">
|
||||
<EnableIndexingSetting />
|
||||
</div>
|
||||
|
||||
<div className="space-y-10">
|
||||
<div className={`space-y-8 ${disableIndexing ? "opacity-50" : ""}`}>
|
||||
<CodebaseSubSection />
|
||||
<DocsSection />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,21 +5,20 @@ import {
|
|||
CircleStackIcon,
|
||||
CommandLineIcon,
|
||||
GlobeAltIcon,
|
||||
PlusCircleIcon,
|
||||
UserCircleIcon,
|
||||
WrenchScrewdriverIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { MCPServerStatus } from "core";
|
||||
import { Fragment, useContext, useMemo, useState } from "react";
|
||||
import { useContext, useMemo, useState } from "react";
|
||||
import { ToolTip } from "../../../components/gui/Tooltip";
|
||||
import EditBlockButton from "../../../components/mainInput/Lump/EditBlockButton";
|
||||
import { Button, Card } from "../../../components/ui";
|
||||
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 { fontSize } from "../../../util";
|
||||
import { ToolTip } from "../../../components/gui/Tooltip";
|
||||
import { Button, Card, Divider } from "../../../components/ui";
|
||||
import EditBlockButton from "../../../components/mainInput/Lump/EditBlockButton";
|
||||
import { ConfigHeader } from "../components/ConfigHeader";
|
||||
|
||||
interface MCPServerStatusProps {
|
||||
server: MCPServerStatus;
|
||||
|
|
@ -67,7 +66,7 @@ function MCPServerCard({ server, serverFromYaml }: MCPServerStatusProps) {
|
|||
|
||||
const handleToggleExpanded = (e: React.MouseEvent) => {
|
||||
// Don't expand if clicking on buttons
|
||||
if ((e.target as HTMLElement).closest('button')) {
|
||||
if ((e.target as HTMLElement).closest("button")) {
|
||||
return;
|
||||
}
|
||||
setIsExpanded(!isExpanded);
|
||||
|
|
@ -75,63 +74,75 @@ function MCPServerCard({ server, serverFromYaml }: MCPServerStatusProps) {
|
|||
|
||||
return (
|
||||
<div>
|
||||
<div
|
||||
className="flex items-center justify-between py-1 cursor-pointer"
|
||||
<div
|
||||
className="hover:bg-input/50 -mx-2 flex cursor-pointer items-center justify-between rounded px-2 py-1"
|
||||
onClick={handleToggleExpanded}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<ChevronDownIcon
|
||||
className={`h-4 w-4 text-description transition-transform ${isExpanded ? 'rotate-180' : ''}`}
|
||||
<ChevronDownIcon
|
||||
className={`text-description h-4 w-4 transition-transform ${isExpanded ? "rotate-180" : ""}`}
|
||||
/>
|
||||
<div className="flex-1">
|
||||
<h3
|
||||
<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"}
|
||||
content={
|
||||
server.status === "error"
|
||||
? "Authenticate"
|
||||
: server.status === "authenticating"
|
||||
? "Authenticating..."
|
||||
: "Remove authentication"
|
||||
}
|
||||
>
|
||||
<Button
|
||||
onClick={server.status === "error" ? onAuthenticate : server.status === "authenticating" ? undefined : onRemoveAuth}
|
||||
onClick={
|
||||
server.status === "error"
|
||||
? onAuthenticate
|
||||
: server.status === "authenticating"
|
||||
? undefined
|
||||
: onRemoveAuth
|
||||
}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
|
||||
disabled={server.status === "authenticating"}
|
||||
>
|
||||
{server.status === "authenticating" ? (
|
||||
<GlobeAltIcon className="animate-spin-slow h-4 w-4 text-description" />
|
||||
<GlobeAltIcon className="animate-spin-slow h-4 w-4 flex-shrink-0" />
|
||||
) : (
|
||||
<UserCircleIcon className="h-4 w-4 text-description" />
|
||||
<UserCircleIcon className="h-4 w-4 flex-shrink-0" />
|
||||
)}
|
||||
</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"
|
||||
className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
|
||||
>
|
||||
<ArrowPathIcon className="h-4 w-4 text-description" />
|
||||
<ArrowPathIcon className="h-4 w-4 flex-shrink-0" />
|
||||
</Button>
|
||||
</ToolTip>
|
||||
|
||||
<div
|
||||
className="h-2 w-2 rounded-full flex-shrink-0"
|
||||
className="h-2 w-2 flex-shrink-0 rounded-full"
|
||||
style={{
|
||||
backgroundColor:
|
||||
server.status === "connected"
|
||||
|
|
@ -149,13 +160,52 @@ function MCPServerCard({ server, serverFromYaml }: MCPServerStatusProps) {
|
|||
{isExpanded && (
|
||||
<div className="mt-3 pl-7">
|
||||
{/* Tools, Prompts, Resources with counts */}
|
||||
<div className="flex flex-row items-center gap-6 mb-3">
|
||||
<div className="mb-3 flex flex-row items-center gap-6">
|
||||
<ToolTip
|
||||
className="flex flex-col gap-0.5"
|
||||
content={
|
||||
<>
|
||||
{server.tools.map((tool, idx) => (
|
||||
<code key={idx}>{tool.name}</code>
|
||||
<div key={idx} className="flex flex-col gap-1">
|
||||
<div className="flex flex-col">
|
||||
<code className="font-semibold">{tool.name}</code>
|
||||
{tool.description && (
|
||||
<span className="mt-0.5 text-xs text-gray-400">
|
||||
{tool.description}
|
||||
</span>
|
||||
)}
|
||||
{tool.inputSchema?.properties &&
|
||||
Object.keys(tool.inputSchema.properties).length >
|
||||
0 && (
|
||||
<div className="mt-1">
|
||||
<span className="text-xs text-gray-500">
|
||||
Args:
|
||||
</span>
|
||||
<div className="ml-2">
|
||||
{Object.entries(
|
||||
tool.inputSchema.properties,
|
||||
).map(([paramName, paramSchema], paramIdx) => (
|
||||
<div key={paramIdx} className="text-xs">
|
||||
<code className="text-blue-400">
|
||||
{paramName}
|
||||
</code>
|
||||
{paramSchema &&
|
||||
typeof paramSchema === "object" &&
|
||||
"type" in paramSchema && (
|
||||
<span className="ml-1 text-gray-500">
|
||||
({paramSchema.type})
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{idx < server.tools.length - 1 && (
|
||||
<div className="my-1 border-b border-gray-600"></div>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
{server.tools.length === 0 && (
|
||||
<span className="text-lightgray">No tools</span>
|
||||
|
|
@ -164,7 +214,7 @@ function MCPServerCard({ server, serverFromYaml }: MCPServerStatusProps) {
|
|||
}
|
||||
>
|
||||
<div className="flex cursor-zoom-in items-center gap-2 hover:opacity-80">
|
||||
<WrenchScrewdriverIcon className="h-4 w-4" />
|
||||
<WrenchScrewdriverIcon className="h-4 w-4 flex-shrink-0" />
|
||||
<span className="text-sm">Tools: {server.tools.length}</span>
|
||||
</div>
|
||||
</ToolTip>
|
||||
|
|
@ -183,8 +233,10 @@ function MCPServerCard({ server, serverFromYaml }: MCPServerStatusProps) {
|
|||
}
|
||||
>
|
||||
<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>
|
||||
<CommandLineIcon className="h-4 w-4 flex-shrink-0" />
|
||||
<span className="text-sm">
|
||||
Prompts: {server.prompts.length}
|
||||
</span>
|
||||
</div>
|
||||
</ToolTip>
|
||||
|
||||
|
|
@ -204,8 +256,11 @@ function MCPServerCard({ server, serverFromYaml }: MCPServerStatusProps) {
|
|||
}
|
||||
>
|
||||
<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>
|
||||
<CircleStackIcon className="h-4 w-4 flex-shrink-0" />
|
||||
<span className="text-sm">
|
||||
Resources:{" "}
|
||||
{server.resources.length + server.resourceTemplates.length}
|
||||
</span>
|
||||
</div>
|
||||
</ToolTip>
|
||||
</div>
|
||||
|
|
@ -216,7 +271,10 @@ function MCPServerCard({ server, serverFromYaml }: MCPServerStatusProps) {
|
|||
{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
|
||||
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}
|
||||
|
|
@ -287,41 +345,33 @@ function McpSection() {
|
|||
|
||||
return (
|
||||
<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>
|
||||
<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>
|
||||
<ConfigHeader
|
||||
title="MCP Servers"
|
||||
onAddClick={handleAddMcpServer}
|
||||
addButtonTooltip="Add MCP server"
|
||||
/>
|
||||
|
||||
{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 className="mt-6">
|
||||
{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>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
import { Cog6ToothIcon, PlusCircleIcon } from "@heroicons/react/24/outline";
|
||||
import { ModelRole } from "@continuedev/config-yaml";
|
||||
import { Cog6ToothIcon } from "@heroicons/react/24/outline";
|
||||
import { ModelDescription } from "core";
|
||||
import { useContext } from "react";
|
||||
import { useContext, useState } from "react";
|
||||
import { ToolTip } from "../../../components/gui/Tooltip";
|
||||
import { Button, Card } from "../../../components/ui";
|
||||
import { Divider } from "../../../components/ui/Divider";
|
||||
import { Button, Card, Divider, Toggle } from "../../../components/ui";
|
||||
import { useAuth } from "../../../context/Auth";
|
||||
import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
||||
import { AddModelForm } from "../../../forms/AddModelForm";
|
||||
|
|
@ -12,6 +11,7 @@ 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 "../components/ConfigHeader";
|
||||
import ModelRoleSelector from "../components/ModelRoleSelector";
|
||||
|
||||
export function ModelsSection() {
|
||||
|
|
@ -21,6 +21,7 @@ export function ModelsSection() {
|
|||
|
||||
const config = useAppSelector((state) => state.config.config);
|
||||
const jetbrains = isJetBrains();
|
||||
const [showAdditionalRoles, setShowAdditionalRoles] = useState(false);
|
||||
|
||||
function handleRoleUpdate(role: ModelRole, model: ModelDescription | null) {
|
||||
if (!model) {
|
||||
|
|
@ -40,7 +41,7 @@ export function ModelsSection() {
|
|||
if (!model) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
ideMessenger.post("config/openProfile", {
|
||||
profileId: undefined,
|
||||
element: model,
|
||||
|
|
@ -49,7 +50,7 @@ export function ModelsSection() {
|
|||
|
||||
function handleAddModel() {
|
||||
const isLocal = selectedProfile?.profileType === "local";
|
||||
|
||||
|
||||
if (isLocal) {
|
||||
dispatch(setShowDialog(true));
|
||||
dispatch(
|
||||
|
|
@ -70,23 +71,15 @@ export function ModelsSection() {
|
|||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<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>
|
||||
<div className="space-y-4">
|
||||
<ConfigHeader
|
||||
title="Models"
|
||||
onAddClick={handleAddModel}
|
||||
addButtonTooltip="Add model"
|
||||
/>
|
||||
|
||||
<Card>
|
||||
<div className="pb-6">
|
||||
<div className="py-6 first:pt-0 last:pb-0">
|
||||
<div className="mb-2">
|
||||
<span className="text-base font-medium">Chat</span>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
|
|
@ -106,19 +99,23 @@ export function ModelsSection() {
|
|||
/>
|
||||
</div>
|
||||
{config.selectedModelByRole.chat && (
|
||||
<ToolTip content="Configure">
|
||||
<Cog6ToothIcon
|
||||
className="h-4 w-4 cursor-pointer text-description-muted hover:text-foreground"
|
||||
onClick={() => handleConfigureModel(config.selectedModelByRole.chat)}
|
||||
/>
|
||||
</ToolTip>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() =>
|
||||
handleConfigureModel(config.selectedModelByRole.chat)
|
||||
}
|
||||
className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
|
||||
>
|
||||
<Cog6ToothIcon className="h-4 w-4 flex-shrink-0" />
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
|
||||
<div className="pt-6">
|
||||
<div className="py-6 first:pt-0 last:pb-0">
|
||||
<div className="mb-2">
|
||||
<span className="text-base font-medium">Autocomplete</span>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
|
|
@ -139,150 +136,193 @@ export function ModelsSection() {
|
|||
</div>
|
||||
{config.selectedModelByRole.autocomplete && (
|
||||
<ToolTip content="Configure">
|
||||
<Cog6ToothIcon
|
||||
className="h-4 w-4 cursor-pointer text-description-muted hover:text-foreground"
|
||||
onClick={() => handleConfigureModel(config.selectedModelByRole.autocomplete)}
|
||||
/>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() =>
|
||||
handleConfigureModel(
|
||||
config.selectedModelByRole.autocomplete,
|
||||
)
|
||||
}
|
||||
className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
|
||||
>
|
||||
<Cog6ToothIcon className="h-4 w-4 flex-shrink-0" />
|
||||
</Button>
|
||||
</ToolTip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card className="mt-10">
|
||||
{/* Jetbrains has a model selector inline */}
|
||||
{!jetbrains && (
|
||||
<>
|
||||
<div className="pb-6">
|
||||
<Card>
|
||||
<Toggle
|
||||
isOpen={showAdditionalRoles}
|
||||
onToggle={() => setShowAdditionalRoles(!showAdditionalRoles)}
|
||||
title="Additional model roles"
|
||||
subtitle="Edit, Apply, Embed, Rerank"
|
||||
>
|
||||
<div className="flex flex-col gap-6">
|
||||
{/* Jetbrains has a model selector inline */}
|
||||
{!jetbrains && (
|
||||
<>
|
||||
<div>
|
||||
<div className="mb-2">
|
||||
<span className="text-base font-medium">Edit</span>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
Used for inline edits
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex-1">
|
||||
<ModelRoleSelector
|
||||
displayName="Edit"
|
||||
description="Used for inline edits"
|
||||
models={config.modelsByRole.edit}
|
||||
selectedModel={config.selectedModelByRole.edit}
|
||||
onSelect={(model) => handleRoleUpdate("edit", model)}
|
||||
setupURL="https://docs.continue.dev/edit/model-setup"
|
||||
hideTitle={true}
|
||||
/>
|
||||
</div>
|
||||
{config.selectedModelByRole.edit && (
|
||||
<ToolTip content="Configure">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() =>
|
||||
handleConfigureModel(
|
||||
config.selectedModelByRole.edit,
|
||||
)
|
||||
}
|
||||
className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
|
||||
>
|
||||
<Cog6ToothIcon className="h-4 w-4 flex-shrink-0" />
|
||||
</Button>
|
||||
</ToolTip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
</>
|
||||
)}
|
||||
|
||||
<div>
|
||||
<div className="mb-2">
|
||||
<span className="text-base font-medium">Edit</span>
|
||||
<span className="text-base font-medium">Apply</span>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
Used for inline edits
|
||||
Used to apply generated codeblocks to files
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex-1">
|
||||
<ModelRoleSelector
|
||||
displayName="Edit"
|
||||
description="Used for inline edits"
|
||||
models={config.modelsByRole.edit}
|
||||
selectedModel={config.selectedModelByRole.edit}
|
||||
onSelect={(model) => handleRoleUpdate("edit", model)}
|
||||
setupURL="https://docs.continue.dev/edit/model-setup"
|
||||
displayName="Apply"
|
||||
description="Used to apply generated codeblocks to files"
|
||||
models={config.modelsByRole.apply}
|
||||
selectedModel={config.selectedModelByRole.apply}
|
||||
onSelect={(model) => handleRoleUpdate("apply", model)}
|
||||
setupURL="https://docs.continue.dev/customize/model-roles/apply"
|
||||
hideTitle={true}
|
||||
/>
|
||||
</div>
|
||||
{config.selectedModelByRole.edit && (
|
||||
{config.selectedModelByRole.apply && (
|
||||
<ToolTip content="Configure">
|
||||
<Cog6ToothIcon
|
||||
className="h-4 w-4 cursor-pointer text-description-muted hover:text-foreground"
|
||||
onClick={() => handleConfigureModel(config.selectedModelByRole.edit)}
|
||||
/>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() =>
|
||||
handleConfigureModel(config.selectedModelByRole.apply)
|
||||
}
|
||||
className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
|
||||
>
|
||||
<Cog6ToothIcon className="h-4 w-4 flex-shrink-0" />
|
||||
</Button>
|
||||
</ToolTip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className={jetbrains ? "pb-6" : "py-6"}>
|
||||
<div className="mb-2">
|
||||
<span className="text-base font-medium">Apply</span>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
Used to apply generated codeblocks to files
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex-1">
|
||||
<ModelRoleSelector
|
||||
displayName="Apply"
|
||||
description="Used to apply generated codeblocks to files"
|
||||
models={config.modelsByRole.apply}
|
||||
selectedModel={config.selectedModelByRole.apply}
|
||||
onSelect={(model) => handleRoleUpdate("apply", model)}
|
||||
setupURL="https://docs.continue.dev/customize/model-roles/apply"
|
||||
hideTitle={true}
|
||||
/>
|
||||
<div>
|
||||
<div className="mb-2">
|
||||
<span className="text-base font-medium">Embed</span>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
Used to generate and query embeddings for the @codebase and
|
||||
@docs context providers
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex-1">
|
||||
<ModelRoleSelector
|
||||
displayName="Embed"
|
||||
description="Used to generate and query embeddings for the @codebase and @docs context providers"
|
||||
models={config.modelsByRole.embed}
|
||||
selectedModel={config.selectedModelByRole.embed}
|
||||
onSelect={(model) => handleRoleUpdate("embed", model)}
|
||||
setupURL="https://docs.continue.dev/customize/model-roles/embeddings"
|
||||
hideTitle={true}
|
||||
/>
|
||||
</div>
|
||||
{config.selectedModelByRole.embed && (
|
||||
<ToolTip content="Configure">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() =>
|
||||
handleConfigureModel(config.selectedModelByRole.embed)
|
||||
}
|
||||
className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
|
||||
>
|
||||
<Cog6ToothIcon className="h-4 w-4 flex-shrink-0" />
|
||||
</Button>
|
||||
</ToolTip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{config.selectedModelByRole.apply && (
|
||||
<ToolTip content="Configure">
|
||||
<Cog6ToothIcon
|
||||
className="h-4 w-4 cursor-pointer text-description-muted hover:text-foreground"
|
||||
onClick={() => handleConfigureModel(config.selectedModelByRole.apply)}
|
||||
/>
|
||||
</ToolTip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
<Divider />
|
||||
|
||||
<div className="py-6">
|
||||
<div className="mb-2">
|
||||
<span className="text-base font-medium">Embed</span>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
Used to generate and query embeddings for the @codebase and @docs
|
||||
context providers
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex-1">
|
||||
<ModelRoleSelector
|
||||
displayName="Embed"
|
||||
description="Used to generate and query embeddings for the @codebase and @docs context providers"
|
||||
models={config.modelsByRole.embed}
|
||||
selectedModel={config.selectedModelByRole.embed}
|
||||
onSelect={(model) => handleRoleUpdate("embed", model)}
|
||||
setupURL="https://docs.continue.dev/customize/model-roles/embeddings"
|
||||
hideTitle={true}
|
||||
/>
|
||||
<div>
|
||||
<div className="mb-2">
|
||||
<span className="text-base font-medium">Rerank</span>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
Used for reranking results from the @codebase and @docs
|
||||
context providers
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex-1">
|
||||
<ModelRoleSelector
|
||||
displayName="Rerank"
|
||||
description="Used for reranking results from the @codebase and @docs context providers"
|
||||
models={config.modelsByRole.rerank}
|
||||
selectedModel={config.selectedModelByRole.rerank}
|
||||
onSelect={(model) => handleRoleUpdate("rerank", model)}
|
||||
setupURL="https://docs.continue.dev/customize/model-roles/reranking"
|
||||
hideTitle={true}
|
||||
/>
|
||||
</div>
|
||||
{config.selectedModelByRole.rerank && (
|
||||
<ToolTip content="Configure">
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
onClick={() =>
|
||||
handleConfigureModel(config.selectedModelByRole.rerank)
|
||||
}
|
||||
className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
|
||||
>
|
||||
<Cog6ToothIcon className="h-4 w-4 flex-shrink-0" />
|
||||
</Button>
|
||||
</ToolTip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{config.selectedModelByRole.embed && (
|
||||
<ToolTip content="Configure">
|
||||
<Cog6ToothIcon
|
||||
className="h-4 w-4 cursor-pointer text-description-muted hover:text-foreground"
|
||||
onClick={() => handleConfigureModel(config.selectedModelByRole.embed)}
|
||||
/>
|
||||
</ToolTip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Divider />
|
||||
|
||||
<div className="pt-6">
|
||||
<div className="mb-2">
|
||||
<span className="text-base font-medium">Rerank</span>
|
||||
<p className="mt-1 text-sm text-gray-500">
|
||||
Used for reranking results from the @codebase and @docs context
|
||||
providers
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex-1">
|
||||
<ModelRoleSelector
|
||||
displayName="Rerank"
|
||||
description="Used for reranking results from the @codebase and @docs context providers"
|
||||
models={config.modelsByRole.rerank}
|
||||
selectedModel={config.selectedModelByRole.rerank}
|
||||
onSelect={(model) => handleRoleUpdate("rerank", model)}
|
||||
setupURL="https://docs.continue.dev/customize/model-roles/reranking"
|
||||
hideTitle={true}
|
||||
/>
|
||||
</div>
|
||||
{config.selectedModelByRole.rerank && (
|
||||
<ToolTip content="Configure">
|
||||
<Cog6ToothIcon
|
||||
className="h-4 w-4 cursor-pointer text-description-muted hover:text-foreground"
|
||||
onClick={() => handleConfigureModel(config.selectedModelByRole.rerank)}
|
||||
/>
|
||||
</ToolTip>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Toggle>
|
||||
</Card>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
import { Cog6ToothIcon, PlusCircleIcon } from "@heroicons/react/24/outline";
|
||||
import { Cog6ToothIcon, PlusIcon } 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";
|
||||
import { ConfigHeader } from "../components/ConfigHeader";
|
||||
|
||||
function getOrgIcon(org: { name: string; iconUrl?: string | null }) {
|
||||
if (org.iconUrl) {
|
||||
|
|
@ -60,19 +61,11 @@ export function OrganizationsSection() {
|
|||
|
||||
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>
|
||||
<ConfigHeader
|
||||
title="Organizations"
|
||||
onAddClick={handleAddOrganization}
|
||||
addButtonTooltip="Add organization"
|
||||
/>
|
||||
|
||||
<Card>
|
||||
{organizations.map((organization, index) => (
|
||||
|
|
@ -90,9 +83,9 @@ export function OrganizationsSection() {
|
|||
onClick={() => handleConfigureOrganization(organization.id)}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
|
||||
>
|
||||
<Cog6ToothIcon className="text-description h-4 w-4" />
|
||||
<Cog6ToothIcon className="h-4 w-4 flex-shrink-0" />
|
||||
</Button>
|
||||
</div>
|
||||
{index < organizations.length - 1 && <Divider />}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { parseConfigYaml } from "@continuedev/config-yaml";
|
|||
import {
|
||||
BookmarkIcon as BookmarkOutline,
|
||||
PencilIcon,
|
||||
PlusCircleIcon,
|
||||
PlusIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { BookmarkIcon as BookmarkSolid } from "@heroicons/react/24/solid";
|
||||
import { SlashCommandDescWithSource } from "core";
|
||||
|
|
@ -15,6 +15,7 @@ import { IdeMessengerContext } from "../../../context/IdeMessenger";
|
|||
import { useBookmarkedSlashCommands } from "../../../hooks/useBookmarkedSlashCommands";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import { fontSize } from "../../../util";
|
||||
import { ConfigHeader } from "../components/ConfigHeader";
|
||||
|
||||
interface PromptCommandWithSlug extends SlashCommandDescWithSource {
|
||||
slug?: string;
|
||||
|
|
@ -178,20 +179,12 @@ export function PromptsSection() {
|
|||
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<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>
|
||||
|
||||
<ConfigHeader
|
||||
title="Prompts"
|
||||
onAddClick={handleAddPrompt}
|
||||
addButtonTooltip="Add prompt"
|
||||
/>
|
||||
|
||||
{sortedCommands.length > 0 ? (
|
||||
<div>
|
||||
{sortedCommands.map((prompt) => (
|
||||
|
|
|
|||
|
|
@ -4,13 +4,19 @@ import {
|
|||
BookmarkIcon as BookmarkOutline,
|
||||
EyeIcon,
|
||||
PencilIcon,
|
||||
PlusCircleIcon,
|
||||
PlusIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { BookmarkIcon as BookmarkSolid } from "@heroicons/react/24/solid";
|
||||
import { RuleWithSource, SlashCommandDescWithSource } from "core";
|
||||
import {
|
||||
BrowserSerializedContinueConfig,
|
||||
RuleSource,
|
||||
RuleWithSource,
|
||||
SlashCommandDescWithSource,
|
||||
} from "core";
|
||||
import {
|
||||
DEFAULT_AGENT_SYSTEM_MESSAGE,
|
||||
DEFAULT_CHAT_SYSTEM_MESSAGE,
|
||||
DEFAULT_PLAN_SYSTEM_MESSAGE,
|
||||
DEFAULT_SYSTEM_MESSAGES_URL,
|
||||
} from "core/llm/defaultSystemMessages";
|
||||
import { useContext, useMemo } from "react";
|
||||
|
|
@ -29,6 +35,7 @@ import {
|
|||
toggleRuleSetting,
|
||||
} from "../../../redux/slices/uiSlice";
|
||||
import { fontSize } from "../../../util";
|
||||
import { ConfigHeader } from "../components/ConfigHeader";
|
||||
|
||||
interface PromptCommandWithSlug extends SlashCommandDescWithSource {
|
||||
slug?: string;
|
||||
|
|
@ -347,17 +354,12 @@ function PromptsSubSection() {
|
|||
|
||||
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>
|
||||
<ConfigHeader
|
||||
title="Prompts"
|
||||
variant="sm"
|
||||
onAddClick={handleAddPrompt}
|
||||
addButtonTooltip="Add prompt"
|
||||
/>
|
||||
|
||||
{sortedCommands.length > 0 ? (
|
||||
<Card>
|
||||
|
|
@ -382,6 +384,49 @@ function PromptsSubSection() {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to add the appropriate default system message based on mode
|
||||
*/
|
||||
function addDefaultSystemMessage(
|
||||
rules: RuleWithSource[],
|
||||
mode: string,
|
||||
config: BrowserSerializedContinueConfig,
|
||||
) {
|
||||
const modeConfig = {
|
||||
chat: {
|
||||
customMessage: config.selectedModelByRole.chat?.baseChatSystemMessage,
|
||||
defaultMessage: DEFAULT_CHAT_SYSTEM_MESSAGE,
|
||||
customSource: "model-options-chat" as RuleSource,
|
||||
defaultSource: "default-chat" as RuleSource,
|
||||
},
|
||||
agent: {
|
||||
customMessage: config.selectedModelByRole.chat?.baseAgentSystemMessage,
|
||||
defaultMessage: DEFAULT_AGENT_SYSTEM_MESSAGE,
|
||||
customSource: "model-options-agent" as RuleSource,
|
||||
defaultSource: "default-agent" as RuleSource,
|
||||
},
|
||||
plan: {
|
||||
customMessage: config.selectedModelByRole.chat?.basePlanSystemMessage,
|
||||
defaultMessage: DEFAULT_PLAN_SYSTEM_MESSAGE,
|
||||
customSource: "model-options-plan" as RuleSource,
|
||||
defaultSource: "default-plan" as RuleSource,
|
||||
},
|
||||
};
|
||||
|
||||
const currentMode = modeConfig[mode as keyof typeof modeConfig];
|
||||
if (currentMode) {
|
||||
const message = currentMode.customMessage || currentMode.defaultMessage;
|
||||
const source = currentMode.customMessage
|
||||
? currentMode.customSource
|
||||
: currentMode.defaultSource;
|
||||
|
||||
rules.unshift({
|
||||
rule: message,
|
||||
source,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function RulesSubSection() {
|
||||
const { selectedProfile } = useAuth();
|
||||
const config = useAppSelector((store) => store.config.config);
|
||||
|
|
@ -437,62 +482,19 @@ function RulesSubSection() {
|
|||
}
|
||||
}
|
||||
|
||||
if (mode === "chat") {
|
||||
if (config.selectedModelByRole.chat?.baseChatSystemMessage) {
|
||||
rules.unshift({
|
||||
rule: config.selectedModelByRole.chat?.baseChatSystemMessage,
|
||||
source: "model-options-chat",
|
||||
});
|
||||
} else {
|
||||
rules.unshift({
|
||||
rule: DEFAULT_CHAT_SYSTEM_MESSAGE,
|
||||
source: "default-chat",
|
||||
});
|
||||
}
|
||||
} else if (mode === "agent") {
|
||||
// agent
|
||||
if (config.selectedModelByRole.chat?.baseAgentSystemMessage) {
|
||||
rules.unshift({
|
||||
rule: config.selectedModelByRole.chat?.baseAgentSystemMessage,
|
||||
source: "model-options-agent",
|
||||
});
|
||||
} else {
|
||||
rules.unshift({
|
||||
rule: DEFAULT_AGENT_SYSTEM_MESSAGE,
|
||||
source: "default-agent",
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// plan
|
||||
if (config.selectedModelByRole.chat?.basePlanSystemMessage) {
|
||||
rules.unshift({
|
||||
rule: config.selectedModelByRole.chat?.basePlanSystemMessage,
|
||||
source: "model-options-plan",
|
||||
});
|
||||
} else {
|
||||
rules.unshift({
|
||||
rule: DEFAULT_AGENT_SYSTEM_MESSAGE,
|
||||
source: "default-agent",
|
||||
});
|
||||
}
|
||||
}
|
||||
addDefaultSystemMessage(rules, mode, config);
|
||||
|
||||
return rules;
|
||||
}, [config, selectedProfile, mode]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<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>
|
||||
<ConfigHeader
|
||||
title="Rules"
|
||||
variant="sm"
|
||||
onAddClick={handleAddRule}
|
||||
addButtonTooltip="Add rule"
|
||||
/>
|
||||
|
||||
<Card>
|
||||
{sortedRules.length > 0 ? (
|
||||
|
|
@ -512,13 +514,9 @@ function RulesSubSection() {
|
|||
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>
|
||||
<ConfigHeader title="Rules" />
|
||||
|
||||
<div className="space-y-10">
|
||||
<div className="space-y-6">
|
||||
<RulesSubSection />
|
||||
<PromptsSubSection />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,331 +1,11 @@
|
|||
import {
|
||||
ChevronDownIcon,
|
||||
ChevronRightIcon,
|
||||
InformationCircleIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { MessageModes, Tool } from "core";
|
||||
import { BUILT_IN_GROUP_NAME } from "core/tools/builtIn";
|
||||
import { 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 { Card, Listbox, ListboxButton, ListboxOption, ListboxOptions } from "../../../components/ui";
|
||||
import { useFontSize } from "../../../components/ui/font";
|
||||
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
|
||||
import {
|
||||
addTool,
|
||||
toggleToolGroupSetting,
|
||||
toggleToolSetting,
|
||||
} from "../../../redux/slices/uiSlice";
|
||||
import { fontSize } from "../../../util";
|
||||
import { ConfigHeader } from "../ConfigHeader";
|
||||
|
||||
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="flex flex-row items-center">
|
||||
<div
|
||||
className={`hover:bg-badge hover:text-list-active-foreground xs:gap-1.5 flex flex-1 cursor-pointer flex-row items-center gap-1 rounded py-0.5 pl-1 pr-2`}
|
||||
onClick={() => setIsExpanded((val) => !val)}
|
||||
>
|
||||
<ChevronRightIcon
|
||||
className={`xs:flex hidden h-3 w-3 flex-shrink-0 transition-all duration-200 ${isExpanded ? "rotate-90" : ""}`}
|
||||
/>
|
||||
|
||||
<div
|
||||
className={`flex items-center gap-1 rounded-md`}
|
||||
style={{
|
||||
fontSize,
|
||||
}}
|
||||
>
|
||||
{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">
|
||||
{props.tool.originalFunctionName ?? props.tool.function.name}
|
||||
</span>
|
||||
</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 ${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"
|
||||
? "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-xs font-bold">Description:</span>
|
||||
<span className="italic">{props.tool.function.description}</span>
|
||||
{parameters ? (
|
||||
<>
|
||||
<span className="text-xs font-bold">Arguments:</span>
|
||||
{parameters.map((param, idx) => (
|
||||
<div key={idx} className="block">
|
||||
<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>
|
||||
);
|
||||
}
|
||||
import { ConfigHeader } from "../components/ConfigHeader";
|
||||
import { ToolPolicies } from "../components/ToolPolicies";
|
||||
|
||||
export const ToolPoliciesSection = () => {
|
||||
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],
|
||||
}));
|
||||
};
|
||||
|
||||
return (
|
||||
<div>
|
||||
<ConfigHeader title="Tool Policies" />
|
||||
|
||||
{(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>
|
||||
</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>
|
||||
)}
|
||||
<ToolPolicies />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,38 +2,26 @@ import { ConfigYaml, parseConfigYaml } from "@continuedev/config-yaml";
|
|||
import {
|
||||
ArrowPathIcon,
|
||||
ChevronDownIcon,
|
||||
ChevronRightIcon,
|
||||
CircleStackIcon,
|
||||
CommandLineIcon,
|
||||
GlobeAltIcon,
|
||||
InformationCircleIcon,
|
||||
PlusCircleIcon,
|
||||
PlusIcon,
|
||||
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 { MCPServerStatus } from "core";
|
||||
import { useContext, useMemo, useState } from "react";
|
||||
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 { Button, Card, EmptyState } from "../../../components/ui";
|
||||
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";
|
||||
import { ConfigHeader } from "../components/ConfigHeader";
|
||||
import { ToolPolicies } from "../components/ToolPolicies";
|
||||
|
||||
interface MCPServerStatusProps {
|
||||
server: MCPServerStatus;
|
||||
|
|
@ -195,13 +183,13 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
|
|||
}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
|
||||
disabled={server.status === "authenticating"}
|
||||
>
|
||||
{server.status === "authenticating" ? (
|
||||
<GlobeAltIcon className="animate-spin-slow text-description h-4 w-4" />
|
||||
<GlobeAltIcon className="animate-spin-slow h-4 w-4 flex-shrink-0" />
|
||||
) : (
|
||||
<UserCircleIcon className="text-description h-4 w-4" />
|
||||
<UserCircleIcon className="h-4 w-4 flex-shrink-0" />
|
||||
)}
|
||||
</Button>
|
||||
</ToolTip>
|
||||
|
|
@ -222,9 +210,9 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
|
|||
onClick={onRefresh}
|
||||
variant="ghost"
|
||||
size="sm"
|
||||
className="my-0 h-8 w-8 p-0"
|
||||
className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0"
|
||||
>
|
||||
<ArrowPathIcon className="text-description h-4 w-4" />
|
||||
<ArrowPathIcon className="h-4 w-4 flex-shrink-0" />
|
||||
</Button>
|
||||
</ToolTip>
|
||||
</div>
|
||||
|
|
@ -235,21 +223,27 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
|
|||
<ResourceRow
|
||||
title="Tools"
|
||||
items={server.tools}
|
||||
icon={<WrenchScrewdriverIcon className="text-description h-4 w-4" />}
|
||||
icon={
|
||||
<WrenchScrewdriverIcon className="text-description h-4 w-4 flex-shrink-0" />
|
||||
}
|
||||
sectionKey={`${server.id}-tools`}
|
||||
/>
|
||||
|
||||
<ResourceRow
|
||||
title="Prompts"
|
||||
items={server.prompts}
|
||||
icon={<CommandLineIcon className="text-description h-4 w-4" />}
|
||||
icon={
|
||||
<CommandLineIcon className="text-description h-4 w-4 flex-shrink-0" />
|
||||
}
|
||||
sectionKey={`${server.id}-prompts`}
|
||||
/>
|
||||
|
||||
<ResourceRow
|
||||
title="Resources"
|
||||
items={[...server.resources, ...server.resourceTemplates]}
|
||||
icon={<CircleStackIcon className="text-description h-4 w-4" />}
|
||||
icon={
|
||||
<CircleStackIcon className="text-description h-4 w-4 flex-shrink-0" />
|
||||
}
|
||||
sectionKey={`${server.id}-resources`}
|
||||
/>
|
||||
</div>
|
||||
|
|
@ -278,180 +272,6 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
|
|||
);
|
||||
}
|
||||
|
||||
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(
|
||||
|
|
@ -466,9 +286,20 @@ function McpSubsection() {
|
|||
const parsed = selectedProfile?.rawYaml
|
||||
? parseConfigYaml(selectedProfile?.rawYaml ?? "")
|
||||
: undefined;
|
||||
return (servers ?? []).map((doc, index) => ({
|
||||
|
||||
// Create a map of YAML servers keyed by name for stable matching
|
||||
const yamlServersByName = new Map(
|
||||
parsed?.mcpServers
|
||||
?.filter(
|
||||
(server): server is NonNullable<typeof server> & { name: string } =>
|
||||
server != null && "name" in server,
|
||||
)
|
||||
.map((server) => [server.name, server]) ?? [],
|
||||
);
|
||||
|
||||
return (servers ?? []).map((doc) => ({
|
||||
block: doc,
|
||||
blockFromYaml: parsed?.mcpServers?.[index],
|
||||
blockFromYaml: yamlServersByName.get(doc.name),
|
||||
}));
|
||||
}, [servers, selectedProfile]);
|
||||
|
||||
|
|
@ -487,19 +318,12 @@ function McpSubsection() {
|
|||
|
||||
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>
|
||||
<ConfigHeader
|
||||
title="MCP Servers"
|
||||
variant="sm"
|
||||
onAddClick={!disableMcp ? handleAddMcpServer : undefined}
|
||||
addButtonTooltip="Add MCP server"
|
||||
/>
|
||||
{disableMcp ? (
|
||||
<Card>
|
||||
<EmptyState message="MCP servers are disabled in your organization" />
|
||||
|
|
@ -523,144 +347,10 @@ function McpSubsection() {
|
|||
}
|
||||
|
||||
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>
|
||||
<ConfigHeader title="Tool Policies" variant="sm" />
|
||||
<ToolPolicies />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -671,12 +361,12 @@ export function ToolsSection() {
|
|||
const hasTools = availableTools && availableTools.length > 0;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<>
|
||||
<ConfigHeader title="Tools" />
|
||||
<div className="space-y-8">
|
||||
<div className="space-y-6">
|
||||
<McpSubsection />
|
||||
{hasTools && <ToolPoliciesSubsection />}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { ChevronRightIcon } from "@heroicons/react/24/outline";
|
||||
import {
|
||||
SharedConfigSchema,
|
||||
modifyAnyConfigWithSharedConfig,
|
||||
|
|
@ -6,16 +5,16 @@ import {
|
|||
import { HubSessionInfo } from "core/control-plane/AuthTypes";
|
||||
import { isContinueTeamMember } from "core/util/isContinueTeamMember";
|
||||
import { useContext, useEffect, useState } from "react";
|
||||
import { Card, useFontSize } from "../../../components/ui";
|
||||
import { Card, Toggle, useFontSize } from "../../../components/ui";
|
||||
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 { setLocalStorage } from "../../../util/localStorage";
|
||||
import { ConfigHeader } from "../components/ConfigHeader";
|
||||
import { ContinueFeaturesMenu } from "../components/ContinueFeaturesMenu";
|
||||
import { UserSetting } from "../components/UserSetting";
|
||||
import { ConfigHeader } from "../ConfigHeader";
|
||||
import { ContinueFeaturesMenu } from "../utils/ContinueFeaturesMenu";
|
||||
|
||||
export function UserSettingsSection() {
|
||||
/////// User settings section //////
|
||||
|
|
@ -80,12 +79,7 @@ export function UserSettingsSection() {
|
|||
config.experimental?.enableStaticContextualization ?? false;
|
||||
|
||||
const allowAnonymousTelemetry = config.allowAnonymousTelemetry ?? true;
|
||||
const disableIndexing = config.disableIndexing ?? false;
|
||||
|
||||
// const useAutocompleteCache = config.tabAutocompleteOptions?.useCache ?? true;
|
||||
// const useChromiumForDocsCrawling =
|
||||
// config.experimental?.useChromiumForDocsCrawling ?? false;
|
||||
// const codeBlockToolbarPosition = config.ui?.codeBlockToolbarPosition ?? "top";
|
||||
const useAutocompleteMultilineCompletions =
|
||||
config.tabAutocompleteOptions?.multilineCompletions ?? "auto";
|
||||
const modelTimeout = config.tabAutocompleteOptions?.modelTimeout ?? 150;
|
||||
|
|
@ -104,295 +98,255 @@ export function UserSettingsSection() {
|
|||
});
|
||||
};
|
||||
|
||||
const [hubEnabled, setHubEnabled] = useState(false);
|
||||
useEffect(() => {
|
||||
void ideMessenger.ide
|
||||
.getIdeSettings()
|
||||
.then(({ continueTestEnvironment }) => {
|
||||
setHubEnabled(continueTestEnvironment === "production");
|
||||
});
|
||||
}, [ideMessenger]);
|
||||
|
||||
const hasContinueEmail = isContinueTeamMember(
|
||||
(session as HubSessionInfo)?.account?.id,
|
||||
);
|
||||
|
||||
const disableTelemetryToggle =
|
||||
currentOrg?.policy?.allowAnonymousTelemetry === false;
|
||||
const disableIndexingToggle =
|
||||
currentOrg?.policy?.allowCodebaseIndexing === false;
|
||||
|
||||
return (
|
||||
<div>
|
||||
{hubEnabled ? (
|
||||
<div className="flex flex-col">
|
||||
<ConfigHeader title="User Settings" />
|
||||
<div className="space-y-6">
|
||||
{/* Chat Interface Settings */}
|
||||
<div>
|
||||
<h3 className="mb-3 mt-0 text-base font-medium">Chat</h3>
|
||||
<Card>
|
||||
<div className="flex flex-col gap-4">
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Show Session Tabs"
|
||||
description="If on, displays tabs above the chat as an alternative way to organize and access your sessions."
|
||||
value={showSessionTabs}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ showSessionTabs: value })
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Wrap Codeblocks"
|
||||
description="If on, wraps long lines in code blocks instead of showing horizontal scroll."
|
||||
value={codeWrap}
|
||||
onChange={(value) => handleUpdate({ codeWrap: value })}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Show Chat Scrollbar"
|
||||
description="If on, enables a scrollbar in the chat window."
|
||||
value={showChatScrollbar}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ showChatScrollbar: value })
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Text-to-Speech Output"
|
||||
description="If on, reads LLM responses aloud with TTS."
|
||||
value={readResponseTTS}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ readResponseTTS: value })
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Enable Session Titles"
|
||||
description="If on, generates summary titles for each chat session after the first message, using the current Chat model."
|
||||
value={!disableSessionTitles}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ disableSessionTitles: !value })
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Format Markdown"
|
||||
description="If off, shows responses as raw text."
|
||||
value={!displayRawMarkdown}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ displayRawMarkdown: !value })
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Auto-Accept Agent Edits"
|
||||
description="If on, diffs generated by the edit tool are automatically accepted and Agent proceeds with the next conversational turn."
|
||||
value={autoAcceptEditToolDiffs}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ autoAcceptEditToolDiffs: value })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
<div className="flex flex-col">
|
||||
<ConfigHeader title="User Settings" />
|
||||
<div className="space-y-6">
|
||||
{/* Chat Interface Settings */}
|
||||
<div>
|
||||
<ConfigHeader title="Chat" variant="sm" />
|
||||
<Card>
|
||||
<div className="flex flex-col gap-4">
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Show Session Tabs"
|
||||
description="If on, displays tabs above the chat as an alternative way to organize and access your sessions."
|
||||
value={showSessionTabs}
|
||||
onChange={(value) => handleUpdate({ showSessionTabs: value })}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Wrap Codeblocks"
|
||||
description="If on, wraps long lines in code blocks instead of showing horizontal scroll."
|
||||
value={codeWrap}
|
||||
onChange={(value) => handleUpdate({ codeWrap: value })}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Show Chat Scrollbar"
|
||||
description="If on, enables a scrollbar in the chat window."
|
||||
value={showChatScrollbar}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ showChatScrollbar: value })
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Text-to-Speech Output"
|
||||
description="If on, reads LLM responses aloud with TTS."
|
||||
value={readResponseTTS}
|
||||
onChange={(value) => handleUpdate({ readResponseTTS: value })}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Enable Session Titles"
|
||||
description="If on, generates summary titles for each chat session after the first message, using the current Chat model."
|
||||
value={!disableSessionTitles}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ disableSessionTitles: !value })
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Format Markdown"
|
||||
description="If off, shows responses as raw text."
|
||||
value={!displayRawMarkdown}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ displayRawMarkdown: !value })
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Auto-Accept Agent Edits"
|
||||
description="If on, diffs generated by the edit tool are automatically accepted and Agent proceeds with the next conversational turn."
|
||||
value={autoAcceptEditToolDiffs}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ autoAcceptEditToolDiffs: value })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Privacy Settings */}
|
||||
<div>
|
||||
<h3 className="mb-3 text-base font-medium">Privacy & Data</h3>
|
||||
<Card>
|
||||
<div className="flex flex-col gap-4">
|
||||
{/* Privacy Settings */}
|
||||
<div>
|
||||
<ConfigHeader title="Privacy" variant="sm" />
|
||||
<Card>
|
||||
<div className="flex flex-col gap-4">
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Allow Anonymous Telemetry"
|
||||
description="If on, allows Continue to send anonymous telemetry."
|
||||
value={allowAnonymousTelemetry}
|
||||
disabled={disableTelemetryToggle}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ allowAnonymousTelemetry: value })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Appearance Settings */}
|
||||
<div>
|
||||
<ConfigHeader title="Appearance" variant="sm" />
|
||||
<Card>
|
||||
<div className="flex flex-col gap-4">
|
||||
<UserSetting
|
||||
type="number"
|
||||
title="Font Size"
|
||||
description="Specifies base font size for UI elements."
|
||||
value={fontSize}
|
||||
onChange={(val) => {
|
||||
setLocalStorage("fontSize", val);
|
||||
handleUpdate({ fontSize: val });
|
||||
}}
|
||||
min={7}
|
||||
max={50}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Autocomplete Settings */}
|
||||
<div>
|
||||
<ConfigHeader title="Autocomplete" variant="sm" />
|
||||
<Card>
|
||||
<div className="flex flex-col gap-4">
|
||||
<UserSetting
|
||||
type="select"
|
||||
title="Multiline Autocompletions"
|
||||
description="Controls multiline completions for autocomplete."
|
||||
value={useAutocompleteMultilineCompletions}
|
||||
onChange={(value) =>
|
||||
handleUpdate({
|
||||
useAutocompleteMultilineCompletions: value as
|
||||
| "auto"
|
||||
| "always"
|
||||
| "never",
|
||||
})
|
||||
}
|
||||
options={[
|
||||
{ label: "Auto", value: "auto" },
|
||||
{ label: "Always", value: "always" },
|
||||
{ label: "Never", value: "never" },
|
||||
]}
|
||||
/>
|
||||
<UserSetting
|
||||
type="number"
|
||||
title="Autocomplete Timeout (ms)"
|
||||
description="Maximum time in milliseconds for autocomplete request/retrieval."
|
||||
value={modelTimeout}
|
||||
onChange={(val) => handleUpdate({ modelTimeout: val })}
|
||||
min={100}
|
||||
max={5000}
|
||||
/>
|
||||
<UserSetting
|
||||
type="number"
|
||||
title="Autocomplete Debounce (ms)"
|
||||
description="Minimum time in milliseconds to trigger an autocomplete request after a change."
|
||||
value={debounceDelay}
|
||||
onChange={(val) => handleUpdate({ debounceDelay: val })}
|
||||
min={0}
|
||||
max={2500}
|
||||
/>
|
||||
<UserSetting
|
||||
type="input"
|
||||
title="Disable autocomplete in files"
|
||||
description="List of comma-separated glob pattern to disable autocomplete in matching files. E.g., **/*.(txt,md)"
|
||||
value={formDisableAutocomplete}
|
||||
onChange={setFormDisableAutocomplete}
|
||||
onSubmit={handleDisableAutocompleteSubmit}
|
||||
onCancel={cancelChangeDisableAutocomplete}
|
||||
isDirty={
|
||||
formDisableAutocomplete !== disableAutocompleteInFiles
|
||||
}
|
||||
isValid={formDisableAutocomplete.trim() !== ""}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Experimental Settings */}
|
||||
<div>
|
||||
<ConfigHeader title="Experimental" variant="sm" />
|
||||
<Card>
|
||||
<Toggle
|
||||
isOpen={showExperimental}
|
||||
onToggle={() => setShowExperimental(!showExperimental)}
|
||||
title="Show Experimental Settings"
|
||||
>
|
||||
<div className="flex flex-col gap-x-1 gap-y-4">
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Allow Anonymous Telemetry"
|
||||
description="If on, allows Continue to send anonymous telemetry."
|
||||
value={allowAnonymousTelemetry}
|
||||
disabled={disableTelemetryToggle}
|
||||
title="Add Current File by Default"
|
||||
description="If on, the currently open file is added as context in every new conversation."
|
||||
value={useCurrentFileAsContext}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ allowAnonymousTelemetry: value })
|
||||
handleUpdate({ useCurrentFileAsContext: value })
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Enable Indexing"
|
||||
description="If on, allows indexing of your codebase for better search and context understanding."
|
||||
value={!disableIndexing}
|
||||
disabled={disableIndexingToggle}
|
||||
title="Enable experimental tools"
|
||||
description="If on, enables access to experimental tools that are still in development."
|
||||
value={enableExperimentalTools}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ disableIndexing: !value })
|
||||
handleUpdate({ enableExperimentalTools: value })
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Appearance Settings */}
|
||||
<div>
|
||||
<h3 className="mb-3 text-base font-medium">Appearance</h3>
|
||||
<Card>
|
||||
<div className="flex flex-col gap-4">
|
||||
<UserSetting
|
||||
type="number"
|
||||
title="Font Size"
|
||||
description="Specifies base font size for UI elements."
|
||||
value={fontSize}
|
||||
onChange={(val) => {
|
||||
setLocalStorage("fontSize", val);
|
||||
handleUpdate({ fontSize: val });
|
||||
}}
|
||||
min={7}
|
||||
max={50}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Autocomplete Settings */}
|
||||
<div>
|
||||
<h3 className="mb-3 text-base font-medium">Autocomplete</h3>
|
||||
<Card>
|
||||
<div className="flex flex-col gap-4">
|
||||
<UserSetting
|
||||
type="select"
|
||||
title="Multiline Autocompletions"
|
||||
description="Controls multiline completions for autocomplete."
|
||||
value={useAutocompleteMultilineCompletions}
|
||||
type="toggle"
|
||||
title="Only use system message tools"
|
||||
description="If on, Continue will not attempt to use native tool calling and will only use system message tools."
|
||||
value={onlyUseSystemMessageTools}
|
||||
onChange={(value) =>
|
||||
handleUpdate({
|
||||
useAutocompleteMultilineCompletions: value as
|
||||
| "auto"
|
||||
| "always"
|
||||
| "never",
|
||||
})
|
||||
handleUpdate({ onlyUseSystemMessageTools: value })
|
||||
}
|
||||
options={[
|
||||
{ label: "Auto", value: "auto" },
|
||||
{ label: "Always", value: "always" },
|
||||
{ label: "Never", value: "never" },
|
||||
]}
|
||||
/>
|
||||
<UserSetting
|
||||
type="number"
|
||||
title="Autocomplete Timeout (ms)"
|
||||
description="Maximum time in milliseconds for autocomplete request/retrieval."
|
||||
value={modelTimeout}
|
||||
onChange={(val) => handleUpdate({ modelTimeout: val })}
|
||||
min={100}
|
||||
max={5000}
|
||||
/>
|
||||
<UserSetting
|
||||
type="number"
|
||||
title="Autocomplete Debounce (ms)"
|
||||
description="Minimum time in milliseconds to trigger an autocomplete request after a change."
|
||||
value={debounceDelay}
|
||||
onChange={(val) => handleUpdate({ debounceDelay: val })}
|
||||
min={0}
|
||||
max={2500}
|
||||
/>
|
||||
<UserSetting
|
||||
type="input"
|
||||
title="Disable autocomplete in files"
|
||||
description="List of comma-separated glob pattern to disable autocomplete in matching files. E.g., **/*.(txt,md)"
|
||||
value={formDisableAutocomplete}
|
||||
onChange={setFormDisableAutocomplete}
|
||||
onSubmit={handleDisableAutocompleteSubmit}
|
||||
onCancel={cancelChangeDisableAutocomplete}
|
||||
isDirty={
|
||||
formDisableAutocomplete !== disableAutocompleteInFiles
|
||||
type="toggle"
|
||||
title="@Codebase: use tool calling only"
|
||||
description="If on, @codebase context provider will only use tool calling for code retrieval."
|
||||
value={codebaseToolCallingOnly}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ codebaseToolCallingOnly: value })
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Stream after tool rejection"
|
||||
description="If on, streaming will continue after the tool call is rejected."
|
||||
value={continueAfterToolRejection}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ continueAfterToolRejection: value })
|
||||
}
|
||||
isValid={formDisableAutocomplete.trim() !== ""}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* Experimental Settings */}
|
||||
<div>
|
||||
<h3 className="mb-3 text-base font-medium">Experimental</h3>
|
||||
<Card>
|
||||
<div
|
||||
className="flex cursor-pointer items-center gap-2 text-left text-sm font-semibold"
|
||||
onClick={() => setShowExperimental(!showExperimental)}
|
||||
>
|
||||
<ChevronRightIcon
|
||||
className={`h-4 w-4 transition-transform ${
|
||||
showExperimental ? "rotate-90" : ""
|
||||
}`}
|
||||
/>
|
||||
<span>Show Experimental Settings</span>
|
||||
</div>
|
||||
<div
|
||||
className={`duration-400 overflow-hidden transition-all ease-in-out ${
|
||||
showExperimental
|
||||
? "max-h-96" /* Increased from max-h-40 to max-h-96 to accommodate ContinueFeaturesMenu */
|
||||
: "max-h-0"
|
||||
}`}
|
||||
>
|
||||
<div className="flex flex-col gap-x-1 gap-y-4 pl-6">
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Add Current File by Default"
|
||||
description="If on, the currently open file is added as context in every new conversation."
|
||||
value={useCurrentFileAsContext}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ useCurrentFileAsContext: value })
|
||||
{hasContinueEmail && (
|
||||
<ContinueFeaturesMenu
|
||||
enableStaticContextualization={
|
||||
enableStaticContextualization
|
||||
}
|
||||
handleEnableStaticContextualizationToggle={
|
||||
handleEnableStaticContextualizationToggle
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Enable experimental tools"
|
||||
description="If on, enables access to experimental tools that are still in development."
|
||||
value={enableExperimentalTools}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ enableExperimentalTools: value })
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Only use system message tools"
|
||||
description="If on, Continue will not attempt to use native tool calling and will only use system message tools."
|
||||
value={onlyUseSystemMessageTools}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ onlyUseSystemMessageTools: value })
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="@Codebase: use tool calling only"
|
||||
description="If on, @codebase context provider will only use tool calling for code retrieval."
|
||||
value={codebaseToolCallingOnly}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ codebaseToolCallingOnly: value })
|
||||
}
|
||||
/>
|
||||
<UserSetting
|
||||
type="toggle"
|
||||
title="Stream after tool rejection"
|
||||
description="If on, streaming will continue after the tool call is rejected."
|
||||
value={continueAfterToolRejection}
|
||||
onChange={(value) =>
|
||||
handleUpdate({ continueAfterToolRejection: value })
|
||||
}
|
||||
/>
|
||||
|
||||
{hasContinueEmail && (
|
||||
<ContinueFeaturesMenu
|
||||
enableStaticContextualization={
|
||||
enableStaticContextualization
|
||||
}
|
||||
handleEnableStaticContextualizationToggle={
|
||||
handleEnableStaticContextualizationToggle
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
</Toggle>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,36 @@
|
|||
// Valid config tab names
|
||||
export type ConfigTab =
|
||||
| "models"
|
||||
| "rules"
|
||||
| "tools"
|
||||
| "agents"
|
||||
| "organizations"
|
||||
| "indexing"
|
||||
| "settings"
|
||||
| "help";
|
||||
|
||||
// TODO: Move all the routes here
|
||||
export const ROUTES = {
|
||||
HOME: "/",
|
||||
CONFIG: "/config",
|
||||
THEME: "/theme",
|
||||
STATS: "/stats",
|
||||
// EXAMPLE_ROUTE_WITH_PARAMS: (params: ParamsType) => `/route/${params}`,
|
||||
};
|
||||
|
||||
// Helper function to build config URLs with tabs
|
||||
export const buildConfigRoute = (tab?: ConfigTab): string => {
|
||||
return tab ? `${ROUTES.CONFIG}?tab=${tab}` : ROUTES.CONFIG;
|
||||
};
|
||||
|
||||
// Typed config route builders for common tabs
|
||||
export const CONFIG_ROUTES = {
|
||||
MODELS: buildConfigRoute("models"),
|
||||
RULES: buildConfigRoute("rules"),
|
||||
TOOLS: buildConfigRoute("tools"),
|
||||
AGENTS: buildConfigRoute("agents"),
|
||||
ORGANIZATIONS: buildConfigRoute("organizations"),
|
||||
INDEXING: buildConfigRoute("indexing"),
|
||||
SETTINGS: buildConfigRoute("settings"),
|
||||
HELP: buildConfigRoute("help"),
|
||||
} as const;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue