This commit is contained in:
Timothy Jaeryang Baek
2026-06-29 13:03:14 -05:00
parent 7ea7680f56
commit 517cd8d102
45 changed files with 1293 additions and 969 deletions
+8 -2
View File
@@ -1156,7 +1156,12 @@ export const getChatAccessGrants = async (token: string, id: string) => {
return res;
};
export const updateChatById = async (token: string, id: string, chat: object) => {
export const updateChatById = async (
token: string,
id: string,
chat: object,
deletedMessageIds: string[] = []
) => {
let error = null;
const res = await fetch(`${WEBUI_API_BASE_URL}/chats/${id}`, {
@@ -1167,7 +1172,8 @@ export const updateChatById = async (token: string, id: string, chat: object) =>
...(token && { authorization: `Bearer ${token}` })
},
body: JSON.stringify({
chat: chat
chat: chat,
...(deletedMessageIds.length && { deleted_message_ids: deletedMessageIds })
})
})
.then(async (res) => {
+4 -2
View File
@@ -512,7 +512,7 @@
}
};
const showMessage = async (message, scroll = true) => {
const showMessage = async (message, scroll = true, save = true) => {
const _chatId = JSON.parse(JSON.stringify($chatId));
let _messageId = JSON.parse(JSON.stringify(message.id));
@@ -545,7 +545,9 @@
await tick();
await tick();
saveChatHandler(_chatId, history);
if (save) {
saveChatHandler(_chatId, history);
}
};
const updateLastReadAt = (id) => {
+14 -5
View File
@@ -35,6 +35,7 @@
export let atSelectedModel;
let messages = [];
let deletedMessageIds = new Set<string>();
export let setInputText: Function = () => {};
@@ -168,10 +169,16 @@
if (!$temporaryChatEnabled) {
history = history;
await tick();
const res = await updateChatById(localStorage.token, chatId, {
history: history,
messages: messages
});
const res = await updateChatById(
localStorage.token,
chatId,
{
history: history,
messages: messages
},
Array.from(deletedMessageIds)
);
deletedMessageIds.clear();
// Refresh local message content from backend (e.g. re-derived via serialize_output)
if (res?.chat?.history?.messages) {
@@ -461,9 +468,11 @@
// Delete the message and its children
[messageId, ...childMessageIds].forEach((id) => {
delete history.messages[id];
deletedMessageIds.add(id);
});
showMessage({ id: parentMessageId }, false);
showMessage({ id: parentMessageId }, false, false);
await updateChat();
};
const triggerScroll = () => {