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(engine): a group speaker from the Model Storage folder gets the engine
purple981c12c84f7e
diff --git a/src/api/__tests__/a-speaker-from-the-model-folder-gets-the-engine.test.ts b/src/api/__tests__/a-speaker-from-the-model-folder-gets-the-engine.test.tsnew file mode 100644index 00000000..feba9017--- /dev/null+++ b/src/api/__tests__/a-speaker-from-the-model-folder-gets-the-engine.test.ts@@ -0,0 +1,54 @@+/**+ * Discord 2026-10-01 (samvenice, 3.0.3, RTX 4090 24 GB): a group chat of+ * two LU Engine models answered with whichever one was loaded. The other+ * speaker got "The LU Engine has X loaded, but this request asked for Y".+ * Both models sat in the folder named under Settings, Model Storage. The+ * picker lists that folder, the swap lookup did not, so the swap called a+ * model the picker had just offered a missing file.+ *+ * Run: npx vitest run src/api/__tests__/a-speaker-from-the-model-folder-gets-the-engine.test.ts+ */+import { describe, it, expect, vi, beforeEach } from 'vitest'++vi.mock('../../stores/providerStore', () => ({+ useProviderStore: {+ getState: () => ({ providers: { openai: { enabled: true, managed: true } } }),+ },+}))++const MY_FOLDER = 'D:\\LLM'+vi.mock('../../stores/settingsStore', () => ({+ useSettingsStore: {+ getState: () => ({ settings: { builtinEngine: { ctx: 16384 }, hfDownloadPathOverride: MY_FOLDER } }),+ },+}))++const backendCall = vi.fn()+vi.mock('../backend', () => ({+ backendCall: (...args: unknown[]) => backendCall(...args),+}))++import { ensureBuiltinEngineAlive } from '../builtin-ensure'++const QWEN = { name: 'Qwen2.5-14B-Instruct-abliterated.Q4_K_M', path: 'D:\\LLM\\Qwen2.5-14B-Instruct-abliterated.Q4_K_M.gguf' }+const ROCINANTE = { name: 'Rocinante-XL-16B-v1a-Q4_K_M', path: 'D:\\LLM\\Rocinante-XL-16B-v1a-Q4_K_M.gguf' }++beforeEach(() => {+ backendCall.mockReset()+ backendCall.mockImplementation(async (cmd: string, args?: { extraDirs?: string[] }) => {+ if (cmd === 'bundled_engine_status') return { running: true, healthy: true, model_path: QWEN.path }+ // Rust walks the extra folders only when it is told about them.+ if (cmd === 'list_bundled_models') return { models: args?.extraDirs?.includes(MY_FOLDER) ? [QWEN, ROCINANTE] : [] }+ if (cmd === 'swap_bundled_model') return { status: 'started', port: 8127 }+ throw new Error(`unexpected command ${cmd}`)+ })+})++describe('a group speaker whose model lives in the Model Storage folder', () => {+ it('gets the engine swapped to its model instead of a mismatch error', async () => {+ await expect(ensureBuiltinEngineAlive('openai::Rocinante-XL-16B-v1a-Q4_K_M')).resolves.toBeUndefined()+ const swaps = backendCall.mock.calls.filter((c) => c[0] === 'swap_bundled_model')+ expect(swaps).toHaveLength(1)+ expect((swaps[0][1] as { modelPath: string }).modelPath).toBe(ROCINANTE.path)+ })+})diff --git a/src/api/builtin-ensure.ts b/src/api/builtin-ensure.tsindex 4b65c366..272ab52a 100644--- a/src/api/builtin-ensure.ts+++ b/src/api/builtin-ensure.ts@@ -31,6 +31,7 @@ import {} from '../lib/builtin-model-identity'import { hostOf, isLocalTransportFailure } from '../lib/local-backend-transport'import { announceEngineCpuFallback } from '../lib/engine-offload'+import { customModelDirs } from '../lib/custom-model-dirs'interface EngineStatusLite {running: boolean@@ -52,6 +53,18 @@ interface BundledList {models?: Array<{ name: string; path: string; ctx_train?: number | null }>}+/** The GGUFs the engine can be started on: the app models dir AND the folder+ * named under Model Storage, exactly the set the picker lists.+ *+ * Discord 2026-10-01 (samvenice, 3.0.3, RTX 4090): a group chat of two models+ * from that folder answered with the loaded one only. The other speaker got+ * "The LU Engine has X loaded, but this request asked for Y", because the+ * lookup here walked the app dir alone, found no Y, and called a model the+ * picker had just offered a missing file. */+function listEngineModels(): Promise<BundledList> {+ return backendCall<BundledList>('list_bundled_models', { extraDirs: customModelDirs() })+}+/** What `start_bundled_engine` / `swap_bundled_model` answer. `port` is the* port the engine ACTUALLY came up on, which since GH #118 need not be the* preferred one. */@@ -254,7 +267,7 @@ async function loadBuiltinModel(modelName: string): Promise<void> {let models: Array<{ name: string; path: string; ctx_train?: number | null }>try {- const res = await backendCall<BundledList>('list_bundled_models')+ const res = await listEngineModels()models = res?.models ?? []} catch {return@@ -373,7 +386,7 @@ export async function ensureBuiltinAgentCtx(modelName: string): Promise<void> {let models: Array<{ name: string; path: string; ctx_train?: number | null }>try {- const res = await backendCall<BundledList>('list_bundled_models')+ const res = await listEngineModels()models = res?.models ?? []} catch {return@@ -482,7 +495,7 @@ export async function diagnoseBuiltinEngine(let models: Array<{ name: string; path: string }>try {- const res = await backendCall<BundledList>('list_bundled_models')+ const res = await listEngineModels()models = res?.models ?? []} catch (e) {return {diff --git a/src/api/engine.ts b/src/api/engine.tsindex 404b255f..55c782a8 100644--- a/src/api/engine.ts+++ b/src/api/engine.ts@@ -20,6 +20,7 @@ import { useSettingsStore } from '../stores/settingsStore'import type { CloudModel } from '../types/models'import type { BuiltinEngineTuning } from '../types/settings'import { LU_ENGINE_NAME } from '../lib/engine-name'+import { customModelDirs } from '../lib/custom-model-dirs'import { announceEngineCpuFallback } from '../lib/engine-offload'/** The user's Built-in Engine expert tuning (settings-backed). Injected into@@ -285,19 +286,7 @@ export async function bundledEmbedLaneReady(): Promise<boolean> {}}-/**- * Every folder the GGUF scan walks: the app models dir (Rust adds that one)- * plus the folder the user named under Settings → Model Storage.- *- * GH #122 (zrmdsxa, 2026-08-28): that setting was a download TARGET and- * nothing else. A GGUF already sitting in it was never looked at, so the- * Models tab stayed empty next to a folder full of models. Empty setting →- * empty list, which is exactly the shipped single-folder scan.- */-export function customModelDirs(): string[] {- const dir = useSettingsStore.getState().settings.hfDownloadPathOverride?.trim() || ''- return dir ? [dir] : []-}+export { customModelDirs }/** How one scanned folder fared. `truncated` is a real answer: the walk has a* wall-clock deadline and an entry budget per folder, because `fetchModels`diff --git a/src/lib/custom-model-dirs.ts b/src/lib/custom-model-dirs.tsnew file mode 100644index 00000000..ec26c70c--- /dev/null+++ b/src/lib/custom-model-dirs.ts@@ -0,0 +1,18 @@+import { useSettingsStore } from '../stores/settingsStore'++/**+ * Every folder the GGUF scan walks: the app models dir (Rust adds that one)+ * plus the folder the user named under Settings → Model Storage.+ *+ * GH #122 (zrmdsxa, 2026-08-28): that setting was a download TARGET and+ * nothing else. A GGUF already sitting in it was never looked at, so the+ * Models tab stayed empty next to a folder full of models. Empty setting →+ * empty list, which is exactly the shipped single-folder scan.+ *+ * Lives here rather than in `api/engine` so `api/builtin-ensure`, which+ * engine imports, can read the same folders without an import cycle.+ */+export function customModelDirs(): string[] {+ const dir = useSettingsStore.getState().settings.hfDownloadPathOverride?.trim() || ''+ return dir ? [dir] : []+}