AI Diff Review - React Component | Kokonut UI
AI Diff Review
A coding agent's edits streaming in file by file, then reviewed per file with accept, reject and undo.
Install with
npx shadcn@latest add https://kokonutui.com/r/ai-diff-review.json, then show me how to use it.
Editing files
3 files changed +12−3
Waiting for edits…
lib/validate.ts new
const POSTCODE = /^\[A-Z\]{1,2}\d\[A-Z\d\]? ?\d\[A-Z\]{2}$/i;
export function isPostcode(value: string) {
return POSTCODE.test(value.trim());
}
- app/checkout/form.tsx
const onSubmit = (data: Address) => {
if (!isPostcode(data.postcode)) {
return setError("Enter a valid postcode");
}
submit(data);
}
- app/checkout/form.test.ts
it("rejects an empty postcode", () => {
expect(errorFor("")):toBe("Required");
expect(errorFor("")):toBe("Enter a valid postcode");
});
Installation
AI Diff Review is a free, open-source React component in the Kokonut UI AI collection. Add it with the shadcn CLI, which copies the source into components/kokonutui/ai-diff-review.tsx, so the code is yours to change.
Or add it by hand: install its packages, then copy the source from above into components/kokonutui/ai-diff-review.tsx.
npm install lucide-react motion
Usage
import AIDiffReview from "@/components/kokonutui/ai-diff-review";
export default function Example() {
return <AIDiffReview />;
}
Props
files:FileChange[]- The agent's edits. When omitted, a demo edit streams in, file by file, then waits for review.
onDecision:(path: string, decision: FileDecision) => void- Called when a file is accepted, rejected or put back to pending.
className:string- Extra classes for the root element.
FileChange
path: requiredstringhunks: requiredDiffHunk[]created:boolean(True for a file the agent created.)
FileDecision
type FileDecision = "pending" | "accepted" | "rejected";
DiffHunk
start: requirednumber(First line number of the hunk in the new file.)lines: requiredDiffLine[]
DiffLine
type: required ("add" | "remove" | "context")text: requiredstring
Dependencies
| Needs | Version | Comes from |
|---|---|---|
lucide-react |
^0.556.0 |
npm, installed by the CLI |
motion |
^12.23.25 |
npm, installed by the CLI |
cn from lib/utils.ts |
shadcn init | |
| React | 19 |
Your app |
| Tailwind CSS | 4 |
Your app |
No provider, font or global CSS to set up: the file works as soon as it lands.
Additional Resources
Example Screenshot
Slash Command Menu
- Type / to pick a command, and a hint bar fills in its arguments.
- 150+ components and templates for AI products.
- One command installation with shadcn/cli.