useChat DX cleanup
@baleybots/react useChat dropped its old server-mode options and useGroupChat — removed, not deprecated behind flags. Today useChat is an adapter over AI SDK's useChat: it returns AI SDK UIMessages as messages, runs the bot in the browser by default, and talks to a createChatRoute server when given api and sessionId. See React Hooks.
What was removed
| Removed | Replacement |
|---|---|
useGroupChat | useChat for one bot; hosted crew UI uses /api/chat + useCrewSessions |
apiUrl, chatId, multiAgent, agents | useChat with model + optional storage, or api + sessionId for a createChatRoute server; hosted crew chat via product /api/chat |
loadHistory, isResuming | History via storage on client; server persistence in your route handler |
pendingApproval, approveToolCall, rejectToolCall | pendingApprovals + respondToToolApprovals (batch) |
SendStreamingOptions | Plain send(text) |
segments, sendStreaming | messages (AI SDK UIMessage[]) + ChatTurns / ChatTurn, and send |
Migration
From useGroupChat / server-mode useChat
// Before — removed
import { useGroupChat } from '@baleybots/react';
const { messages, sendMessage } = useGroupChat({
apiUrl: 'https://your-api.com/chat',
chatId: 'conversation-123',
});
// After — client-side chat in the browser
import { useChat, ChatTurns, ChatTurn } from '@baleybots/react';
import { openai } from '@baleybots/core';
const { messages, send } = useChat({
model: openai('gpt-5.6-luna'),
systemPrompt: 'You are a helpful assistant',
});
// Render
<ChatTurns messages={messages}>
{(message) => <ChatTurn key={message.id} message={message} />}
</ChatTurns>
For multi-agent crew chat in the Baleybots product UI, connect to the host /api/chat endpoint and consume SSE with useCrewSessions — do not point useChat at a backend URL.
For your own server with tools, use createChatRoute from @baleybots/proxy-server (session HistoryStorage, streamed as an AI SDK UI message stream) and point useChat({ api, sessionId }) at it, or createBotRoute for a single-shot Processable. See Chat with Tools.
From hand-rolled message lists to ChatTurns
// Before
{messages.map((msg) => (
<div key={msg.id}>
<b>{msg.role}:</b> {msg.content}
</div>
))}
// After
import { useChat, ChatTurns, ChatTurn } from '@baleybots/react';
const { messages } = useChat({ model: 'openai|gpt-5.6-luna' });
<ChatTurns messages={messages}>
{(message) => <ChatTurn key={message.id} message={message} />}
</ChatTurns>
From scalar approvals to batch approvals
// Before — removed
const { pendingApproval, approveToolCall, rejectToolCall } = useChat({ tools });
// After
const { pendingApprovals, respondToToolApprovals } = useChat({ tools });
if (pendingApprovals.length > 0) {
respondToToolApprovals(
pendingApprovals.map((p) => ({ approvalId: p.approvalId, approved: true })),
);
}
Submit exactly one decision per entry in pendingApprovals before the turn resumes.
Legacy UIChatMessage[] consumers
If another hook or analytics layer still needs OpenAI-shaped rows:
import { deriveUIMessages } from '@baleybots/core';
const messages = deriveUIMessages(history.getSegments()); // a core `History`
Key differences (summary)
| Old pattern | New pattern |
|---|---|
useGroupChat + apiUrl | Client useChat or host /api/chat |
messages.map(...) over { role, content } | ChatTurns + ChatTurn over UIMessages |
sendMessage | send |
pendingApproval / approveToolCall() | pendingApprovals / respondToToolApprovals([...]) |
multiAgent + agents | Crew UI / orchestration layer (out of scope for useChat) |