Skip to content

DiffView

Stable

Review the changes an assistant made to your files, and keep or reject each one.

Also known as diff viewer, code diff, compare changes

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

Review two files

  • 1 line added, 1 removed
  • 1 line added, 0 removed

Hunk 1 @@ -4,5 +4,6 @@

Day 1: Arrive in Lisbon
Removed: Hotel: not booked yet
Added: Hotel: Casa Azul, booked for 3 nights
Day 2: Walk the old town

2 files left to review

Decide per file, per change, or use the bottom bar. Next file jumps to a file you have not finished.

When to use it

The place to decide what stays after an assistant edits files. Files are listed on one side and the chosen file's changes on the other, so people can decide one group of lines, a whole file, or everything at once.

Made of: File list (one row per file) · Change heading with Keep and Reject · Changed lines (old number, new number, sign, text) · Bottom bar (files left, Keep all, Reject all, Next file) · Spoken update

Use it for

  • Reviewing edits an assistant made before they are saved or shared.
  • Letting people keep some changes in a file and reject others.
  • Working through many changed files, with a count of how many are left.

Not for

  • A short summary of changed files without the lines: use DiffFileRow.
  • Showing code that is not a change: use CodeBlock.
  • Going back to an earlier saved version of the whole work: use VersionHistory.

Do and avoid

  • 1 line added, 1 removed

Hunk 1

const tax = 0.2;
Removed: const total = sub + tax;
Added: const total = sub * (1 + tax);

1 file left to review

Do. Short code lines with plus and minus signs are easy to compare.
  • 1 line added, 1 removed

Hunk 1

Removed: Thank you for your order, which we were very happy to receive and which will be sent to you as soon as we possibly can.
Added: Thank you for your order. We were glad to get it and will send it to you as soon as we can, most likely by Friday.

1 file left to review

Avoid. Long sentences in a code font are hard to read and compare.

Do

  • Show how many files are left, so people know how much remains.
  • Give Keep all and Reject all the same visual weight.
  • Save people's choices in your app if the review must survive a page reload.
  • Show real line numbers so people can find each change.

Avoid

  • Don't mark lines with only color. Keep the plus and minus signs.
  • Don't offer Keep all without showing how many files it affects. Changes already decided stay as they are.
  • Don't use it to compare long paragraphs of writing. It shows lines in a fixed-width font.

On a phone

  • Below 768px wide the file list sits above the changes instead of beside them.
  • Each block of lines scrolls sideways on its own, because the lines do not wrap, and the two line-number columns use 96px of a phone screen.
  • Keep, Reject and Undo buttons keep their size and have a 44px tap area on a touch screen, and the footer buttons wrap onto more rows.

Seen in products

  • Cursor has a Review tab with a file list, per-file Keep and Reject, a bottom bar with Keep All and Reject All, and Review Next File navigation (from a search snippet plus community threads).
  • Cursor community feedback asks for per-change (hunk) apply, which suggests a recent regression. DiffView offers per-hunk Keep and Reject for that reason.
  • Windsurf lets you accept or reject proposed modifications.
  • GitHub Copilot coding agent has the diff reviewed on a branch before the pull request is created.
  • Vercel AI Elements ships a Commit component.

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started