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.

fix(appshell): auto-enable first non-Ollama backend when multiple are detected

PurpleDoubleD0ab6697ec86a
diff --git a/src/components/layout/AppShell.tsx b/src/components/layout/AppShell.tsx
index 6045b634..c22a775c 100644
--- a/src/components/layout/AppShell.tsx
+++ b/src/components/layout/AppShell.tsx
@@ -294,21 +294,29 @@ export function AppShell() {
detectLocalBackends().then((backends) => {
if (backends.length === 0) return
- // Only 1 backend (any) → auto-enable it silently
- if (backends.length === 1) {
- const backend = backends[0]
- if (backend.id !== 'ollama') {
- useProviderStore.getState().setProviderConfig('openai', {
- enabled: true,
- name: backend.name,
- baseUrl: backend.baseUrl,
- isLocal: true,
- })
- }
- return
+ // Always auto-enable the first non-Ollama openai-compat backend we find.
+ // Ollama has its own provider slot and is handled separately.
+ // Without this, a user running e.g. Ollama + LM Studio together would
+ // see the BackendSelector modal; if they dismissed it, LM Studio stayed
+ // disabled and its models never appeared in the chat dropdown ("no models
+ // recognized" from the user's POV). Pre-enabling the first detected
+ // non-Ollama backend guarantees models show up, and the selector below
+ // stays available so the user can still pick a different one.
+ const nonOllama = backends.find((b) => b.id !== 'ollama')
+ if (nonOllama) {
+ useProviderStore.getState().setProviderConfig('openai', {
+ enabled: true,
+ name: nonOllama.name,
+ baseUrl: nonOllama.baseUrl,
+ isLocal: true,
+ })
}
- // Multiple backends detected → show selection dialog
+ // Single backend → we're done (already enabled above, or was Ollama).
+ if (backends.length === 1) return
+
+ // Multiple backends detected → show selection dialog so the user can
+ // change which one is the primary openai-compat provider if they want.
setDetectedBackends(backends)
setShowSelector(true)
})
diff --git a/src/components/layout/__tests__/AppShell-backend-autoenable.test.ts b/src/components/layout/__tests__/AppShell-backend-autoenable.test.ts
new file mode 100644
index 00000000..9e50f04a
--- /dev/null
+++ b/src/components/layout/__tests__/AppShell-backend-autoenable.test.ts
@@ -0,0 +1,60 @@
+/**
+ * Regression: when multiple local backends are detected on startup the user
+ * used to see the BackendSelector modal without anything being pre-enabled.
+ * If they skipped or dismissed the modal, LM Studio / vLLM / etc. stayed
+ * disabled and their models never appeared in the chat model dropdown.
+ *
+ * Reported on Discord #help-chat (2026-04-21, user djoks.exe, "LU does not
+ * recognize the models"). Fix: always pre-enable the first non-Ollama
+ * openai-compat backend that was detected, even when multiple are running.
+ * The selector modal is kept as an educational picker so the user can still
+ * change which one is primary.
+ *
+ * This test checks the source of AppShell.tsx for the fix pattern — we're
+ * not mounting the full component, just guarding against a regression where
+ * the 2+ branch silently does nothing.
+ */
+import { describe, it, expect } from 'vitest'
+import { readFileSync } from 'fs'
+import { fileURLToPath } from 'url'
+import { dirname, join } from 'path'
+
+const __filename = fileURLToPath(import.meta.url)
+const __dirname = dirname(__filename)
+const src = readFileSync(join(__dirname, '../AppShell.tsx'), 'utf8')
+
+describe('AppShell multi-backend auto-enable', () => {
+ it('finds a non-Ollama backend before enabling', () => {
+ // We look for the pattern introduced by the fix: a find() that excludes
+ // ollama and pre-enables the first matching backend.
+ expect(src).toMatch(/backends\.find\(.*b\.id\s*!==\s*['"]ollama['"]/)
+ })
+
+ it('calls setProviderConfig for the detected non-Ollama backend', () => {
+ // The enablement must happen through the provider store and must flag
+ // the backend as local (so the provider UI treats it correctly).
+ expect(src).toContain("setProviderConfig('openai',")
+ expect(src).toContain('enabled: true')
+ expect(src).toContain('isLocal: true')
+ })
+
+ it('still shows the selector modal when more than one backend is detected', () => {
+ // After the fix, the selector must remain for the 2+ case as a way to
+ // change the picked primary. This guards against accidentally deleting
+ // the selector along with the auto-enable.
+ expect(src).toContain('setDetectedBackends(backends)')
+ expect(src).toContain('setShowSelector(true)')
+ })
+
+ it('early-returns on the single-backend path after pre-enabling', () => {
+ // Single backend + already auto-enabled above → return before showing the
+ // selector (which would look weird with one option).
+ expect(src).toMatch(/if \(backends\.length === 1\) return/)
+ })
+
+ it('leaves the zero-backends early-return intact', () => {
+ // If detection finds nothing, we still bail early. Guards against the
+ // refactor accidentally trying to auto-enable with an empty list.
+ expect(src).toContain('if (backends.length === 0) return')
+ })
+})