({ file_path, old_string, new_string, result: _result })
| 1126 | new_string: string; |
| 1127 | result?: any; |
| 1128 | }> = ({ file_path, old_string, new_string, result: _result }) => { |
| 1129 | const { theme } = useTheme(); |
| 1130 | const syntaxTheme = getClaudeSyntaxTheme(theme); |
| 1131 | |
| 1132 | const diffResult = Diff.diffLines(old_string || '', new_string || '', { |
| 1133 | newlineIsToken: true, |
| 1134 | ignoreWhitespace: false |
| 1135 | }); |
| 1136 | const language = getLanguage(file_path); |
| 1137 | |
| 1138 | return ( |
| 1139 | <div className="space-y-2"> |
| 1140 | <div className="flex items-center gap-2 mb-2"> |
| 1141 | <FileEdit className="h-4 w-4 text-primary" /> |
| 1142 | <span className="text-sm font-medium">Applying Edit to:</span> |
| 1143 | <code className="text-sm font-mono bg-background px-2 py-0.5 rounded flex-1 truncate"> |
| 1144 | {file_path} |
| 1145 | </code> |
| 1146 | </div> |
| 1147 | |
| 1148 | <div className="rounded-lg border bg-zinc-950 overflow-hidden text-xs font-mono"> |
| 1149 | <div className="max-h-[440px] overflow-y-auto overflow-x-auto"> |
| 1150 | {diffResult.map((part, index) => { |
| 1151 | const partClass = part.added |
| 1152 | ? 'bg-green-950/20' |
| 1153 | : part.removed |
| 1154 | ? 'bg-red-950/20' |
| 1155 | : ''; |
| 1156 | |
| 1157 | if (!part.added && !part.removed && part.count && part.count > 8) { |
| 1158 | return ( |
| 1159 | <div key={index} className="px-4 py-1 bg-zinc-900 border-y border-zinc-800 text-center text-zinc-500 text-xs"> |
| 1160 | ... {part.count} unchanged lines ... |
| 1161 | </div> |
| 1162 | ); |
| 1163 | } |
| 1164 | |
| 1165 | const value = part.value.endsWith('\n') ? part.value.slice(0, -1) : part.value; |
| 1166 | |
| 1167 | return ( |
| 1168 | <div key={index} className={cn(partClass, "flex")}> |
| 1169 | <div className="w-8 select-none text-center flex-shrink-0"> |
| 1170 | {part.added ? <span className="text-green-400">+</span> : part.removed ? <span className="text-red-400">-</span> : null} |
| 1171 | </div> |
| 1172 | <div className="flex-1"> |
| 1173 | <SyntaxHighlighter |
| 1174 | language={language} |
| 1175 | style={syntaxTheme} |
| 1176 | PreTag="div" |
| 1177 | wrapLongLines={false} |
| 1178 | customStyle={{ |
| 1179 | margin: 0, |
| 1180 | padding: 0, |
| 1181 | background: 'transparent', |
| 1182 | }} |
| 1183 | codeTagProps={{ |
| 1184 | style: { |
| 1185 | fontSize: '0.75rem', |
nothing calls this directly
no test coverage detected