Skip to content
Focsd homeFocsd homeFocsd
Forms

File changes

The files an agent changed, with status, line counts and a change bar; pick one to review it.

  • Tag: focsd-file-changes
  • Pattern: List of buttons (arrow keys)
  • Category: AI

Example

HTML
<focsd-file-changes
selected="src/lib/runs.ts"
style="max-inline-size: 34rem"
files='[{"path":"src/lib/runs.ts","status":"modified","additions":24,"deletions":9},{"path":"src/app/runs/page.tsx","status":"modified","additions":4,"deletions":2},{"path":"src/app/runs/load-more.tsx","status":"added","additions":36,"deletions":0},{"path":"src/app/api/projects/[projectId]/runs/route.ts","status":"added","additions":11,"deletions":0},{"path":"src/app/runs/run-row.tsx","status":"renamed","additions":1,"deletions":0},{"path":"src/lib/legacy-runs-cache.ts","status":"deleted","additions":0,"deletions":12}]'></focsd-file-changes>

Usage

Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.

<script type="module">
import '@focsd-dev/ai';
</script>
<focsd-file-changes selected="src/lib/runs.ts" files='[{"path":"src/lib/runs.ts","status":"modified","additions":24,"deletions":9},{"path":"src/app/runs/page.tsx","status":"modified","additions":4,"deletions":2},{"path":"src/app/runs/load-more.tsx","status":"added","additions":36,"deletions":0},{"path":"src/app/api/projects/[projectId]/runs/route.ts","status":"added","additions":11,"deletions":0},{"path":"src/app/runs/run-row.tsx","status":"renamed","additions":1,"deletions":0},{"path":"src/lib/legacy-runs-cache.ts","status":"deleted","additions":0,"deletions":12}]'></focsd-file-changes>

API

Attributes

AttributePropertyTypeDefault
filesfilesFileChange[][]
selectedselectedstring—
headingheadingstring—

CSS parts

Style the inside of the component with ::part(), for example focsd-file-changes::part(header).

PartDescription
headerThe title and totals row.
titleThe title.
countThe number of files.
totalsThe total added and removed lines.
listThe list of files.
fileA file's button; also `selected` on the chosen one.
statusA file's status letter.
pathA file's path; `dir` is the folders, `name` the file name.
addedA count of added lines.
deletedA count of removed lines.
barA file's change bar; `block`, `block-added`, `block-deleted` are its squares.

Accessibility

  • Each file is a button named in full ("src/lib/runs.ts, modified, 24 lines added, 9 removed"); the status letter, colors, counts and bar are hidden from assistive technology, so nothing depends on color.
  • The chosen file has aria-current="true". One file is in the tab order (the chosen one, or the first); arrow keys move between files.
  • Long paths are cut at the start, so the file name stays visible; the full path is in the name.
  • Choosing a file fires focsd-file-select with detail: { path, file }.

Keyboard

KeyAction
Up / DownPrevious / next file
Home / EndFirst / last file
Enter / SpaceChoose the file