Commit
A commit in one row: its message, author, time and lines changed, with the hash to copy, opening to the files it touched.
- Changed: app/components/chart.tsxAdded +6Removed −2
- Added: app/components/use-container-width.tsAdded +18
- Removed: app/components/chart.cssRemoved −9
Installation
npx shadcn@latest add "@aiellie/commit"shadcn needs the @aiellie registry in components.json first. npx aiellie add commit adds it on its first run, then installs the same way.
Commit shows a commit in one row: its message, who made it and when, how many lines it added and removed, and its hash to copy. It opens to the files it touched, each marked added, changed or removed in the same ink as File Tree and Code Diff.
Getting started
Pass the commit
filesgoes on the root, so the header can count them and the list can show them.components/agent-commit.tsximport { Commit, CommitFiles, CommitHash, CommitHeader, } from "@/components/aiellie/commit" export function AgentCommit() { return ( <Commit files={[ { path: "app/chart.tsx", status: "modified", additions: 6, deletions: 2 }, { path: "app/use-width.ts", status: "added", additions: 18 }, ]} > <CommitHeader message="Size the chart from its container" author="Ada Lovelace" time="42 minutes ago" > <CommitHash hash="4f2c9e1b7a03d5e8" /> </CommitHeader> <CommitFiles /> </Commit> ) }
Anatomy
<div data-slot="commit"> {/* Base UI Collapsible */}
<div data-slot="commit-header">
<button /> {/* the author, the message and the counts */}
<button data-slot="commit-hash" />
</div>
<div data-slot="commit-files">
<ul>
<li data-status="added" />
</ul>
</div>
</div>The header's children sit at its end, outside the button that opens it. Without an avatar the author's initials stand in. A commit with no files doesn't open.
Examples
Open a file
onOpenFile on the list makes each path a button.
- Changed: Added +3Removed −1
- Added: Added +40
API reference
Commit
| Prop | Type | Default | Description |
|---|---|---|---|
files | CommitFile[] | [] | What it changed. |
All other Collapsible.Root props are forwarded.
CommitHeader
| Prop | Type | Default | Description |
|---|---|---|---|
message | ReactNode | required | The subject line. |
author | string | ||
avatar | string | A picture of the author. | |
time | ReactNode | When it was made, like a Timestamp. | |
children | ReactNode | Actions at the header's end. |
CommitHash
| Prop | Type | Default | Description |
|---|---|---|---|
hash | string | required | The full hash, which is what's copied. |
length | number | 7 | How much of it to show. |
tooltip | string | "Copy hash" |
CommitFile
| Field | Type | Default | Description |
|---|---|---|---|
path | string | required | |
status | "added" | "modified" | "removed" | "modified" | |
additions, deletions | number | Lines added and removed. |
CommitFiles takes onOpenFile: (file: CommitFile) => void.