From a7e392bddee4c73ecdffc410d4d9009be64196af Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Mon, 29 Sep 2025 15:59:46 -0700 Subject: [PATCH] feat: better settings page and open settings fixes --- .vscode/settings.json | 1 + core/commands/slash/customSlashCommand.ts | 3 +- .../commands/slash/promptBlockSlashCommand.ts | 2 +- core/commands/slash/promptFileSlashCommand.ts | 2 +- core/commands/slash/ruleBlockSlashCommand.ts | 3 +- core/config/loadLocalAssistants.ts | 5 +- core/config/markdown/loadMarkdownRules.ts | 1 - core/context/mcp/MCPConnection.ts | 7 +- core/context/mcp/MCPManagerSingleton.ts | 46 +-- .../context/mcp/MCPManagerSingleton.vitest.ts | 22 -- core/core.ts | 22 +- core/index.d.ts | 7 +- core/promptFiles/getPromptFiles.ts | 2 +- core/protocol/core.ts | 8 +- core/protocol/passThrough.ts | 3 +- .../constants/MessageTypes.kt | 1 + .../components/config/FatalErrorNotice.tsx | 15 +- gui/src/components/gui/Switch.tsx | 9 +- .../mainInput/Lump/EditBlockButton.tsx | 58 ---- .../components/mainInput/Lump/useEditBlock.ts | 73 +++++ .../TipTapEditor/utils/renderPromptv2.ts | 4 +- gui/src/components/ui/Card.tsx | 4 +- .../pages/config/components/ConfigHeader.tsx | 10 +- .../pages/config/components/ToolPolicies.tsx | 60 ---- .../config/components/ToolPoliciesGroup.tsx | 131 ++++---- .../config/components/ToolPolicyItem.tsx | 6 +- gui/src/pages/config/hooks/useToolPolicies.ts | 74 ----- gui/src/pages/config/index.tsx | 10 +- .../pages/config/sections/AgentsSection.tsx | 4 +- .../pages/config/sections/ModelsSection.tsx | 12 +- .../pages/config/sections/PromptsSection.tsx | 207 ------------- .../pages/config/sections/RulesSection.tsx | 41 +-- .../config/sections/ToolPoliciesSection.tsx | 11 - .../pages/config/sections/ToolsSection.tsx | 279 +++++++++--------- .../sections/docs/DocsIndexingStatus.tsx | 22 +- gui/src/pages/gui/StreamError.tsx | 10 +- 36 files changed, 402 insertions(+), 773 deletions(-) delete mode 100644 gui/src/components/mainInput/Lump/EditBlockButton.tsx create mode 100644 gui/src/components/mainInput/Lump/useEditBlock.ts delete mode 100644 gui/src/pages/config/components/ToolPolicies.tsx delete mode 100644 gui/src/pages/config/hooks/useToolPolicies.ts delete mode 100644 gui/src/pages/config/sections/PromptsSection.tsx delete mode 100644 gui/src/pages/config/sections/ToolPoliciesSection.tsx diff --git a/.vscode/settings.json b/.vscode/settings.json index 9f3f17f98..0e2cdfd7e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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, diff --git a/core/commands/slash/customSlashCommand.ts b/core/commands/slash/customSlashCommand.ts index 9526cbca8..91ca1c060 100644 --- a/core/commands/slash/customSlashCommand.ts +++ b/core/commands/slash/customSlashCommand.ts @@ -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, } diff --git a/core/commands/slash/promptBlockSlashCommand.ts b/core/commands/slash/promptBlockSlashCommand.ts index 4f3446a21..284a499ab 100644 --- a/core/commands/slash/promptBlockSlashCommand.ts +++ b/core/commands/slash/promptBlockSlashCommand.ts @@ -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, }; } diff --git a/core/commands/slash/promptFileSlashCommand.ts b/core/commands/slash/promptFileSlashCommand.ts index e076086c0..693d2f856 100644 --- a/core/commands/slash/promptFileSlashCommand.ts +++ b/core/commands/slash/promptFileSlashCommand.ts @@ -15,7 +15,7 @@ export function slashCommandFromPromptFile( description, prompt, source: version === 1 ? "prompt-file-v1" : "prompt-file-v2", - promptFile: path, + sourceFile: path, overrideSystemMessage: systemMessage, }; } diff --git a/core/commands/slash/ruleBlockSlashCommand.ts b/core/commands/slash/ruleBlockSlashCommand.ts index d907768cb..d9fe7646d 100644 --- a/core/commands/slash/ruleBlockSlashCommand.ts +++ b/core/commands/slash/ruleBlockSlashCommand.ts @@ -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, }; } diff --git a/core/config/loadLocalAssistants.ts b/core/config/loadLocalAssistants.ts index b05c50729..f0d96cbf4 100644 --- a/core/config/loadLocalAssistants.ts +++ b/core/config/loadLocalAssistants.ts @@ -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") || diff --git a/core/config/markdown/loadMarkdownRules.ts b/core/config/markdown/loadMarkdownRules.ts index 42bfcd21d..9e9de9be2 100644 --- a/core/config/markdown/loadMarkdownRules.ts +++ b/core/config/markdown/loadMarkdownRules.ts @@ -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 } diff --git a/core/context/mcp/MCPConnection.ts b/core/context/mcp/MCPConnection.ts index b79647c57..4caaa921b 100644 --- a/core/context/mcp/MCPConnection.ts +++ b/core/context/mcp/MCPConnection.ts @@ -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") { diff --git a/core/context/mcp/MCPManagerSingleton.ts b/core/context/mcp/MCPManagerSingleton.ts index f9e6ff29c..f05b13f8e 100644 --- a/core/context/mcp/MCPManagerSingleton.ts +++ b/core/context/mcp/MCPManagerSingleton.ts @@ -8,7 +8,6 @@ export class MCPManagerSingleton { public onConnectionsRefreshed?: () => void; public connections: Map = 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(); diff --git a/core/context/mcp/MCPManagerSingleton.vitest.ts b/core/context/mcp/MCPManagerSingleton.vitest.ts index 6a6fc3842..96d4c78e5 100644 --- a/core/context/mcp/MCPManagerSingleton.vitest.ts +++ b/core/context/mcp/MCPManagerSingleton.vitest.ts @@ -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]; diff --git a/core/core.ts b/core/core.ts index dd66dae44..f068622a2 100644 --- a/core/core.ts +++ b/core/core.ts @@ -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; diff --git a/core/index.d.ts b/core/index.d.ts index 8650c6ae2..3ddc0da82 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -918,7 +918,8 @@ export interface SlashCommand extends SlashCommandDescription { export interface SlashCommandWithSource extends SlashCommandDescription { run?: (sdk: ContinueSDK) => AsyncGenerator; // 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" diff --git a/core/promptFiles/getPromptFiles.ts b/core/promptFiles/getPromptFiles.ts index 8ca4f1966..94f539cdc 100644 --- a/core/promptFiles/getPromptFiles.ts +++ b/core/promptFiles/getPromptFiles.ts @@ -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 diff --git a/core/protocol/core.ts b/core/protocol/core.ts index c92945888..a14c2dcba 100644 --- a/core/protocol/core.ts +++ b/core/protocol/core.ts @@ -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; diff --git a/core/protocol/passThrough.ts b/core/protocol/passThrough.ts index f02727a37..192e5596b 100644 --- a/core/protocol/passThrough.ts +++ b/core/protocol/passThrough.ts @@ -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", diff --git a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt index f9d82e377..34c3dad6b 100644 --- a/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +++ b/extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt @@ -94,6 +94,7 @@ class MessageTypes { "mcp/reloadServer", "mcp/startAuthentication", "mcp/removeAuthentication", + "mcp/setServerEnabled", "mcp/getPrompt", "context/getContextItems", "context/getSymbolsForFiles", diff --git a/gui/src/components/config/FatalErrorNotice.tsx b/gui/src/components/config/FatalErrorNotice.tsx index 2bb9a43b4..4d20aba1c 100644 --- a/gui/src/components/config/FatalErrorNotice.tsx +++ b/gui/src/components/config/FatalErrorNotice.tsx @@ -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 )} -
- View -
+ {currentPath !== CONFIG_ROUTES.AGENTS && ( +
+ View +
+ )} ); diff --git a/gui/src/components/gui/Switch.tsx b/gui/src/components/gui/Switch.tsx index ddb90af9d..ab70b06b4 100644 --- a/gui/src/components/gui/Switch.tsx +++ b/gui/src/components/gui/Switch.tsx @@ -38,7 +38,14 @@ const ToggleSwitch: React.FC = ({ {isToggled && !!showIfToggled && showIfToggled}
{ + e.stopPropagation(); + onToggle(); + } + } style={{ height: size, width: size * 2, diff --git a/gui/src/components/mainInput/Lump/EditBlockButton.tsx b/gui/src/components/mainInput/Lump/EditBlockButton.tsx deleted file mode 100644 index ca8df051c..000000000 --- a/gui/src/components/mainInput/Lump/EditBlockButton.tsx +++ /dev/null @@ -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 { - blockType: T; - block?: NonNullable[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({ - block, - blockType, - className = "", - sourceFile, -}: EditBlockButtonProps) { - 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 ( - - ); -} diff --git a/gui/src/components/mainInput/Lump/useEditBlock.ts b/gui/src/components/mainInput/Lump/useEditBlock.ts new file mode 100644 index 000000000..d9bac6cb7 --- /dev/null +++ b/gui/src/components/mainInput/Lump/useEditBlock.ts @@ -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); + } + }; +} diff --git a/gui/src/components/mainInput/TipTapEditor/utils/renderPromptv2.ts b/gui/src/components/mainInput/TipTapEditor/utils/renderPromptv2.ts index afc6c2e2c..64960312b 100644 --- a/gui/src/components/mainInput/TipTapEditor/utils/renderPromptv2.ts +++ b/gui/src/components/mainInput/TipTapEditor/utils/renderPromptv2.ts @@ -13,8 +13,8 @@ export async function getPromptV2ContextRequests( } const workspaceDirs = await ideMessenger.ide.getWorkspaceDirs(); const visitedFiles = new Set(); - if (command.promptFile) { - visitedFiles.add(command.promptFile); + if (command.sourceFile) { + visitedFiles.add(command.sourceFile); } const contextRequests: GetContextRequest[] = []; diff --git a/gui/src/components/ui/Card.tsx b/gui/src/components/ui/Card.tsx index 8d315c0d6..2b1a53f68 100644 --- a/gui/src/components/ui/Card.tsx +++ b/gui/src/components/ui/Card.tsx @@ -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 (
{children}
diff --git a/gui/src/pages/config/components/ConfigHeader.tsx b/gui/src/pages/config/components/ConfigHeader.tsx index 6449d11d1..73779258d 100644 --- a/gui/src/pages/config/components/ConfigHeader.tsx +++ b/gui/src/pages/config/components/ConfigHeader.tsx @@ -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 (
{title} {subtext &&

{subtext}

}
- {onAddClick && ( + {showAddButton && onAddClick && (