POLPOUI

ChatMessages

Virtualized, auto-scrolling message list powered by react-virtuoso.

ChatMessages renders the conversation as a virtualized list with automatic scroll-following during streaming. It includes a built-in ChatScrollButton and skeleton loading state. Must be rendered inside a ChatProvider.

Messages

Can you refactor the auth middleware?

2m ago
Coder

I'll refactor the auth middleware to use a cleaner pattern with early returns and proper error handling. Let me update the file.

Looks good, now add rate limiting

30s ago

Loading state

Import

import { ChatMessages, type ChatMessagesHandle, type ChatMessagesProps } from "@polpo-ai/chat";

Props

PropTypeDefaultDescription
renderItem(msg: ChatMessage, index: number, isLast: boolean, isStreaming: boolean) => ReactNodeplain text fallbackCustom renderer for each message
classNamestringExtra classes applied to the container
skeletonCountnumber3Number of skeleton pairs to show during initial load

Ref handle

The component exposes a ChatMessagesHandle via ref:

MethodSignatureDescription
scrollToBottom(behavior?: "smooth" | "auto") => voidProgrammatically scroll to the bottom

Usage

const messagesRef = useRef<ChatMessagesHandle>(null);

<ChatProvider agent="my-agent">
  <ChatMessages
    ref={messagesRef}
    renderItem={(msg, index, isLast, isStreaming) => (
      <ChatMessage
        msg={msg}
        isLast={isLast}
        isStreaming={isStreaming}
        avatar={<BotIcon />}
      />
    )}
  />
  <ChatInput />
</ChatProvider>

On this page