# File edits

An agent's edit across files as one row: Edited 3 files +22 −5 with Undo all and Keep all, over each file's diff hung from a hairline. Decide all at once or file by file and change by change; the row keeps count.

Tier: pro. Type: component. Category: ai. Tags: agent, approval, undo, keyboard, motion.

## Install

```bash
npx shadcn@latest add @pixilui-pro/file-edits
```

One-time setup: add the registry to `components.json`:

```json
{
  "registries": {
    "@pixilui": "https://pixilui.com/r/{name}.json",
    "@pixilui-pro": {
      "url": "https://pixilui.com/r/pro/{name}.json",
      "headers": { "Authorization": "Bearer ${PIXILUI_TOKEN}" }
    }
  }
}
```

Pro items need a license. Create a token on https://pixilui.com/account and set `PIXILUI_TOKEN` in `.env.local`; the CLI sends it as a bearer header.

Files: `components/pixilui/file-edits.tsx`.

## Preview

Live preview: https://pixilui.com/components/file-edits

Knobs:

- `files`: `first open`, `all folded`

Signature: Keep all: the three files keep a beat apart down the list, their tints draining one after another, and the row reads Kept.

Styles: `lively` (default), `quiet`, set with `data-style` on <html>. The item reads the style through the foundation; it needs no prop.

## Code

Pro source is available to license holders.

## Usage

When to use:

- One edit the agent made across several files, decided as a whole or file by file.
- A change set a person reviews in the chat before it lands: a refactor, a fix with its tests.

When not to use:

- One file: use Diff.
- A whole pull request review with comments: a code host does that.

```tsx
import { useRef } from "react";
import { Button } from "@/components/pixilui/button";
import { FileEdits, type FileEditsHandle } from "@/components/pixilui/file-edits";
import { refundEdits } from "@/components/pixilui/file-edits.examples";

// The first option of each knob is the demo's default; the docs preview starts there.
export const knobs = {
  files: ["first open", "all folded"],
} as const;

const ANSWER = { fontSize: "var(--pixilui-text-answer)", lineHeight: "var(--pixilui-text-answer-leading)", letterSpacing: "var(--pixilui-text-answer-tracking)" };

/** One edit across three files: Keep all or Undo all from the row, or decide each file and each change on its own. */
export default function FileEditsDemo({ files = "first open" }: KnobValues<typeof knobs>) {
  const ref = useRef<FileEditsHandle>(null);
  const list = files === "first open" ? refundEdits : refundEdits.map((f) => ({ ...f, open: false }));
  return (
    <div className="grid w-full max-w-xl gap-3 rounded-panel bg-surface p-5 elevation-raised">
      <p className="m-0 text-foreground" style={ANSWER}>
        Done. The limit is $500, anything above it goes to a review queue, and the tests cover both.
      </p>
      <FileEdits key={files} ref={ref} files={list} />
      <div>
        <Button variant="secondary-2" size="sm" onClick={() => ref.current?.reset()}>
          Reset
        </Button>
      </div>
    </div>
  );
}
```

## Examples

None.

## API

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `files` (required) | `FileEdit[]` |  | The files the agent changed, each the Diff's options. |
| `onStateChange` | `(states: DiffFileState[]) => void` |  | Each file's state changed (in order). |
| `words` | `Partial<FileEditsWords>` |  | Every word the row says (each file's own words are on the file). |
| `icons` | `{ chevron?: ReactNode; undo?: ReactNode; redo?: ReactNode; done?: ReactNode }` | `{}` | The icons it draws (the locked disclosure, undo, redo and done). |

Also accepts every native `<section>` attribute, and a ref to it.

## Keyboard

- `Tab`: Reaches the row's Undo all and Keep all, then each file's row and its controls.
- `Enter` + `Space`: Decides all, or folds the list from its row.

## Accessibility

- The row's status line says what all-at-once did (Kept 3 files.); focus moves to what took the button's place.
- Each file is a Diff with its own named row, decisions and announcements.

## Motion

- Keep all and Undo all reach the files 90ms apart, down the list; each file plays its own Keep or Undo.
- The row's end swaps with the quiet blur swap: Undo all and Keep all, then Kept, Undone with Redo all, or 2 kept · 1 undone.
- Reduced motion: at once.

## Responsive

- Fills its container; the files sit in 14 from the row on a hairline.

## Performance

- Each file's diff is worked out once; the row reads the files' states on the next frame.

## Notes for AI

- <FileEdits files={[{ path, before, after }, ...]} onStateChange={(states) => save(states)} />: each file takes Diff's options (state, context, open).
- Only the first file opens by default; pass open per file. A ref has keepAll(), undoAll(), redoAll() and reset().
- Every word on the row is in words; each file's own words are on the file.

## Related

- [Diff](https://pixilui.com/components/diff/markdown): 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.
- [Code block](https://pixilui.com/components/code-block/markdown): Code the agent shows you in its answer, in a grey well: the file with its folders quiet, Copy, the syntax in six picked inks and a write-in replay. A well of JSON masks any key as it renders, and Copy copies the mask.
- [Command](https://pixilui.com/components/command/markdown): A command the agent ran: the row reads Ran pnpm test · 4.2 s and folds a well with the command, Copy and what it printed. Running, its output prints in, the clock ticks and Stop ends it; a failure reads red with its exit code.
