Let people accept or reject an agent's edits
Per-change review for anything a model rewrites.
The problem
A model rewrites a document and hands back the whole thing. Now someone has to read all of it to find what moved, and the only controls are "keep everything" or "throw it away" — so people paste it into a diff tool, or just accept it and hope.
Rewriting is not the hard part. Reviewing is. What is missing is a way to see each change on its own and take the good ones.
What you are building
Live surfaces, not screenshots — every one composed from the same components you would install.
Per-hunk review
A real git unified diff, with accept/reject per hunk — an agent proposes, a human decides.
The code
// `source` is a discriminated union: {before, after} to diff in-house,
// {unified} for a git patch, {diff} for a pre-built structure. Accepting the
// unified format matters because it is what your VCS and your agent already
// produce -- no conversion step to get wrong.
<FancyDiff
source={{ unified: patch }}
onAcceptHunk={(hunk) => apply(hunk)}
onRejectHunk={(hunk) => discard(hunk)}
/>How to solve it
Render the before and after as hunks
The diff surface splits a rewrite into individual changes, each accepted or rejected on its own.
Run thisbash npm install @particle-academy/fancy-diffKeep the agent on the same document model
The shared document core gives the editors, viewers and writers one node/tree/op model, so a change proposed against one surface means the same thing in another.
Apply only what was accepted
Accepted hunks compose back into the document. Rejected ones never landed, so there is nothing to undo.
