Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

Fix: Deleting temporary chat resulted in an error. (#17694)

balibabu5aa60cbb674c
diff --git a/web/src/components/next-message-item/utils.ts b/web/src/components/next-message-item/utils.ts
index 615d7a192d..45dca5b6b7 100644
--- a/web/src/components/next-message-item/utils.ts
+++ b/web/src/components/next-message-item/utils.ts
@@ -1,7 +1,7 @@
import { currentReg, parseCitationIndex } from '@/utils/chat';
export const extractNumbersFromMessageContent = (content: string) => {
- const matches = content.match(currentReg);
+ const matches = content?.match(currentReg);
if (matches) {
const list = matches
.map((match) => {
diff --git a/web/src/pages/next-chats/hooks/use-select-conversation-list.ts b/web/src/pages/next-chats/hooks/use-select-conversation-list.ts
index 674cb9f8ac..754869d6f2 100644
--- a/web/src/pages/next-chats/hooks/use-select-conversation-list.ts
+++ b/web/src/pages/next-chats/hooks/use-select-conversation-list.ts
@@ -15,7 +15,7 @@ export const useFindPrologueFromDialogList = () => {
const { data } = useFetchChatList();
const prologue = useMemo(() => {
- return data.chats.find((x) => x.id === dialogId)?.prompt_config?.prologue;
+ return data?.chats.find((x) => x.id === dialogId)?.prompt_config?.prologue;
}, [dialogId, data]);
return prologue;
@@ -74,7 +74,14 @@ export const useSelectDerivedConversationList = () => {
// When you first enter the page, select the top conversation card
useEffect(() => {
- setList([...conversationList]);
+ setList((prevList) => {
+ const tempItems = prevList.filter((item) => item.is_new);
+ const existingTempIds = new Set(tempItems.map((t) => t.id));
+ const newItems = conversationList.filter(
+ (item) => !existingTempIds.has(item.id),
+ );
+ return [...tempItems, ...newItems];
+ });
}, [conversationList]);
return {
diff --git a/web/src/pages/next-chats/utils.ts b/web/src/pages/next-chats/utils.ts
index b3d57b44d2..6718bfb57b 100644
--- a/web/src/pages/next-chats/utils.ts
+++ b/web/src/pages/next-chats/utils.ts
@@ -34,7 +34,8 @@ export const buildMessageItemReference = (
const assistantMessages = conversation.messages
?.filter(
(x) =>
- x.role === MessageType.Assistant && !x.content.startsWith('**ERROR**:'), // Exclude error messages
+ x.role === MessageType.Assistant &&
+ !x.content?.startsWith('**ERROR**:'), // Exclude error messages
)
.slice(1);
const referenceIndex = assistantMessages.findIndex(