Newer
Older
navi-1 / webclient / src / stores / chat / naming.js
@Eugene Sukhodolskiy Eugene Sukhodolskiy 23 hours ago 672 bytes webclient: split the chat store into area modules
import * as api from '@/api/index.js'
import { useSessionsStore } from '@/stores/sessions.js'

/**
 * Give a finished session a name, in the background. Fire-and-forget: the
 * answer is already on screen and a naming failure must not surface anywhere.
 */
export async function tryGenerateName(sessionId) {
  try {
    const sessionsStore = useSessionsStore()
    const session = sessionsStore.sessions.find(s => s.session_id === sessionId)
    if (session?.name) return  // already has a name
    const { name } = await api.generateSessionName(sessionId)
    if (name) sessionsStore.updateName(sessionId, name)
  } catch {
    // fire-and-forget — ignore errors
  }
}