Skip to content
Eskais UI

Git

Commit History

A commit trail, one line per commit: a graph lane down the side, merges collapsed to one row that open their branch on a curved side lane, a pending commit that spins until it lands, and a commit's details inline under its row. Virtualized for 50,000+ commits; agents read and act on commits by name.

Example

9 commits
Retry failed webhooks in queue.ts, Committing
Bump version in package.json, 26 minutes ago, Release
Fix rounding in proration.ts, 44 minutes ago, Fix
Create the billing service, 2 hours ago

Installation

npx shadcn@latest add @eskais/commit-history

Usage

Import
import { CommitHistory, commitHistoryLabels, WORKING_TREE } from "@/components/ui/commit-history"import {  BranchCounts,  BranchPill,  branchName,  CommitRow,  commitHistoryLabels,  commitName,  hashOf,  lineIndent,  selectedLine,} from "@/components/ui/commit-history-row"import { commitHistory, createCommitHistoryController, WORKING_TREE } from "@/components/ui/commit-history-primitive"import { CommitGraphCell, graphColumns, laneColor } from "@/components/ui/commit-graph-cell"import {  useBranchModel,  useCommitGraph,  useCommitTrail,  useFocusHead,  useJustExpanded,  useReachEnd,} from "@/components/ui/use-commit-history"import { doneCount, entriesOf, Rows, summaryOf, treeItemsOf, unpushedCount } from "@/components/ui/commit-history-rows"import { CommitBranchSelect } from "@/components/ui/commit-branch-select"import { commitHistoryLabels, formatCount } from "@/components/ui/commit-history-labels"import { CommitHistoryHeader } from "@/components/ui/commit-history-header"import { WorkingTreeRow, workingTreeText } from "@/components/ui/commit-working-tree-row"

Use it for a branch's history: one line per commit, merges folded until opened, details inline. Give it a bounded height.

API reference

CommitHistory

PropTypeDefault
aria-labelrequiredstring–
commitsrequiredNewest first, children before parents: the order of `git log --topo-order`.readonly Commit[]–
branchThe base branch; with `branches` and `onBranchChange`, a switcher chooses it.string–
branchesBranch names for the switcher, or branches with their head (`{ name, head, tone?, ahead?, behind?, updatedAt?, author? }`), which the branches view draws.readonly (string | CommitBranch)[]–
onBranchChangeCommitHistoryOptions["onBranchChange"]–
countThe count in the header; the finished commits loaded by default. Pass the server's total when paging.number–
expandedMerges whose merged commits show, by id. Collapsed by default: one line per commit.readonly string[]–
defaultExpandedreadonly string[]–
onExpandedChangeCommitHistoryOptions["onExpandedChange"]–
selectedThe selected commit's id, for a list beside a detail pane; `null` for none. Passing `selected`, `defaultSelected` or `onSelect` turns selection on: a press, Enter or Space selects a row (`aria-selected`), and a press or Enter on the row already selected opens its details, or its merged commits on a merge.string | null–
defaultSelectedstring | null–
onSelectCommitHistoryOptions["onSelectedChange"]–
detailsCommits whose details show under their row.readonly string[]–
defaultDetailsreadonly string[]–
onDetailsChangeCommitHistoryOptions["onDetailsChange"]–
detailsMode`"single"` (default) keeps one commit's details open at a time."single" | "multiple"–
focusModeDims the rows other than the focused, hovered or open one. On while details are open by default.boolean–
onOpenCommitClick or Enter on a commit runs this instead of showing its details, for apps that navigate to a commit.(commit: Commit, details: ChangeDetails<CommitHistoryChangeReason>) => void–
onCopyHashCommitHistoryOptions["onCopyHash"]–
hasMoreOlder commits exist: a Load more button, and `onLoadMore` once the end scrolls into view.booleanfalse
loadingMorebooleanfalse
onLoadMore() => unknown–
nowOne clock for every time in the list; a 30-second `useNow` by default.Instant–
localestring–
timeZonestring–
labelsPartial<CommitHistoryLabels>–
estimateSizeA row's estimated height in px before it is measured. Default 30.number30
findableFind in page reaches commits scrolled out of view, by subject, through UI SDK's virtualizer and its findable layers, built once the page is idle after its first paint. Off by default: on 50,000 commits it costs about a frame on some held-arrow presses (p95 22-27 ms against 10 ms) and 10-40% on the first paint.booleanfalse
maxLanesLanes the graph opens at most; an octopus merge's extra parents past it draw no lane. Default 12.number–
controllerCommitHistoryController–
actionsContent at the end of the header, before the count.ReactNode–
headerStartContent at the start of the header, before the branch switcher: a repository picker, say.ReactNode–
workingTreeA dirty checkout: a row above the newest commit with the staged and unstaged counts, a hollow dashed node, and `labels.workingTree` or `label` as its name. It takes focus and selection like a commit, as `WORKING_TREE`.WorkingTree–
upstreamHeadThe upstream's head (`git rev-parse @{u}`): the commits above it aren't pushed yet. Each gets a cloud mark and "not pushed" in its name, and the header counts them. A commit's own `unpushed` marks it too.string–
view`"branches"` draws every active branch in `branches` as its own lane beside the base, coloured and labelled at its head, with a select (or a press on a pill) to show one alone; merged branches stay folded under their merge. Commits are then `git log --all --topo-order`. Default `"trail"`."trail" | "branches""trail"
focusedBranchThe branch in focus in the branches view: its head scrolled to and focused.string | null–
onFocusedBranchChangeCommitHistoryOptions["onFocusedBranchChange"]–
filterBranchIn the branches view, a branch in focus hides the other branches' commits.booleanfalse
staleAfterA branch with no update for this long, in ms, shows as stale. Default 30 days.number–

Also takes <div> attributes and render except children, onSelect.

BranchPill

PropTypeDefault
branchrequiredBranchInfo–
localestring–
focusedrequiredboolean–

BranchCounts

PropTypeDefault
aheadrequirednumber–
behindrequirednumber–
localestring–
spokenSays the counts in words for screen readers, where nothing around them already does.Pick<CommitHistoryLabels, "ahead" | "behind">–

Rows

PropTypeDefault
trailrequiredTrail–
detailsrequiredReadonlySet<string>–
justExpandedrequiredReadonlySet<string>–
contextrequiredCommitRowContext–
virtualrequiredOmit<ReturnType<typeof useTrailRows>, "setScroller" | "anchor">–
headsrequiredReadonlyMap<string, readonly BranchInfo[]> | undefined–
upstreamRowrequiredRows before this one aren't on the upstream; -1 when every commit's own `unpushed` decides.number–

CommitHistoryHeader

PropTypeDefault
labelsrequiredCommitHistoryLabels–
nowrequiredInstant | undefined–
localerequiredstring | undefined–
activeThe branches view's active branches: a select shows one alone.readonly BranchInfo[]–
focusedBranchrequiredstring | null–
onFocusBranchrequired(name: string | null) => void–
switcherBranch names for the switcher, when there's more than one and a handler.readonly string[]–
branchrequiredstring | undefined–
onBranchrequired(name: string) => void–
actionsReactNode–
startContent before the branch, like a repository picker.ReactNode–
totalrequirednumber–
unpushedCommits the upstream doesn't have yet.number0

Other exports

commitHistoryLabelsWORKING_TREEbranchNameCommitRowcommitNamehashOflineIndentselectedLinecommitHistorycreateCommitHistoryControllerCommitGraphCellgraphColumnslaneColoruseBranchModeluseCommitGraphuseCommitTrailuseFocusHeaduseJustExpandeduseReachEnddoneCountentriesOfsummaryOftreeItemsOfunpushedCountCommitBranchSelectformatCountWorkingTreeRowworkingTreeTexttype CommitHistoryLabelstype CommitHistoryPropstype WorkingTreetype CommitRowContexttype CommitRowPropstype CommitBranchSummarytype CommitHistoryChangeReasontype CommitHistoryControllertype CommitHistoryOptionstype CommitLookuptype CommitLookupEntrytype CommitGraphCellPropstype CommitNodeKindtype RowsPropstype CommitBranchSelectPropstype CommitHistoryHeaderProps

Accessibility

  • A tree with one tab stop: arrows, Home/End and typeahead move; Right and Left open and close a merge; Enter opens a commit's details.
  • A workingTree row (uncommitted changes, staged and unstaged counts) comes first, in the same tab stop and selection as the commits, named in full.
  • A commit the upstream doesn't have (upstreamHead, or unpushed on the commit) carries a cloud mark and "not pushed" in its name; the header's count of them is read in words.
  • With selected or onSelect, a press, Enter or Space selects a row (aria-selected, and the nav-current fill, hairline and weight, so it never rests on colour); a press or Enter on the selected row opens its details.
  • Each row is named in full, like "Merge invoice-pdf into main, 38 minutes ago, Release"; the graph is decorative.
  • Dimmed rows use muted-foreground, which keeps 4.5:1; the spinner and every transition stop under reduced motion.
  • Find in page sees the rows in view; findable adds UI SDK's findable layers for the rest, at a cost to held arrow keys.
  • In the branches view each lane is named by its pill and in the branch select, never by colour alone.

Agent actions

Agents get select, expandDetails, collapseDetails, expand, collapse, copyHash (it returns the hash), openCommit and selectBranch, by id, hash or subject.

Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.