Diff review
Review an agent's diff one hunk at a time. Swipe right to accept, left to reject, or press A and R; the hunk follows your finger, tilts as you throw it, and the tally keeps count.
npx shadcn@latest add @captain/diff-review1 accepted0 rejected2 leftApplying +1 −1
billing/invoice.ts totalFor()+1 −1
41 const subtotal = lines.reduce((s, l) => s + l.amount, 0);42− return Math.round(subtotal * 100) / 100;42+ return roundHalfEven(subtotal, 2);
billing/rounding.ts roundHalfEven()+4 −0
1+export function roundHalfEven(x: number, dp: number) {2+ const f = 10 ** dp, n = x * f, r = Math.round(n);3+ return (Math.abs(n % 1) === 0.5 ? 2 * Math.round(n / 2) : r) / f;4+}
api/routes/invoices.ts GET /invoices/:id+1 −1
Diff review is a Pro component
The demo and the docs are free. The source comes with Pro, through this page, the shadcn CLI and the MCP.
Usage
import { DiffReview } from "@/components/ui/diff-review"
<DiffReview hunks={hunks} onValueChange={setVerdicts} />Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| hunks | Hunk[] | { id, file, header, lines: { type: add | del | ctx, text, n }[] }. | |
| value | Record<string, Verdict> | Controlled verdicts by hunk id: accepted or rejected. | |
| defaultValue | Record<string, Verdict> | Initial verdicts when uncontrolled. | |
| onValueChange | (v) => void | Called on every swipe, key or undo. | |
| threshold | number | 96 | Swipe distance that decides. A fast flick decides sooner. |
Keyboard
- A
- Accept the focused hunk
- R
- Reject it
- U
- Undo a decided hunk
- ↑ ↓ or J K
- Move between hunks
Accessibility
- Each hunk is a focusable group labelled with its file, change counts and verdict.
- Swiping is optional: A, R and U do the same, and focus moves to the next open hunk.
- The tally is a polite live region. Vertical drags scroll the page as usual.