Skip to content

Commit 75ccbcc

Browse files
piecykclaude
andcommitted
docs(examples): keep the chat opened while a send is in flight
The send selects its chat when it finishes, about 100 ms later. Opening another chat in that time was undone. Select the sent-to chat only when the selection has not changed since the send started. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 49293e6 commit 75ccbcc

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎examples/react/chat/src/main.tsx‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,13 @@ function App() {
6969
const onSend = (text: string) => {
7070
send(
7171
{ chatId: activeChatId, text },
72-
{ onSuccess: ({ chatId }) => setActiveChatId(chatId) },
72+
{
73+
// Keep a chat the user opened while the send was in flight.
74+
onSuccess: ({ chatId }) =>
75+
setActiveChatId((current) =>
76+
current === activeChatId ? chatId : current,
77+
),
78+
},
7379
)
7480
}
7581

0 commit comments

Comments
 (0)