linshenkx/prompt-optimizer · error · Error

modelManager.noModelsAvailable

Error message

modelManager.noModelsAvailable

What it means

testConfigConnection in useTextModelManager resolves the model by ID via modelManager.getModel; if the model cannot be found it throws the localized 'noModelsAvailable' message before ever testing connectivity. Despite the generic wording, it specifically means the model with the given id is missing from the model manager.

Source

Thrown at packages/ui/src/composables/model/useTextModelManager.ts:439

            return aDefault ? -1 : 1
          }
          return a.name.localeCompare(b.name)
        })
    } catch (error) {
      console.error('Failed to load models:', error)
      toast.error(t('modelManager.loadFailed'))
    } finally {
      loadingModels.value = false
    }
  }

  const testConfigConnection = async (id: string) => {
    if (!id || testingConnections.value[id]) return
    testingConnections.value[id] = true
    try {
      const model = await modelManager.getModel(id)
      if (!model) {
        throw new Error(t('modelManager.noModelsAvailable'))
      }
      await llmService.testConnection(id)
      toast.success(t('modelManager.testSuccess', { provider: model.name }))
    } catch (error) {
      console.error('Connection test failed:', error)
      const model = await modelManager.getModel(id)
      const modelName = model?.name || id
      toast.error(t('modelManager.testFailed', {
        provider: modelName,
        error: getErrorDetail(error)
      }))
    } finally {
      delete testingConnections.value[id]
    }
  }

  const enableModel = async (id: string) => {
    try {

View on GitHub (pinned to 3e677b1d9f)

Solutions

  1. Refresh/reload models (loadModels) and confirm the row's id still resolves before testing.
  2. Ensure modelManager initialization completed before rendering the models list.
  3. Remove or rebuild config entries for models that no longer register.

Example fix

// before
await testConfigConnection(id)

// after
if (!(await modelManager.getModel(id))) {
  toast.error(t('modelManager.noModelsAvailable'))
  await loadModels()
  return
}
await testConfigConnection(id)
Defensive patterns

Strategy: validation

Validate before calling

if (!(await modelManager.getModel(id))) { toast.error(t('modelManager.noModelsAvailable')); await loadModels(); return }

Try / catch

catch (e) { if (e instanceof Error && e.message === t('modelManager.noModelsAvailable')) { await loadModels(); return } throw e }

Prevention

When it happens

Trigger: Clicking 'Test' on a model row whose id no longer resolves — model was deleted or failed to load during modelManager init; store reset between listing and testing; race where loadModels hasn't finished.

Common situations: Model removed/uninstalled while its row was still rendered; persisted config referencing a model that failed to register on startup; concurrent refresh removing the entry.

Related errors


AI-assisted analysis of linshenkx/prompt-optimizer@3e677b1d9f (2026-08-27). Data as JSON: /api/errors/48725fc918bb7835. Report an issue: GitHub.