From 627f14d856a4bcbff218bc4f3a13979330f86cd7 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 24 Apr 2025 13:16:01 -0700 Subject: [PATCH] display tool info in notch and fix narrow screen ui --- gui/src/components/mainInput/Lump/index.tsx | 2 +- .../tool-policies/ToolPoliciesSection.tsx | 5 +- .../sections/tool-policies/ToolPolicyItem.tsx | 180 ++++++++++++------ 3 files changed, 120 insertions(+), 67 deletions(-) diff --git a/gui/src/components/mainInput/Lump/index.tsx b/gui/src/components/mainInput/Lump/index.tsx index 32222af65..218c23b68 100644 --- a/gui/src/components/mainInput/Lump/index.tsx +++ b/gui/src/components/mainInput/Lump/index.tsx @@ -37,7 +37,7 @@ export function Lump() { return ( -
+
{ size={10} />
-
+
{tools.map((tool) => ( { excluded={toolGroupSettings[groupName] === "exclude"} /> ))} - {toolGroupSettings[groupName] === "exclude" && ( -
- )}
))} diff --git a/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx b/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx index c19c926af..703fa3a9a 100644 --- a/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx +++ b/gui/src/components/mainInput/Lump/sections/tool-policies/ToolPolicyItem.tsx @@ -1,6 +1,9 @@ -import { InformationCircleIcon } from "@heroicons/react/24/outline"; +import { + ChevronRightIcon, + InformationCircleIcon, +} from "@heroicons/react/24/outline"; import { Tool } from "core"; -import { useEffect } from "react"; +import { useEffect, useMemo, useState } from "react"; import { useDispatch } from "react-redux"; import { useAppSelector } from "../../../../../redux/hooks"; import { @@ -21,6 +24,7 @@ function ToolPolicyItem(props: ToolDropdownItemProps) { const policy = useAppSelector( (state) => state.ui.toolSettings[props.tool.function.name], ); + const [isExpanded, setIsExpanded] = useState(false); useEffect(() => { if (!policy) { @@ -28,74 +32,126 @@ function ToolPolicyItem(props: ToolDropdownItemProps) { } }, [props.tool.function.name, policy]); + const parameters = useMemo(() => { + if (props.tool.function.parameters?.properties) { + return Object.entries(props.tool.function.parameters.properties).map( + ([name, schema]) => + [name, schema] as [string, { description: string; type: string }], + ); + } + return undefined; + }, [props.tool.function.parameters]); + if (!policy) { return null; } return ( -
{ - dispatch(toggleToolSetting(props.tool.function.name)); - e.stopPropagation(); - e.preventDefault(); - }} - > -
- {props.duplicatesDetected ? ( - <> -
- +
+
setIsExpanded((val) => !val)} + > +
- {props.excluded ? ( - Excluded - ) : ( -
- {(policy === "allowedWithPermission" || policy === undefined) && ( - Ask First - )} - {policy === "allowedWithoutPermission" && ( - Automatic - )} - {policy === "disabled" && ( - Excluded + )} + + {props.tool.function.name} + +
+
+
{ + dispatch(toggleToolSetting(props.tool.function.name)); + e.stopPropagation(); + e.preventDefault(); + }} + > + {props.excluded || policy === "disabled" ? ( + <> + Off + + Excluded + + + ) : policy === "allowedWithoutPermission" ? ( + <> + Auto + + Automatic + + + ) : ( + // allowedWithPermission + <> + Ask + + Ask First + + )}
- )} +
+
+ Description: + {props.tool.function.description} + {parameters ? ( + <> + Arguments: + {parameters.map((param) => ( +
+ {param[0]} + {`(${param[1].type}):`} + {param[1].description} +
+ ))} + + ) : null} +
+
); }