CoUI.ai

Principles

Six design principles and three naming principles, each with an example.

The state has two writers

UI = f(state) stays; only who can write the state changes. A filter can be changed by the person dragging a slider or by the agent, and the component does not tell them apart.

The agent sees what the person sees

Only what is mounted is in the context. With the cart drawer closed, the agent has no checkout.

The person's value is on top

The agent always writes its own layer and can never cover what the person wrote. Once the person sets the price limit to $100, an agent's change only waits for approval.

Hand over only what is uncertain

What can be computed stays in code: do not turn every useState into useCoState. The filter is a CoState; the filtered list is a plain derived value.

Each hook mirrors a React hook

The same signature, plus a key or a description, and no deps array. Without its third return value, useCoState reads like useState.

The output is plain data, not a protocol

A context as text and three fixed JSON Schema tools: any agent with function calling can take them. The AI SDK integration is about ten lines.

Naming

  1. As few concepts as possible. One word, one meaning: CoApproval is used for both a state and a callback.
  2. As few invented words as possible. Prefer what React and agent developers already know: reducer, version.
  3. Borrowed words keep their meaning. needsApproval, approve and reject are what TanStack AI, the OpenAI Agents SDK and the AI SDK call them. React's pending means "still running", so CoUI does not use it for "waiting for approval".