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): P3a — onboarding defaults to the built-in engine

purple71f0fe33d56b
diff --git a/src/components/onboarding/Onboarding.tsx b/src/components/onboarding/Onboarding.tsx
index 0b6256ed..2d47a005 100644
--- a/src/components/onboarding/Onboarding.tsx
+++ b/src/components/onboarding/Onboarding.tsx
@@ -1,6 +1,6 @@
import { useState, useEffect } from 'react'
import { motion, AnimatePresence } from 'framer-motion'
-import { Minus, Square, X as XIcon, ArrowRight, Download, Check, ChevronRight, Loader2, RefreshCw, ExternalLink, FolderOpen } from 'lucide-react'
+import { Minus, Square, X as XIcon, ArrowRight, Download, Check, ChevronRight, Loader2, RefreshCw, ExternalLink, FolderOpen, Cpu } from 'lucide-react'
import { useSettingsStore } from '../../stores/settingsStore'
import { useProviderStore } from '../../stores/providerStore'
import { ONBOARDING_MODELS } from '../../lib/constants'
@@ -15,6 +15,8 @@ import { backendCall } from '../../api/backend'
import { getSystemVRAM } from '../../api/comfyui'
import { pullModelTauri, checkConnection as checkOllama } from '../../api/ollama'
import { hfUrlToOllamaRef, hfUrlToLmStudioSubdir } from '../../lib/hf-to-provider'
+import { startBundledEngine } from '../../api/engine'
+import { BUILTIN_BACKEND_ID, classifyOnboardingBackend, resolveOnboardingBackend } from '../../lib/onboarding-backend'
// Bug (h): the dedicated 'theme' onboarding step was removed because users
// kept ending up on Light by accident, and the project standard is "dark
@@ -65,7 +67,9 @@ export function Onboarding() {
const [downloadError, setDownloadError] = useState<string | null>(null)
const [detectedBackends, setDetectedBackends] = useState<DetectedBackend[]>([])
const [detecting, setDetecting] = useState(false)
- const [selectedBackend, setSelectedBackend] = useState<string>('')
+ // 2.5.7: the built-in engine is the pre-selected default — a fresh install
+ // needs nothing installed. Detected Ollama/LM Studio are offered as Advanced.
+ const [selectedBackend, setSelectedBackend] = useState<string>(BUILTIN_BACKEND_ID)
const { setProviderConfig } = useProviderStore()
// ComfyUI step state. `comfyFound.complete` distinguishes a working
@@ -174,6 +178,18 @@ export function Onboarding() {
)
}
+ // Resolve once the download store reports the file finished (or errored).
+ // Used by the built-in engine path, which must not boot llama-server until
+ // the GGUF is fully on disk. Polls the same store the progress UI renders.
+ const awaitDownloadComplete = (filename: string) =>
+ new Promise<void>((resolve, reject) => {
+ const poll = setInterval(() => {
+ const d = useDownloadStore.getState().downloads[filename]
+ if (d?.status === 'complete') { clearInterval(poll); resolve() }
+ else if (d?.status === 'error') { clearInterval(poll); reject(new Error(d.error || 'Download failed')) }
+ }, 500)
+ })
+
const handleDownloadSelected = async () => {
setDownloadError(null)
const providers = useProviderStore.getState().providers
@@ -185,8 +201,10 @@ export function Onboarding() {
// .gguf into `~/.ollama/models` regardless — Ollama ignores files placed
// there directly, which is the root cause of the "downloaded model
// never appears" bug reported on Discord and GH discussion #35.
- const targetBackend = selectedBackend || (ollamaReady ? 'ollama' : detectedBackends[0]?.id) || 'ollama'
- const useOllamaPath = targetBackend === 'ollama'
+ const targetBackend = resolveOnboardingBackend(selectedBackend, ollamaReady, detectedBackends)
+ const kind = classifyOnboardingBackend(targetBackend)
+ const useBuiltinPath = kind === 'builtin'
+ const useOllamaPath = kind === 'ollama'
// Sanity-check / auto-start Ollama before pulling. The pull command will
// otherwise spin in "connecting" with no actionable error if the daemon
@@ -206,9 +224,18 @@ export function Onboarding() {
}
}
- // Direct-write providers (LM Studio etc.) still need a base dir.
+ // Direct-write providers (built-in engine, LM Studio etc.) need a base dir.
+ // The built-in engine has a dedicated, app-owned models dir resolved by the
+ // Rust side (detect_model_path("builtin")); other OpenAI-compat providers
+ // reuse the LM-Studio-style detection / user override.
let destDir: string | null = null
- if (!useOllamaPath) {
+ if (useBuiltinPath) {
+ destDir = await detectProviderModelPath(BUILTIN_BACKEND_ID)
+ if (!destDir) {
+ setDownloadError('Could not create the built-in engine model folder. Check app permissions and retry.')
+ return
+ }
+ } else if (!useOllamaPath) {
const settingsOverride = useSettingsStore.getState().settings.hfDownloadPathOverride?.trim() || ''
destDir = settingsOverride || hfModelPath || (await detectProviderModelPath(providers.openai?.name || 'LM Studio'))
if (!destDir) {
@@ -272,6 +299,22 @@ export function Onboarding() {
// Mark complete in case the final progress event didn't include
// a "success" status string (Ollama varies between versions).
useDownloadStore.getState().markComplete(model.filename)
+ } else if (useBuiltinPath) {
+ // Built-in engine: write the GGUF flat into the app models dir, wait
+ // for it to finish, then boot llama-server on it. Unlike LM Studio
+ // there's no <user>/<repo> nesting — list_bundled_models scans the
+ // dir directly. We await completion here (not fire-and-forget) so the
+ // engine starts on a fully-downloaded file and the first chat works.
+ dlStore.getState().setMeta(model.filename, model.downloadUrl, 'gguf', destDir!)
+ const expectedBytes = model.sizeGB ? Math.round(model.sizeGB * 1_073_741_824) : undefined
+ await startModelDownloadToPath(model.downloadUrl, destDir!, model.filename, expectedBytes)
+ dlStore.getState().startPolling()
+ await awaitDownloadComplete(model.filename)
+ try {
+ await startBundledEngine(`${destDir}/${model.filename}`)
+ } catch (e) {
+ setDownloadError(`Model downloaded, but the built-in engine failed to start: ${e instanceof Error ? e.message : String(e)}`)
+ }
} else {
// LM Studio etc.: nest under <user>/<repo>/ so the scanner finds
// it. A bare .gguf in the model root is silently ignored by LM
@@ -301,6 +344,32 @@ export function Onboarding() {
if (isTauri) backendCall('set_onboarding_done').catch(() => {})
}
+ // Commit the chosen backend to the provider store and advance to ComfyUI.
+ // Built-in (default) reasserts the managed OpenAI-slot config; a detected
+ // Ollama takes over the primary slot (managed built-in disabled) so there
+ // aren't two defaults; other OpenAI-compat backends fill the openai slot.
+ const selectBackendAndContinue = () => {
+ if (selectedBackend === BUILTIN_BACKEND_ID) {
+ setProviderConfig('openai', {
+ enabled: true, name: 'Built-in Engine',
+ baseUrl: 'http://127.0.0.1:8127/v1', isLocal: true, managed: true,
+ })
+ } else if (selectedBackend === 'ollama') {
+ setProviderConfig('ollama', { enabled: true })
+ setProviderConfig('openai', { enabled: false, managed: false })
+ } else {
+ const backend = detectedBackends.find(b => b.id === selectedBackend)
+ const preset = backend && PROVIDER_PRESETS.find(p => p.id === backend.id)
+ if (backend && preset && preset.providerId !== 'ollama') {
+ setProviderConfig('openai', {
+ enabled: true, name: backend.name, baseUrl: backend.baseUrl,
+ isLocal: true, managed: false,
+ })
+ }
+ }
+ setStep('comfyui')
+ }
+
/* ── Scan for backends ──────────────────────────────────── */
const runDetection = async () => {
setDetecting(true)
@@ -679,9 +748,49 @@ export function Onboarding() {
Checking {LOCAL_BACKENDS.length} backends on their default ports.
</p>
</>
- ) : detectedBackends.length > 0 ? (
- /* ── Backends found ──────────────────────────────── */
+ ) : (
<>
+ {/* Built-in engine — the 2.5.7 default. Runs locally, nothing to
+ install. Detected/installable external engines move under the
+ Advanced disclosure below (kept, just no longer required). */}
+ <h2 className="text-base font-semibold">Ready to chat</h2>
+ <p className={`text-[0.7rem] ${isDark ? 'text-gray-400' : 'text-gray-500'}`}>
+ Locally Uncensored runs its own engine on your machine — nothing to install. Pick a starter model next.
+ </p>
+
+ <button
+ onClick={() => setSelectedBackend(BUILTIN_BACKEND_ID)}
+ className={`w-full flex items-center gap-2.5 px-2.5 py-2.5 rounded-lg border text-left transition-all ${
+ selectedBackend === BUILTIN_BACKEND_ID
+ ? isDark ? 'bg-white/10 border-white/20' : 'bg-gray-100 border-gray-900'
+ : isDark ? 'border-white/10 hover:border-white/20' : 'border-gray-200 hover:border-gray-400'
+ }`}
+ >
+ <Cpu size={16} className={selectedBackend === BUILTIN_BACKEND_ID ? (isDark ? 'text-white' : 'text-gray-900') : 'text-gray-500'} />
+ <div className="flex-1 min-w-0">
+ <p className="text-[0.72rem] font-medium">Built-in Engine</p>
+ <p className={`text-[0.55rem] ${isDark ? 'text-gray-500' : 'text-gray-400'}`}>Runs on your machine · nothing to install</p>
+ </div>
+ {selectedBackend === BUILTIN_BACKEND_ID && <Check size={14} className="text-green-400 shrink-0" />}
+ </button>
+
+ <div className="flex items-center justify-center gap-2 pt-1">
+ <button onClick={selectBackendAndContinue} className={primaryBtn}>
+ Continue <ArrowRight size={14} />
+ </button>
+ </div>
+
+ {/* Advanced: connect to a detected engine or install another one.
+ All the existing Ollama/LM-Studio detection + install UI lives
+ here now — available, but off the critical path. */}
+ <details className="text-left pt-1">
+ <summary className={`text-[0.6rem] cursor-pointer hover:underline text-center list-none ${isDark ? 'text-gray-500 hover:text-gray-300' : 'text-gray-400 hover:text-gray-600'}`}>
+ Use another engine (Ollama, LM Studio…)
+ </summary>
+ <div className="mt-3 space-y-4 text-center">
+ {detectedBackends.length > 0 ? (
+ /* ── Backends found ──────────────────────────────── */
+ <>
<h2 className="text-base font-semibold">
{detectedBackends.length} backend{detectedBackends.length > 1 ? 's' : ''} detected
</h2>
@@ -718,22 +827,7 @@ export function Onboarding() {
<RefreshCw size={12} /> Re-Scan
</button>
<button
- onClick={() => {
- const backend = detectedBackends.find(b => b.id === selectedBackend)
- if (backend) {
- const preset = PROVIDER_PRESETS.find(p => p.id === backend.id)
- if (preset && preset.providerId !== 'ollama') {
- setProviderConfig('openai', {
- enabled: true,
- name: backend.name,
- baseUrl: backend.baseUrl,
- isLocal: true,
- })
- }
- }
- // Go to ComfyUI step next
- setStep('comfyui')
- }}
+ onClick={selectBackendAndContinue}
className={primaryBtn}
>
Continue <ArrowRight size={14} />
@@ -1040,6 +1134,10 @@ export function Onboarding() {
)}
</div>
</>
+ )}
+ </div>
+ </details>
+ </>
)}
</motion.div>
)}
@@ -1628,6 +1726,8 @@ export function Onboarding() {
<p className={`text-[0.75rem] ${isDark ? 'text-gray-400' : 'text-gray-500'}`}>
{pulledModels.length > 0
? `${pulledModels.length} model${pulledModels.length > 1 ? 's' : ''} installed. You're ready to go.`
+ : selectedBackend === BUILTIN_BACKEND_ID
+ ? 'The built-in engine is ready. Install a model anytime from Model Manager.'
: detectedBackends.length > 0
? `Connected to ${detectedBackends.find(b => b.id === selectedBackend)?.name || detectedBackends[0].name}. You're ready to go.`
: 'You can configure backends and install models anytime from Settings and Model Manager.'}
diff --git a/src/lib/__tests__/onboarding-backend.test.ts b/src/lib/__tests__/onboarding-backend.test.ts
new file mode 100644
index 00000000..8f6dbec4
--- /dev/null
+++ b/src/lib/__tests__/onboarding-backend.test.ts
@@ -0,0 +1,41 @@
+import { describe, it, expect } from 'vitest'
+import {
+ BUILTIN_BACKEND_ID,
+ classifyOnboardingBackend,
+ resolveOnboardingBackend,
+} from '../onboarding-backend'
+
+describe('resolveOnboardingBackend', () => {
+ it('honours an explicit selection (built-in default)', () => {
+ expect(resolveOnboardingBackend(BUILTIN_BACKEND_ID, false, [])).toBe('builtin')
+ expect(resolveOnboardingBackend('lmstudio', true, [{ id: 'ollama' }])).toBe('lmstudio')
+ })
+
+ it('falls back to ollama when it was just installed in-app', () => {
+ expect(resolveOnboardingBackend('', true, [])).toBe('ollama')
+ })
+
+ it('falls back to the first detected backend when nothing is selected', () => {
+ expect(resolveOnboardingBackend('', false, [{ id: 'jan' }, { id: 'vllm' }])).toBe('jan')
+ })
+
+ it('defaults to the built-in engine when there is nothing else', () => {
+ expect(resolveOnboardingBackend('', false, [])).toBe(BUILTIN_BACKEND_ID)
+ })
+})
+
+describe('classifyOnboardingBackend', () => {
+ it('routes the built-in engine to its own path', () => {
+ expect(classifyOnboardingBackend('builtin')).toBe('builtin')
+ })
+
+ it('routes ollama to the pull path', () => {
+ expect(classifyOnboardingBackend('ollama')).toBe('ollama')
+ })
+
+ it('routes every other backend to the OpenAI-compat direct-write path', () => {
+ for (const id of ['lmstudio', 'vllm', 'jan', 'koboldcpp', 'localai']) {
+ expect(classifyOnboardingBackend(id)).toBe('openai-compat')
+ }
+ })
+})
diff --git a/src/lib/onboarding-backend.ts b/src/lib/onboarding-backend.ts
new file mode 100644
index 00000000..ad5bf122
--- /dev/null
+++ b/src/lib/onboarding-backend.ts
@@ -0,0 +1,38 @@
+/**
+ * Onboarding backend routing (2.5.7).
+ *
+ * The built-in engine (bundled llama-server, managed lifecycle) is the default
+ * backend a fresh install downloads its starter model into. A user who picked a
+ * detected backend on the backends step — or who just installed Ollama in-app —
+ * overrides that. These pure helpers decide which download/lifecycle path the
+ * models step must take, kept out of the component so they can be unit-tested.
+ */
+
+export const BUILTIN_BACKEND_ID = 'builtin'
+
+export type OnboardingBackendKind = 'builtin' | 'ollama' | 'openai-compat'
+
+/**
+ * Resolve which backend id the model download must feed. `selectedBackend` (set
+ * on the backends step, defaults to the built-in engine) wins; the ollamaReady /
+ * first-detected fallbacks only matter if it was somehow cleared.
+ */
+export function resolveOnboardingBackend(
+ selectedBackend: string,
+ ollamaReady: boolean,
+ detectedBackends: { id: string }[],
+): string {
+ return selectedBackend || (ollamaReady ? 'ollama' : detectedBackends[0]?.id) || BUILTIN_BACKEND_ID
+}
+
+/**
+ * Classify a backend id into the download/lifecycle path it needs:
+ * - `builtin` → GGUF into the app models dir, then start the bundled engine.
+ * - `ollama` → `ollama pull` (blob/manifest store).
+ * - `openai-compat`→ GGUF written into the provider's model dir (LM Studio etc.).
+ */
+export function classifyOnboardingBackend(backendId: string): OnboardingBackendKind {
+ if (backendId === BUILTIN_BACKEND_ID) return 'builtin'
+ if (backendId === 'ollama') return 'ollama'
+ return 'openai-compat'
+}