Inline hunk reviewPro
Accept or reject an agent's edit hunk by hunk inside the file it changed. Y accepts, N rejects and both move on, J and K step between hunks, U undoes.
On this page
ProAn agent's rounding fix inside the file it changed. Y accepts, N rejects and moves to the next hunk, J and K step between hunks, U undoes, then Save file.
Installation
Usage
import { InlineHunkReview } from "@/components/ui/chatcn/pro/inline-hunk-review"
<InlineHunkReview path="src/payouts/allocate.ts" oldText={before} newText={after} onSave={write} />The whole file shows with each change in place, highlighted by the shared grammar. Accepted hunks settle into the file with a green edge, rejected ones bring the old lines back with a gray edge, and the mark in the gutter undoes either. onSave gets the file that results from your decisions. While streaming, the last hunk waits with a Writing label.
Examples
States
ProThe agent still writing, hunks already decided, a failed save with long lines, read only, no changes and loading.
Props
| Prop | Type | Notes |
|---|---|---|
oldText, newText, path | string | The file before and after |
language | string | Defaults to the extension |
decisions, defaultDecisions, onDecisionsChange | Record<string, HunkDecision> | By hunk id; buildBlocks lists the ids |
streaming | boolean | The last hunk is not final |
disabled | boolean | Read only |
onSave, saving, saved, error | Save file, once every hunk has a decision | |
loading, height |
Keyboard
| Key | Action |
|---|---|
Y / N | Accept or reject the active hunk, then go to the next one that needs you |
J K (ArrowDown ArrowUp) | Next and previous hunk |
Shift Y / Shift N | Accept all or reject all |
U | Undo, back to the hunk it changed |
Accessibility
- Each hunk is a group named Change n of m with its line. Buttons carry the same name, so a screen reader hears which change they act on.
- Every decision is announced politely. Lines keep + and - glyphs and read Added and Removed.
Motion
None. Decisions are made from the keyboard many times in a row, so hunks swap in place without animation.