Skip to content
Eskais UI

Git

Git Tree

A repository's files at a commit on UI SDK's Tree: folders first with lucide icons, changed files marked added, modified, deleted or renamed in their tone, folders that hold a change marked too. Virtualized for 100,000 files; agents open and expand by path.

Example

src, Has changes
billing, Has changes
proration.ts, Modified
plans.ts
legacy-rates.ts, Deleted
invoice, Has changes
pdf.ts, Renamed, from src/invoice/print.ts
fonts.ts
routes.ts, Added
index.ts
package.json
README.md
tsconfig.json

src/billing/proration.ts

Installation

npx shadcn@latest add @eskais/git-tree
npm packageslucide-react

Usage

Import
import { GitTree, gitTreeLabels } from "@/components/ui/git-tree"import { gitTree } from "@/components/ui/git-tree-primitive"import { gitStatusTones, indexGitFiles, parentsOf } from "@/lib/git-status"

Use it for a repository's files at a commit, with what changed marked.

API reference

GitTree

PropTypeDefault
aria-labelrequiredstring–
filesrequiredA path ending in `/` is an empty folder.readonly (string | GitTreeFile)[]–
expandedBy default the folders that hold a change start open.readonly string[]–
defaultExpandedreadonly string[]–
onExpandedChangeGitTreeOptions["onExpandedChange"]–
currentThe file shown elsewhere, like the one a diff is open on.string | null–
onOpenFileGitTreeOptions["onOpenFile"]–
labelsPartial<GitTreeLabels>–
estimateSizeA row's height in px before it is measured. @defaultValue 32number32
findableFind in page reaches rows scrolled out of view, once the page is idle after its first paint. Off by default: on 100,000 files it costs up to a frame on some held-arrow presses (p95 about 16 ms against 10 ms).booleanfalse

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

Other exports

gitTreeLabelsgitTreegitStatusTonesindexGitFilesparentsOftype GitTreeLabelstype GitTreePropstype GitTreeChangeReasontype GitTreeLookuptype GitTreeOptionstype GitFileStatustype GitTreeFiletype GitTreeIndex

Accessibility

  • UI SDK's tree pattern: arrows, typeahead, Left and Right to fold, Enter to open a file.
  • A changed file's status is part of its name, not only its colour or letter.

Agent actions

Agents open, expand and collapse by path; the files are listed for query().

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