Skip to content

Commit 9ddd5a0

Browse files
authored
Merge pull request #5432 from ConnectAI-E/Feature-fork
feat fork
2 parents b4dc4d3 + fd47bc1 commit 9ddd5a0

File tree

5 files changed

+26
-0
lines changed

5 files changed

+26
-0
lines changed

app/command.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ interface ChatCommands {
3838
next?: Command;
3939
prev?: Command;
4040
clear?: Command;
41+
fork?: Command;
4142
del?: Command;
4243
}
4344

app/components/chat.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ function _Chat() {
980980
chatStore.updateCurrentSession(
981981
(session) => (session.clearContextIndex = session.messages.length),
982982
),
983+
fork: () => chatStore.forkSession(),
983984
del: () => chatStore.deleteSession(chatStore.currentSessionIndex),
984985
});
985986

app/locales/cn.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const cn = {
5252
next: "下一个聊天",
5353
prev: "上一个聊天",
5454
clear: "清除上下文",
55+
fork: "复制聊天",
5556
del: "删除聊天",
5657
},
5758
InputActions: {

app/locales/en.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const en: LocaleType = {
5454
next: "Next Chat",
5555
prev: "Previous Chat",
5656
clear: "Clear Context",
57+
fork: "Copy Chat",
5758
del: "Delete Chat",
5859
},
5960
InputActions: {

app/store/chat.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,28 @@ export const useChatStore = createPersistStore(
170170
}
171171

172172
const methods = {
173+
forkSession() {
174+
// 获取当前会话
175+
const currentSession = get().currentSession();
176+
if (!currentSession) return;
177+
178+
const newSession = createEmptySession();
179+
180+
newSession.topic = currentSession.topic;
181+
newSession.messages = [...currentSession.messages];
182+
newSession.mask = {
183+
...currentSession.mask,
184+
modelConfig: {
185+
...currentSession.mask.modelConfig,
186+
},
187+
};
188+
189+
set((state) => ({
190+
currentSessionIndex: 0,
191+
sessions: [newSession, ...state.sessions],
192+
}));
193+
},
194+
173195
clearSessions() {
174196
set(() => ({
175197
sessions: [createEmptySession()],

0 commit comments

Comments
 (0)