{"record":{"id":"48725fc918bb7835","repo":"linshenkx/prompt-optimizer","slug":"modelmanager-nomodelsavailable","errorCode":null,"errorMessage":"modelManager.noModelsAvailable","messagePattern":"modelManager\\.noModelsAvailable","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/ui/src/composables/model/useTextModelManager.ts","lineNumber":439,"sourceCode":"            return aDefault ? -1 : 1\n          }\n          return a.name.localeCompare(b.name)\n        })\n    } catch (error) {\n      console.error('Failed to load models:', error)\n      toast.error(t('modelManager.loadFailed'))\n    } finally {\n      loadingModels.value = false\n    }\n  }\n\n  const testConfigConnection = async (id: string) => {\n    if (!id || testingConnections.value[id]) return\n    testingConnections.value[id] = true\n    try {\n      const model = await modelManager.getModel(id)\n      if (!model) {\n        throw new Error(t('modelManager.noModelsAvailable'))\n      }\n      await llmService.testConnection(id)\n      toast.success(t('modelManager.testSuccess', { provider: model.name }))\n    } catch (error) {\n      console.error('Connection test failed:', error)\n      const model = await modelManager.getModel(id)\n      const modelName = model?.name || id\n      toast.error(t('modelManager.testFailed', {\n        provider: modelName,\n        error: getErrorDetail(error)\n      }))\n    } finally {\n      delete testingConnections.value[id]\n    }\n  }\n\n  const enableModel = async (id: string) => {\n    try {","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/linshenkx/prompt-optimizer/blob/3e677b1d9f7e0493c142c175560531e7ae786dce/packages/ui/src/composables/model/useTextModelManager.ts#L421-L457","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Refresh/reload models (loadModels) and confirm the row's id still resolves before testing.","Ensure modelManager initialization completed before rendering the models list.","Remove or rebuild config entries for models that no longer register."],"exampleFix":"// before\nawait testConfigConnection(id)\n\n// after\nif (!(await modelManager.getModel(id))) {\n  toast.error(t('modelManager.noModelsAvailable'))\n  await loadModels()\n  return\n}\nawait testConfigConnection(id)","handlingStrategy":"validation","validationCode":"if (!(await modelManager.getModel(id))) { toast.error(t('modelManager.noModelsAvailable')); await loadModels(); return }","typeGuard":null,"tryCatchPattern":"catch (e) { if (e instanceof Error && e.message === t('modelManager.noModelsAvailable')) { await loadModels(); return } throw e }","preventionTips":["Ensure modelManager finished initializing before showing test buttons","Reload models when list state may be stale"],"tags":["model-not-found","stale-state","i18n"],"backgroundTag":"model-not-found","analyzedSha":"3e677b1d9f7e0493c142c175560531e7ae786dce","analyzedAt":"2026-08-27T21:29:16.709Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}