feat: better settings page and open settings fixes

This commit is contained in:
Dallin Romney 2025-09-29 15:59:46 -07:00
parent e6b93fccc3
commit a7e392bdde
36 changed files with 402 additions and 773 deletions

View file

@ -23,6 +23,7 @@
"binary/build/**": true,
"binary/out/**": true,
"binary/tmp/**": true,
"core/dist/**": true,
"core/edit/lazy/test-examples/**": true,
"core/llm/llamaTokenizer.js": true,
"core/llm/llamaTokenizer.mjs": true,

View file

@ -11,6 +11,5 @@ export function convertCustomCommandToSlashCommand(
description: customCommand.description ?? "",
prompt: customCommand.prompt,
source: "json-custom-command",
promptFile: customCommand.sourceFile, // TODO refactor promptFile to align with sourceFile
};
sourceFile: customCommand.sourceFile,
}

View file

@ -9,6 +9,6 @@ export function convertPromptBlockToSlashCommand(
description: prompt.description ?? "",
prompt: prompt.prompt,
source: "yaml-prompt-block",
promptFile: prompt.sourceFile, // Align with the sourceFile property
sourceFile: prompt.sourceFile,
};
}

View file

@ -15,7 +15,7 @@ export function slashCommandFromPromptFile(
description,
prompt,
source: version === 1 ? "prompt-file-v1" : "prompt-file-v2",
promptFile: path,
sourceFile: path,
overrideSystemMessage: systemMessage,
};
}

View file

@ -10,6 +10,7 @@ export function convertRuleBlockToSlashCommand(
description: rule.description ?? "",
prompt: rule.rule,
source: "invokable-rule",
promptFile: rule.ruleFile,
sourceFile: rule.ruleFile,
slug: rule.slug,
};
}

View file

@ -12,13 +12,12 @@ import { getGlobalFolderWithName } from "../util/paths";
import { localPathToUri } from "../util/pathToUri";
import { getUriPathBasename, joinPathsToUri } from "../util/uri";
import { SYSTEM_PROMPT_DOT_FILE } from "./getWorkspaceContinueRuleDotFiles";
import { SUPPORTED_AGENT_FILES } from "./markdown";
export function isContinueConfigRelatedUri(uri: string): boolean {
return (
uri.endsWith(".continuerc.json") ||
uri.endsWith(".prompt") ||
uri.endsWith("AGENTS.md") ||
uri.endsWith("AGENT.md") ||
uri.endsWith("CLAUDE.md") ||
!!SUPPORTED_AGENT_FILES.find((file) => uri.endsWith(`/${file}`)) ||
uri.endsWith(SYSTEM_PROMPT_DOT_FILE) ||
(uri.includes(".continue") &&
(uri.endsWith(".yaml") ||

View file

@ -44,7 +44,6 @@ export async function loadMarkdownRules(ide: IDE): Promise<{
// File doesn't exist or can't be read, continue to next file
}
}
if (agentFileFound) {
break; // Use agent file from first workspace that has one
}

View file

@ -88,11 +88,11 @@ class MCPConnection {
this.abortController = new AbortController();
}
async disconnect() {
this.status = "not-connected";
async disconnect(disable = false) {
this.abortController.abort();
await this.client.close();
await this.transport.close();
this.status = disable ? "disabled" : "not-connected";
}
getStatus(): MCPServerStatus {
@ -110,6 +110,9 @@ class MCPConnection {
}
async connectClient(forceRefresh: boolean, externalSignal: AbortSignal) {
if (this.status === "disabled") {
return;
}
if (!forceRefresh) {
// Already connected
if (this.status === "connected") {

View file

@ -8,7 +8,6 @@ export class MCPManagerSingleton {
public onConnectionsRefreshed?: () => void;
public connections: Map<string, MCPConnection> = new Map();
private disconnectedServers: string[] = [];
private abortController: AbortController = new AbortController();
@ -21,16 +20,16 @@ export class MCPManagerSingleton {
return MCPManagerSingleton.instance;
}
addDisconnectedServer(serverId: string) {
this.disconnectedServers.push(serverId);
}
removeDisconnectedServer(serverId: string) {
this.disconnectedServers = this.disconnectedServers.filter(
(server) => server !== serverId,
);
}
getDisconnectedServers() {
return this.disconnectedServers;
async setEnabled(serverId: string, enabled: boolean) {
const conn = this.connections.get(serverId);
if (conn) {
if (enabled) {
conn.status = "not-connected";
await this.refreshConnection(serverId);
} else {
await conn.disconnect(true);
}
}
}
createConnection(id: string, options: InternalMcpOptions): MCPConnection {
@ -47,15 +46,6 @@ export class MCPManagerSingleton {
return this.connections.get(id);
}
async removeConnection(id: string) {
const connection = this.connections.get(id);
if (connection) {
await connection.client.close();
}
this.connections.delete(id);
}
async shutdown() {
if (this.connections.size > 0) {
await Promise.allSettled(
@ -169,19 +159,9 @@ export class MCPManagerSingleton {
}),
(async () => {
await Promise.all(
Array.from(this.connections.values())
.filter(
(connection) =>
!this.disconnectedServers.some(
(s) => s === connection.options.id,
),
)
.map(async (connection) => {
await connection.connectClient(
force,
this.abortController.signal,
);
}),
Array.from(this.connections.values()).map(async (connection) => {
await connection.connectClient(force, this.abortController.signal);
}),
);
if (this.onConnectionsRefreshed) {
this.onConnectionsRefreshed();

View file

@ -94,28 +94,6 @@ describe("MCPManagerSingleton", () => {
});
});
describe("removeConnection", () => {
it("should remove connection and close client", async () => {
// Create a spy on the close method
const connection = manager.createConnection(
"test-id",
testOptions,
) as TestMCPConnection;
const closeSpy = vi.spyOn(connection.client, "close");
await manager.removeConnection("test-id");
expect(closeSpy).toHaveBeenCalled();
expect(manager.getConnection("test-id")).toBeUndefined();
});
it("should handle non-existent connection", async () => {
await expect(
manager.removeConnection("non-existent"),
).resolves.toBeUndefined();
});
});
describe("setConnections", () => {
it("should add new connections", () => {
const servers = [testOptions];

View file

@ -411,10 +411,7 @@ export class Core {
});
on("config/openProfile", async (msg) => {
await this.configHandler.openConfigProfile(
msg.data.profileId,
msg.data?.element,
);
await this.configHandler.openConfigProfile(msg.data.profileId);
});
on("config/ideSettingsUpdate", async (msg) => {
@ -483,20 +480,13 @@ export class Core {
on("mcp/reloadServer", async (msg) => {
await MCPManagerSingleton.getInstance().refreshConnection(msg.data.id);
MCPManagerSingleton.getInstance().removeDisconnectedServer(msg.data.id);
});
on("mcp/disconnectServer", async (msg) => {
const mcpConnection = MCPManagerSingleton.getInstance().getConnection(
msg.data.id,
on("mcp/setServerEnabled", async (msg) => {
const { id, enabled } = msg.data;
await MCPManagerSingleton.getInstance().setEnabled(id, enabled);
await this.configHandler.reloadConfig(
`MCP Server ${enabled ? "enabled" : "disabled"}`,
);
if (!mcpConnection)
throw new Error(`MCP connection with id ${msg.data.id} not found`);
MCPManagerSingleton.getInstance().addDisconnectedServer(msg.data.id);
await mcpConnection.disconnect();
await this.configHandler.refreshAll("MCP Servers disconnected");
});
on("mcp/getDisconnectedServers", async (_msg) => {
return MCPManagerSingleton.getInstance().getDisconnectedServers();
});
on("mcp/getPrompt", async (msg) => {
const { serverName, promptName, args } = msg.data;

7
core/index.d.ts vendored
View file

@ -918,7 +918,8 @@ export interface SlashCommand extends SlashCommandDescription {
export interface SlashCommandWithSource extends SlashCommandDescription {
run?: (sdk: ContinueSDK) => AsyncGenerator<string | undefined>; // Optional - only needed for legacy
source: SlashCommandSource;
promptFile?: string;
sourceFile?: string;
slug?: string;
overrideSystemMessage?: string;
}
@ -936,7 +937,8 @@ export type SlashCommandSource =
export interface SlashCommandDescWithSource extends SlashCommandDescription {
isLegacy: boolean; // Maps to if slashcommand.run exists
source: SlashCommandSource;
promptFile?: string;
sourceFile?: string;
slug?: string;
mcpServerName?: string;
mcpArgs?: MCPPromptArgs;
}
@ -1273,6 +1275,7 @@ export type TransportOptions =
| StreamableHTTPOptions;
export type MCPConnectionStatus =
| "disabled"
| "connecting"
| "connected"
| "error"

View file

@ -131,7 +131,7 @@ export async function getAllPromptFiles(
await Promise.all(fullDirs.map((dir) => getPromptFilesFromDir(ide, dir)))
).flat();
// Also read from ~/.continue/.prompts
// Also read from ~/.continue/prompts
promptFiles.push(...readAllGlobalPromptFiles());
// Add hardcoded init prompt

View file

@ -117,10 +117,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
),
void,
];
"config/openProfile": [
{ profileId: string | undefined; element?: { sourceFile?: string } },
void,
];
"config/openProfile": [{ profileId: string | undefined }, void];
"config/updateSharedConfig": [SharedConfigSchema, SharedConfigSchema];
"config/updateSelectedModel": [
{
@ -147,8 +144,7 @@ export type ToCoreFromIdeOrWebviewProtocol = {
},
void,
];
"mcp/disconnectServer": [{ id: string }, void];
"mcp/getDisconnectedServers": [undefined, string[]];
"mcp/setServerEnabled": [{ id: string; enabled: boolean }, void];
"mcp/getPrompt": [
{
serverName: string;

View file

@ -32,8 +32,7 @@ export const WEBVIEW_TO_CORE_PASS_THROUGH: (keyof ToCoreFromWebviewProtocol)[] =
"mcp/getPrompt",
"mcp/startAuthentication",
"mcp/removeAuthentication",
"mcp/disconnectServer",
"mcp/getDisconnectedServers",
"mcp/setServerEnabled",
"context/getContextItems",
"context/getSymbolsForFiles",
"context/loadSubmenuItems",

View file

@ -94,6 +94,7 @@ class MessageTypes {
"mcp/reloadServer",
"mcp/startAuthentication",
"mcp/removeAuthentication",
"mcp/setServerEnabled",
"mcp/getPrompt",
"context/getContextItems",
"context/getSymbolsForFiles",

View file

@ -1,5 +1,5 @@
import { useContext, useMemo } from "react";
import { useNavigate } from "react-router-dom";
import { useLocation, useNavigate } from "react-router-dom";
import { useAuth } from "../../context/Auth";
import { IdeMessengerContext } from "../../context/IdeMessenger";
import { useAppSelector } from "../../redux/hooks";
@ -10,7 +10,7 @@ export const FatalErrorIndicator = () => {
const { refreshProfiles } = useAuth();
const configError = useAppSelector((store) => store.config.configError);
const ideMessenger = useContext(IdeMessengerContext);
const location = useLocation();
const navigate = useNavigate();
const hasFatalErrors = useMemo(() => {
@ -18,10 +18,11 @@ export const FatalErrorIndicator = () => {
}, [configError]);
const configLoading = useAppSelector((state) => state.config.loading);
const showConfigPage = () => {
navigate(CONFIG_ROUTES.AGENTS);
};
// const onAgentsPage = location.
const currentPath = `${location.pathname}${location.search}`;
const { selectedProfile } = useAuth();
@ -64,9 +65,11 @@ export const FatalErrorIndicator = () => {
Reload
</div>
)}
<div onClick={showConfigPage} className="cursor-pointer underline">
View
</div>
{currentPath !== CONFIG_ROUTES.AGENTS && (
<div onClick={showConfigPage} className="cursor-pointer underline">
View
</div>
)}
</div>
</Alert>
);

View file

@ -38,7 +38,14 @@ const ToggleSwitch: React.FC<ToggleSwitchProps> = ({
{isToggled && !!showIfToggled && showIfToggled}
<div
className={`border-command-border bg-vsc-input-background relative flex items-center rounded-full border border-solid`}
onClick={disabled ? undefined : onToggle}
onClick={
disabled
? undefined
: (e) => {
e.stopPropagation();
onToggle();
}
}
style={{
height: size,
width: size * 2,

View file

@ -1,58 +0,0 @@
import { ConfigYaml } from "@continuedev/config-yaml";
import { PencilIcon } from "@heroicons/react/24/outline";
import { useContext } from "react";
import { useAuth } from "../../../context/Auth";
import { IdeMessengerContext } from "../../../context/IdeMessenger";
type SectionKey = Exclude<
keyof ConfigYaml,
"name" | "version" | "schema" | "metadata" | "env" | "requestOptions"
>;
interface EditBlockButtonProps<T extends SectionKey> {
blockType: T;
block?: NonNullable<Omit<ConfigYaml, "env">[T]>[number];
className?: string;
sourceFile?: string;
}
function isUsesBlock(block: any): block is { uses: string } {
return typeof block !== "string" && "uses" in block;
}
export default function EditBlockButton<T extends SectionKey>({
block,
blockType,
className = "",
sourceFile,
}: EditBlockButtonProps<T>) {
const ideMessenger = useContext(IdeMessengerContext);
const { selectedProfile } = useAuth();
const openUrl = (path: string) =>
ideMessenger.request("controlPlane/openUrl", {
path,
orgSlug: undefined,
});
const handleEdit = () => {
if (selectedProfile?.profileType === "local") {
ideMessenger.post("config/openProfile", {
profileId: undefined,
element: { sourceFile },
});
} else if (block && isUsesBlock(block)) {
void openUrl(`${block.uses}/new-version`);
} else if (selectedProfile?.fullSlug) {
const slug = `${selectedProfile.fullSlug.ownerSlug}/${selectedProfile.fullSlug.packageSlug}`;
void openUrl(`${slug}/new-version`);
}
};
return (
<PencilIcon
className={`h-3 w-3 cursor-pointer text-gray-400 hover:brightness-125 ${className}`}
onClick={handleEdit}
/>
);
}

View file

@ -0,0 +1,73 @@
import { ModelDescription } from "core";
import { useContext } from "react";
import { useAuth } from "../../../context/Auth";
import { IdeMessengerContext } from "../../../context/IdeMessenger";
export function useEditBlock() {
const ideMessenger = useContext(IdeMessengerContext);
const { selectedProfile } = useAuth();
return (slug?: string, sourceFile?: string) => {
if (slug) {
ideMessenger.post("controlPlane/openUrl", {
path: `${slug}/new-version`,
orgSlug: undefined,
});
} else if (sourceFile) {
ideMessenger.post("openFile", {
path: sourceFile,
});
} else if (selectedProfile?.fullSlug) {
ideMessenger.post("controlPlane/openUrl", {
path: `${selectedProfile.fullSlug.ownerSlug}/${selectedProfile.fullSlug.packageSlug}/new-version`,
orgSlug: undefined,
});
} else {
// Local etc
ideMessenger.post("config/openProfile", {
profileId: undefined,
});
}
};
}
export function useEditModel() {
const editBlock = useEditBlock();
return (model?: ModelDescription | null) => {
editBlock(undefined, model?.sourceFile);
};
}
export function useEditDoc() {
const editBlock = useEditBlock();
return (
docConfig?: { uses?: string } | { name: string; sourceFile?: string },
) => {
if (!docConfig) {
editBlock(undefined, undefined);
return;
}
if ("name" in docConfig) {
editBlock(undefined, docConfig.sourceFile);
} else {
editBlock(docConfig.uses, undefined);
}
};
}
export function useEditMcp() {
const editBlock = useEditBlock();
return (
mcpConfig?: { uses?: string } | { name: string; sourceFile?: string },
) => {
if (!mcpConfig) {
editBlock(undefined, undefined);
return;
}
if ("name" in mcpConfig) {
editBlock(undefined, mcpConfig.sourceFile);
} else {
editBlock(mcpConfig.uses, undefined);
}
};
}

View file

@ -13,8 +13,8 @@ export async function getPromptV2ContextRequests(
}
const workspaceDirs = await ideMessenger.ide.getWorkspaceDirs();
const visitedFiles = new Set<string>();
if (command.promptFile) {
visitedFiles.add(command.promptFile);
if (command.sourceFile) {
visitedFiles.add(command.sourceFile);
}
const contextRequests: GetContextRequest[] = [];

View file

@ -1,3 +1,5 @@
import { cn } from "../../util/cn";
interface CardProps extends React.ComponentProps<"div"> {
children: React.ReactNode;
}
@ -5,8 +7,8 @@ interface CardProps extends React.ComponentProps<"div"> {
export function Card({ children, className = "", ...props }: CardProps) {
return (
<div
className={`bg-editor rounded-default space-y-0 px-4 py-3 ${className}`}
{...props}
className={cn("bg-editor rounded-default space-y-0 px-4 py-3", className)}
>
{children}
</div>

View file

@ -1,6 +1,7 @@
import { PlusIcon } from "@heroicons/react/24/outline";
import { ToolTip } from "../../../components/gui/Tooltip";
import { Button } from "../../../components/ui";
import { cn } from "../../../util/cn";
interface ConfigHeaderProps {
title: string;
@ -9,6 +10,7 @@ interface ConfigHeaderProps {
addButtonTooltip?: string;
className?: string;
variant?: "default" | "sm";
showAddButton?: boolean;
}
export function ConfigHeader({
@ -18,6 +20,7 @@ export function ConfigHeader({
addButtonTooltip = "Add item",
className = "",
variant = "default",
showAddButton = true,
}: ConfigHeaderProps) {
const isSmall = variant === "sm";
const marginBottom = isSmall ? "mb-4" : "mb-6";
@ -26,13 +29,16 @@ export function ConfigHeader({
return (
<div
className={`${marginBottom} flex items-center justify-between ${className}`}
className={cn(
`${marginBottom} flex items-center justify-between`,
className,
)}
>
<div className="flex flex-col">
<HeadingTag className={`my-0 ${titleSize}`}>{title}</HeadingTag>
{subtext && <p className="text-description mt-1 text-sm">{subtext}</p>}
</div>
{onAddClick && (
{showAddButton && onAddClick && (
<ToolTip content={addButtonTooltip}>
<Button
onClick={onAddClick}

View file

@ -1,60 +0,0 @@
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>
);
}

View file

@ -1,87 +1,100 @@
import { ChevronDownIcon } from "@heroicons/react/24/outline";
import { Tool } from "core";
import {
ChevronDownIcon,
WrenchScrewdriverIcon,
} from "@heroicons/react/24/outline";
import { useMemo, useState } from "react";
import ToggleSwitch from "../../../components/gui/Switch";
import { ToolTip } from "../../../components/gui/Tooltip";
import { Card } from "../../../components/ui";
import { useAppDispatch } from "../../../redux/hooks";
import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
import { toggleToolGroupSetting } from "../../../redux/slices/uiSlice";
import { ToolPolicyItem } from "./ToolPolicyItem";
interface ToolPoliciesGroupProps {
showIcon: boolean;
groupName: string;
tools: Tool[];
isGroupEnabled: boolean;
isExpanded: boolean;
displayName: string;
allToolsOff: boolean;
duplicateDetection: Record<string, boolean>;
onToggleGroup: (groupName: string) => void;
}
export function ToolPoliciesGroup({
showIcon,
groupName,
tools,
isGroupEnabled,
isExpanded,
displayName,
allToolsOff,
duplicateDetection,
onToggleGroup,
}: ToolPoliciesGroupProps) {
const dispatch = useAppDispatch();
const [isExpanded, setIsExpanded] = useState(false);
const availableTools = useAppSelector((state) => state.config.config.tools);
const tools = useMemo(() => {
return availableTools.filter((t) => t.group === groupName);
}, [availableTools]);
const toolGroupSettings = useAppSelector(
(state) => state.ui.toolGroupSettings,
);
const isGroupEnabled = useMemo(() => {
return toolGroupSettings[groupName] !== "exclude";
}, [toolGroupSettings, groupName]);
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>
<Card className="flex flex-1 flex-col p-0">
<div
className="flex cursor-pointer items-center justify-between gap-3 rounded px-2 py-2 hover:bg-gray-50 hover:bg-opacity-5"
onClick={() => setIsExpanded(!isExpanded)}
>
<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">
{showIcon && (
<WrenchScrewdriverIcon className="h-4 w-4 flex-shrink-0" />
)}
<span className="text-sm font-semibold">{displayName}</span>
<div className="flex h-5 w-5 items-center justify-center rounded-md bg-gray-600 px-0.5 text-xs font-medium text-white">
{tools.length}
</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}
/>
))}
<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 pl-2">
{tools.map((tool) => (
<ToolPolicyItem
key={tool.uri + tool.function.name}
tool={tool}
duplicatesDetected={duplicateDetection[tool.function.name]}
isGroupEnabled={isGroupEnabled}
/>
))}
</div>
)}
</Card>
);
}

View file

@ -70,14 +70,14 @@ export function ToolPolicyItem(props: ToolPolicyItemProps) {
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-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"
className="flex flex-1 cursor-pointer flex-row items-start gap-1.5"
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" : ""}`}
className={`xs:flex hidden h-3 w-3 flex-shrink-0 pt-1 transition-all duration-200 ${isExpanded ? "rotate-90" : ""}`}
/>
<div className="flex flex-col gap-1">

View file

@ -1,74 +0,0 @@
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 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,
};
}

View file

@ -1,5 +1,5 @@
import { isOnPremSession } from "core/control-plane/AuthTypes";
import React, { useState } from "react";
import React from "react";
import { useNavigate, useSearchParams } from "react-router-dom";
import { AssistantAndOrgListbox } from "../../components/AssistantAndOrgListbox";
import Alert from "../../components/gui/Alert";
@ -14,9 +14,7 @@ function ConfigPage() {
useNavigationListener();
const navigate = useNavigate();
const [searchParams] = useSearchParams();
const [activeTab, setActiveTab] = useState(() => {
return searchParams.get("tab") || "settings";
});
const activeTab = searchParams.get("tab") || "settings";
const { session, organizations } = useAuth();
const allTabs = getAllTabs();
@ -27,7 +25,7 @@ function ConfigPage() {
if (tabId === "back") {
navigate("/");
} else {
setActiveTab(tabId);
navigate(`/config?tab=${tabId}`);
}
};
@ -91,7 +89,7 @@ function ConfigPage() {
</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">
<div className="thin-scrollbar hidden flex-1 space-y-6 overflow-y-auto px-4 py-4 sm:block">
{allTabs.find((tab) => tab.id === activeTab)?.component}
</div>
</div>

View file

@ -41,14 +41,14 @@ export function AgentsSection() {
<div className="flex h-6 w-6 flex-shrink-0 items-center justify-center">
<AssistantIcon assistant={profile} />
</div>
<div className="flex-1">
<div className="flex flex-1 flex-col gap-2">
<h3
className={`my-2 text-sm font-medium ${errors && errors.length > 0 ? "text-error" : ""}`}
>
{profile.title}
</h3>
{errors && errors.length > 0 && (
<div className="mt-2 space-y-1">
<div className="space-y-1 overflow-hidden">
{errors.map((error, errorIndex) => (
<div
key={errorIndex}

View file

@ -2,6 +2,7 @@ import { ModelRole } from "@continuedev/config-yaml";
import { ModelDescription } from "core";
import { useContext, useState } from "react";
import Shortcut from "../../../components/gui/Shortcut";
import { useEditModel } from "../../../components/mainInput/Lump/useEditBlock";
import { Card, Divider, Toggle } from "../../../components/ui";
import { useAuth } from "../../../context/Auth";
import { IdeMessengerContext } from "../../../context/IdeMessenger";
@ -37,16 +38,7 @@ export function ModelsSection() {
);
}
function handleConfigureModel(model: ModelDescription | null) {
if (!model) {
return;
}
ideMessenger.post("config/openProfile", {
profileId: undefined,
element: model,
});
}
const handleConfigureModel = useEditModel();
function handleAddModel() {
const isLocal = selectedProfile?.profileType === "local";

View file

@ -1,207 +0,0 @@
import { parseConfigYaml } from "@continuedev/config-yaml";
import {
BookmarkIcon as BookmarkOutline,
PencilIcon,
PlusIcon,
} from "@heroicons/react/24/outline";
import { BookmarkIcon as BookmarkSolid } from "@heroicons/react/24/solid";
import { SlashCommandDescWithSource } from "core";
import { useContext, useMemo } from "react";
import { useMainEditor } from "../../../components/mainInput/TipTapEditor";
import { ToolTip } from "../../../components/gui/Tooltip";
import { Button, Card, EmptyState } from "../../../components/ui";
import { useAuth } from "../../../context/Auth";
import { IdeMessengerContext } from "../../../context/IdeMessenger";
import { useBookmarkedSlashCommands } from "../../../hooks/useBookmarkedSlashCommands";
import { useAppSelector } from "../../../redux/hooks";
import { fontSize } from "../../../util";
import { ConfigHeader } from "../components/ConfigHeader";
interface PromptCommandWithSlug extends SlashCommandDescWithSource {
slug?: string;
}
interface PromptRowProps {
prompt: PromptCommandWithSlug;
isBookmarked: boolean;
setIsBookmarked: (isBookmarked: boolean) => void;
onEdit?: () => void;
}
/**
* Displays a single prompt row with bookmark and edit controls
*/
function PromptRow({
prompt,
isBookmarked,
setIsBookmarked,
onEdit,
}: PromptRowProps) {
const { mainEditor } = useMainEditor();
const handlePromptClick = (e: React.MouseEvent) => {
e.stopPropagation();
mainEditor?.commands.insertPrompt({
title: prompt.name,
description: prompt.description,
content: prompt.prompt,
});
};
const handleBookmarkClick = (e: React.MouseEvent) => {
e.stopPropagation();
setIsBookmarked(!isBookmarked);
};
const handleEditClick = (e: React.MouseEvent) => {
e.stopPropagation();
if (onEdit) {
onEdit();
}
};
const canEdit =
prompt.promptFile && !prompt.promptFile.startsWith("builtin:");
return (
<div
className="hover:bg-list-active hover:text-list-active-foreground flex items-center justify-between gap-3 rounded-md px-2 py-1 hover:cursor-pointer"
onClick={handlePromptClick}
style={{
fontSize: fontSize(-3),
}}
>
<div className="flex min-w-0 flex-col">
<span className="text-vscForeground shrink-0 font-medium">
{prompt.name}
</span>
<span className="line-clamp-2 text-[11px] text-gray-400">
{prompt.description}
</span>
</div>
<div className="flex items-center gap-2">
<PencilIcon
className={`h-3 w-3 cursor-pointer text-gray-400 hover:brightness-125 ${!canEdit ? "pointer-events-none cursor-not-allowed opacity-50" : ""}`}
onClick={canEdit ? handleEditClick : undefined}
aria-disabled={!canEdit}
/>
<div
onClick={handleBookmarkClick}
className="cursor-pointer pt-0.5 text-gray-400 hover:brightness-125"
>
{isBookmarked ? (
<BookmarkSolid className="h-3 w-3" />
) : (
<BookmarkOutline className="h-3 w-3" />
)}
</div>
</div>
</div>
);
}
/**
* Section that displays all available prompts with bookmarking functionality
*/
export function PromptsSection() {
const { selectedProfile } = useAuth();
const { isCommandBookmarked, toggleBookmark } = useBookmarkedSlashCommands();
const ideMessenger = useContext(IdeMessengerContext);
const isLocal = selectedProfile?.profileType === "local";
const slashCommands = useAppSelector(
(state) => state.config.config.slashCommands ?? [],
);
const handleEdit = (prompt: PromptCommandWithSlug) => {
if (prompt.promptFile) {
ideMessenger.post("openFile", {
path: prompt.promptFile,
});
} else if (prompt.slug) {
void ideMessenger.request("controlPlane/openUrl", {
path: `${prompt.slug}/new-version`,
orgSlug: undefined,
});
} else {
ideMessenger.post("config/openProfile", {
profileId: undefined,
element: { sourceFile: (prompt as any).sourceFile },
});
}
};
const handleAddPrompt = () => {
if (isLocal) {
void ideMessenger.request("config/addLocalWorkspaceBlock", {
blockType: "prompts",
});
} else {
void ideMessenger.request("controlPlane/openUrl", {
path: "new?type=block&blockType=prompts",
orgSlug: undefined,
});
}
};
const sortedCommands = useMemo(() => {
const promptsWithSlug: PromptCommandWithSlug[] =
structuredClone(slashCommands);
// get the slugs from rawYaml
if (selectedProfile?.rawYaml) {
const parsed = parseConfigYaml(selectedProfile.rawYaml);
const parsedPrompts = parsed.prompts ?? [];
let index = 0;
for (const commandWithSlug of promptsWithSlug) {
// skip for local prompt files
if (commandWithSlug.promptFile) continue;
const yamlPrompt = parsedPrompts[index];
if (yamlPrompt) {
if ("uses" in yamlPrompt) {
commandWithSlug.slug = yamlPrompt.uses;
} else {
commandWithSlug.slug = `${selectedProfile?.fullSlug.ownerSlug}/${selectedProfile?.fullSlug.packageSlug}`;
}
}
index = index + 1;
}
}
return promptsWithSlug.sort((a, b) => {
const aBookmarked = isCommandBookmarked(a.name);
const bBookmarked = isCommandBookmarked(b.name);
if (aBookmarked && !bBookmarked) return -1;
if (!aBookmarked && bBookmarked) return 1;
return 0;
});
}, [slashCommands, isCommandBookmarked, selectedProfile]);
return (
<div className="flex flex-col">
<ConfigHeader
title="Prompts"
onAddClick={handleAddPrompt}
addButtonTooltip="Add prompt"
/>
{sortedCommands.length > 0 ? (
<div>
{sortedCommands.map((prompt) => (
<PromptRow
key={prompt.name}
prompt={prompt}
isBookmarked={isCommandBookmarked(prompt.name)}
setIsBookmarked={() => toggleBookmark(prompt)}
onEdit={() => handleEdit(prompt)}
/>
))}
</div>
) : (
<Card>
<EmptyState message="No prompts configured. Click the + button to add your first prompt." />
</Card>
)}
</div>
);
}

View file

@ -22,6 +22,7 @@ import { getRuleDisplayName } from "core/llm/rules/rules-utils";
import { useContext, useMemo } from "react";
import HeaderButtonWithToolTip from "../../../components/gui/HeaderButtonWithToolTip";
import Switch from "../../../components/gui/Switch";
import { useEditBlock } from "../../../components/mainInput/Lump/useEditBlock";
import { useMainEditor } from "../../../components/mainInput/TipTapEditor";
import { Card, EmptyState, useFontSize } from "../../../components/ui";
import { useAuth } from "../../../context/Auth";
@ -80,8 +81,7 @@ function PromptRow({
}
};
const canEdit =
prompt.promptFile && !prompt.promptFile.startsWith("builtin:");
const canEdit = prompt.sourceFile && prompt.source !== "built-in";
return (
<div
@ -136,27 +136,16 @@ const RuleCard: React.FC<RuleCardProps> = ({ rule }) => {
const isDisabled = policy === "off";
const editBlock = useEditBlock();
const handleOpen = async () => {
if (rule.slug) {
void ideMessenger.request("controlPlane/openUrl", {
path: `${rule.slug}/new-version`,
orgSlug: undefined,
});
} else if (rule.ruleFile) {
ideMessenger.post("openFile", {
path: rule.ruleFile,
});
} else if (
if (
rule.source === "default-chat" ||
rule.source === "default-plan" ||
rule.source === "default-agent"
) {
ideMessenger.post("openUrl", DEFAULT_SYSTEM_MESSAGES_URL);
} else {
ideMessenger.post("config/openProfile", {
profileId: undefined,
element: { sourceFile: (rule as any).sourceFile },
});
editBlock(rule?.slug, rule?.ruleFile);
}
};
@ -268,22 +257,10 @@ function PromptsSubSection() {
(state) => state.config.config.slashCommands ?? [],
);
const editBlock = useEditBlock();
const handleEdit = (prompt: PromptCommandWithSlug) => {
if (prompt.promptFile) {
ideMessenger.post("openFile", {
path: prompt.promptFile,
});
} else if (prompt.slug) {
void ideMessenger.request("controlPlane/openUrl", {
path: `${prompt.slug}/new-version`,
orgSlug: undefined,
});
} else {
ideMessenger.post("config/openProfile", {
profileId: undefined,
element: { sourceFile: (prompt as any).sourceFile },
});
}
editBlock(prompt.slug, prompt.sourceFile);
};
const handleAddPrompt = () => {
@ -310,7 +287,7 @@ function PromptsSubSection() {
let index = 0;
for (const commandWithSlug of promptsWithSlug) {
// skip for local prompt files
if (commandWithSlug.promptFile) continue;
if (commandWithSlug.sourceFile) continue;
const yamlPrompt = parsedPrompts[index];
if (yamlPrompt) {

View file

@ -1,11 +0,0 @@
import { ConfigHeader } from "../components/ConfigHeader";
import { ToolPolicies } from "../components/ToolPolicies";
export const ToolPoliciesSection = () => {
return (
<div>
<ConfigHeader title="Tool Policies" />
<ToolPolicies />
</div>
);
};

View file

@ -6,16 +6,17 @@ import {
CommandLineIcon,
EllipsisVerticalIcon,
GlobeAltIcon,
PencilIcon,
PlayCircleIcon,
StopCircleIcon,
UserCircleIcon,
WrenchScrewdriverIcon,
} from "@heroicons/react/24/outline";
import { MCPConnectionStatus, MCPServerStatus } from "core";
import { useContext, useEffect, useMemo, useState } from "react";
import { BUILT_IN_GROUP_NAME } from "core/tools/builtIn";
import { useContext, useMemo, useState } from "react";
import Alert from "../../../components/gui/Alert";
import { ToolTip } from "../../../components/gui/Tooltip";
import EditBlockButton from "../../../components/mainInput/Lump/EditBlockButton";
import { useEditMcp } from "../../../components/mainInput/Lump/useEditBlock";
import {
Button,
Card,
@ -31,17 +32,20 @@ import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
import { updateConfig } from "../../../redux/slices/configSlice";
import { selectCurrentOrg } from "../../../redux/slices/profilesSlice";
import { ConfigHeader } from "../components/ConfigHeader";
import { ToolPolicies } from "../components/ToolPolicies";
import { ToolPoliciesGroup } from "../components/ToolPoliciesGroup";
interface MCPServerStatusProps {
allToolsOff: boolean;
server: MCPServerStatus;
serverFromYaml?: NonNullable<ConfigYaml["mcpServers"]>[number];
duplicateDetection: Record<string, boolean>;
}
const ServerStatusTooltip: Record<MCPConnectionStatus, string> = {
connected: "Active",
connecting: "Connecting",
"not-connected": "Inactive",
disabled: "Off",
authenticating: "Authenticating",
error: "Error",
};
@ -50,19 +54,24 @@ const ServerStatusColor: Record<MCPConnectionStatus, string> = {
connected: "bg-success",
connecting: "bg-warning",
"not-connected": "bg-description-muted",
disabled: "bg-description-muted",
authenticating: "bg-warning",
error: "bg-error",
};
function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
function MCPServerPreview({
server,
serverFromYaml,
allToolsOff,
duplicateDetection,
}: MCPServerStatusProps) {
const [expandedSections, setExpandedSections] = useState<{
[key: string]: boolean;
}>({});
const [disconnectedMCPServers, setDisconnectedMCPServers] = useState<
string[]
>([]);
const ideMessenger = useContext(IdeMessengerContext);
const config = useAppSelector((store) => store.config.config);
const editMcp = useEditMcp();
const dispatch = useAppDispatch();
const updateMCPServerStatus = (status: MCPServerStatus["status"]) => {
// optimistic config update
@ -106,32 +115,20 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
await ideMessenger.request("mcp/reloadServer", {
id: server.id,
});
await fetchDisconectedMCPServers();
};
const onDisconnect = async () => {
updateMCPServerStatus("not-connected");
setDisconnectedMCPServers((prev) => [...prev, server.id]);
dispatch(
updateConfig({
...config,
tools: config.tools.filter((tool) => tool.group !== server.id),
}),
);
await ideMessenger.request("mcp/disconnectServer", {
await ideMessenger.request("mcp/setServerEnabled", {
id: server.id,
enabled: false,
});
await fetchDisconectedMCPServers();
};
const fetchDisconectedMCPServers = async () => {
const disconnectedServersData = await ideMessenger.request(
"mcp/getDisconnectedServers",
undefined,
);
if (disconnectedServersData.status === "success") {
setDisconnectedMCPServers(disconnectedServersData.content);
}
};
const toggleSection = (section: string) => {
@ -141,8 +138,6 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
}));
};
useEffect(() => void fetchDisconectedMCPServers(), []);
const ResourceRow = ({
title,
items,
@ -151,7 +146,6 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
}: {
title: string;
items:
| MCPServerStatus["tools"]
| MCPServerStatus["prompts"]
| MCPServerStatus["resources"]
| MCPServerStatus["resourceTemplates"];
@ -164,7 +158,7 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
return (
<div>
<div
className="-mx-2 flex cursor-pointer items-center justify-between rounded px-2 py-2 hover:bg-gray-50 hover:bg-opacity-5"
className="mx-2 flex cursor-pointer items-center justify-between rounded hover:bg-gray-50 hover:bg-opacity-5"
onClick={() => toggleSection(sectionKey)}
>
<div className="flex items-center gap-3">
@ -174,7 +168,7 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
<div className="flex items-center gap-2">
{icon}
<span className="text-sm">{title}</span>
<div className="flex h-5 w-5 items-center justify-center rounded-full bg-gray-600 text-xs font-medium text-white">
<div className="flex h-5 w-5 items-center justify-center rounded-md bg-gray-600 px-0.5 text-xs font-medium text-white">
{items.length}
</div>
</div>
@ -182,22 +176,24 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
</div>
{isExpanded && (
<div className="mb-3 ml-6 mt-2">
<div className="mx-2 my-2 mb-3">
{hasItems ? (
<div className="space-y-1">
{items.map((item, idx) => (
<div
key={idx}
className="text-description rounded bg-gray-50 bg-opacity-5 px-2 py-1 text-xs"
>
<code>{item.name}</code>
{item.description && (
<div className="mt-1 text-xs text-gray-500">
{item.description}
</div>
)}
</div>
))}
{items.map((item, idx) => {
return (
<div
key={idx}
className="text-description rounded bg-gray-50 bg-opacity-5 px-2 py-1 text-xs"
>
<code>{item.name}</code>
{item.description && (
<div className="mt-1 text-xs text-gray-500">
{item.description}
</div>
)}
</div>
);
})}
</div>
) : (
<div className="text-xs italic text-gray-500">
@ -211,7 +207,7 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
};
return (
<div>
<div className="">
<div className="flex items-center justify-between py-1">
<div className="flex items-center gap-3">
<div className="flex-1">
@ -226,7 +222,7 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
</div>
</div>
<div className="-mr-2.5 flex items-center gap-1">
<div className="flex items-center gap-1">
{server.isProtectedResource &&
"url" in server &&
server.status !== "connected" && (
@ -278,17 +274,17 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
<ListboxOption
value="edit mcp"
className="justify-start gap-x-1.5"
onClick={() => editMcp(serverFromYaml)}
>
<EditBlockButton
blockType={"mcpServers"}
block={serverFromYaml}
sourceFile={server.sourceFile}
className="h-3.5 w-3.5 text-inherit"
<PencilIcon
className={
"h-3.5 w-3.5 flex-shrink-0 cursor-pointer text-gray-400 text-inherit hover:brightness-125"
}
/>
Edit
</ListboxOption>
{!disconnectedMCPServers.includes(server.name) && (
{server.status === "connected" && (
<ListboxOption
value="disconnect"
onClick={onDisconnect}
@ -299,18 +295,20 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
</ListboxOption>
)}
<ListboxOption
value="reconnect"
onClick={onRefresh}
className="justify-start gap-x-1.5"
>
{disconnectedMCPServers.includes(server.name) ? (
<PlayCircleIcon className="h-4 w-4 flex-shrink-0" />
) : (
<ArrowPathIcon className="h-4 w-4 flex-shrink-0" />
)}
Reload
</ListboxOption>
{server.status !== "connecting" && (
<ListboxOption
value="reconnect"
onClick={onRefresh}
className="justify-start gap-x-1.5"
>
{server.status === "disabled" ? (
<PlayCircleIcon className="h-4 w-4 flex-shrink-0" />
) : (
<ArrowPathIcon className="h-4 w-4 flex-shrink-0" />
)}
Reload
</ListboxOption>
)}
</ListboxOptions>
</Listbox>
</div>
@ -318,13 +316,12 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
{/* Individual resource rows */}
<div className="mt-1">
<ResourceRow
title="Tools"
items={server.tools}
icon={
<WrenchScrewdriverIcon className="text-description h-4 w-4 flex-shrink-0" />
}
sectionKey={`${server.id}-tools`}
<ToolPoliciesGroup
showIcon={true}
groupName={server.name}
displayName={"Tools"}
allToolsOff={allToolsOff}
duplicateDetection={duplicateDetection}
/>
{server.prompts.length > 0 && (
<ResourceRow
@ -336,16 +333,6 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
sectionKey={`${server.id}-prompts`}
/>
)}
{server.prompts.length > 0 && (
<ResourceRow
title="Prompts"
items={server.prompts}
icon={
<CommandLineIcon className="text-description h-4 w-4 flex-shrink-0" />
}
sectionKey={`${server.id}-prompts`}
/>
)}
{(server.resources.length > 0 ||
server.resourceTemplates.length > 0) && (
<ResourceRow
@ -404,7 +391,9 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
);
}
function McpSubsection() {
export function ToolsSection() {
const availableTools = useAppSelector((state) => state.config.config.tools);
const currentOrg = useAppSelector(selectCurrentOrg);
const mode = useAppSelector((store) => store.session.mode);
const servers = useAppSelector(
@ -415,6 +404,20 @@ function McpSubsection() {
const disableMcp = currentOrg?.policy?.allowMcpServers === false;
const isLocal = selectedProfile?.profileType === "local";
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 mergedBlocks = useMemo(() => {
const parsed = selectedProfile?.rawYaml
? parseConfigYaml(selectedProfile?.rawYaml ?? "")
@ -449,63 +452,75 @@ function McpSubsection() {
}
};
return (
<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" />
</Card>
) : mode === "chat" ? (
<Alert type="info" size="sm">
<span className="text-2xs italic">
All MCPs are disabled in Chat, switch to Plan or Agent mode to use
MCPs
</span>
</Alert>
) : mergedBlocks.length > 0 ? (
mergedBlocks.map(({ block, blockFromYaml }, index) => (
<div key={block.id}>
<Card>
<MCPServerPreview server={block} serverFromYaml={blockFromYaml} />
</Card>
{index < mergedBlocks.length - 1 && <div className="mb-4" />}
</div>
))
) : (
<Card>
<EmptyState message="No MCP servers configured. Click the + button to add your first server." />
</Card>
)}
</div>
);
}
const allToolsOff = useMemo(() => {
return mode === "chat";
}, [mode]);
function ToolPoliciesSubsection() {
return (
<div>
<ConfigHeader title="Tool Policies" variant="sm" />
<ToolPolicies />
</div>
);
}
export function ToolsSection() {
const availableTools = useAppSelector((state) => state.config.config.tools);
const hasTools = availableTools && availableTools.length > 0;
const availableToolsMessage =
mode === "chat"
? "All tools disabled in Chat, switch to Plan or Agent mode to use tools"
: mode === "plan"
? "Read-only tools available in Plan mode"
: "";
return (
<>
<ConfigHeader title="Tools" />
<div className="space-y-6">
<McpSubsection />
{hasTools && <ToolPoliciesSubsection />}
<ConfigHeader
title="Tools"
subtext="Manage MCP servers and tool policies"
className="mb-2"
/>
{!!availableToolsMessage && (
<div className="mb-4">
<Alert type="info" size="sm">
<span className="text-2xs italic">{availableToolsMessage}</span>
</Alert>
</div>
)}
<div className="mb-4 space-y-6">
<ToolPoliciesGroup
showIcon={false}
groupName={BUILT_IN_GROUP_NAME}
displayName={"Built-in Tools"}
allToolsOff={allToolsOff}
duplicateDetection={duplicateDetection}
/>
<ConfigHeader
className="pr-2"
title="MCP Servers"
variant="sm"
onAddClick={handleAddMcpServer}
addButtonTooltip="Add MCP server"
showAddButton={!disableMcp}
/>
{disableMcp ? (
<Card>
<EmptyState message="MCP servers are disabled in your organization" />
</Card>
) : mode === "chat" ? (
<Alert type="info" size="sm">
<span className="text-2xs italic">
All MCPs are disabled in Chat, switch to Plan or Agent mode to use
MCPs
</span>
</Alert>
) : mergedBlocks.length > 0 ? (
mergedBlocks.map(({ block, blockFromYaml }) => {
return (
<MCPServerPreview
key={block.name}
server={block}
serverFromYaml={blockFromYaml}
allToolsOff={allToolsOff}
duplicateDetection={duplicateDetection}
/>
);
})
) : (
<Card>
<EmptyState message="No MCP servers configured. Click the + button to add your first server." />
</Card>
)}
</div>
</>
);

View file

@ -1,7 +1,14 @@
import { ConfigYaml } from "@continuedev/config-yaml";
import { ArrowPathIcon, StopIcon } from "@heroicons/react/24/outline";
import {
ArrowPathIcon,
PencilIcon,
StopIcon,
} from "@heroicons/react/24/outline";
import { SiteIndexingConfig } from "core";
import { useContext, useEffect, useMemo, useState } from "react";
import ConfirmationDialog from "../../../../components/dialogs/ConfirmationDialog";
import { ToolTip } from "../../../../components/gui/Tooltip";
import { useEditDoc } from "../../../../components/mainInput/Lump/useEditBlock";
import { IdeMessengerContext } from "../../../../context/IdeMessenger";
import { useAppDispatch, useAppSelector } from "../../../../redux/hooks";
import { updateIndexingStatus } from "../../../../redux/slices/indexingSlice";
@ -10,9 +17,6 @@ import {
setShowDialog,
} from "../../../../redux/slices/uiSlice";
import { fontSize } from "../../../../util";
import ConfirmationDialog from "../../../../components/dialogs/ConfirmationDialog";
import { ToolTip } from "../../../../components/gui/Tooltip";
import EditBlockButton from "../../../../components/mainInput/Lump/EditBlockButton";
import { IndexedPagesTooltip } from "./IndexedPagesTooltip";
import { StatusIndicator } from "./StatusIndicator";
@ -25,6 +29,7 @@ function DocsIndexingStatus({
docConfig,
docFromYaml,
}: IndexingStatusViewerProps) {
const editDoc = useEditDoc();
const ideMessenger = useContext(IdeMessengerContext);
const dispatch = useAppDispatch();
const [indexedPages, setIndexedPages] = useState<null | string[]>(null);
@ -159,10 +164,11 @@ function DocsIndexingStatus({
/>
)}
<EditBlockButton
blockType="docs"
block={docFromYaml}
sourceFile={docConfig.sourceFile}
<PencilIcon
className={
"h-3 w-3 cursor-pointer text-gray-400 hover:brightness-125"
}
onClick={() => editDoc(docFromYaml)}
/>
{["aborted", "complete", "failed"].includes(

View file

@ -8,6 +8,7 @@ import {
import { DISCORD_LINK, GITHUB_LINK } from "core/util/constants";
import { useContext, useMemo } from "react";
import { GhostButton, SecondaryButton } from "../../components";
import { useEditModel } from "../../components/mainInput/Lump/useEditBlock";
import { useMainEditor } from "../../components/mainInput/TipTapEditor";
import { DiscordIcon } from "../../components/svg/DiscordIcon";
import { GithubIcon } from "../../components/svg/GithubIcon";
@ -66,15 +67,12 @@ const StreamErrorDialog = ({ error }: StreamErrorProps) => {
</GhostButton>
) : null;
const handleEditModel = useEditModel();
const configButton = (
<GhostButton
className="flex items-center"
onClick={() => {
ideMessenger.post("config/openProfile", {
profileId: undefined,
element: selectedModel ?? undefined,
});
}}
onClick={() => handleEditModel(selectedModel)}
>
<Cog6ToothIcon className="mr-1.5 h-3.5 w-3.5" />
<span>View config</span>