MCPcopy Create free account
hub / github.com/GCWing/BitFun / activateMainSession

Function activateMainSession

src/web-ui/src/flow_chat/services/sessionActivation.ts:31–59  ·  view source on GitHub ↗
(sessionId: string)

Source from the content-addressed store, hash-verified

29}
30
31export 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}

Callers 3

FloatingMiniChatFunction · 0.90
ToolbarModeFunction · 0.90
openMainSessionFunction · 0.85

Calls 5

syncSessionToModernStoreFunction · 0.90
isTargetActiveFunction · 0.85
switchChatSessionMethod · 0.80
getStateMethod · 0.65
getMethod · 0.45

Tested by

no test coverage detected