affectUI › Components › Agents

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.

Part of affectUI Pro. Install: npx shadcn@latest add https://www.affectui.com/r/source-map.json · Import from @/components/ui/source-map

When to use

  • Showing what a model pulled out of an email, a chat or a contract, and where in the text each value stands
  • Extraction people have to trust – invoices, orders, contracts – where every value should point back to its words
  • Making "no guessing" visible: a field the text doesn't hold says Not in input instead of a made-up value

When not to use

  • Showing how a decision turns into an action, with rules in between – use Decision Loop
  • Sending requests to the agents that handle them – use Agent Router
  • Citing sources under an answer in a chat – use a citations or sources list

Usage

import { SourceMap, type SourceDoc } from "@/components/ui/source-map";

const docs: SourceDoc[] = [
  {
    id: "invoice",
    source: { name: "Gmail", logo: <GmailLogo /> },
    title: "Invoice INV-20418 – November retainer",
    meta: "billing@northwind.example · Nov 30",
    text: "Please find attached invoice INV-20418. The total due is $4,280.00, payable by December 15, 2026.",
    fields: [
      { id: "invoice", label: "invoice_no", type: "string", value: "INV-20418", quote: "invoice INV-20418" },
      { id: "amount", label: "amount", type: "number", value: 4280, quote: "$4,280.00" },
      { id: "due", label: "due_date", type: "date", value: "2026-12-15", quote: "December 15, 2026" },
      { id: "po", label: "po_number", type: "string" }, // no quote → Not in input
    ],
  },
];

export function Extraction() {
  return <SourceMap docs={docs} model={{ id: "field-extractor", name: "Field extractor" }} />;
}

Props

NameTypeDefaultDescription
docsSourceDoc[]{ id, title, text, fields, source?, meta? } – shown one after another
docs[].fieldsSourceField[]{ id, label, type, value?, quote? } – a quote that isn't in the text, or none, shows Not in input
model{ id, name, subtitle? }The model that reads them – its pixel mark comes from id
autoPlaybooleanFills the fields and moves on to the next document by itself – on by default; reduced motion shows them all
classNamestringAn extra class on the root

Accessibility

  • Each field is a button named with its key and value – "due_date: 2026-12-15" – or "not in input"
  • Focusing a field lights its words and its line like pointing at it, and a long text scrolls them into view
  • A long document's text is a scroll area of its own you can reach with Tab
  • Pause stops the loop; paused, Previous and Next step through the documents
  • Once a document is read it's announced – "Invoice INV-20418: 5 of 6 fields found in the input"
  • A focus ring shows only for the keyboard

Responsive

  • Fills its container's width; below 640px the cards stack and the lines step aside – the colours still pair words and fields
  • A long document scrolls inside its card, with a soft fade where more waits below; in a narrow card the type steps aside so the value keeps its room
  • Long names, keys and values end in … and show in full on hover
  • Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"

Requirements

  • React 19

Related

  • 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
  • Agent Router – A router agent sorting incoming requests to the agents that handle them – a light runs to the chosen agent with a confidence, and unsure requests go to a person
  • Decision Table – An agent deciding by a DMN decision table – the request on top, rules below checked row by row until the matching rule lights up with its outputs