From 840c151ab9ea7e384be37b774ea339264b5c0dc6 Mon Sep 17 00:00:00 2001 From: lvguanjun Date: Sun, 5 Jan 2025 11:22:53 +0800 Subject: [PATCH] fix: prevent message sync between forked sessions by generating unique IDs --- app/store/chat.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/store/chat.ts b/app/store/chat.ts index 63d7394ece6..7a476fa7f6e 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -214,7 +214,11 @@ export const useChatStore = createPersistStore( const newSession = createEmptySession(); newSession.topic = currentSession.topic; - newSession.messages = [...currentSession.messages]; + // 深拷贝消息 + newSession.messages = currentSession.messages.map(msg => ({ + ...msg, + id: nanoid(), // 生成新的消息 ID + })); newSession.mask = { ...currentSession.mask, modelConfig: {