/** * Render Helpers * * Shared rendering functions for tool input and output. */ import React from 'react'; import { COLOR_TEXT, COLOR_TEXT_MUTED, DIFF_ADDED_TEXT, DIFF_REMOVED_TEXT, } from '@renderer/constants/cssVariables'; /** * Renders the input section based on tool type with theme-aware styling. */ export function renderInput(toolName: string, input: Record): React.ReactElement { // Special rendering for Edit tool - show diff-like format if (toolName === 'Edit') { const filePath = input.file_path as string | undefined; const oldString = input.old_string as string | undefined; const newString = input.new_string as string | undefined; const replaceAll = input.replace_all as boolean | undefined; return (
{filePath && (
{filePath} {replaceAll && ( (replace all) )}
)} {oldString && (
{oldString.split('\n').map((line, i) => (
- {line}
))}
)} {newString && (
{newString.split('\n').map((line, i) => (
+ {line}
))}
)}
); } // Special rendering for Bash tool if (toolName === 'Bash') { const command = input.command as string | undefined; const description = input.description as string | undefined; return (
{description && (
{description}
)} {command && ( {command} )}
); } // Special rendering for Read tool if (toolName === 'Read') { const filePath = input.file_path as string | undefined; const offset = input.offset as number | undefined; const limit = input.limit as number | undefined; return (
{filePath}
{(offset !== undefined || limit !== undefined) && (
{offset !== undefined && `offset: ${offset}`} {offset !== undefined && limit !== undefined && ', '} {limit !== undefined && `limit: ${limit}`}
)}
); } // Default: JSON format return (
      {JSON.stringify(input, null, 2)}
    
); } /** * Renders the output section with theme-aware styling. */ export function renderOutput(content: string | unknown[]): React.ReactElement { const displayText = typeof content === 'string' ? content : JSON.stringify(content, null, 2); return (
      {displayText}
    
); }