MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / DiffViewer

Function DiffViewer

src/cli/prompts/diff-viewer.tsx:12–30  ·  view source on GitHub ↗
({ path, before, after, maxLines = 30 }: DiffViewerProps)

Source from the content-addressed store, hash-verified

10}
11
12export 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}

Callers

nothing calls this directly

Calls 2

generateUnifiedDiffFunction · 0.85
parseDiffForDisplayFunction · 0.85

Tested by

no test coverage detected