diff --git a/src/hooks/auto-update-checker/index.ts b/src/hooks/auto-update-checker/index.ts index 08cbd64c..72cd5630 100644 --- a/src/hooks/auto-update-checker/index.ts +++ b/src/hooks/auto-update-checker/index.ts @@ -5,6 +5,7 @@ import { PACKAGE_NAME } from "./constants" import { log } from "../../shared/logger" import { getConfigLoadErrors, clearConfigLoadErrors } from "../../shared/config-errors" import { runBunInstall } from "../../cli/config-manager" +import { isModelCacheAvailable } from "../../shared/model-availability" import type { AutoUpdateCheckerOptions } from "./types" const SISYPHUS_SPINNER = ["·", "•", "●", "○", "◌", "◦", " "] @@ -75,6 +76,7 @@ export function createAutoUpdateCheckerHook(ctx: PluginInput, options: AutoUpdat const displayVersion = localDevVersion ?? cachedVersion await showConfigErrorsIfAny(ctx) + await showModelCacheWarningIfNeeded(ctx) if (localDevVersion) { if (showStartupToast) { @@ -167,6 +169,23 @@ async function runBunInstallSafe(): Promise { } } +async function showModelCacheWarningIfNeeded(ctx: PluginInput): Promise { + if (isModelCacheAvailable()) return + + await ctx.client.tui + .showToast({ + body: { + title: "Model Cache Not Found", + message: "Run 'opencode models --refresh' or restart OpenCode to populate the models cache for optimal agent model selection.", + variant: "warning" as const, + duration: 10000, + }, + }) + .catch(() => {}) + + log("[auto-update-checker] Model cache warning shown") +} + async function showConfigErrorsIfAny(ctx: PluginInput): Promise { const errors = getConfigLoadErrors() if (errors.length === 0) return diff --git a/src/shared/model-availability.ts b/src/shared/model-availability.ts index 3873591d..7abc1d3c 100644 --- a/src/shared/model-availability.ts +++ b/src/shared/model-availability.ts @@ -147,3 +147,8 @@ export async function fetchAvailableModels(_client?: any): Promise> export function __resetModelCache(): void { cachedModels = null } + +export function isModelCacheAvailable(): boolean { + const cacheFile = join(getOpenCodeCacheDir(), "models.json") + return existsSync(cacheFile) +}