affectUI › Components › Agents

Case Model

An open case worked by agents and people as a CMMN case plan – stages, tasks that start once their entry criterion holds, optional tasks someone has to plan, milestones.

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

When to use

  • Agents working an open case rather than a fixed flow – insurance claims, support tickets, KYC checks, onboarding – where work starts as soon as what it needs is there
  • Showing why a task hasn't started yet: its diamond stays hollow and its card lists what it still waits for
  • Cases with people in the loop – approvals that wait for someone, optional tasks someone has to plan first

When not to use

  • A fixed order of steps, lane by lane – use Handoff Swimlanes
  • Steps that fire only when every input holds a token, with parallel branches joining – use Petri Net
  • Steps over time with their duration – use Trace Waterfall or Agent Timing

Usage

import { CaseModel, type CaseFile, type CaseItem, type CaseMilestone, type CaseStage, type CaseTask } from "@/components/ui/case-model";

const stages: CaseStage[] = [
  { id: "intake", label: "Intake" },
  { id: "settle", label: "Settlement" },
];

// The case file – the photos come in four seconds after the case opens
const items: CaseItem[] = [
  { id: "form", label: "Claim form" },
  { id: "photos", label: "Photos", at: 4000 },
];

const tasks: CaseTask[] = [
  { id: "read", stage: "intake", label: "Read the claim", kind: "agent", by: "Intake agent", entry: ["form"] },
  { id: "assess", stage: "intake", label: "Assess the damage", kind: "agent", by: "Vision agent", entry: ["read", "photos"] },
  { id: "approve", stage: "settle", label: "Approve the payout", kind: "person", by: "Mara Lindqvist", photo: "/mara.jpg", entry: ["assess"] },
];

const milestones: CaseMilestone[] = [{ id: "settled", stage: "settle", label: "Claim settled", entry: ["approve"] }];

export function Claim() {
  return <CaseModel name="Claim #4821" detail="Water damage" stages={stages} items={items} tasks={tasks} milestones={milestones} />;
}

Props

NameTypeDefaultDescription
casesCaseFile[]{ id, name, detail?, color?, stages, items?, tasks, milestones?, planned? } – several cases as folder tabs, overlapping a little – the open one in front in the folder's white, the others further back a step darker each; each tab's folder icon in its color on a light tint of it (default the palette in order); a click or the arrow keys open one: it comes forward, the open one steps back, the old case fades out as the new one fades in, its run starting fresh. Leave it out for one case given by the props below
defaultCasestringThe case open first – default the first
onCaseChange(caseId: string) => voidCalled when another case's tab is opened
namestringOne case: its name, on the folder's tab
detailstringOne case: a line about it – shown when you hover its tab
stagesCaseStage[]{ id, label } – side by side as very light gray, dashed areas, in order
itemsCaseItem[]{ id, label, at? } – the case file along the top: documents and data. at is when it comes in, in milliseconds after the case opens; until then it shows dashed with a clock
tasksCaseTask[]{ id, stage, label, kind, by, agentId?, color?, photo?, logo?, entry?, optional?, takes? } – gray trays with a white lower row, stacked in their stage. kind "agent" draws its pixel mark (from agentId, in color), "person" their photo and waits for approval, "tool" its logo. entry lists the items, tasks and milestones it waits for – all of them; optional makes it a dashed, discretionary task that runs only once planned; takes is how long it runs
milestonesCaseMilestone[]{ id, stage, label, entry? } – pills under the tasks of their stage, a check once everything in entry is done
plannedstring[]Optional tasks planned from the start
autoApprovebooleanA person's task approves itself after a moment, as if they'd decided – default true. Off, only Approve in its card does
loopbooleanOpen the case again once it's closed – default true
onApprove(taskId: string) => voidCalled when Approve is pressed in a person's task card
onPlan(taskId: string) => voidCalled when Plan task is pressed in an optional task's card
classNamestringExtra class on the root – set the color variables on it, e.g. --ui-csm-blue

Keyboard

  • Tab: The open case's tab, Pause and Restart, then each task and milestone in turn
  • ← / → / Home / End: On the tabs: opens the case before or after, the first or the last
  • Enter / Space: Opens its card below it – stage, when it started or how long it took, and everything it waits for, each ticked once there; Approve or Plan task where it applies. The focus moves into the card
  • Esc: Closes the card and puts the focus back on the task

Accessibility

  • Every task is a button that reads its name, who does it, its state and whether it's optional; milestones read whether they're reached
  • Several cases are a tablist – each tab says its case and whether it's open; only the open one sits in the tab order
  • The case file is a list – each document says whether it's in yet
  • A polite live region (not shown) says what just happened – a task started or done, a document in, a milestone reached
  • The run holds while a card is open; focus rings show for the keyboard only (:focus-visible)
  • Names in any script keep their own direction – the case plan and its cards read left to right, also in RTL

Responsive

  • The case sits right on the page – drawn at its own size and zoomed to the width (never larger), its info cards with it; below 62% it scrolls sideways, with a soft fade on the side that has more; an open card closes as you scroll
  • With many cases or a full case file the tabs shorten their names and the documents show as icons – the full name shows on hover
  • Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"

Requirements

  • React 19

Related

  • Petri Net – Agents working in parallel and waiting on each other, as a Petri net – tokens in places, steps that fire only when every input is ready, a person's step waiting for approval
  • Handoff Swimlanes – Who does what in an agent run, and where work changes hands – a lane per person, agent and tool, handoffs as arrows, approvals as diamonds you can approve in place
  • 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
  • Threat Model – Where an agent's data goes, as a data-flow diagram with trust boundaries – every flow says what it carries, and personal data leaving unredacted turns red with its fix