({ path, before, after, maxLines = 30 }: DiffViewerProps)
| 10 | } |
| 11 | |
| 12 | export function DiffViewer({ path, before, after, maxLines = 30 }: DiffViewerProps): React.ReactElement { |
| 13 | const diff = generateUnifiedDiff(before ?? '', after, path); |
| 14 | const lines = parseDiffForDisplay(diff); |
| 15 | const truncated = lines.length > maxLines; |
| 16 | const shown = truncated ? lines.slice(0, maxLines) : lines; |
| 17 | |
| 18 | return ( |
| 19 | <Box flexDirection="column" borderStyle="round" borderColor="gray" paddingX={1}> |
| 20 | <Text color="cyan">📝 {path}</Text> |
| 21 | {shown.map((l, i) => { |
| 22 | if (l.type === 'add') return <Text key={i} color="green">{l.text}</Text>; |
| 23 | if (l.type === 'del') return <Text key={i} color="red">{l.text}</Text>; |
| 24 | if (l.type === 'hunk') return <Text key={i} color="cyan" dimColor>{l.text}</Text>; |
| 25 | return <Text key={i} dimColor>{l.text}</Text>; |
| 26 | })} |
| 27 | {truncated && <Text dimColor>... ({lines.length - maxLines} more lines)</Text>} |
| 28 | </Box> |
| 29 | ); |
| 30 | } |
nothing calls this directly
no test coverage detected