Skip to content

Commit

Permalink
Merge pull request ChatGPTNextWeb#6033 from lvguanjun/fix_fork_session
Browse files Browse the repository at this point in the history
fix: prevent message sync between forked sessions by generating unique IDs
  • Loading branch information
Dogtiti authored Jan 11, 2025
2 parents b6b2c50 + 840c151 commit 4ac27fd
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 4ac27fd

Please sign in to comment.