Prechádzať zdrojové kódy

Merge pull request #6033 from lvguanjun/fix_fork_session

fix: prevent message sync between forked sessions by generating unique IDs
Dogtiti 11 mesiacov pred
rodič
commit
4ac27fdd4d
1 zmenil súbory, kde vykonal 5 pridanie a 1 odobranie
  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: {