From a3be8f6376b9abe580113b15c508982db840ca77 Mon Sep 17 00:00:00 2001 From: kavinkumarbaskar Date: Sat, 5 Apr 2025 23:24:10 +0530 Subject: [PATCH] feat: highlight tool errors in red text --- client/src/components/JsonView.tsx | 15 ++++++++++----- client/src/components/ToolsTab.tsx | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/client/src/components/JsonView.tsx b/client/src/components/JsonView.tsx index b59f3cc..a4ed95f 100644 --- a/client/src/components/JsonView.tsx +++ b/client/src/components/JsonView.tsx @@ -11,6 +11,7 @@ interface JsonViewProps { initialExpandDepth?: number; className?: string; withCopyButton?: boolean; + isError?: boolean; } function tryParseJson(str: string): { success: boolean; data: JsonValue } { @@ -35,6 +36,7 @@ const JsonView = memo( initialExpandDepth = 3, className, withCopyButton = true, + isError = false }: JsonViewProps) => { const { toast } = useToast(); const [copied, setCopied] = useState(false); @@ -100,6 +102,7 @@ const JsonView = memo( name={name} depth={0} initialExpandDepth={initialExpandDepth} + isError = {isError} /> @@ -114,10 +117,11 @@ interface JsonNodeProps { name?: string; depth: number; initialExpandDepth: number; + isError?: boolean; } const JsonNode = memo( - ({ data, name, depth = 0, initialExpandDepth }: JsonNodeProps) => { + ({ data, name, depth = 0, initialExpandDepth, isError = false }: JsonNodeProps) => { const [isExpanded, setIsExpanded] = useState(depth < initialExpandDepth); const getDataType = (value: JsonValue): string => { @@ -133,7 +137,8 @@ const JsonNode = memo( boolean: "text-amber-600", null: "text-purple-600", undefined: "text-gray-600", - string: "text-green-600 break-all whitespace-pre-wrap", + string: "text-green-600 group-hover:text-green-500", + error: "text-red-600 group-hover:text-red-500", default: "text-gray-700", }; @@ -236,7 +241,7 @@ const JsonNode = memo( {name}: )} -
"{value}"
+
"{value}"
); } @@ -250,8 +255,8 @@ const JsonNode = memo( )}
 setIsExpanded(!isExpanded)}
             title={isExpanded ? "Click to collapse" : "Click to expand"}
diff --git a/client/src/components/ToolsTab.tsx b/client/src/components/ToolsTab.tsx
index a9e9bf8..7f84eac 100644
--- a/client/src/components/ToolsTab.tsx
+++ b/client/src/components/ToolsTab.tsx
@@ -66,11 +66,11 @@ const ToolsTab = ({
       return (
         <>
           

- Tool Result: {isError ? "Error" : "Success"} + Tool Result: {isError ? Error : Success}

{structuredResult.content.map((item, index) => (
- {item.type === "text" && } + {item.type === "text" && } {item.type === "image" && (