Agent-Facing UI: A Stable Contract and an Approval That Means Something
A screen that shows an AI agent should depend on the agent's event contract rather than its prompts, and approvals must be enforced by the host, not the page.
A team adds accessibility after launch, and the audit comes back with a familiar list: inputs without labels, a modal you can tab straight out of, error text no screen reader announces. The odd part is not the length of the list. It is that the same handful of faults repeats on screen after screen, because every screen rebuilt the same widgets by hand.
The book's argument for accessibility is an argument about placement. The UI layer has its own gradient of change, from rarely touched building blocks at the bottom to pages that are rewritten constantly at the top. Accessibility is cheapest at the calm end, in the shared components that every feature is assembled from. If the button, the modal and the data table behave correctly, everything built on them behaves correctly too, and the book names WCAG 2.2 level AA as the target.
Think about what the alternative costs. Ten features each hand-roll a confirmation dialog, so you need ten audits, ten fixes, and a way to stop an eleventh from regressing. One well-built dialog needs one audit, and the features can only get it wrong by refusing to use it.
Take the dialog, the component that fails most often. A trustworthy one needs a short contract, none of which is specific to LVD:
Write that down once, build it once, and let feature code treat it as a black box.
Testing is where the placement argument pays off a second time. The book recommends locating elements as a person would, through their role and the name shown on them, and checking outcomes a person could observe. That has a bonus: a test that asks for a button called "Change delivery address" fails the moment the button loses its name, so the test suite doubles as an accessibility check.
it("returns focus to the trigger when the dialog is dismissed", async () => {
render(<AddressSettings />);
const trigger = screen.getByRole("button", { name: "Change delivery address" });
await userEvent.click(trigger);
expect(screen.getByRole("dialog", { name: "Delivery address" })).toBeVisible();
await userEvent.keyboard("{Escape}");
expect(trigger).toHaveFocus();
});
Nothing in the test mentions a CSS class, a component's internal structure or a test identifier. You can restyle the dialog, swap its internals or move it to a new library, and the test still means the same thing. If it fails, a real user would have noticed too.
Put this test next to the shared dialog and not inside any feature. It then runs once, covers every dialog in the product, and fails in one obvious place. Feature tests can stay focused on what the feature does, trusting the building blocks beneath them.
A caveat from ordinary practice, not from the book: automated checks catch only a fraction of accessibility problems. A script can tell you a label is missing, but it cannot tell you whether the reading order makes sense or whether a screen reader user can complete checkout. Pair role-based tests with occasional manual passes, by keyboard alone and with a screen reader, and treat the shared components as the place where the findings get fixed permanently.
Accessibility is a placement decision before it is a compliance exercise. Build the behaviour once in the layer's calm bottom, query by role so the tests notice when it breaks, and let every feature inherit the result. For the testing strategy around the UI, read layer-specific testing for the upper layers, and for how the code surrounding those components should behave, thin components and honest state.