/** * @license * Copyright 2025 Qwen Team * SPDX-License-Identifier: Apache-2.0 * * Write/Edit tool call component - specialized for file writing and editing operations */ import type React from 'react'; import type { BaseToolCallProps } from './shared/types.js'; import { ToolCallCard, ToolCallRow, StatusIndicator, CodeBlock, LocationsList, DiffDisplay, } from './shared/LayoutComponents.js'; import { formatValue, safeTitle, groupContent } from './shared/utils.js'; /** * Specialized component for Write/Edit tool calls * Optimized for displaying file writing and editing operations with diffs */ export const WriteToolCall: React.FC = ({ toolCall }) => { const { kind, title, status, rawInput, content, locations } = toolCall; const titleText = safeTitle(title); const isEdit = kind.toLowerCase() === 'edit'; // Group content by type const { textOutputs, errors, diffs, otherData } = groupContent(content); return ( {/* Title row */} {/* File path(s) */} {locations && locations.length > 0 && ( )} {/* Input parameters (e.g., old_string, new_string for edits) */} {rawInput && ( {formatValue(rawInput)} )} {/* Diff display - most important for write/edit operations */} {diffs.map( (item: import('./shared/types.js').ToolCallContent, idx: number) => ( ), )} {/* Success message or output */} {textOutputs.length > 0 && ( {textOutputs.join('\n')} )} {/* Error handling */} {errors.length > 0 && (
{errors.join('\n')}
)} {/* Other data */} {otherData.length > 0 && ( {otherData.map((data: unknown) => formatValue(data)).join('\n\n')} )}
); };