update message approval status after processing message

This commit is contained in:
Will Chen
2025-04-18 14:00:05 -07:00
parent a4629e7698
commit e3568f9a97
3 changed files with 33 additions and 16 deletions

View File

@@ -261,18 +261,27 @@ export function registerChatStreamHandlers() {
})
.returning();
await db
.update(messages)
.set({ content: fullResponse })
.where(eq(messages.id, assistantMessage.id));
if (readSettings().autoApproveChanges) {
const status = await processFullResponseActions(
fullResponse,
req.chatId,
{ chatSummary }
{ chatSummary, messageId: assistantMessage.id }
);
const chat = await db.query.chats.findFirst({
where: eq(chats.id, req.chatId),
with: {
messages: {
orderBy: (messages, { asc }) => [asc(messages.createdAt)],
},
},
});
event.sender.send("chat:response:chunk", {
chatId: req.chatId,
messages: chat!.messages,
});
if (status.error) {
event.sender.send(
"chat:response:error",