From ff4b1b9824d38f19286b590f219c26a4b0b79300 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Thu, 27 Nov 2025 00:10:53 -0500 Subject: [PATCH] refac: chat history data structure --- backend/open_webui/main.py | 3 +++ src/lib/components/chat/Chat.svelte | 2 ++ 2 files changed, 5 insertions(+) diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 899a3e08e1..f7c14ab5ad 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -1577,6 +1577,7 @@ async def chat_completion( "user_id": user.id, "chat_id": form_data.pop("chat_id", None), "message_id": form_data.pop("id", None), + "parent_message_id": form_data.pop("parent_id", None), "session_id": form_data.pop("session_id", None), "filter_ids": form_data.pop("filter_ids", []), "tool_ids": form_data.get("tool_ids", None), @@ -1633,6 +1634,7 @@ async def chat_completion( metadata["chat_id"], metadata["message_id"], { + "parentId": metadata.get("parent_message_id", None), "model": model_id, }, ) @@ -1665,6 +1667,7 @@ async def chat_completion( metadata["chat_id"], metadata["message_id"], { + "parentId": metadata.get("parent_message_id", None), "error": {"content": str(e)}, }, ) diff --git a/src/lib/components/chat/Chat.svelte b/src/lib/components/chat/Chat.svelte index 49b21aa35b..7f80bca601 100644 --- a/src/lib/components/chat/Chat.svelte +++ b/src/lib/components/chat/Chat.svelte @@ -1955,7 +1955,9 @@ session_id: $socket?.id, chat_id: $chatId, + id: responseMessageId, + parent_id: userMessage?.id ?? null, background_tasks: { ...(!$temporaryChatEnabled &&