All components

Diff Viewer

AI

The review UI for an AI edit: a real diff between two versions with word-level highlights and per-hunk accept/reject you can drive from the keyboard. The engine is an actual longest-common-subsequence diff (DP + backtrack) run over lines to find changed regions, then again over the words of a changed line pair to highlight exactly what moved. Each hunk resolves to its new side (accept) or old side (reject); the composed document is handed back via onResolve. Arrow/j/k move, a/r/u resolve, and the active hunk scrolls into view. Monochrome and dependency-light.

1 change · 1 pending
export function total(items) {
let sum = 0;
for (const item of items) {
sum += item.price;
}
return sum;
export function total(items, tax = 0) {
const subtotal = items.reduce((s, item) => s + item.price, 0);
return subtotal * (1 + tax);
}

Click the diff, then use ↑/↓ and a / r to review each hunk.

Installation

Terminal
npx shadcn@latest add https://ui.saumyarex.xyz/r/diff-viewer.json

Props

PropTypeDefaultDescription
original / modifiedstringThe two versions to diff, line by line.
onResolve(text: string) => voidCalled with the composed document as hunks are accepted / rejected.
...propsReact.ComponentProps<"div">All native div attributes are forwarded.

Dependencies

clsxtailwind-merge