Diff

Pro

An agent's edit to one file, waiting in its answer: the row reads Edited policy.ts +5 −2 with Undo and Keep, over the path and the line diff. Keep and Undo turn the diff into the file in place, and each change can be kept or undone on its own.

Pro opens soon
npx shadcn@latest add @pixilui-pro/diff

Preview

Keep folds the old lines away, Undo erases the new ones, and the numbers stay right.
State
Context

When to use

Use it when

  • An edit the agent made to a file that the person keeps or undoes, inside the chat.
  • A file with several changes, where some are right and some are not: each change has its own Undo and Keep.
  • A replay of the agent writing the edit (a ref's write()).

Use something else when

  • An edit across several files under one decision: use File edits.
  • Code with nothing to decide: use Code block.
  • A side by side review of a whole pull request: a code host does that.

Installation

diff.tsx733 linesPro
Pro opens soon

Join the waitlist and we'll email you when PixilUI launches. The preview, props and docs stay open until then.

Pro installs with the same CLI as the free items. One command adds diff.tsx and the free button.tsx, the free kbd.tsx, the free tooltip.tsx and the free code-block.tsx it uses; your license key goes in once, as in Installation.

{
  "registries": {
    "@pixilui-pro": {
      "url": "https://pixilui.com/r/pro/{name}.json",
      "headers": { "Authorization": "Bearer ${PIXILUI_TOKEN}" }
    }
  }
}
Terminal
npx shadcn@latest add @pixilui-pro/diff

Adds diff.tsx with button.tsx, kbd.tsx, tooltip.tsx and code-block.tsx, and installs clsx and tailwind-merge. The CLI reads PIXILUI_TOKEN from .env.local; if this computer has not logged in yet, run npx pixilui@latest login once.

Usage

example.tsx
import { Diff } from "@/components/pixilui/diff";

<Diff
  path={path}
  before={before}
  after={after}
  onOpenChange={onOpenChange}
  onStateChange={onStateChange}
/>

Fills its container. Long lines wrap under their own column; under 330 wide Undo keeps only its icon; nothing scrolls sideways at 390.

API reference

PropTypeDefault
pathRequiredstring–The file: "src/refunds/policy.ts". The folders go quiet, the file name leads.
beforeRequiredstring–The file as it was (an empty string: a new file, all added).
afterRequiredstring–The file as the agent left it.
contextnumber3Unchanged lines kept around each change (3, as git); longer runs fold into a band you can open.
state"review" | "kept" | "undone" | "editing""review"How it starts: review (waiting, the default), kept, undone or editing.
defaultOpenbooleantrueOpen (default) or folded, uncontrolled.
openboolean–Open or folded, controlled.

Also takes every native <section> attribute except onToggle, and a ref.

Keyboard

TabReaches the row, Undo and Keep, each change's Undo and Keep (shown at once on focus), the unchanged-lines bands, then the code when it scrolls sideways.
Enter SpaceDecides, folds the file from its row, or opens a band.

Accessibility

  • After Undo focus moves to Redo, after Redo to Undo, after a change's Keep to the next waiting change; each decision is said in the row's status line.
  • Signs carry the change as well as color, and each changed line says Added or Removed to a screen reader.
  • A change's Undo and Keep are a group named Change 1 of 2; on touch they take a 44 row of their own inside the green block; Keep reaches 44 on touch.

Motion

  • Keep: the removed rows fold shut and the tints drain left to right. Undo: the new words erase from the right, then their rows fold, and the numbers below roll back.
  • Redo and the replay: rows open and the words write in across the line (560ms, even), a row apart; the counts roll up from nothing.
  • A change's buttons wait 80ms for a hover, then grow from their right edge out of a 2px blur; they leave faster. The header's words swap with the quiet blur swap.
  • Reduced motion: every fold, wipe, write and swap at once.
File editsKeep all reaches the files a beat apart, down the list, and the row reads Kept.
Code blockA key in the code renders masked, and Copy copies the mask, never the key.
CommandWhile it runs, the output prints in line by line and Stop ends it with ^C.

PixilUI Pro opens soon. The first 20 licenses are $99.