Преглед изворни кода

fix: prevent message sync between forked sessions by generating unique IDs

lvguanjun пре 1 година
родитељ
комит
840c151ab9
1 измењених фајлова са 5 додато и 1 уклоњено
  1. 5 1
      app/store/chat.ts

+ 5 - 1
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: {