mirror of https://github.com/kortix-ai/suna.git
fixed success and failure messaged to be shown on a toast instead if console log.
This commit is contained in:
parent
a004a1b2ee
commit
124fb0e1c8
|
@ -12,6 +12,7 @@ import { useIsMobile } from '@/hooks/use-mobile';
|
|||
import { Button } from '@/components/ui/button';
|
||||
import { ToolView } from './tool-views/wrapper';
|
||||
import { motion, AnimatePresence } from 'framer-motion';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
export interface ToolCallInput {
|
||||
assistantCall: {
|
||||
|
@ -259,10 +260,9 @@ export function ToolCallSidePanel({
|
|||
setIsCopyingContent(true);
|
||||
const success = await copyToClipboard(fileContent);
|
||||
if (success) {
|
||||
// Use toast if available, otherwise just log
|
||||
console.log('File content copied to clipboard');
|
||||
toast.success('File content copied to clipboard');
|
||||
} else {
|
||||
console.error('Failed to copy file content');
|
||||
toast.error('Failed to copy file content');
|
||||
}
|
||||
setTimeout(() => setIsCopyingContent(false), 500);
|
||||
}, [displayToolCall?.toolResult?.content, copyToClipboard]);
|
||||
|
|
|
@ -16,6 +16,7 @@ import { Badge } from '@/components/ui/badge';
|
|||
import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { LoadingState } from './shared/LoadingState';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
export function GenericToolView({
|
||||
name = 'generic-tool',
|
||||
|
@ -143,9 +144,9 @@ export function GenericToolView({
|
|||
setIsCopyingInput(true);
|
||||
const success = await copyToClipboard(formattedAssistantContent);
|
||||
if (success) {
|
||||
console.log('Tool input copied to clipboard');
|
||||
toast.success('File content copied to clipboard');
|
||||
} else {
|
||||
console.error('Failed to copy tool input');
|
||||
toast.error('Failed to copy file content');
|
||||
}
|
||||
setTimeout(() => setIsCopyingInput(false), 500);
|
||||
}, [formattedAssistantContent, copyToClipboard]);
|
||||
|
@ -156,9 +157,9 @@ export function GenericToolView({
|
|||
setIsCopyingOutput(true);
|
||||
const success = await copyToClipboard(formattedToolContent);
|
||||
if (success) {
|
||||
console.log('Tool output copied to clipboard');
|
||||
toast.success('File content copied to clipboard');
|
||||
} else {
|
||||
console.error('Failed to copy tool output');
|
||||
toast.error('Failed to copy file content');
|
||||
}
|
||||
setTimeout(() => setIsCopyingOutput(false), 500);
|
||||
}, [formattedToolContent, copyToClipboard]);
|
||||
|
@ -224,7 +225,7 @@ export function GenericToolView({
|
|||
onClick={handleCopyInput}
|
||||
disabled={isCopyingInput}
|
||||
className="h-6 w-6 p-0"
|
||||
title="Copy input"
|
||||
title="Copy file content"
|
||||
>
|
||||
{isCopyingInput ? (
|
||||
<Check className="h-3 w-3" />
|
||||
|
@ -256,7 +257,7 @@ export function GenericToolView({
|
|||
onClick={handleCopyOutput}
|
||||
disabled={isCopyingOutput}
|
||||
className="h-6 w-6 p-0"
|
||||
title="Copy output"
|
||||
title="Copy file content"
|
||||
>
|
||||
{isCopyingOutput ? (
|
||||
<Check className="h-3 w-3" />
|
||||
|
|
|
@ -56,6 +56,7 @@ import {
|
|||
import { ToolViewProps } from '../types';
|
||||
import { GenericToolView } from '../GenericToolView';
|
||||
import { LoadingState } from '../shared/LoadingState';
|
||||
import { toast } from 'sonner';
|
||||
|
||||
export function FileOperationToolView({
|
||||
assistantContent,
|
||||
|
@ -90,9 +91,9 @@ export function FileOperationToolView({
|
|||
setIsCopyingContent(true);
|
||||
const success = await copyToClipboard(fileContent);
|
||||
if (success) {
|
||||
console.log('File content copied to clipboard');
|
||||
toast.success('File content copied to clipboard');
|
||||
} else {
|
||||
console.error('Failed to copy file content');
|
||||
toast.error('Failed to copy file content');
|
||||
}
|
||||
setTimeout(() => setIsCopyingContent(false), 500);
|
||||
};
|
||||
|
@ -313,6 +314,14 @@ export function FileOperationToolView({
|
|||
</div>
|
||||
</div>
|
||||
<div className='flex items-center gap-2'>
|
||||
{isHtml && htmlPreviewUrl && !isStreaming && (
|
||||
<Button variant="outline" size="sm" className="h-8 text-xs bg-white dark:bg-muted/50 hover:bg-zinc-100 dark:hover:bg-zinc-800 shadow-none" asChild>
|
||||
<a href={htmlPreviewUrl} target="_blank" rel="noopener noreferrer">
|
||||
<ExternalLink className="h-3.5 w-3.5 mr-1.5" />
|
||||
Open in Browser
|
||||
</a>
|
||||
</Button>
|
||||
)}
|
||||
{/* Copy button - only show when there's file content */}
|
||||
{fileContent && !isStreaming && (
|
||||
<Button
|
||||
|
@ -331,14 +340,6 @@ export function FileOperationToolView({
|
|||
<span className="hidden sm:inline">Copy</span>
|
||||
</Button>
|
||||
)}
|
||||
{isHtml && htmlPreviewUrl && !isStreaming && (
|
||||
<Button variant="outline" size="sm" className="h-8 text-xs bg-white dark:bg-muted/50 hover:bg-zinc-100 dark:hover:bg-zinc-800 shadow-none" asChild>
|
||||
<a href={htmlPreviewUrl} target="_blank" rel="noopener noreferrer">
|
||||
<ExternalLink className="h-3.5 w-3.5 mr-1.5" />
|
||||
Open in Browser
|
||||
</a>
|
||||
</Button>
|
||||
)}
|
||||
<TabsList className="h-8 bg-muted/50 border border-border/50 p-0.5 gap-1">
|
||||
<TabsTrigger
|
||||
value="code"
|
||||
|
|
Loading…
Reference in New Issue