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.
TypeScript agentai-chatai-studioall-in-onecoding-agentdesktop-appfluximage-generationlinuxllmlocal-ailocal-llmopen-sourceprivacyself-hostedstable-diffusionuncensoreduncensored-aivideo-generationwindows
fix(models): ein geladenes Modell wird das aktive, und der Motor startet dafuer nur einmal
David7a2d48a28543
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0f3208f4..e2371343 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -210,7 +210,16 @@ and the built-in engine has a name of its own, the LU Engine.as researched rather than proven, because no such reservation could be stagedhere.- **A chat model you downloaded stays visible as Installed** even while the- engine is not running.+ engine is not running, and it becomes the active chat model the moment the+ download is done. Measured on the Windows box on 2026-09-05: the download+ started the engine on the new file, but the picker still named the previous+ model, so the first message would have swapped the engine straight back,+ and a Use click restarted the engine on the same file because the path the+ frontend had glued together did not match the one the engine lists. The+ download now goes through the picker's own activation, so the path comes+ from the model list, the picker follows, and the engine starts once. The+ Installed search also answers to catalogue spelling now, so "Llama 3.2 3B+ Abliterated" finds Llama-3.2-3B-Instruct-abliterated.Q4_K_M.- **A running LM Studio stays in the model picker** after the chat has moved tothe LU Engine. Its models keep their own heading, and picking one hands thelocal slot back to LM Studio with a line that says so. The way back is onediff --git a/src/components/models/DiscoverModels.tsx b/src/components/models/DiscoverModels.tsxindex a5ea82fb..f5ce8ea7 100644--- a/src/components/models/DiscoverModels.tsx+++ b/src/components/models/DiscoverModels.tsx@@ -23,7 +23,7 @@ import { useSettingsStore } from '../../stores/settingsStore'import { useModelStore } from '../../stores/modelStore'import { useWorkflowStore } from '../../stores/workflowStore'import { getProviderIdFromModel } from '../../api/providers'-import { startBundledEngine } from '../../api/engine'+import { activateDownloadedBundledModel } from '../../lib/bundled-download-activation'import { diagnoseBuiltinEngine } from '../../api/builtin-ensure'import type { InstalledModelLike } from '../../lib/lmstudio-match'import { findInstalledForDiscoverModel } from '../../lib/discover-installed'@@ -788,8 +788,8 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:}dlStore.getState().startPolling()if (isActiveBuiltin) {- // Built-in engine: await the flat GGUF, then (re)boot llama-server on- // it so the freshly-added model is chat-ready without a manual switch.+ // Built-in engine: await the flat GGUF, then make it the active chat+ // model so the freshly-added model is chat-ready without a manual switch.// The projector is awaited too: booting before it lands would bring the// model up text-only and the image button would lie.//@@ -814,8 +814,13 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:}return}+ // The downloaded file becomes the active chat model through the+ // picker's own activation (lib/bundled-download-activation): the+ // engine path comes from the model list, the picker follows, and the+ // first message goes to the model the user just fetched instead of+ // swapping the engine back to the previous one.try {- await startBundledEngine(`${targetDir}/${realName}`)+ await activateDownloadedBundledModel({ filename: realName, refresh: fetchModels, activate: setActiveModel })} catch (e) {setInstallError(`Model downloaded, but the LU Engine failed to start: ${e instanceof Error ? e.message : String(e)}`)}diff --git a/src/components/models/ModelManager.tsx b/src/components/models/ModelManager.tsxindex 33bffcc1..08d268eb 100644--- a/src/components/models/ModelManager.tsx+++ b/src/components/models/ModelManager.tsx@@ -23,6 +23,7 @@ import { customModelDirs } from '../../api/engine'import { counterView } from '../../lib/inventory-counter'import { groupInstalledByProvider, needsBackendSwitchHeading, foldedRowsSentence, LU_ENGINE_GROUP } from '../../lib/lu-engine-rows'import { isBuiltinEngineEntry } from '../../lib/lmstudio-match'+import { installedRowMatchesSearch } from '../../lib/model-search'import { useBuiltinEngineStatus, engineIsIdle } from '../../hooks/useBuiltinEngineStatus'import { LuEngineSwitchBar } from '../chat/LuEngineSwitchBar'import type { InstalledModelLike } from '../../lib/lmstudio-match'@@ -411,7 +412,7 @@ export function ModelManager() {(() => {const SectionIcon = modeMeta.iconconst shown = searchQuery- ? filteredModels.filter(m => m.name.toLowerCase().includes(searchQuery.toLowerCase()))+ ? filteredModels.filter(m => installedRowMatchesSearch(m.name, searchQuery)): filteredModelsreturn (<section className="space-y-1.5">diff --git a/src/components/onboarding/ModelsStep.tsx b/src/components/onboarding/ModelsStep.tsxindex c4232038..bd53f986 100644--- a/src/components/onboarding/ModelsStep.tsx+++ b/src/components/onboarding/ModelsStep.tsx@@ -38,7 +38,9 @@ import { useModelStore } from '../../stores/modelStore'import { detectProviderModelPath, startModelDownloadToPath, luEngineDownloadDir } from '../../api/discover'import { hfUrlToOllamaRef, hfUrlToLmStudioSubdir } from '../../lib/hf-to-provider'import { pullModelTauri, checkConnection as checkOllama } from '../../api/ollama'-import { startBundledEngine } from '../../api/engine'+import { activateBuiltinModel } from '../../api/engine'+import { builtinModelNameFromPath } from '../../lib/builtin-model-identity'+import { bundledPickerIdForFile } from '../../lib/bundled-download-activation'import { backendCall } from '../../api/backend'import { getSystemVRAM } from '../../api/comfyui'import { classifyOnboardingBackend, resolveOnboardingBackend } from '../../lib/onboarding-backend'@@ -209,7 +211,7 @@ export function ModelsStep({ skin, scan, fleet, step, setStep, pulledModels, setuseDownloadStore.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+ // for it to finish, then make it the active model. 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.@@ -218,8 +220,13 @@ export function ModelsStep({ skin, scan, fleet, step, setStep, pulledModels, setawait startModelDownloadToPath(model.downloadUrl, destDir!, model.filename, expectedBytes)dlStore.getState().startPolling()await awaitDownloadComplete(model.filename)+ // Same door as the Models page (lib/bundled-download-activation):+ // the engine path comes from the model list, not from a string glued+ // together here, and the downloaded model is the one the chat uses.try {- await startBundledEngine(`${destDir}/${model.filename}`)+ const found = await activateBuiltinModel(builtinModelNameFromPath(model.filename))+ if (!found) setDownloadError(`Model downloaded, but the LU Engine did not find ${model.filename} in its model folder.`)+ else setActiveModel(bundledPickerIdForFile(model.filename))} catch (e) {setDownloadError(`Model downloaded, but the LU Engine failed to start: ${e instanceof Error ? e.message : String(e)}`)}diff --git a/src/lib/__tests__/bundled-download-activation.test.ts b/src/lib/__tests__/bundled-download-activation.test.tsnew file mode 100644index 00000000..165c7cc9--- /dev/null+++ b/src/lib/__tests__/bundled-download-activation.test.ts@@ -0,0 +1,64 @@+/**+ * A downloaded GGUF becomes the active chat model, through the picker.+ *+ * Measured on the Windows box, 2026-09-05, build 4070cd91: after the download+ * of Llama-3.2-3B-Instruct-abliterated.Q4_K_M.gguf the engine ran on+ * C:\...\models/Llama-3.2-3B-Instruct-abliterated.Q4_K_M.gguf+ * while list_bundled_models listed+ * C:\...\models\Llama-3.2-3B-Instruct-abliterated.Q4_K_M.gguf+ * so `loaded` stayed false, the picker still named the previous model, and+ * the Use click restarted the engine on the same file (PID 36576 -> 30264).+ *+ * Run: npx vitest run src/lib/__tests__/bundled-download-activation.test.ts+ */+import { describe, it, expect, vi } from 'vitest'+import { readFileSync } from 'node:fs'+import { resolve, dirname } from 'node:path'+import { fileURLToPath } from 'node:url'+import { activateDownloadedBundledModel, bundledPickerIdForFile } from '../bundled-download-activation'++const root = resolve(dirname(fileURLToPath(import.meta.url)), '../../..')+const read = (rel: string) => readFileSync(resolve(root, rel), 'utf8')++describe('the picker id of a downloaded file', () => {+ it('is the file stem behind the LU Engine prefix, exactly as list_bundled_models names it', () => {+ expect(bundledPickerIdForFile('Llama-3.2-3B-Instruct-abliterated.Q4_K_M.gguf'))+ .toBe('openai::Llama-3.2-3B-Instruct-abliterated.Q4_K_M')+ })+ it('never carries a folder, whichever separator a caller glued on', () => {+ expect(bundledPickerIdForFile('C:\\Users\\x\\models/orcarouter_Qwen3.8-27B-Uncensored-IQ2_M.gguf'))+ .toBe('openai::orcarouter_Qwen3.8-27B-Uncensored-IQ2_M')+ })+})++describe('activating the model the user just downloaded', () => {+ it('refreshes the list first and then asks the picker for the id, never for a path', async () => {+ const order: string[] = []+ const refresh = vi.fn(async () => { order.push('refresh') })+ const activate = vi.fn(async (id: string) => { order.push(`activate:${id}`) })+ const id = await activateDownloadedBundledModel({+ filename: 'Llama-3.2-3B-Instruct-abliterated.Q4_K_M.gguf', refresh, activate,+ })+ expect(id).toBe('openai::Llama-3.2-3B-Instruct-abliterated.Q4_K_M')+ expect(order).toEqual(['refresh', 'activate:openai::Llama-3.2-3B-Instruct-abliterated.Q4_K_M'])+ expect(activate.mock.calls[0][0]).not.toMatch(/[\\/]/)+ })+ it('lets a failed activation reach the caller, who owns the error line', async () => {+ await expect(activateDownloadedBundledModel({+ filename: 'x.gguf', refresh: async () => undefined, activate: async () => { throw new Error('engine died') },+ })).rejects.toThrow('engine died')+ })+})++describe('no component starts the engine on a path it glued together itself', () => {+ // NEGATIVE CONTROL for the measured fault: the two download paths used to+ // call startBundledEngine(`${dir}/${file}`). Either coming back is the bug.+ for (const rel of ['src/components/models/DiscoverModels.tsx', 'src/components/onboarding/ModelsStep.tsx']) {+ it(`${rel} goes through the picker`, () => {+ const src = read(rel)+ expect(src, 'a hand-built engine path').not.toMatch(/startBundledEngine\(`\$\{/)+ expect(src, 'the engine started outside the picker').not.toContain('startBundledEngine(')+ expect(src).toContain('bundled-download-activation')+ })+ }+})diff --git a/src/lib/__tests__/model-search.test.ts b/src/lib/__tests__/model-search.test.tsnew file mode 100644index 00000000..98bed554--- /dev/null+++ b/src/lib/__tests__/model-search.test.ts@@ -0,0 +1,33 @@+/**+ * The Installed search answers to catalogue spelling.+ *+ * Measured 2026-09-05: "Llama 3.2 3B Abliterated" found the catalogue tile and+ * then, on the Installed tab, matched nothing although+ * openai::Llama-3.2-3B-Instruct-abliterated.Q4_K_M was installed.+ *+ * Run: npx vitest run src/lib/__tests__/model-search.test.ts+ */+import { describe, it, expect } from 'vitest'+import { installedRowMatchesSearch } from '../model-search'++const ROW = 'openai::Llama-3.2-3B-Instruct-abliterated.Q4_K_M'++describe('installedRowMatchesSearch', () => {+ it('matches the catalogue name of the file that was just downloaded (the measured case)', () => {+ expect(installedRowMatchesSearch(ROW, 'Llama 3.2 3B Abliterated')).toBe(true)+ })+ it('still matches a plain substring of the row id', () => {+ expect(installedRowMatchesSearch(ROW, 'abliterated.Q4')).toBe(true)+ })+ it('takes the words in any order and any case', () => {+ expect(installedRowMatchesSearch(ROW, 'ABLITERATED llama')).toBe(true)+ })+ it('does not match a word the row does not carry', () => {+ expect(installedRowMatchesSearch(ROW, 'Llama 3.2 3B Heretic')).toBe(false)+ expect(installedRowMatchesSearch(ROW, 'Gemma')).toBe(false)+ })+ it('an empty search matches everything', () => {+ expect(installedRowMatchesSearch(ROW, '')).toBe(true)+ expect(installedRowMatchesSearch(ROW, ' ')).toBe(true)+ })+})diff --git a/src/lib/bundled-download-activation.ts b/src/lib/bundled-download-activation.tsnew file mode 100644index 00000000..162774fc--- /dev/null+++ b/src/lib/bundled-download-activation.ts@@ -0,0 +1,50 @@+/**+ * What happens to a GGUF the moment its download is complete.+ *+ * Measured on the Windows box, 2026-09-05 (build 4070cd91): the download+ * started the LU Engine on the new file, and nothing else followed. The+ * picker still named the previous model, the Installed tab still marked it+ * ACTIVE, `list_bundled_models` said `loaded: false` for every row, and the+ * first Use click tore the engine down and started it again on the very same+ * file. A first chat message would have done the same, because the send path+ * activates whatever the picker holds, and the picker held the old model.+ *+ * Two causes, one door. The engine was started with a path the frontend had+ * glued together (`${dir}/${file}`, a forward slash inside a Windows path), so+ * the argv never matched the path Rust lists and every later activation+ * counted as a change. And the picker was never told. Going through the+ * picker's own activation instead fixes both: the path comes from the model+ * list, and the model the user just downloaded is the model the chat uses.+ *+ * This module is the rule; the components call it. It is a .ts file so the+ * test below actually runs (vitest collects src/**\/__tests__/**\/*.test.ts).+ */+import { prefixModelName } from '../api/providers/model-name'+import { builtinModelNameFromPath } from './builtin-model-identity'++/** The picker id an LU Engine row gets for this file: `openai::<stem>`. */+export function bundledPickerIdForFile(filename: string): string {+ return prefixModelName('openai', builtinModelNameFromPath(filename))+}++export interface DownloadedModelActivation {+ /** The file that just finished, as it lies in the LU Engine folder. */+ filename: string+ /** Re-reads the model list so the new row exists before it is picked. */+ refresh: () => Promise<unknown>+ /** The picker's own activation: sets the active model and swaps the engine. */+ activate: (pickerId: string) => Promise<unknown>+}++/**+ * Make the downloaded file the active chat model, through the picker's+ * activation and never through a hand-built path. The refresh comes first:+ * a row that is not in the list yet cannot be picked, and the engine path is+ * read from that list.+ */+export async function activateDownloadedBundledModel(a: DownloadedModelActivation): Promise<string> {+ const id = bundledPickerIdForFile(a.filename)+ await a.refresh()+ await a.activate(id)+ return id+}diff --git a/src/lib/model-search.ts b/src/lib/model-search.tsnew file mode 100644index 00000000..1a8a6f75--- /dev/null+++ b/src/lib/model-search.ts@@ -0,0 +1,25 @@+/**+ * Does an installed row answer a search typed against the catalogue?+ *+ * Measured 2026-09-05 on the Windows box: the search text "Llama 3.2 3B+ * Abliterated" found the catalogue tile under Get new and then, with the same+ * text still in the box, the Installed tab said no installed chat model+ * matched, while the file `Llama-3.2-3B-Instruct-abliterated.Q4_K_M` sat+ * right there. The row was matched on its picker id, which spells the model+ * the way the file does, not the way the catalogue does.+ *+ * The rule: every word of the query has to appear in the row id once both+ * are reduced to letters and digits. "3.2" becomes "32", "Llama-3.2-3B" becomes+ * "llama323b", and the words may come in any order. A plain substring of the+ * id still matches as before.+ */+const bare = (s: string) => s.toLowerCase().replace(/[^a-z0-9]+/g, '')++export function installedRowMatchesSearch(rowId: string, query: string): boolean {+ const q = query.trim().toLowerCase()+ if (!q) return true+ if (rowId.toLowerCase().includes(q)) return true+ const id = bare(rowId)+ const words = q.split(/\s+/).map(bare).filter(Boolean)+ return words.length > 0 && words.every((w) => id.includes(w))+}diff --git a/src/lib/release-notes.ts b/src/lib/release-notes.tsindex a0b63044..70681ee6 100644--- a/src/lib/release-notes.ts+++ b/src/lib/release-notes.ts@@ -73,7 +73,7 @@ export const RELEASE_NOTES: ReleaseNote[] = [items: ['The built-in engine goes by LU Engine now. It is the same engine with the same models in the same folder; only the name in Settings, in the model list and in the messages changed.','The LU Engine moves to a free port when 8127 is taken or reserved by the system, and after a start that fails it retries once instead of giving up until the next restart. The next start begins at 8127 again rather than staying on the port it had to move to. Windows port reservations are marked as researched rather than proven, because no such reservation could be staged here.',- 'A chat model you downloaded stays visible as Installed even while the engine is not running, and its tile has a Use button that starts the engine and loads that model, rather than leaving you with a file you cannot reach.',+ 'A chat model you downloaded stays visible as Installed even while the engine is not running, and its tile has a Use button that starts the engine and loads that model, rather than leaving you with a file you cannot reach. The model you just downloaded also becomes the active chat model, so the first message goes to it instead of swapping the engine back to the previous one, and the engine starts on it once rather than twice.','A running LM Studio stays in the model picker after the chat has moved to the LU Engine. Its models keep their own heading in the list, and picking one hands the local slot back to LM Studio, with a line that says so. The way back is one click, the same as the way out.','A click on a file the LU Engine cannot open no longer costs you the engine that is running. The first bytes of the file are read before anything is stopped, and a file without the GGUF mark is named and left alone instead of taking down a healthy engine for two failed attempts.','The uncensored Qwen 3.8 27B rows come from OrcaRouter\'s abliteration now, bartowski\'s ungated GGUF requant with the vision projector, and Ollama gets OrcaRouter\'s own tag. A gated Hugging Face repo used to end in "trying again cannot help"; the download now says that the repo needs an accepted licence and a Hugging Face token, and names the field: Settings, AI Backends, Hugging Face token. The field exists on Windows and Linux now, and the token goes to huggingface.co with every model download.',