Skip to content

Commit 4ac27fd

Browse files
authored
Merge pull request ChatGPTNextWeb#6033 from lvguanjun/fix_fork_session
fix: prevent message sync between forked sessions by generating unique IDs
2 parents b6b2c50 + 840c151 commit 4ac27fd

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

app/store/chat.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,11 @@ export const useChatStore = createPersistStore(
214214
const newSession = createEmptySession();
215215

216216
newSession.topic = currentSession.topic;
217-
newSession.messages = [...currentSession.messages];
217+
// 深拷贝消息
218+
newSession.messages = currentSession.messages.map(msg => ({
219+
...msg,
220+
id: nanoid(), // 生成新的消息 ID
221+
}));
218222
newSession.mask = {
219223
...currentSession.mask,
220224
modelConfig: {

0 commit comments

Comments
 (0)