import { useState } from 'react' import type { components } from '@/api/opencode-types' import { getRelativePath } from './FileToolRender' import { ChevronDown, ChevronUp } from 'lucide-react' type PatchPartType = components['schemas']['PatchPart'] interface PatchPartProps { part: PatchPartType onFileClick?: (filePath: string) => void } const INITIAL_FILES_SHOWN = 3 export function PatchPart({ part, onFileClick }: PatchPartProps) { const [expanded, setExpanded] = useState(false) const hasMoreFiles = part.files.length > INITIAL_FILES_SHOWN const displayedFiles = expanded ? part.files : part.files.slice(0, INITIAL_FILES_SHOWN) const hiddenCount = part.files.length - INITIAL_FILES_SHOWN return (
{displayedFiles.map((file, index) => (
onFileClick?.(file)} > {getRelativePath(file)}
))} {!expanded && hasMoreFiles && ( )} {expanded && hasMoreFiles && ( )}
) }