MCPcopy
hub / github.com/ChatGPTNextWeb/NextChat / forkSession

Function forkSession

app/store/chat.ts:243–267  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

241
242 const methods = {
243 forkSession() {
244 // 获取当前会话
245 const currentSession = get().currentSession();
246 if (!currentSession) return;
247
248 const newSession = createEmptySession();
249
250 newSession.topic = currentSession.topic;
251 // 深拷贝消息
252 newSession.messages = currentSession.messages.map((msg) => ({
253 ...msg,
254 id: nanoid(), // 生成新的消息 ID
255 }));
256 newSession.mask = {
257 ...currentSession.mask,
258 modelConfig: {
259 ...currentSession.mask.modelConfig,
260 },
261 };
262
263 set((state) => ({
264 currentSessionIndex: 0,
265 sessions: [newSession, ...state.sessions],
266 }));
267 },
268
269 clearSessions() {
270 set(() => ({

Callers

nothing calls this directly

Calls 4

createEmptySessionFunction · 0.85
nanoidFunction · 0.85
getFunction · 0.70
setFunction · 0.50

Tested by

no test coverage detected