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

This commit is contained in:
balibabu
2026-08-03 11:49:12 +08:00
committed by GitHub
parent 8353fc7855
commit 5aa60cbb67
3 changed files with 12 additions and 4 deletions

View File

@@ -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) => {

View File

@@ -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 {

View File

@@ -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(