File edits
ProAn 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.
npx shadcn@latest add @pixilui-pro/file-editsPreview
import { useRef } from "react";
import { Button } from "../../../registry/ui/button/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>
);
}When to use
Use it when
- 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.
Use something else when
- One file: use Diff.
- A whole pull request review with comments: a code host does that.
Installation
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 file-edits.tsx and the free button.tsx, the free kbd.tsx, the free tooltip.tsx, the free code-block.tsx and diff.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}" }
}
}
}npx shadcn@latest add @pixilui-pro/file-editsAdds file-edits.tsx with button.tsx, kbd.tsx, tooltip.tsx, code-block.tsx and diff.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.
components/pixilui/file-edits.tsxthe item, 269 linescomponents/pixilui/button.tsxused inside, freecomponents/pixilui/kbd.tsxused inside, freecomponents/pixilui/tooltip.tsxused inside, freecomponents/pixilui/code-block.tsxused inside, freecomponents/pixilui/diff.tsxused insideIt uses Button, Kbd, Tooltip, Code block and Diff: add them the same way. Then npm i clsx tailwind-merge, and add the foundation once per app, as in Installation.
Usage
import { FileEdits } from "@/components/pixilui/file-edits";
<FileEdits files={files} onStateChange={onStateChange} />Fills its container; the files sit in 14 from the row on a hairline.
API reference
filesRequiredFileEdit[]–The files the agent changed, each the Diff's options.onStateChange(states: DiffFileState[]) => void–Each file's state changed (in order).wordsPartial<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 takes every native <section> attribute, and a ref.
Keyboard
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.