diff --git a/extensions/vscode/package-lock.json b/extensions/vscode/package-lock.json index 7cf0b9dd7..805cd2d4a 100644 --- a/extensions/vscode/package-lock.json +++ b/extensions/vscode/package-lock.json @@ -1,12 +1,12 @@ { "name": "continue", - "version": "1.1.24", + "version": "1.1.25", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "continue", - "version": "1.1.24", + "version": "1.1.25", "license": "Apache-2.0", "dependencies": { "@continuedev/fetch": "^1.0.3", diff --git a/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx b/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx index 2ec82b660..00d00a8c7 100644 --- a/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx +++ b/gui/src/components/mainInput/Lump/BlockSettingsTopToolbar.tsx @@ -9,15 +9,21 @@ import { Squares2X2Icon, WrenchScrewdriverIcon, } from "@heroicons/react/24/outline"; +import { ReactNode } from "react"; import { vscBadgeForeground } from "../.."; import { useAppSelector } from "../../../redux/hooks"; import { fontSize } from "../../../util"; +import { ToolTip } from "../../gui/Tooltip"; import AssistantSelect from "../../modelSelection/platform/AssistantSelect"; import HoverItem from "../InputToolbar/HoverItem"; import { useLump } from "./LumpContext"; +import { ErrorsSectionTooltip } from "./sections/errors/ErrorsSectionTooltip"; +import { McpSectionTooltip } from "./sections/mcp/MCPTooltip"; +import { ToolsSectionTooltip } from "./sections/tool-policies/ToolPoliciesSectionTooltip"; interface BlockSettingsToolbarIcon { - tooltip: string; + title: string; + tooltip: ReactNode; icon: React.ComponentType; itemCount?: number; onClick: () => void; @@ -27,18 +33,39 @@ interface BlockSettingsToolbarIcon { interface Section { id: string; - tooltip: string; + title: string; + tooltip: ReactNode; icon: React.ComponentType; } const sections: Section[] = [ - { id: "models", tooltip: "Models", icon: CubeIcon }, - { id: "rules", tooltip: "Rules", icon: PencilIcon }, - { id: "docs", tooltip: "Docs", icon: BookOpenIcon }, - { id: "prompts", tooltip: "Prompts", icon: ChatBubbleLeftIcon }, - { id: "tools", tooltip: "Tools", icon: WrenchScrewdriverIcon }, - { id: "mcp", tooltip: "MCP", icon: Squares2X2Icon }, - { id: "error", tooltip: "Errors", icon: ExclamationTriangleIcon }, + { id: "models", title: "Models", tooltip: "Models", icon: CubeIcon }, + { id: "rules", title: "Rules", tooltip: "Rules", icon: PencilIcon }, + { id: "docs", title: "Docs", tooltip: "Docs", icon: BookOpenIcon }, + { + id: "prompts", + title: "Prompts", + tooltip: "Prompts", + icon: ChatBubbleLeftIcon, + }, + { + id: "tools", + title: "Tools", + tooltip: , + icon: WrenchScrewdriverIcon, + }, + { + id: "mcp", + title: "MCP", + tooltip: , + icon: Squares2X2Icon, + }, + { + id: "error", + title: "Errors", + tooltip: , + icon: ExclamationTriangleIcon, + }, ]; function BlockSettingsToolbarIcon( @@ -46,53 +73,60 @@ function BlockSettingsToolbarIcon( ) { const isErrorSection = props.sectionId === "error"; + const id = `block-settings-toolbar-icon-${props.sectionId}`; return ( - -
{ - if (e.key === "Enter" || e.key === " ") { - e.preventDefault(); - props.onClick(); - } - }} - className={`${ - props.isSelected - ? isErrorSection - ? "bg-red-600" - : "bg-badge" - : undefined - } relative flex select-none items-center rounded-full px-1 transition-all duration-200 focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500/50 ${props.className || ""}`} + <> + -
-
+ + + {props.tooltip} + + ); } @@ -129,6 +163,7 @@ export function BlockSettingsTopToolbar() { tooltip={ isToolbarExpanded ? "Collapse sections" : "Expand sections" } + title="" isSelected={false} onClick={handleEllipsisClick} /> @@ -142,6 +177,7 @@ export function BlockSettingsTopToolbar() { sectionId={section.id} icon={section.icon} tooltip={section.tooltip} + title={section.title} isSelected={selectedSection === section.id} onClick={() => setSelectedSection( diff --git a/gui/src/components/mainInput/Lump/sections/MCPSection.tsx b/gui/src/components/mainInput/Lump/sections/MCPSection.tsx deleted file mode 100644 index b365dca34..000000000 --- a/gui/src/components/mainInput/Lump/sections/MCPSection.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import MCPServersPreview from "../../../../pages/config/MCPServersPreview"; - -export function MCPSection() { - return ; -} diff --git a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx index 0fae7611e..d6129eef8 100644 --- a/gui/src/components/mainInput/Lump/sections/RulesSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/RulesSection.tsx @@ -209,3 +209,7 @@ export function RulesSection() { ); } + +export function RulesSectionToolTip() { + return "rules"; +} diff --git a/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx b/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx index 85f72078f..f7fca7a35 100644 --- a/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/SelectedSection.tsx @@ -1,8 +1,8 @@ import { useLump } from "../LumpContext"; import { ContextSection } from "./ContextSection"; import DocsSection from "./docs/DocsSection"; -import { ErrorSection } from "./ErrorSection"; -import { MCPSection } from "./MCPSection"; +import { ErrorSection } from "./errors/ErrorSection"; +import { MCPSection } from "./mcp/MCPSection"; import { ModelsSection } from "./ModelsSection"; import { PromptsSection } from "./PromptsSection"; import { RulesSection } from "./RulesSection"; diff --git a/gui/src/components/mainInput/Lump/sections/ErrorSection.tsx b/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx similarity index 95% rename from gui/src/components/mainInput/Lump/sections/ErrorSection.tsx rename to gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx index d4d01141c..dbd72de65 100644 --- a/gui/src/components/mainInput/Lump/sections/ErrorSection.tsx +++ b/gui/src/components/mainInput/Lump/sections/errors/ErrorSection.tsx @@ -2,7 +2,7 @@ import { ExclamationCircleIcon, ExclamationTriangleIcon, } from "@heroicons/react/24/outline"; -import { useAppSelector } from "../../../../redux/hooks"; +import { useAppSelector } from "../../../../../redux/hooks"; export function ErrorSection() { const configError = useAppSelector((state) => state.config.configError); diff --git a/gui/src/components/mainInput/Lump/sections/errors/ErrorsSectionTooltip.tsx b/gui/src/components/mainInput/Lump/sections/errors/ErrorsSectionTooltip.tsx new file mode 100644 index 000000000..fd2199ede --- /dev/null +++ b/gui/src/components/mainInput/Lump/sections/errors/ErrorsSectionTooltip.tsx @@ -0,0 +1,14 @@ +import { useAppSelector } from "../../../../../redux/hooks"; + +export const ErrorsSectionTooltip = () => { + const configError = useAppSelector((store) => store.config.configError); + + const numErrors = configError?.length ?? 0; + const plural = numErrors > 1 ? "s" : ""; + + return ( +
+ {`${numErrors} Config Error${plural}`} +
+ ); +}; diff --git a/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx b/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx new file mode 100644 index 000000000..9c2f888eb --- /dev/null +++ b/gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx @@ -0,0 +1,5 @@ +import MCPServersPreview from "../../../../../pages/config/MCPServersPreview"; + +export function MCPSection() { + return ; +} diff --git a/gui/src/components/mainInput/Lump/sections/mcp/MCPTooltip.tsx b/gui/src/components/mainInput/Lump/sections/mcp/MCPTooltip.tsx new file mode 100644 index 000000000..b06528fdb --- /dev/null +++ b/gui/src/components/mainInput/Lump/sections/mcp/MCPTooltip.tsx @@ -0,0 +1,18 @@ +import { useAppSelector } from "../../../../../redux/hooks"; + +export const McpSectionTooltip = () => { + const mcpServers = useAppSelector( + (store) => store.config.config.mcpServerStatuses, + ); + + const numServers = mcpServers.length; + const numActiveServers = mcpServers.filter( + (server) => server.status === "connected", + ).length; + + return ( +
+ {`MCP Servers (${numActiveServers}/${numServers} active)`} +
+ ); +}; diff --git a/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPoliciesSectionTooltip.tsx b/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPoliciesSectionTooltip.tsx new file mode 100644 index 000000000..7e3334b1a --- /dev/null +++ b/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPoliciesSectionTooltip.tsx @@ -0,0 +1,16 @@ +import { useAppSelector } from "../../../../../redux/hooks"; +import { selectActiveTools } from "../../../../../redux/selectors/selectActiveTools"; + +export const ToolsSectionTooltip = () => { + const tools = useAppSelector((store) => store.config.config.tools); + const activeTools = useAppSelector(selectActiveTools); + + const numTools = tools.length; + const numActiveTools = activeTools.length; + + return ( +
+ {`Tools (${numActiveTools}/${numTools} active)`} +
+ ); +}; diff --git a/gui/src/redux/selectors/selectActiveTools.ts b/gui/src/redux/selectors/selectActiveTools.ts new file mode 100644 index 000000000..bae3426e0 --- /dev/null +++ b/gui/src/redux/selectors/selectActiveTools.ts @@ -0,0 +1,22 @@ +import { createSelector } from "@reduxjs/toolkit"; +import { Tool } from "core"; +import { RootState } from "../store"; + +export const selectActiveTools = createSelector( + [ + (store: RootState) => store.session.mode, + (store: RootState) => store.config.config.tools, + (store: RootState) => store.ui.toolSettings, + (store: RootState) => store.ui.toolGroupSettings, + ], + (mode, tools, policies, groupPolicies): Tool[] => { + if (mode !== "agent") { + return []; + } + return tools.filter( + (tool) => + policies[tool.function.name] !== "disabled" && + groupPolicies[tool.group] !== "exclude", + ); + }, +); diff --git a/gui/src/redux/slices/sessionSlice.ts b/gui/src/redux/slices/sessionSlice.ts index 002b809db..6adbabcf7 100644 --- a/gui/src/redux/slices/sessionSlice.ts +++ b/gui/src/redux/slices/sessionSlice.ts @@ -768,9 +768,6 @@ export const sessionSlice = createSlice({ selectHasCodeToEdit: (state) => { return state.codeToEdit.length > 0; }, - selectUseTools: (state) => { - return state.mode === "agent"; - }, }, extraReducers: (builder) => { addPassthroughCases(builder, [streamResponseThunk]); @@ -852,7 +849,6 @@ export const { selectCurrentMode, selectIsSingleRangeEditOrInsertion, selectHasCodeToEdit, - selectUseTools, } = sessionSlice.selectors; export default sessionSlice.reducer; diff --git a/gui/src/redux/slices/uiSlice.ts b/gui/src/redux/slices/uiSlice.ts index 7cc964cd6..2fb5f4759 100644 --- a/gui/src/redux/slices/uiSlice.ts +++ b/gui/src/redux/slices/uiSlice.ts @@ -7,12 +7,15 @@ import { } from "../../components/OnboardingCard"; import { getLocalStorage, LocalStorageKey } from "../../util/localStorage"; -type ToolSetting = +export type ToolPolicy = | "allowedWithPermission" | "allowedWithoutPermission" | "disabled"; -type ToolGroupSetting = "include" | "exclude"; +export type ToolGroupPolicy = "include" | "exclude"; + +export type ToolPolicies = { [toolName: string]: ToolPolicy }; +export type ToolGroupPolicies = { [toolGroupName: string]: ToolGroupPolicy }; type UIState = { showDialog: boolean; @@ -22,12 +25,12 @@ type UIState = { isExploreDialogOpen: boolean; hasDismissedExploreDialog: boolean; shouldAddFileForEditing: boolean; - toolSettings: { [toolName: string]: ToolSetting }; - toolGroupSettings: { [toolGroupName: string]: ToolGroupSetting }; + toolSettings: ToolPolicies; + toolGroupSettings: ToolGroupPolicies; ttsActive: boolean; }; -export const DEFAULT_TOOL_SETTING: ToolSetting = "allowedWithPermission"; +export const DEFAULT_TOOL_SETTING: ToolPolicy = "allowedWithPermission"; export const uiSlice = createSlice({ name: "ui", diff --git a/gui/src/redux/thunks/streamNormalInput.ts b/gui/src/redux/thunks/streamNormalInput.ts index 819ec79ee..43e431271 100644 --- a/gui/src/redux/thunks/streamNormalInput.ts +++ b/gui/src/redux/thunks/streamNormalInput.ts @@ -1,13 +1,13 @@ import { createAsyncThunk, unwrapResult } from "@reduxjs/toolkit"; -import { ChatMessage } from "core"; +import { ChatMessage, LLMFullCompletionOptions } from "core"; import { modelSupportsTools } from "core/llm/autodetect"; import { ToCoreProtocol } from "core/protocol"; +import { selectActiveTools } from "../selectors/selectActiveTools"; import { selectCurrentToolCall } from "../selectors/selectCurrentToolCall"; import { selectSelectedChatModel } from "../slices/configSlice"; import { abortStream, addPromptCompletionPair, - selectUseTools, setToolGenerated, streamUpdate, } from "../slices/sessionSlice"; @@ -31,27 +31,24 @@ export const streamNormalInput = createAsyncThunk< const state = getState(); const selectedChatModel = selectSelectedChatModel(state); - const toolSettings = state.ui.toolSettings; - const toolGroupSettings = state.ui.toolGroupSettings; const streamAborter = state.session.streamAborter; - const useTools = selectUseTools(state); if (!selectedChatModel) { throw new Error("Default model not defined"); } - const includeTools = useTools && modelSupportsTools(selectedChatModel); + + let completionOptions: LLMFullCompletionOptions = {}; + const activeTools = selectActiveTools(state); + const toolsSupported = modelSupportsTools(selectedChatModel); + if (toolsSupported && activeTools.length > 0) { + completionOptions = { + tools: activeTools, + }; + } // Send request const gen = extra.ideMessenger.llmStreamChat( { - completionOptions: includeTools - ? { - tools: state.config.config.tools.filter( - (tool) => - toolSettings[tool.function.name] !== "disabled" && - toolGroupSettings[tool.group] !== "exclude", - ), - } - : {}, + completionOptions, title: selectedChatModel.title, messages, legacySlashCommandData, @@ -105,7 +102,9 @@ export const streamNormalInput = createAsyncThunk< } // If it's a tool call that is automatically accepted, we should call it - const toolCallState = selectCurrentToolCall(getState()); + const newState = getState(); + const toolSettings = newState.ui.toolSettings; + const toolCallState = selectCurrentToolCall(newState); if (toolCallState) { dispatch( setToolGenerated({