MCPcopy Create free account
hub / github.com/QuantumNous/new-api / SourceDiff

Function SourceDiff

web/src/features/task-plugins/components/source-diff.tsx:71–110  ·  view source on GitHub ↗
(props: SourceDiffProps)

Source from the content-addressed store, hash-verified

69}
70
71export function SourceDiff(props: SourceDiffProps) {
72 const { t } = useTranslation()
73 if (props.before === props.after) {
74 return (
75 <p
76 role='status'
77 className='text-muted-foreground rounded-md border px-3 py-6 text-center text-sm'
78 >
79 {props.emptyText ?? t('No source changes')}
80 </p>
81 )
82 }
83 const lines = diffLines(props.before, props.after)
84 return (
85 <div
86 className={cn(
87 'max-h-96 overflow-auto rounded-md border font-mono text-xs',
88 props.className
89 )}
90 aria-label={props.label ?? t('Source diff')}
91 >
92 {lines.map((line) => {
93 let prefix = ' '
94 let color = ''
95 if (line.kind === 'added') {
96 prefix = '+'
97 color = 'bg-green-500/10 text-green-700 dark:text-green-300'
98 } else if (line.kind === 'removed') {
99 prefix = '-'
100 color = 'bg-red-500/10 text-red-700 dark:text-red-300'
101 }
102 return (
103 <div key={line.id} className={`px-3 whitespace-pre ${color}`}>
104 {prefix} {line.text || ' '}
105 </div>
106 )
107 })}
108 </div>
109 )
110}

Callers

nothing calls this directly

Calls 3

cnFunction · 0.90
tFunction · 0.85
diffLinesFunction · 0.85

Tested by

no test coverage detected