PAIPAI

React UI

Chat, composer, thread list, and tool cards.

The React chat tutorial is the first UI. This page is the map. Working pages cover the branches.

You are buildingPage
Transcript, composer, stop, thread listChat
Tool cards, pending approvalsTool UI
<Pai.Provider client={paiClient}>
  <Assistant.ThreadProvider threadId={threadId}>
    <Chat />
  </Assistant.ThreadProvider>
</Pai.Provider>

Pai.Provider holds the app client. ThreadProvider opens one thread and keeps it live.

Hooks on the binding

A chat page uses these three:

HookRe-renders whenUse for
useChat()The thread movesMessages, stop
useComposer()The draft changesThe text box
useThreads()The thread list changesThe sidebar

Do not read the draft from useChat(). That would re-render the transcript on every keystroke.

Also on Pai.agent("main"): useThread(), useClient(), useClientTool(), useFileUrl(), useSubagent(), Tool. Full list: @pai/react.

Next

On this page