Output & generative UI
Diff view
Use when the agent proposes edits to code or config and people need to accept or reject each change on its own.
Proposed code edits side by side with per-hunk accept and reject.
Part of Output & generative UI. The stage where the response is a thing, not a paragraph: a document, a set of edits, a record, a chart. These patterns give that output a container the user can review, accept in part, and come back to later.
Do
- Put before and after side by side with aligned rows and line numbers.
- Let each hunk be accepted or rejected separately.
- Keep the rejected side visible but dimmed, so the layout does not jump.
Don't
- Don't apply anything until every hunk has a decision.
- Don't offer only accept all. Partial acceptance is the point.
- Don't show a diff for prose. Use an artifact with versions.
States
- Unreviewed: Removed lines are tinted red on the left, added lines green on the right. Each hunk has accept and reject controls and the header counts 0 of 2 reviewed.
- Hunk accepted: The controls become an Accepted label, the tint clears and the old lines dim.
- Hunk rejected: The controls become a Rejected label, the tint clears and the new lines dim.
- All reviewed: A footer appears saying all changes are reviewed, with an Apply button.
- Applied: The button turns green and reads Applied.
Usage
import { DiffViewPattern } from "./halaska-kit";
<DiffViewPattern />
Built from
Related patterns
Halaska UI · Components · Patterns · Screens · Install