/** * EditToolViewer * * Renders the Edit tool with DiffViewer. */ import React from 'react'; import { DiffViewer } from '@renderer/components/chat/viewers'; import { type ItemStatus, StatusDot } from '../BaseItem'; import { formatTokens } from '../baseItemHelpers'; import { renderOutput } from './renderHelpers'; import type { LinkedToolItem } from '@renderer/types/groups'; interface EditToolViewerProps { linkedTool: LinkedToolItem; status: ItemStatus; } export const EditToolViewer: React.FC = ({ linkedTool, status }) => { const toolUseResult = linkedTool.result?.toolUseResult as Record | undefined; const filePath = (toolUseResult?.filePath as string) || (linkedTool.input.file_path as string); const oldString = (toolUseResult?.oldString as string) || (linkedTool.input.old_string as string) || ''; const newString = (toolUseResult?.newString as string) || (linkedTool.input.new_string as string) || ''; return (
{/* Show result status if available */} {!linkedTool.isOrphaned && linkedTool.result != null && (
Result {linkedTool.result?.tokenCount !== undefined && linkedTool.result.tokenCount > 0 && ( ~{formatTokens(linkedTool.result.tokenCount)} tokens )}
{renderOutput(linkedTool.result.content)}
)}
); };