notch tooltips

This commit is contained in:
Dallin Romney 2025-04-24 16:07:57 -07:00
parent 1469e0fcda
commit fb7a145c1c
14 changed files with 193 additions and 85 deletions

View file

@ -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",

View file

@ -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<any>;
itemCount?: number;
onClick: () => void;
@ -27,18 +33,39 @@ interface BlockSettingsToolbarIcon {
interface Section {
id: string;
tooltip: string;
title: string;
tooltip: ReactNode;
icon: React.ComponentType<any>;
}
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: <ToolsSectionTooltip />,
icon: WrenchScrewdriverIcon,
},
{
id: "mcp",
title: "MCP",
tooltip: <McpSectionTooltip />,
icon: Squares2X2Icon,
},
{
id: "error",
title: "Errors",
tooltip: <ErrorsSectionTooltip />,
icon: ExclamationTriangleIcon,
},
];
function BlockSettingsToolbarIcon(
@ -46,53 +73,60 @@ function BlockSettingsToolbarIcon(
) {
const isErrorSection = props.sectionId === "error";
const id = `block-settings-toolbar-icon-${props.sectionId}`;
return (
<HoverItem
px={0}
onClick={props.onClick}
data-testid={`block-settings-toolbar-icon-${props.sectionId}`}
>
<div
role="button"
tabIndex={0}
onKeyDown={(e) => {
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 || ""}`}
<>
<HoverItem
px={0}
onClick={props.onClick}
data-testid={id}
data-tooltip-id={id}
>
<props.icon
className={`h-[13px] w-[13px] flex-shrink-0 hover:brightness-125 ${
isErrorSection ? "text-red-600" : ""
}`}
style={{
color: props.isSelected ? vscBadgeForeground : undefined,
}}
aria-hidden="true"
/>
<div
style={{ fontSize: fontSize(-3) }}
className={`overflow-hidden transition-all duration-200 ${
props.isSelected ? "ml-1 w-auto opacity-100" : "w-0 opacity-0"
}`}
role="button"
tabIndex={0}
onKeyDown={(e) => {
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 || ""}`}
>
<span
className="whitespace-nowrap"
style={{ color: vscBadgeForeground }}
<props.icon
className={`h-[13px] w-[13px] flex-shrink-0 hover:brightness-125 ${
isErrorSection ? "text-red-600" : ""
}`}
style={{
color: props.isSelected ? vscBadgeForeground : undefined,
}}
aria-hidden="true"
/>
<div
style={{ fontSize: fontSize(-3) }}
className={`overflow-hidden transition-all duration-200 ${
props.isSelected ? "ml-1 w-auto opacity-100" : "w-0 opacity-0"
}`}
>
{props.tooltip}
</span>
<span
className="whitespace-nowrap"
style={{ color: vscBadgeForeground }}
>
{props.title}
</span>
</div>
</div>
</div>
</HoverItem>
</HoverItem>
<ToolTip delayShow={700} id={id}>
{props.tooltip}
</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(

View file

@ -1,5 +0,0 @@
import MCPServersPreview from "../../../../pages/config/MCPServersPreview";
export function MCPSection() {
return <MCPServersPreview />;
}

View file

@ -209,3 +209,7 @@ export function RulesSection() {
</div>
);
}
export function RulesSectionToolTip() {
return "rules";
}

View file

@ -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";

View file

@ -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);

View file

@ -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 (
<div>
<span>{`${numErrors} Config Error${plural}`}</span>
</div>
);
};

View file

@ -0,0 +1,5 @@
import MCPServersPreview from "../../../../../pages/config/MCPServersPreview";
export function MCPSection() {
return <MCPServersPreview />;
}

View file

@ -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 (
<div>
<span>{`MCP Servers (${numActiveServers}/${numServers} active)`}</span>
</div>
);
};

View file

@ -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 (
<div>
<span>{`Tools (${numActiveTools}/${numTools} active)`}</span>
</div>
);
};

View file

@ -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",
);
},
);

View file

@ -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;

View file

@ -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",

View file

@ -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({