import React from 'react'; import { ToolViewProps } from '../types'; import { formatTimestamp, getToolTitle } from '../utils'; import { getToolIcon } from '../../utils'; import { CircleDashed, CheckCircle, AlertTriangle } from 'lucide-react'; import { cn } from '@/lib/utils'; export interface ToolViewWrapperProps extends ToolViewProps { children: React.ReactNode; headerContent?: React.ReactNode; footerContent?: React.ReactNode; className?: string; contentClassName?: string; headerClassName?: string; footerClassName?: string; showStatus?: boolean; customStatus?: { success?: string; failure?: string; streaming?: string; }; } export function ToolViewWrapper({ name = 'unknown', isSuccess = true, isStreaming = false, assistantTimestamp, toolTimestamp, children, headerContent, footerContent, className, contentClassName, headerClassName, footerClassName, showStatus = true, customStatus, }: ToolViewWrapperProps) { const toolTitle = getToolTitle(name); const Icon = getToolIcon(name); return (
{(headerContent || showStatus) && (
{Icon && } {toolTitle}
{headerContent}
)}
{children}
{(footerContent || showStatus) && (
{!isStreaming && showStatus && (
{isSuccess ? ( ) : ( )} {isSuccess ? customStatus?.success || "Completed successfully" : customStatus?.failure || "Execution failed"}
)} {isStreaming && showStatus && (
{customStatus?.streaming || "Processing..."}
)}
{toolTimestamp && !isStreaming ? formatTimestamp(toolTimestamp) : assistantTimestamp ? formatTimestamp(assistantTimestamp) : ""}
{footerContent}
)}
); }