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 125f265eaad..e0d42359f5b 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 144b28ff317..01535260c02 100644 --- a/app/locales/cn.ts +++ b/app/locales/cn.ts @@ -52,6 +52,7 @@ const cn = { next: "下一个聊天", prev: "上一个聊天", clear: "清除上下文", + fork: "复制聊天", del: "删除聊天", }, InputActions: { diff --git a/app/locales/en.ts b/app/locales/en.ts index 049447569f7..d5116a2d6f5 100644 --- a/app/locales/en.ts +++ b/app/locales/en.ts @@ -54,6 +54,7 @@ const en: LocaleType = { next: "Next Chat", prev: "Previous Chat", clear: "Clear Context", + fork: "Copy Chat", del: "Delete Chat", }, InputActions: { diff --git a/app/store/chat.ts b/app/store/chat.ts index 3bcda75389a..86de998364b 100644 --- a/app/store/chat.ts +++ b/app/store/chat.ts @@ -170,6 +170,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()],