affectUI › Components › Agents
Extraction Review
Checking what an agent pulled out of documents – every field shows where it came from, and a wrong lookup becomes a failure case the agent learns from.
Part of affectUI Pro. Install: npx shadcn@latest add https://www.affectui.com/r/extraction-review.json · Import from @/components/ui/extraction-review
When to use
- Letting people check what an agent pulled out of emails, chats or contracts before it goes anywhere
- Showing where every value came from – the words in the input, or the system the agent looked it up in and the call it made
- Turning a wrong value into a failure case with a lesson, so the agent doesn't make the same mistake twice
When not to use
- Only showing the extraction, without checking it – use Source Map
- Approving an agent's actions before they run – use Approval Gates
- Scoring a model against a test set – use an eval view
Usage
import { ExtractionReview, type ReviewDoc, type FailureCase } from "@/components/ui/extraction-review";
const docs: ReviewDoc[] = [
{
id: "order",
short: "Broken lamp",
source: { name: "Intercom", logo: <IntercomLogo /> },
title: "My order arrived broken",
text: "Hey, my order #48213 arrived today and the glass lamp is cracked. I'd like my money back.",
fields: [
{ id: "order", label: "order_id", type: "string", value: "48213", quote: "#48213" },
{ id: "refund", label: "wants_refund", type: "boolean", value: "true", quote: "I'd like my money back" },
// Not in the text – looked up by the agent
{ id: "total", label: "order_total", type: "number", value: "189.00",
from: { source: "Orders", logo: <OrdersLogo />, call: 'orders.get("48213")', record: "Order #48213 · $189.00" } },
],
},
];
export function Review() {
return (
<ExtractionReview
docs={docs}
model={{ id: "field-extractor", name: "Field extractor" }}
onSaveCase={(c) => saveToAgentMemory(c)}
/>
);
}Props
| Name | Type | Default | Description |
|---|---|---|---|
docs | ReviewDoc[] | Source Map's documents – { id, title, text, fields, source?, meta?, short? }; short names the tab | |
docs[].fields[].from | FieldOrigin | { source, logo?, call?, record? } – where the agent looked a value up that isn't in the text | |
model | { id, name, subtitle? } | The agent that reads them – its pixel mark comes from id | |
cases | FailureCase[] | { id, field, source, wrong, right?, reason, lesson, logo?, avoided? } – failure cases saved before | |
reasons | { label, lesson(field, source) }[] | What can go wrong – Wrong record, Out of date and Misread by default | |
onSaveCase | (case, doc) => void | Called when a failure case is saved – send it to the agent's memory | |
initialDoc | string | The document open at first – the first by default | |
initialField | string | The field open at first – by default the selection follows the fields as they fill | |
className | string | An extra class on the root |
Accessibility
- The documents are buttons in a list, the open one marked as current
- Each field is a pressed-state button named with its value and where it came from; the card beside it is announced as it changes
- Mark as wrong opens a form with a labelled input and the reasons as a radio group; Escape closes it and focus goes back to Mark as wrong; once saved, back to the field in the map
- The failure cases are a list you can reach with Tab and scroll; each row's lesson is in its title
- A focus ring shows only for the keyboard – the right-value input only firms up its edge
Responsive
- Fills its container's width; below 1060px the card moves under the map and the line steps aside, below 640px Source Map stacks too
- The tabs stay centred and scroll sideways when they don't fit
- The failure cases scroll inside their card, so the component keeps its height as more are saved; below 480px only the count stays beside each – "6×" – and the wrong value gives way first
- Long keys, values and calls end in … and show in full on hover
- The classic style turns the cards into soft gray trays with white cards on them, with pill-shaped tabs, tags and buttons and firmer type – the same behavior as the clean one
- Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
Requirements
- React 19
- Source Map (installs with it)
Related
- Source Map – What a model pulled out of a document, with a line from every typed field to the words it came from – and "Not in input" where it would otherwise have to guess
- Approval Gates – The approval requests of an agent run as a stack of cards – the one to decide now on top with the diff or arguments, approve, reject or change it, then the next rises
- Decision Loop – How an AI decision becomes an action – the event, the model's typed choice and score, plain-code rules that tick or cross, then the action or a person, and back to learn