Skip to content

Commit

Permalink
styles: tweaks to tool call UI (#812)
Browse files Browse the repository at this point in the history
  • Loading branch information
nahiyankhan authored Feb 6, 2025
1 parent 680b219 commit b3978c7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 26 deletions.
7 changes: 6 additions & 1 deletion ui/desktop/src/components/MarkdownContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default function MarkdownContent({ content, className = '' }: MarkdownCon
<ReactMarkdown
rehypePlugins={[rehypeinlineCodeProperty]}
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
${className}`}
components={{
Expand All @@ -102,6 +102,11 @@ export default function MarkdownContent({ content, className = '' }: MarkdownCon
</code>
);
},
// h3: 'div',
h3(props) {
const { node, ...rest } = props;
return <div className="text-textStandard text-sm" {...rest} />;
},
}}
>
{content}
Expand Down
46 changes: 28 additions & 18 deletions ui/desktop/src/components/ToolCallArguments.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ChevronUp } from 'lucide-react';
import React, { useState } from 'react';
import MarkdownContent from './MarkdownContent';

Expand All @@ -19,34 +20,43 @@ export function ToolCallArguments({ args }: ToolCallArgumentsProps) {

if (!needsExpansion) {
return (
<div className="p-1">
<div className="flex">
<span className="text-textStandard mr-2">{key}:</span>
<span className="text-textStandard">{value}</span>
<div className="mb-2">
<div className="flex flex-row">
<span className="text-sm font-medium text-textSubtle min-w-[140px]">{key}</span>
<span className="text-sm text-textStandard">{value}</span>
</div>
</div>
);
}

return (
<div className="p-1">
<div className="flex items-baseline">
<span className="text-textStandard mr-2">{key}:</span>
<div className="flex-1">
<div className="mb-2">
<div className="flex flex-row">
<span className="text-sm font-medium text-textSubtle min-w-[140px]">{key}</span>
<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
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>
{!isExpanded && <span className="ml-2 text-gray-600">{value.slice(0, 60)}...</span>}
</div>
</div>
{isExpanded && (
<div className="mt-2 ml-4">
{/* {isExpanded && (
<div className="mt-2">
<MarkdownContent content={value} />
</div>
)}
)} */}
</div>
);
}
Expand All @@ -59,17 +69,17 @@ export function ToolCallArguments({ args }: ToolCallArgumentsProps) {
: String(value);

return (
<div className="p-1">
<div className="flex">
<span className="font-medium mr-2">{key}:</span>
<div className="mb-2">
<div className="flex flex-row">
<span className="font-medium mr- min-w-[140px]2">{key}:</span>
<pre className="whitespace-pre-wrap">{content}</pre>
</div>
</div>
);
};

return (
<div className="mt-2">
<div className="my-2">
{Object.entries(args).map(([key, value]) => (
<div key={key}>{renderValue(key, value)}</div>
))}
Expand Down
14 changes: 7 additions & 7 deletions ui/desktop/src/components/ToolInvocations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ interface ToolCallProps {
function ToolCall({ call }: ToolCallProps) {
return (
<div>
<div className="flex items-center">
<Box size={15} />
<span className="ml-[8px] text-sm text-textStandard font-medium tracking-widest">
{call.toolName.substring(call.toolName.lastIndexOf('__') + 2).toUpperCase()}
<div className="flex items-center mb-4">
<Box size={16} />
<span className="ml-[8px] text-textStandard">
{snakeToTitleCase(call.toolName.substring(call.toolName.lastIndexOf('__') + 2))}
</span>
</div>

Expand Down Expand Up @@ -116,7 +116,7 @@ function ToolResult({ result }: ToolResultProps) {
};

return (
<div className="mt-2">
<div className="">
{filteredResults.map((item: ResultItem, index: number) => {
const isExpanded = shouldShowExpanded(item, index);
// minimize if priority is not set or < 0.5
Expand All @@ -127,9 +127,9 @@ function ToolResult({ result }: ToolResultProps) {
{shouldMinimize && (
<button
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
className={`h-5 w-5 transition-all origin-center ${!isExpanded ? 'rotate-180' : ''}`}
/>
Expand Down

0 comments on commit b3978c7

Please sign in to comment.