Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## vNEXT (not yet published)

### `@liveblocks/client`

- Fix race condition where AI tools were not always executing. This could happen
when using `useSendAiMessage` first and then immediately opening the
`<AiChat />` afterwards.

## v3.3.1

### `@liveblocks/react-ui`
Expand Down
9 changes: 7 additions & 2 deletions packages/liveblocks-core/src/ai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,12 @@ function createStore_forChatMessages(
}
}
} else {
myMessages.delete(message.id);
// Clean up the ownership administration
if (message.role === "assistant" && message.status === "generating") {
// ...unless it's still generating
} else {
myMessages.delete(message.id);
}
}
});
}
Expand Down Expand Up @@ -1293,6 +1298,7 @@ export function createAi(config: AiConfig): Ai {
const combinedKnowledge = [...globalKnowledge, ...requestKnowledge];
const tools = context.toolsStore.getToolDescriptions(chatId);

messagesStore.markMine(targetMessageId);
const resp: AskInChatResponse = await sendClientMsgWithResponse({
cmd: "ask-in-chat",
chatId,
Expand All @@ -1309,7 +1315,6 @@ export function createAi(config: AiConfig): Ai {
tools: tools.length > 0 ? tools : undefined,
},
});
messagesStore.markMine(resp.targetMessage.id);
return resp;
},

Expand Down
Loading