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.

feat(engine): P4 — built-in engine as stable default, externals opt-in (advanced)

purple7df47b5b21eb
diff --git a/src/components/layout/AppShell.tsx b/src/components/layout/AppShell.tsx
index cfb3889e..efd30d71 100644
--- a/src/components/layout/AppShell.tsx
+++ b/src/components/layout/AppShell.tsx
@@ -524,21 +524,28 @@ export function AppShell() {
detectLocalBackends().then((backends) => {
if (backends.length === 0) 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.
+ // Auto-adopt the first non-Ollama openai-compat backend we find — but
+ // NOT when the app-managed built-in engine owns the `openai` slot.
+ // 2.5.7: that slot now holds the bundled llama-server (managed:true) by
+ // default. Silently overwriting it here would leave `managed:true`
+ // pointing at a foreign URL (LM Studio / vLLM), breaking the model list
+ // (`list_bundled_models`) and the fixed-URL assumption. So we only
+ // auto-adopt an external backend when the user has already switched away
+ // from the built-in engine (slot not managed). When the built-in engine
+ // is the active default, detected externals stay opt-in via the selector
+ // modal below and Settings → Providers ("use another engine").
+ // (Pre-2.5.7 rationale — Discord #help-chat, djoks.exe 2026-04-21: without
+ // auto-enable, dismissing the selector left LM Studio disabled and its
+ // models never appeared. Still true for users who left the built-in slot.)
+ const openaiSlot = useProviderStore.getState().providers.openai
const nonOllama = backends.find((b) => b.id !== 'ollama')
- if (nonOllama) {
+ if (nonOllama && !openaiSlot.managed) {
useProviderStore.getState().setProviderConfig('openai', {
enabled: true,
name: nonOllama.name,
baseUrl: nonOllama.baseUrl,
isLocal: true,
+ managed: false,
})
}
diff --git a/src/components/layout/__tests__/AppShell-backend-autoenable.test.ts b/src/components/layout/__tests__/AppShell-backend-autoenable.test.ts
index 48b497f9..0110d9db 100644
--- a/src/components/layout/__tests__/AppShell-backend-autoenable.test.ts
+++ b/src/components/layout/__tests__/AppShell-backend-autoenable.test.ts
@@ -69,4 +69,14 @@ describe('AppShell multi-backend auto-enable', () => {
expect(src).toMatch(/hideBackendSelector/)
expect(src).toMatch(/if \(useProviderStore\.getState\(\)\.hideBackendSelector\) return/)
})
+
+ // 2.5.7 — the `openai` slot now holds the app-managed built-in engine by
+ // default. Auto-enabling a detected external backend must NOT clobber it,
+ // otherwise `managed:true` ends up pointing at a foreign URL (LM Studio/vLLM)
+ // and the model list / fixed-URL assumptions break.
+ it('does not auto-clobber the managed built-in engine slot', () => {
+ // The auto-enable must be guarded on the openai slot NOT being managed.
+ expect(src).toMatch(/!\s*openaiSlot\.managed/)
+ expect(src).toMatch(/nonOllama\s*&&\s*!openaiSlot\.managed/)
+ })
})
diff --git a/src/components/onboarding/BackendSelector.tsx b/src/components/onboarding/BackendSelector.tsx
index 130e1311..95f8e0c8 100644
--- a/src/components/onboarding/BackendSelector.tsx
+++ b/src/components/onboarding/BackendSelector.tsx
@@ -27,6 +27,12 @@ export function BackendSelector({ open, backends, onClose }: Props) {
// uncheck if they want it to re-appear on next launch.
const [dontShowAgain, setDontShowAgain] = useState(true)
const { setProviderConfig, setHideBackendSelector } = useProviderStore()
+ // 2.5.7: the `openai` slot holds the app-managed built-in engine by default.
+ // When it does, this modal offers *alternatives* — skipping keeps the
+ // built-in engine, and picking one switches away from it (clears `managed`).
+ const builtinActive = useProviderStore(
+ (s) => s.providers.openai.enabled && s.providers.openai.managed === true,
+ )
const dismiss = () => {
// Persist the user's choice on EVERY dismissal (Skip, Use selected, X).
@@ -53,11 +59,15 @@ export function BackendSelector({ open, backends, onClose }: Props) {
isLocal: true,
})
} else {
+ // Switching to an external openai-compat backend clears the built-in
+ // engine's `managed` flag — otherwise the fixed-URL/model-list behavior
+ // would stay pinned while the URL now points at LM Studio/vLLM/etc.
setProviderConfig('openai', {
enabled: true,
name: backend.name,
baseUrl: backend.baseUrl,
isLocal: true,
+ managed: false,
})
}
@@ -81,6 +91,14 @@ export function BackendSelector({ open, backends, onClose }: Props) {
: 'Multiple backends running. Select your primary backend.'}
</p>
+ {/* 2.5.7: reassure that these are optional alternatives — the built-in
+ engine already works out of the box and stays active if skipped. */}
+ {builtinActive && (
+ <p className="text-[0.65rem] text-gray-500 text-center leading-relaxed">
+ You're already set up with the built-in engine. Switching is optional.
+ </p>
+ )}
+
<div className="space-y-1">
{backends.map(backend => (
<button
@@ -129,7 +147,7 @@ export function BackendSelector({ open, backends, onClose }: Props) {
onClick={dismiss}
className="px-4 py-1.5 rounded-lg text-[0.7rem] text-gray-400 hover:text-white hover:bg-white/10 transition-colors"
>
- Skip
+ {builtinActive ? 'Keep built-in engine' : 'Skip'}
</button>
<button
onClick={handleConfirm}
diff --git a/src/components/onboarding/__tests__/BackendSelector-builtin.test.ts b/src/components/onboarding/__tests__/BackendSelector-builtin.test.ts
new file mode 100644
index 00000000..606c1d60
--- /dev/null
+++ b/src/components/onboarding/__tests__/BackendSelector-builtin.test.ts
@@ -0,0 +1,43 @@
+/**
+ * P4 (2.5.7): the BackendSelector modal now offers *alternatives* to the
+ * app-managed built-in engine, which owns the `openai` slot by default.
+ *
+ * - Skipping keeps the built-in engine (relabeled "Keep built-in engine").
+ * - Picking an external openai-compat backend must clear the `managed` flag,
+ * otherwise the fixed-URL / `list_bundled_models` behavior stays pinned
+ * while the URL now points at LM Studio / vLLM / etc.
+ *
+ * Source-level guard (matches the repo's AppShell-backend-autoenable pattern)
+ * — we assert the wiring, not a full React mount.
+ */
+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, '../BackendSelector.tsx'), 'utf8')
+
+describe('BackendSelector built-in engine awareness', () => {
+ it('clears the managed flag when switching to an external backend', () => {
+ // handleConfirm's external branch must explicitly write managed:false.
+ expect(src).toMatch(/managed:\s*false/)
+ })
+
+ it('reads whether the built-in engine is the active default', () => {
+ // Drives the relabeled skip action + the reassurance copy.
+ expect(src).toContain('builtinActive')
+ expect(src).toMatch(/providers\.openai\.managed\s*===\s*true/)
+ })
+
+ it('relabels the dismiss action to keep the built-in engine', () => {
+ expect(src).toMatch(/Keep built-in engine/i)
+ })
+
+ it('still persists the opt-out and can enable a picked external backend', () => {
+ // Non-destructive to the existing wiring: opt-out + external enable remain.
+ expect(src).toContain('setHideBackendSelector')
+ expect(src).toContain("setProviderConfig('openai',")
+ })
+})
diff --git a/src/components/settings/ProviderConfig.tsx b/src/components/settings/ProviderConfig.tsx
index a749be86..a78d1120 100644
--- a/src/components/settings/ProviderConfig.tsx
+++ b/src/components/settings/ProviderConfig.tsx
@@ -191,6 +191,7 @@ export function ProviderSettings() {
'bg-gray-500'
}`} />
<span className="text-[0.65rem] text-gray-300 font-medium truncate">{preset?.name || config.name}</span>
+ {config.managed && <span className="text-[0.5rem] px-1 py-0.5 rounded bg-purple-500/15 text-purple-300 shrink-0">DEFAULT</span>}
{config.isLocal && <span className="text-[0.5rem] px-1 py-0.5 rounded bg-green-500/10 text-green-400 shrink-0">LOCAL</span>}
{!config.isLocal && <span className="text-[0.5rem] px-1 py-0.5 rounded bg-blue-500/10 text-blue-400 shrink-0">CLOUD</span>}
{status === 'connected' && <Wifi size={8} className="text-green-400 shrink-0" />}