Skip to content
GitHub (opens in a new tab)

InlineDiff

Proposed text or code edits you accept or reject in place: unified, split or inline phrase diff, always with + / − marks and counts ("+2 −2", read as "2 added, 2 removed"), then one line.

stableOrganismcontracts/inlinediff.json

Preview

InlineDiff

Accept or reject a proposed edit in place. Not ApprovalCard. Not CodeSnippet.

Master

Accept (⌘/Ctrl+Enter) or Reject (Escape) and the card settles to one line.

Proposed edit · calcTotal

Pending
src/billing/invoice.ts@@ -41,2 +41,3 @@ calcTotal2 added, 1 removed
const subtotal = sumLines(lines);Removed: return subtotal * (1 + rate);Added: const total = subtotal * (1 + rate);Added: return Math.round(total * 100) / 100;
1 of 2 hunks

Usage

InlineDiff reviews one proposed edit. Changes always carry + / − marks and say Added / Removed to screen readers. Accept is the one solid primary.

Do's

  • an agent proposes an edit to a file or a paragraph
  • accept or reject hunks before they land
  • show that a proposal went stale

Don'ts

  • approving one command or whole action — ApprovalCard
  • read-only code — CodeSnippet
  • a review tool across many files — not in kit, ask
<InlineDiff
  title="Proposed edit · calcTotal"
  file="src/billing/invoice.ts"
  hunkHeader="@@ -41,2 +41,3 @@ calcTotal"
  lines={lines}
  hunkLabel="1 of 2 hunks"
  onAccept={accept}
  onReject={reject}
  onAcceptAll={acceptAll}
/>

When to use

  • an agent proposes an edit to a file or a paragraph
  • accept or reject hunks before they land
  • show that a proposal went stale

When not to use

  • approving one command or whole action — ApprovalCard
  • read-only code — CodeSnippet
  • a review tool across many files — not in kit, ask

What an agent reads

import { InlineDiff } from "agentic-ds-kit";
must
  • section aria-labelledby the h3 title
  • added and removed lines carry + / − marks and say Added / Removed to screen readers; the file header shows "+2 −2" and says the counts in words to screen readers, e.g. "2 added, 2 removed"
  • inline edits use del and ins
  • Escape rejects (not on another control) and ⌘/Ctrl+Enter accepts while focus is in the card; buttons carry aria-keyshortcuts; the Esc and ⌘⏎ key chips are aria-hidden and hidden on touch screens and below --grid-breakpoint-sm
  • stale disables the actions and says why
  • once resolved, focus moves to the one-line row
defaults
  • mode unified
  • status pending
stops if
  • Do not invent a local DiffView, PatchCard, or SuggestionCard
  • Never show a change by colour alone; keep the + / − marks
  • Accept is the one solid primary
  • Do not use raw hex

From contracts/inlinediff.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
titlestringYes——
modeunified | split | inlineNounified—
filestringNo——
hunkHeaderstringNo—e.g. "@@ -41,2 +41,3 @@ calcTotal".
linesarrayNo—{ type: "context" | "add" | "remove", text, oldNo?, newNo? }[] for unified and split.
segmentsarrayNo—{ type: "same" | "add" | "remove", text }[] for inline.
statusenumNopendingaccepted and rejected render one line. pending | accepted | rejected | stale | loading | error | empty
hunkLabelstringNo——
staleReasonstringNo——
errorMessagestringNo——
onRetryfunctionNo——
onAcceptfunctionNo—Accept, the one solid primary, with a ⌘⏎ key chip (hidden on touch screens and below --grid-breakpoint-sm). ⌘/Ctrl+Enter in the card.
onRejectfunctionNo—Reject (outline), first in the footer, with an Esc key chip. Escape in the card, not on another control.
onAcceptAllfunctionNo—Accept all (ghost), between Reject and Accept. Pass it only when the proposal has 2 or more hunks.
resolvedSummarystringNo——
resolvedAtstringNo——
  • Component
    →

    ApprovalCard

    The agent asks before it acts: risk, what will happen in words, an exact preview of the command or diff, and Approve (⌘/Ctrl+Enter) / Deny (Escape) with an optional auto-deny countdown.

  • Component
    →

    CodeSnippet

    Read-only block of code with a copy button, optional title, language label, tabs, and line numbers.

  • Component
    →

    Empty

    Placeholder when a list, page, or region has nothing to show.

  • Block
    →

    Change review

    Review an agent's change file by file, then accept or reject each file, or the rest at once.