MCPcopy Create free account
hub / github.com/ChatLab/ChatLab / ensureSessionState

Function ensureSessionState

src/stores/aiChat.ts:332–351  ·  view source on GitHub ↗
(params: EnsureAIChatSessionParams)

Source from the content-addressed store, hash-verified

330 }
331
332 function ensureSessionState(params: EnsureAIChatSessionParams): { chatKey: string; state: AIChatSessionState } {
333 const chatKey = buildAIChatKey(params)
334 const existing = sessionStates.value[chatKey]
335
336 if (existing) {
337 existing.sessionName = params.sessionName
338 existing.chatType = params.chatType
339 existing.locale = params.locale
340 existing.timeFilter = params.timeFilter
341 return { chatKey, state: existing }
342 }
343
344 const state = createSessionState(params)
345 sessionStates.value[chatKey] = state
346 // 新建会话状态后,必须返回 store 中的响应式代理对象;
347 // 否则首屏会绑定到原始对象,点击后要切页回来才会看到更新。
348 const reactiveState = sessionStates.value[chatKey]
349 void ensureOwnerInfo(chatKey)
350 return { chatKey, state: reactiveState }
351 }
352
353 function getSessionState(chatKey: string): AIChatSessionState | null {
354 return sessionStates.value[chatKey] ?? null

Callers

nothing calls this directly

Calls 3

buildAIChatKeyFunction · 0.85
createSessionStateFunction · 0.85
ensureOwnerInfoFunction · 0.85

Tested by

no test coverage detected