From 0a898ed2de337e56a962058131285086be0e3a04 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 28 May 2025 16:35:01 -0700 Subject: [PATCH 1/2] fix tool call args UI --- .../gui/ToolCallDiv/SimpleToolCallUI.tsx | 38 +++++++++---------- gui/src/pages/gui/ToolCallDiv/ToolCall.tsx | 4 +- .../pages/gui/ToolCallDiv/ToolCallArgs.tsx | 11 +++--- 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx index 3342eabda..d17633a13 100644 --- a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx +++ b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx @@ -2,7 +2,7 @@ import { ChevronDownIcon, ChevronRightIcon } from "@heroicons/react/24/outline"; import { ContextItemWithId, Tool, ToolCallState } from "core"; import { ComponentType, useMemo, useState } from "react"; import { ContextItemsPeekItem } from "../../../components/mainInput/belowMainInput/ContextItemsPeek"; -import { ArgsItems } from "./ToolCallArgs"; +import { ArgsItems, ArgsToggleIcon } from "./ToolCallArgs"; import { ToolCallStatusMessage } from "./ToolCallStatusMessage"; interface SimpleToolCallUIProps { @@ -32,10 +32,10 @@ export function SimpleToolCallUI({ }, [toolCallState.parsedArgs]); return ( -
-
+
+
setOpen((prev) => !prev)} onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} @@ -43,38 +43,36 @@ export function SimpleToolCallUI({ >
{Icon && !isHovered && !open ? ( - + ) : ( <> )}
- - +
- {/*
- {args.length > 0 ? ( - - ) : null} -
*/} + {args.length > 0 ? ( + + ) : null}
)) ) : ( -
+
No tool call output
)} diff --git a/gui/src/pages/gui/ToolCallDiv/ToolCall.tsx b/gui/src/pages/gui/ToolCallDiv/ToolCall.tsx index 6f313236d..263c15dc0 100644 --- a/gui/src/pages/gui/ToolCallDiv/ToolCall.tsx +++ b/gui/src/pages/gui/ToolCallDiv/ToolCall.tsx @@ -26,8 +26,8 @@ export function ToolCallDisplay({ <>
-
-
+
+
{icon}
diff --git a/gui/src/pages/gui/ToolCallDiv/ToolCallArgs.tsx b/gui/src/pages/gui/ToolCallDiv/ToolCallArgs.tsx index 738be01f9..a451ec135 100644 --- a/gui/src/pages/gui/ToolCallDiv/ToolCallArgs.tsx +++ b/gui/src/pages/gui/ToolCallDiv/ToolCallArgs.tsx @@ -25,10 +25,9 @@ export const ArgsToggleIcon = ({ e.stopPropagation(); setIsShowing(!isShowing); }} - className={`cursor-pointer select-none rounded-sm px-1 py-0.5 hover:bg-gray-400/40 hover:opacity-80 ${isShowing ? "bg-gray-400/40" : "bg-transparent"}`} + className={`hover:description-muted/30 cursor-pointer select-none rounded px-1 py-0.5 hover:opacity-80 ${isShowing ? "bg-description-muted/30" : "bg-transparent"}`} > - - {/* {`{}`} */} +
{isShowing ? "Hide args" : "Show args"} @@ -52,11 +51,13 @@ export const ArgsItems = ({ args, isShowing }: ArgsItemsProps) => { } return ( -
+
{args.map(([key, value]) => (
{key}: - {value.toString()} + + {JSON.stringify(value)} +
))}
From 204a96fe137dcfd018232e82cc20219e46be8b5e Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Wed, 28 May 2025 17:34:13 -0700 Subject: [PATCH 2/2] clean up tool call args UI --- gui/src/pages/gui/Chat.tsx | 17 +++---- .../gui/ToolCallDiv/SimpleToolCallUI.tsx | 36 +++++-------- gui/src/pages/gui/ToolCallDiv/ToolCall.tsx | 14 +++-- .../pages/gui/ToolCallDiv/ToolCallArgs.tsx | 2 +- .../gui/ToolCallDiv/ToolCallStatusMessage.tsx | 51 ++++++++----------- gui/src/pages/gui/ToolCallDiv/index.tsx | 18 +++---- 6 files changed, 55 insertions(+), 83 deletions(-) diff --git a/gui/src/pages/gui/Chat.tsx b/gui/src/pages/gui/Chat.tsx index 75fb48c4b..c3e8ac512 100644 --- a/gui/src/pages/gui/Chat.tsx +++ b/gui/src/pages/gui/Chat.tsx @@ -333,17 +333,16 @@ export function Chat() { "assistant" && item.message.toolCalls && item.toolCallState ? ( -
+
{item.message.toolCalls?.map((toolCall, i) => { return ( -
- -
+ ); })}
diff --git a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx index d17633a13..07b7838a7 100644 --- a/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx +++ b/gui/src/pages/gui/ToolCallDiv/SimpleToolCallUI.tsx @@ -1,4 +1,4 @@ -import { ChevronDownIcon, ChevronRightIcon } from "@heroicons/react/24/outline"; +import { ChevronRightIcon } from "@heroicons/react/24/outline"; import { ContextItemWithId, Tool, ToolCallState } from "core"; import { ComponentType, useMemo, useState } from "react"; import { ContextItemsPeekItem } from "../../../components/mainInput/belowMainInput/ContextItemsPeek"; @@ -32,39 +32,27 @@ export function SimpleToolCallUI({ }, [toolCallState.parsedArgs]); return ( -
-
+
+
setOpen((prev) => !prev)} onMouseEnter={() => setIsHovered(true)} onMouseLeave={() => setIsHovered(false)} data-testid="context-items-peek" > -
+
{Icon && !isHovered && !open ? ( - + ) : ( - <> - - - + )}
-
- -
+
{args.length > 0 ? ( -
+
-
+
{icon}
{tool?.faviconUrl && ( )} -
- -
+
{!!args.length ? ( { } return ( -
+
{args.map(([key, value]) => (
{key}: diff --git a/gui/src/pages/gui/ToolCallDiv/ToolCallStatusMessage.tsx b/gui/src/pages/gui/ToolCallDiv/ToolCallStatusMessage.tsx index 7a25a7605..40a5f06ef 100644 --- a/gui/src/pages/gui/ToolCallDiv/ToolCallStatusMessage.tsx +++ b/gui/src/pages/gui/ToolCallDiv/ToolCallStatusMessage.tsx @@ -1,7 +1,5 @@ import { Tool, ToolCallState } from "core"; import Mustache from "mustache"; -import { ReactNode } from "react"; -import { getFontSize } from "../../../util"; import { useFontSize } from "../../../components/ui/font"; interface ToolCallStatusMessageProps { @@ -16,35 +14,26 @@ export function ToolCallStatusMessage({ const fontSize = useFontSize(); if (!tool) return "Agent tool use"; - const defaultToolDescription = ( - <> - {tool.displayTitle ?? tool.function.name} tool - - ); + const toolName = tool.displayTitle ?? tool.function.name; + const defaultToolDescription = `${toolName} tool`; - const futureMessage = tool.wouldLikeTo ? ( - Mustache.render(tool.wouldLikeTo, toolCallState.parsedArgs) - ) : ( - <> - use the {defaultToolDescription} - - ); + const futureMessage: string = tool.wouldLikeTo + ? Mustache.render(tool.wouldLikeTo, toolCallState.parsedArgs) + : `use the ${defaultToolDescription}`; + // TODO go back and replace arg string values and tool names with tags + // to make them more readable let intro = ""; - let message: ReactNode = ""; + let message = ""; if ( toolCallState.status === "done" || (tool.isInstant && toolCallState.status === "calling") ) { intro = ""; - message = tool.hasAlready ? ( - Mustache.render(tool.hasAlready, toolCallState.parsedArgs) - ) : ( - <> - used the {defaultToolDescription} - - ); + message = tool.hasAlready + ? Mustache.render(tool.hasAlready, toolCallState.parsedArgs) + : `used the ${defaultToolDescription}`; } else if (toolCallState.status === "generating") { intro = "is generating output to"; message = futureMessage; @@ -53,13 +42,9 @@ export function ToolCallStatusMessage({ message = futureMessage; } else if (toolCallState.status === "calling") { intro = "is"; - message = tool.isCurrently ? ( - Mustache.render(tool.isCurrently, toolCallState.parsedArgs) - ) : ( - <> - calling the {defaultToolDescription} - - ); + message = tool.isCurrently + ? Mustache.render(tool.isCurrently, toolCallState.parsedArgs) + : `calling the ${defaultToolDescription}`; } else if ( toolCallState.status === "canceled" || toolCallState.status === "errored" @@ -68,8 +53,12 @@ export function ToolCallStatusMessage({ message = futureMessage; } return ( -
- Continue {intro} {message} +
+ {`Continue ${intro} ${message}`}
); } diff --git a/gui/src/pages/gui/ToolCallDiv/index.tsx b/gui/src/pages/gui/ToolCallDiv/index.tsx index 39d14cd0a..c919c0ca1 100644 --- a/gui/src/pages/gui/ToolCallDiv/index.tsx +++ b/gui/src/pages/gui/ToolCallDiv/index.tsx @@ -80,16 +80,14 @@ export function ToolCallDiv(props: ToolCallDivProps) { if (icon) { return ( -
- -
+ ); }