affectUI › Components › Agents

Decision Table

An agent deciding by a DMN decision table – the request on top with its values, the rules below with inputs and outputs on either side of a quiet divider and the hit policy in the corner. When a request comes in, the agent checks the rules row by row: every cell ticks or crosses, the value being checked lights up in the request, rules that fail fade back, and the rule that matches lights up with its outputs – what it decides and where the request goes next. Click a rule for every condition against the request.

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

When to use

  • An agent that decides by business rules – refunds, approvals, routing, pricing – and should show exactly why
  • Making a policy auditable: every condition is visible, and every decision points at the rule that made it
  • Next to a process diagram (Handoff Swimlanes) as the decision behind one of its diamonds – the DMN partner of BPMN

When not to use

  • A branching path the agent took step by step – use Decision Tree
  • A single decision a person has to make – use Decision Card or Approval Card
  • Routing traffic between models – use Model Router

Usage

import { DecisionTable, type DecisionInput, type DecisionOutput, type DecisionRule } from "@/components/ui/decision-table";

const inputs: DecisionInput[] = [
  { id: "amount", label: "Amount", type: "number", format: (v) => `$${v}` },
  { id: "tier", label: "Tier", type: "string" },
  { id: "days", label: "Days", type: "number" },
];
const outputs: DecisionOutput[] = [{ id: "decision", label: "Decision" }];

const rules: DecisionRule[] = [
  { id: "r1", when: { amount: "> 500" }, then: { decision: { text: "Review", tone: "warn" } } },
  { id: "r2", when: { tier: '"Gold", "Platinum"', days: "<= 60" }, then: { decision: { text: "Approve", tone: "ok" } } },
  { id: "r3", when: {}, then: { decision: { text: "Reject", tone: "bad" } }, note: "Anything else" },
];

export function Refunds({ request }) {
  return <DecisionTable name="Refund approval" hitPolicy="F" inputs={inputs} outputs={outputs} rules={rules} request={request} />;
}

Props

NameTypeDefaultDescription
namestringThe decision's name, in the head
inputsDecisionInput[]The input columns – { id, label, type?, format?, width? }. format turns a request's value into its chip text; width is the column's weight against the others (default 1)
outputsDecisionOutput[]The output columns, right of a quiet divider (where DMN draws its double rule) – { id, label, width? }
rulesDecisionRule[]One row per rule – { id, when, then, note? }. when maps input ids to DMN conditions (a missing one is "-", anything); then maps output ids to text or { text, tone?, logo? } – tone ok, warn, bad or info makes a badge
hitPolicy"U" | "F" | "P" | "A" | "C"Unique, First, Priority, Any or Collect – shown in the corner. F stops at the first rule that matches; the others check every rule and show each match. Default F
requestDecisionRequestThe request being decided – { id, name, photo?, source?, detail?, values }. A new id starts the check
agent{ id, name }The agent that decides – its pixel mark twinkles while it checks
versionstringA small tag beside the name – "v3"
historyDecisionRequest[]Earlier requests as faces in the foot – with onPick, a click checks one again
onPick(requestId: string) => voidCalled when a face in the foot is clicked
onDecide(ruleIds: string[]) => voidCalled once a check is finished, with the rules that matched
pacenumberMilliseconds per rule while checking – default 420
classNamestringExtra class on the root – set the color variables on it, e.g. --ui-dmn-blue

Keyboard

  • Tab: One stop for the rules, then the faces in the foot
  • ↑ / ↓: The rule before or after
  • Home / End: The first or the last rule
  • Enter / Space: Opens the rule's card – every condition against the request; Esc closes it

Accessibility

  • The rules are a table with column headers; each rule reads its number and whether it matched
  • Every checked cell reads true, false or unknown; the rule's card lists each condition with the request's value
  • A polite live region says which rule is being checked and which one matched
  • Focus rings show for the keyboard only (:focus-visible)

Responsive

  • Below 800px the notes column steps aside – each rule's card still shows its note
  • Narrow: the request's chips wrap under the person, and the table scrolls sideways inside its frame
  • Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"

Requirements

  • React 19

Related

  • Decision Tree – An agent stuck on a decision lays out its options as a tree – the consequences of each branch, the risky ones marked, its own pick highlighted – and you choose a path or write your own
  • Handoff Swimlanes – Who does what in an agent run, and where the work changes hands – a process diagram with a lane for you, every agent and every tool. Each task is a box in the lane of whoever does it, a handoff an arrow to the next one, an approval a diamond; done boxes are quiet, the running one shimmers in its agent's color, waiting is amber, failed is red, and a light runs along every handoff that's happening now. Click a box, a diamond or a lane and its card opens – an approval waiting for you can be approved right there
  • Approval Card – An agent asks before it acts – risk badge, preview, Approve and Deny with shortcuts, a pausing countdown, and a smooth morph into a resolved row
  • Model Router – How a gateway splits its traffic across AI models – requests run as streaks of light from the gateway into each model's line, the line as wide as its share. The blended cost per 1K tokens on top and how it compares to what's live; pick Cost, Balanced or Quality and the split changes, the lines widen and narrow and the numbers roll. Every route below with share, p95 latency and price, a fallback to retry on another model, and Deploy