From 6e79b9a7a2609691f41f1b1663a3bed455ebdc42 Mon Sep 17 00:00:00 2001 From: lyf <1910527151@qq.com> Date: Sat, 14 Sep 2024 14:19:11 +0800 Subject: [PATCH 1/2] add fork --- app/command.ts | 1 + app/components/chat.tsx | 1 + app/locales/cn.ts | 1 + app/store/chat.ts | 22 ++++++++++++++++++++++ 4 files changed, 25 insertions(+) diff --git a/app/command.ts b/app/command.ts index bea4e06f381..aec73ef53d6 100644 --- a/app/command.ts +++ b/app/command.ts @@ -38,6 +38,7 @@ interface ChatCommands { next?: Command; prev?: Command; clear?: Command; + fork?: Command; del?: Command; } diff --git a/app/components/chat.tsx b/app/components/chat.tsx index dafb9846421..1b1c2a0451c 100644 --- a/app/components/chat.tsx +++ b/app/components/chat.tsx @@ -980,6 +980,7 @@ function _Chat() { chatStore.updateCurrentSession( (session) => (session.clearContextIndex = session.messages.length), ), + fork: () => chatStore.forkSession(), del: () => chatStore.deleteSession(chatStore.currentSessionIndex), }); diff --git a/app/locales/cn.ts b/app/locales/cn.ts index 92e81bcb1ba..a93b2defc87 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -51,6 +51,7 @@ const cn = { next: "下一个聊天", prev: "上一个聊天", clear: "清除上下文", + fork: "复制聊天", del: "删除聊天", }, InputActions: { diff --git a/app/store/chat.ts b/app/store/chat.ts index 58c105e7ef7..2b7fa7e34fe 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -195,6 +195,28 @@ export const useChatStore = createPersistStore( } const methods = { + forkSession() { + // 获取当前会话 + const currentSession = get().currentSession(); + if (!currentSession) return; + + const newSession = createEmptySession(); + + newSession.topic = currentSession.topic; + newSession.messages = [...currentSession.messages]; + newSession.mask = { + ...currentSession.mask, + modelConfig: { + ...currentSession.mask.modelConfig, + }, + }; + + set((state) => ({ + currentSessionIndex: 0, + sessions: [newSession, ...state.sessions], + })); + }, + clearSessions() { set(() => ({ sessions: [createEmptySession()], From fd47bc1dc3e969d98410f0ea384b71c5ec26de34 Mon Sep 17 00:00:00 2001 From: lyf <1910527151@qq.com> Date: Wed, 18 Sep 2024 13:56:44 +0800 Subject: [PATCH 2/2] Add English copy --- app/locales/en.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/app/locales/en.ts b/app/locales/en.ts index 09b76f1fa12..80859c543d6 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -52,6 +52,7 @@ const en: LocaleType = { next: "Next Chat", prev: "Previous Chat", clear: "Clear Context", + fork: "Copy Chat", del: "Delete Chat", }, InputActions: {