Skip to content

Commit

Permalink
fix: prevent message sync between forked sessions by generating uniqu…
Browse files Browse the repository at this point in the history
…e IDs
  • Loading branch information
lvguanjun committed Jan 5, 2025
1 parent 0af04e0 commit 840c151
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/store/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 840c151

Please sign in to comment.