()
| 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(() => ({ |
nothing calls this directly
no test coverage detected