File changes
The files an agent changed, with status, line counts and a change bar; pick one to review it.
Example
<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>import { useEffect, useRef } from 'react';import '@focsd-dev/ai';
export function Example() { const ref = useRef(null); return <focsd-file-changes ref={ref} 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>;}<script setup>import '@focsd-dev/ai';</script>
<template> <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></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/ai';
// template<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><script> 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
| Attribute | Property | Type | Default |
|---|---|---|---|
files | files | FileChange[] | [] |
selected | selected | string | — |
heading | heading | string | — |
CSS parts
Style the inside of the component with ::part(), for example focsd-file-changes::part(header).
| Part | Description |
|---|---|
header | The title and totals row. |
title | The title. |
count | The number of files. |
totals | The total added and removed lines. |
list | The list of files. |
file | A file's button; also `selected` on the chosen one. |
status | A file's status letter. |
path | A file's path; `dir` is the folders, `name` the file name. |
added | A count of added lines. |
deleted | A count of removed lines. |
bar | A 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-selectwithdetail: { path, file }.
Keyboard
| Key | Action |
|---|---|
| Up / Down | Previous / next file |
| Home / End | First / last file |
| Enter / Space | Choose the file |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.