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.

989 B
Raw Blame
import { useModelStore } from '../stores/modelStore'
import { useSettingsStore } from '../stores/settingsStore'
import { modelOutOfMode } from './modeGate'

/**
 * Does a chat send have a model to run on? The composer asks this before it
 * hands the message over, because `sendMessage` (hooks/useChat.ts) returns
 * without a word when it has none, and the composer would then clear a message
 * that went nowhere.
 *
 * The same two cases `sendMessage` turns away: nothing picked, and a model
 * from the other side of the Cloud switch. That one is cleared here exactly
 * as `sendMessage` clears it (the switch is a money gate), so the picker shows
 * the honest "Select Model" when it opens.
 */
export function chatModelReady(): boolean {
  const { activeModel, setActiveModel } = useModelStore.getState()
  if (!activeModel) return false
  if (modelOutOfMode(activeModel, useSettingsStore.getState().settings.appMode)) {
    setActiveModel(null)
    return false
  }
  return true
}