The files an agent's turn changed, as a card with each file's stat and Review.
- 16.1 kB JS 5.8 kB CSS gzipped
- No serious axe issues
- Server-rendered, hydrates
- 44px touch targets
- Right-to-left
Edited 6 files
Nothing opened yet.
import { UiSchema } from "effect/ui"import { Html } from "effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { type ChangedFileStat, ChangeSummary } from "./ui/uicontext/components/ChangeSummary.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, font, space } from "./ui/uicontext/components/tokens.stylex.ts"const files: ReadonlyArray<ChangedFileStat> = [ { path: "app/src/api/reports.ts", additions: 126, deletions: 43 }, { path: "app/src/pages/reports/index.tsx", additions: 184, deletions: 76, unseen: true }, { path: "app/src/pages/reports/EmptyState.tsx", additions: 38, deletions: 0, status: "added" }, { path: "app/src/hooks/useReport.ts", additions: 22, deletions: 9 }, { path: "app/src/pages/reports/Chart.tsx", additions: 11, deletions: 14 }, { path: "app/src/legacy/reportsV1.ts", additions: 0, deletions: 141, status: "removed" },]const Message = UiSchema.TaggedEnum({ ReviewedChanges: {}, OpenedChangesFile: { path: Schema.String } })const styles = stylex.create({ frame: { display: "grid", gap: space.md, inlineSize: "min(100%, 34rem)" }, said: { margin: 0, fontSize: font.sm, color: color.muted },})export const TurnChanges = Html.component({ name: "TurnChanges", model: Schema.Struct({ said: Schema.String }), message: Message,}).make({ init: () => ({ said: "Nothing opened yet." }), update: { ReviewedChanges: ($) => $.evolve({ said: "Opened the whole change for review." }), OpenedChangesFile: ($, { path }) => $.evolve({ said: `Opened ${path}.` }), }, view: (h, model) => h.div.attrs(sx(styles.frame)).children( ChangeSummary(h, { props: { id: "turn-4", files }, onEmit: { RequestedReview: () => Message.ReviewedChanges(), RequestedOpen: ({ path }) => Message.OpenedChangesFile({ path }) }, }), h.p.attrs({ role: "status", ...sx(styles.said) }).children(model.said), ),})When to use
The files an agent's turn changed, as a card with each file's stat and Review. Use Diff instead when people read the change line by line.
Usage
import { type ChangedFileStat, ChangeSummary } from "./ui/uicontext/components/ChangeSummary.ts"const Message = UiSchema.TaggedEnum({ ReviewedTurn: {}, OpenedTurnFile: { path: Schema.String } })// at the end of a turn: Review opens the whole change, a file opens its own diffexport const TurnChanges = (h: Html.H<typeof Message.Type>, turn: string, files: ReadonlyArray<ChangedFileStat>) => ChangeSummary(h, { key: turn, props: { id: turn, files }, onEmit: { RequestedReview: () => Message.ReviewedTurn(), RequestedOpen: ({ path }) => Message.OpenedTurnFile({ path }) }, })API reference
Props
| Name | Type | Default | Description |
|---|---|---|---|
idrequired | string | — | — |
filesrequired | ChangedFileStat[] | — | — |
limit | number | 3 | Files shown before "+N more"; 3 by default |
reviewLabel | string | "Review" | "Review" by default; leave can without "review" for no button |
can | ("review" | "open")[] | — | "review" shows the button; "open" makes each file a button |
agentId | string | — | — |
locale | string | — | — |
Events
| Event | Payload | Description |
|---|---|---|
RequestedReview | { id: string } | Review the whole change |
RequestedOpen | { id: string; path: string } | Open one file's change |
Agent actions
| Action | Description |
|---|---|
ClickedReview | Review the whole change |
ClickedFile | Open one file's change, by its path |
Keyboard and accessibility
- The card is a section named by its heading, "Edited 6 files"; Review and each file are real buttons.
- +N more is a button with
aria-expanded. A new or deleted file says so in words.
Installation
pnpm dlx shadcn@latest add checkfu/uicontext/changed-files