From f862d5a9750dfb5e7e9184d711546d8d814fca32 Mon Sep 17 00:00:00 2001 From: akhisud3195 Date: Sun, 13 Jul 2025 14:54:31 +0530 Subject: [PATCH] Fix tool message sizing issues --- .../playground/components/messages.tsx | 131 +++++++++++++----- 1 file changed, 97 insertions(+), 34 deletions(-) diff --git a/apps/rowboat/app/projects/[projectId]/playground/components/messages.tsx b/apps/rowboat/app/projects/[projectId]/playground/components/messages.tsx index 1cb751bc..945f6764 100644 --- a/apps/rowboat/app/projects/[projectId]/playground/components/messages.tsx +++ b/apps/rowboat/app/projects/[projectId]/playground/components/messages.tsx @@ -5,7 +5,7 @@ import z from "zod"; import { Workflow } from "@/app/lib/types/workflow_types"; import { WorkflowTool } from "@/app/lib/types/workflow_types"; import MarkdownContent from "@/app/lib/components/markdown-content"; -import { ChevronRightIcon, ChevronDownIcon, ChevronUpIcon, CodeIcon, CheckCircleIcon, FileTextIcon } from "lucide-react"; +import { ChevronRightIcon, ChevronDownIcon, ChevronUpIcon, CodeIcon, CheckCircleIcon, FileTextIcon, EyeIcon, EyeOffIcon, WrapTextIcon, ArrowRightFromLineIcon, BracesIcon, TextIcon } from "lucide-react"; import { TestProfile } from "@/app/lib/types/testing_types"; import { ProfileContextBox } from "./profile-context-box"; import { Message, ToolMessage, AssistantMessageWithToolCalls } from "@/app/lib/types/types"; @@ -81,7 +81,7 @@ function InternalAssistantMessage({ content, sender, latency, delta, showJsonMod
{deltaDisplay} @@ -97,7 +97,7 @@ function InternalAssistantMessage({ content, sender, latency, delta, showJsonMod className="flex items-center gap-1 text-xs text-blue-600 dark:text-blue-400 hover:underline self-start" onClick={() => setJsonMode(!jsonMode)} > - + {jsonMode ? : } {jsonMode ? 'View in text mode' : 'View in JSON mode'} {jsonMode && ( @@ -105,7 +105,7 @@ function InternalAssistantMessage({ content, sender, latency, delta, showJsonMod className="flex items-center gap-1 text-xs text-green-600 dark:text-green-400 hover:underline self-start" onClick={() => setWrapText(!wrapText)} > - + {wrapText ? : } {wrapText ? 'Overflow' : 'Wrap'} )} @@ -115,7 +115,7 @@ function InternalAssistantMessage({ content, sender, latency, delta, showJsonMod
                                         {formattedJson}
@@ -127,7 +127,7 @@ function InternalAssistantMessage({ content, sender, latency, delta, showJsonMod
                             
{deltaDisplay} @@ -298,9 +298,74 @@ function ClientToolCall({ const [wrapText, setWrapText] = useState(true); const [paramsExpanded, setParamsExpanded] = useState(false); const [resultsExpanded, setResultsExpanded] = useState(false); - const hasExpandedContent = paramsExpanded || resultsExpanded; + const isCompressed = !paramsExpanded && !resultsExpanded; + // Compressed state: stretch header, no wrapping + if (isCompressed) { + return ( +
+ {sender && ( +
+ {sender} +
+ )} +
+
+
+
+ {!availableResult && } + {availableResult && } +
+ Invoked Tool: + + {toolCall.function.name} + +
+
+ {hasExpandedContent && ( +
+ +
+ )} +
+
+ } + wrapText={wrapText} + onExpandedChange={setParamsExpanded} + /> + {availableResult && ( +
+ } + wrapText={wrapText} + onExpandedChange={setResultsExpanded} + /> +
+ )} +
+
+
+
+ ); + } + + // Expanded state: respect 85% max width, prevent overshoot return (
{sender && ( @@ -308,53 +373,51 @@ function ClientToolCall({ {sender}
)} -
+
-
-
+ bg-gray-50 dark:bg-gray-800 shadow-sm dark:shadow-gray-950/20 w-full"> +
+
{!availableResult && } {availableResult && } -
+
Invoked Tool: - + {toolCall.function.name}
+ {hasExpandedContent && ( +
+ +
+ )}
- -
+
} wrapText={wrapText} onExpandedChange={setParamsExpanded} /> {availableResult && ( -
+
} wrapText={wrapText} onExpandedChange={setResultsExpanded} - rightButton={hasExpandedContent ? ( - - ) : undefined} />
)} @@ -408,8 +471,8 @@ function ExpandableContent({ const isMarkdown = label === 'Result' && typeof content === 'string' && !content.startsWith('{'); - return
-
+ return
+
{!isExpanded && } {isExpanded && } {icon && {icon}} @@ -418,14 +481,14 @@ function ExpandableContent({
{isExpanded && ( isMarkdown ? ( -
+
) : (
                     {formattedContent}