Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

address copilot review (round 7): real LM Studio list-error + cache Ollama tags failure

Adam Eivy359161d04883
diff --git a/client/src/components/settings/LocalLlmTab.jsx b/client/src/components/settings/LocalLlmTab.jsx
index f7c17d5afb..540f6869e2 100644
--- a/client/src/components/settings/LocalLlmTab.jsx
+++ b/client/src/components/settings/LocalLlmTab.jsx
@@ -268,6 +268,11 @@ export function LocalLlmTab() {
: 'install it first (Settings → Local LLMs prompts at setup, or run `npm run setup:llm`).'}
</p>
)}
+ {selectedData?.available && selectedData?.modelsError && (
+ <p className="text-xs text-port-warning">
+ Couldn't list {labelFor(selected)} models (showing what's available): {selectedData.modelsError}
+ </p>
+ )}
{/* Free-text install + search */}
<div className="flex flex-col sm:flex-row gap-2">
diff --git a/server/services/lmStudioManager.js b/server/services/lmStudioManager.js
index 44c3f05a14..0302289e11 100644
--- a/server/services/lmStudioManager.js
+++ b/server/services/lmStudioManager.js
@@ -36,6 +36,10 @@ let loadedModels = []
// catalog-overlay path (queried per keystroke) reuse the list instead of
// re-hitting /api/v0/models each time. Busted to null by resetCache().
let availableModels = null
+// Last error from the model-LIST call (/api/v0/models), distinct from the
+// availability probe (/v1/models): LM Studio can answer the probe yet fail the
+// list, so this lets callers tell "0 models" from "couldn't list models".
+let lastListError = null
let lastCheckAt = null
// Status tracking
@@ -155,11 +159,14 @@ async function getAvailableModels(forceRefresh = false) {
if (!forceRefresh && availableModels !== null) return availableModels
const available = await checkLMStudioAvailable()
if (!available) {
+ // Unreachable is surfaced by the availability probe (`available`), not here.
+ lastListError = null
return []
}
- const response = await lmStudioRequest('/api/v0/models').catch(() => null)
+ const response = await lmStudioRequest('/api/v0/models').catch((err) => ({ _err: err.message }))
if (response?.data) {
+ lastListError = null
availableModels = response.data.map(model => ({
id: model.id,
type: model.type,
@@ -172,10 +179,18 @@ async function getAvailableModels(forceRefresh = false) {
return availableModels
}
- // Fallback to loaded models only
+ // Reachable (the /v1/models probe passed) but the native model-list call
+ // failed or returned no data — record it so callers can distinguish this from
+ // a genuinely empty list. Fall back to loaded models for a best-effort list.
+ lastListError = response?._err || 'LM Studio model list (/api/v0/models) returned no data'
return getLoadedModels(true)
}
+/** Last `/api/v0/models` list error (null if the most recent list succeeded). */
+function getLastListError() {
+ return lastListError
+}
+
/**
* Download a model from LM Studio catalog
* @param {string} modelId - Model identifier to download
@@ -445,6 +460,7 @@ function resetCache() {
isAvailable = null
loadedModels = []
availableModels = null
+ lastListError = null
lastCheckAt = null
}
@@ -541,6 +557,7 @@ export {
updateConfig,
resetCache,
isAppInstalled,
+ getLastListError,
resolveLocalModel,
importModelFromGguf,
DEFAULT_CONFIG
diff --git a/server/services/localLlm.js b/server/services/localLlm.js
index 8a7e480137..22bf71ee9a 100644
--- a/server/services/localLlm.js
+++ b/server/services/localLlm.js
@@ -252,9 +252,7 @@ export async function getStatus() {
commandExists('ollama', ['--version']),
lmStudioManager.getStatus(),
commandExists('lms', ['version']),
- // forceRefresh: status/refresh path bypasses the list cache. "Couldn't
- // reach LM Studio" is carried by the `available` field below (the model
- // list is [] in that case), so we don't double-report it here.
+ // forceRefresh: status/refresh path bypasses the list cache.
listModels('lmstudio', true).catch(() => [])
])
@@ -278,6 +276,9 @@ export async function getStatus() {
baseUrl: lmStudioStatus.baseUrl,
modelCount: lmStudioModels.length,
models: lmStudioModels,
+ // Non-null when LM Studio answered the availability probe but the model
+ // list call failed — lets the UI tell "0 models" from "couldn't list".
+ modelsError: lmStudioManager.getLastListError(),
canAutoInstall: canAutoInstall('lmstudio'),
downloadUrl: DOWNLOAD_URL.lmstudio
}
diff --git a/server/services/localLlm.test.js b/server/services/localLlm.test.js
index c00ec0ad76..5ecb0593c7 100644
--- a/server/services/localLlm.test.js
+++ b/server/services/localLlm.test.js
@@ -26,6 +26,7 @@ const mocks = vi.hoisted(() => ({
getStatus: vi.fn(async () => ({ available: false, baseUrl: 'y', loadedModels: 0 })),
resetCache: vi.fn(),
isAppInstalled: vi.fn(() => false),
+ getLastListError: vi.fn(() => null),
resolveLocalModel: vi.fn(async () => null),
importModelFromGguf: vi.fn(async ({ lmstudioId }) => ({ success: true, modelId: lmstudioId }))
},
diff --git a/server/services/ollamaManager.js b/server/services/ollamaManager.js
index 1c4ae1d11c..1866ce9609 100644
--- a/server/services/ollamaManager.js
+++ b/server/services/ollamaManager.js
@@ -98,7 +98,13 @@ async function getInstalledModels(forceRefresh = false) {
if (!(await checkOllamaAvailable())) return []
const data = await ollamaRequest('/api/tags').catch(() => null)
- if (!data?.models) return []
+ if (!data?.models) {
+ // Cache the empty result so a /api/tags failure while Ollama stays up for
+ // /api/version (the availability probe) doesn't re-hit on every catalog
+ // keystroke; a forceRefresh (status refresh / pull / delete) recovers it.
+ installedModels = []
+ return installedModels
+ }
installedModels = data.models.map((m) => ({
id: m.name || m.model,