styles: tweaks to tool call UI (#812)

This commit is contained in:
Nahiyan Khan
2025-02-06 14:42:34 -05:00
committed by GitHub
parent 680b219674
commit b3978c7a5e
3 changed files with 41 additions and 26 deletions
@@ -84,7 +84,7 @@ export default function MarkdownContent({ content, className = '' }: MarkdownCon
<ReactMarkdown <ReactMarkdown
rehypePlugins={[rehypeinlineCodeProperty]} rehypePlugins={[rehypeinlineCodeProperty]}
className={`prose prose-xs dark:prose-invert w-full max-w-full break-words className={`prose prose-xs dark:prose-invert w-full max-w-full break-words
prose-pre:p-0 prose-pre:m-0 prose-pre:p-0 prose-pre:m-0 !p-0
prose-code:break-all prose-code:whitespace-pre-wrap prose-code:break-all prose-code:whitespace-pre-wrap
${className}`} ${className}`}
components={{ components={{
@@ -102,6 +102,11 @@ export default function MarkdownContent({ content, className = '' }: MarkdownCon
</code> </code>
); );
}, },
// h3: 'div',
h3(props) {
const { node, ...rest } = props;
return <div className="text-textStandard text-sm" {...rest} />;
},
}} }}
> >
{content} {content}
+28 -18
View File
@@ -1,3 +1,4 @@
import { ChevronUp } from 'lucide-react';
import React, { useState } from 'react'; import React, { useState } from 'react';
import MarkdownContent from './MarkdownContent'; import MarkdownContent from './MarkdownContent';
@@ -19,34 +20,43 @@ export function ToolCallArguments({ args }: ToolCallArgumentsProps) {
if (!needsExpansion) { if (!needsExpansion) {
return ( return (
<div className="p-1"> <div className="mb-2">
<div className="flex"> <div className="flex flex-row">
<span className="text-textStandard mr-2">{key}:</span> <span className="text-sm font-medium text-textSubtle min-w-[140px]">{key}</span>
<span className="text-textStandard">{value}</span> <span className="text-sm text-textStandard">{value}</span>
</div> </div>
</div> </div>
); );
} }
return ( return (
<div className="p-1"> <div className="mb-2">
<div className="flex items-baseline"> <div className="flex flex-row">
<span className="text-textStandard mr-2">{key}:</span> <span className="text-sm font-medium text-textSubtle min-w-[140px]">{key}</span>
<div className="flex-1"> <div className="flex items-center">
{isExpanded ? (
<div className="mt-2">
<MarkdownContent content={value} />
</div>
) : (
<span className="text-sm text-textStandard mr-2">{value.slice(0, 60)}...</span>
)}
<button <button
onClick={() => toggleKey(key)} onClick={() => toggleKey(key)}
className="hover:opacity-75 text-gray-600 dark:text-white" className="text-sm hover:opacity-75 text-textStandard"
> >
{isExpanded ? '▼ ' : '▶ '} {/* {isExpanded ? '▼ ' : '▶ '} */}
<ChevronUp
className={`h-5 w-5 transition-all origin-center ${!isExpanded ? 'rotate-180' : ''}`}
/>
</button> </button>
{!isExpanded && <span className="ml-2 text-gray-600">{value.slice(0, 60)}...</span>}
</div> </div>
</div> </div>
{isExpanded && ( {/* {isExpanded && (
<div className="mt-2 ml-4"> <div className="mt-2">
<MarkdownContent content={value} /> <MarkdownContent content={value} />
</div> </div>
)} )} */}
</div> </div>
); );
} }
@@ -59,9 +69,9 @@ export function ToolCallArguments({ args }: ToolCallArgumentsProps) {
: String(value); : String(value);
return ( return (
<div className="p-1"> <div className="mb-2">
<div className="flex"> <div className="flex flex-row">
<span className="font-medium mr-2">{key}:</span> <span className="font-medium mr- min-w-[140px]2">{key}:</span>
<pre className="whitespace-pre-wrap">{content}</pre> <pre className="whitespace-pre-wrap">{content}</pre>
</div> </div>
</div> </div>
@@ -69,7 +79,7 @@ export function ToolCallArguments({ args }: ToolCallArgumentsProps) {
}; };
return ( return (
<div className="mt-2"> <div className="my-2">
{Object.entries(args).map(([key, value]) => ( {Object.entries(args).map(([key, value]) => (
<div key={key}>{renderValue(key, value)}</div> <div key={key}>{renderValue(key, value)}</div>
))} ))}
@@ -44,10 +44,10 @@ interface ToolCallProps {
function ToolCall({ call }: ToolCallProps) { function ToolCall({ call }: ToolCallProps) {
return ( return (
<div> <div>
<div className="flex items-center"> <div className="flex items-center mb-4">
<Box size={15} /> <Box size={16} />
<span className="ml-[8px] text-sm text-textStandard font-medium tracking-widest"> <span className="ml-[8px] text-textStandard">
{call.toolName.substring(call.toolName.lastIndexOf('__') + 2).toUpperCase()} {snakeToTitleCase(call.toolName.substring(call.toolName.lastIndexOf('__') + 2))}
</span> </span>
</div> </div>
@@ -116,7 +116,7 @@ function ToolResult({ result }: ToolResultProps) {
}; };
return ( return (
<div className="mt-2"> <div className="">
{filteredResults.map((item: ResultItem, index: number) => { {filteredResults.map((item: ResultItem, index: number) => {
const isExpanded = shouldShowExpanded(item, index); const isExpanded = shouldShowExpanded(item, index);
// minimize if priority is not set or < 0.5 // minimize if priority is not set or < 0.5
@@ -127,9 +127,9 @@ function ToolResult({ result }: ToolResultProps) {
{shouldMinimize && ( {shouldMinimize && (
<button <button
onClick={() => toggleExpand(index)} onClick={() => toggleExpand(index)}
className="mb-1 p-1 flex items-center text-textStandard" className="mb-1 flex items-center text-textStandard"
> >
<span className="mr-2">Output</span> <span className="mr-2 text-sm">Output</span>
<ChevronUp <ChevronUp
className={`h-5 w-5 transition-all origin-center ${!isExpanded ? 'rotate-180' : ''}`} className={`h-5 w-5 transition-all origin-center ${!isExpanded ? 'rotate-180' : ''}`}
/> />