(sessionId: string)
| 29 | } |
| 30 | |
| 31 | export async function activateMainSession(sessionId: string): Promise<boolean> { |
| 32 | const isTargetActive = () => flowChatStore.getState().activeSessionId === sessionId; |
| 33 | const targetSession = flowChatStore.getState().sessions.get(sessionId) ?? null; |
| 34 | if (!targetSession) { |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | if (isTargetActive()) { |
| 39 | const activeSession = flowChatStore.getState().sessions.get(sessionId) ?? null; |
| 40 | if ( |
| 41 | activeSession?.isHistorical && |
| 42 | (activeSession.historyState === 'metadata-only' || activeSession.historyState === 'failed') |
| 43 | ) { |
| 44 | await flowChatManager.switchChatSession(sessionId); |
| 45 | if (!isTargetActive()) { |
| 46 | return false; |
| 47 | } |
| 48 | } |
| 49 | syncSessionToModernStore(sessionId); |
| 50 | } else { |
| 51 | await flowChatManager.switchChatSession(sessionId); |
| 52 | if (!isTargetActive()) { |
| 53 | return false; |
| 54 | } |
| 55 | syncSessionToModernStore(sessionId); |
| 56 | } |
| 57 | |
| 58 | return true; |
| 59 | } |
no test coverage detected