Skip to content

The all-in-one local AI studio for your desktop: chat, image and video generation and a coding agent in one free, open source app. Windows and Linux. No Docker, no terminal, no cloud required.

617 B
Raw Blame
import { useSyncExternalStore } from 'react'
import { useChatStore } from '../../../../stores/chatStore'

function subscribeHydration(notify: () => void): () => void {
  try {
    return useChatStore.persist.onFinishHydration(notify)
  } catch {
    return () => {}
  }
}

function hasHydrated(): boolean {
  try {
    return useChatStore.persist.hasHydrated()
  } catch {
    return true
  }
}

/** False until the chats were read from storage. Until then a list is "loading", not "empty". */
export function useChatsHydrated(): boolean {
  return useSyncExternalStore(subscribeHydration, hasHydrated, () => true)
}