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): der LAN-Zweig warf den ganzen Server-Katalog weg
purple797055f241e8
diff --git a/src/api/providers/openai-provider.ts b/src/api/providers/openai-provider.tsindex 69b0907a..feadde35 100644--- a/src/api/providers/openai-provider.ts+++ b/src/api/providers/openai-provider.ts@@ -774,19 +774,42 @@ export class OpenAIProvider implements ProviderClient {// (['tool_use', ...]); one fetch covers all models. Backends without// the enhanced API leave the map empty → optimistic as before.const { lanCaps, serverTools } = await this.liveToolCaps()- return Promise.all(models.map(async m => ({- id: m.id,- name: m.id,- provider: 'openai' as const,- providerName: this.config.name,- contextLength:- KNOWN_CONTEXT[m.id] ??- (await this.probeContextFromServer(m.id)) ??- guessContextFromName(m.id),- supportsTools: lanCaps.has(m.id)- ? lanCaps.get(m.id)!.includes('tool_use')- : (serverTools ?? m.supports_tools ?? true),- })))+ return Promise.all(models.map(async m => {+ // A catalogue answer is a catalogue answer wherever the server sits.+ // This branch used to keep ONLY the id and the tool flag, which was+ // fine while "LAN" meant LM Studio and llama.cpp, and wrong the moment+ // LU Cloud ran on localhost:3000: every model arrived with the raw id+ // for a name, no think mode (so the Think button rendered grey on a+ // model that always reasons), no vision flag and no effort ladder (so+ // the composer drew no effort control at all). Measured on the 2.6.8+ // Mac bundle, 2026-09-02.+ if (m.context_length && m.context_length > 0) {+ catalogContext.set(this.catalogKey(m.id), m.context_length)+ }+ return {+ id: m.id,+ name: m.name ?? m.id,+ provider: 'openai' as const,+ providerName: this.config.name,+ // The declared window comes BEFORE the probe: a server that already+ // answered the question in its listing must not be asked again per+ // model. That probe is what fired a GET /models/<id> at LU Cloud for+ // every entry, collected a 404 each time, and stretched one listing+ // to between eight and twenty-one seconds.+ contextLength:+ KNOWN_CONTEXT[m.id] ??+ (m.context_length && m.context_length > 0 ? m.context_length : undefined) ??+ (await this.probeContextFromServer(m.id)) ??+ guessContextFromName(m.id),+ supportsTools: lanCaps.has(m.id)+ ? lanCaps.get(m.id)!.includes('tool_use')+ : (serverTools ?? m.supports_tools ?? true),+ supportsVision: m.input_modalities?.includes('image') || undefined,+ thinkMode: m.think,+ effortLevels: m.reasoning_effort_levels,+ effortDefault: m.reasoning_effort_default,+ }+ }))}return models.map(m => {diff --git a/src/components/chat/__tests__/effort-reaches-the-composer.test.ts b/src/components/chat/__tests__/effort-reaches-the-composer.test.tsnew file mode 100644index 00000000..93b6de1f--- /dev/null+++ b/src/components/chat/__tests__/effort-reaches-the-composer.test.ts@@ -0,0 +1,137 @@+/**+ * @vitest-environment jsdom+ *+ * THE BUNDLE FAILURE, 2026-09-02, and the chain it broke.+ *+ * The 2.6.8 Mac bundle was pointed at a cloud base of http://localhost:3000.+ * The composer showed a GREY Think button on zai-org/GLM-5.3-Flash, a model+ * that always reasons, and no effort control at all. The picker showed raw+ * model ids instead of the friendly names, and the dev server logged one+ * GET /api/inference/v1/models/<id> per model, each answered 404, with the+ * listing itself taking eight to twenty-one seconds.+ *+ * One cause for all four. listModels has a branch for a backend on this machine+ * or the LAN, written when "LAN" meant LM Studio and llama.cpp, and it rebuilt+ * every row from the id alone: no name, no think mode, no vision flag, no+ * effort ladder, plus a per-model context probe that the cloud does not answer.+ * A cloud base on localhost IS a LAN host, so LU Cloud fell into it and the+ * whole server catalogue was thrown away on the way in.+ *+ * This test drives the real chain, without a bundle: an HTTP response, the real+ * OpenAIProvider, the real row mapper the hook uses, the real model store, and+ * the real composer. Nothing in the middle is stubbed, so a field that dies+ * anywhere along it turns this red.+ *+ * Run: npx vitest run src/components/chat/__tests__/effort-reaches-the-composer.test.ts+ */+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'+import { createElement } from 'react'+import { render, screen, cleanup } from '@testing-library/react'+import { ChatInput } from '../ChatInput'+import { OpenAIProvider } from '../../../api/providers/openai-provider'+import { cloudModelRow } from '../../../lib/cloud-model-row'+import { useSettingsStore } from '../../../stores/settingsStore'+import { useModelStore } from '../../../stores/modelStore'+import { DEFAULT_SETTINGS } from '../../../lib/constants'+import type { AIModel } from '../../../types/models'++vi.mock('../VoiceButton', () => ({ VoiceButton: () => null }))++/** Exactly what the web route answers for these two models. */+const CATALOGUE = [+ {+ id: 'zai-org/GLM-5.3-Flash', object: 'model', owned_by: 'lu-labs', name: 'GLM 5.3 Flash',+ context_length: 1048576, max_output_length: 8192, input_modalities: ['text', 'image'],+ think: 'always', supports_tools: true,+ reasoning_effort_levels: ['low', 'medium', 'high', 'max'], reasoning_effort_default: 'high',+ },+ {+ id: 'meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo', object: 'model', owned_by: 'lu-labs',+ name: 'Llama 3.1 8B Turbo', context_length: 131072, max_output_length: 8192,+ input_modalities: ['text'], think: 'never', supports_tools: true,+ },+]++/** Every base the app can be pointed at. Both must behave identically. */+const BASES = {+ 'the production cloud': 'https://lu-labs.ai/api/inference/v1',+ 'a cloud base on localhost, which is what the bundle ran against': 'http://localhost:3000/api/inference/v1',+ 'a cloud base on the LAN': 'http://192.168.0.54:3000/api/inference/v1',+}++const seen: string[] = []++function serveCatalogue() {+ seen.length = 0+ vi.spyOn(globalThis, 'fetch').mockImplementation((async (url: unknown) => {+ const u = String(url)+ seen.push(u)+ if (u.endsWith('/v1/models')) {+ return new Response(JSON.stringify({ object: 'list', tier: 'pro', data: CATALOGUE }), { status: 200 })+ }+ // Everything else is what LU Cloud really answers: there is no per-model+ // endpoint and no llama.cpp props endpoint on it.+ return new Response('Not Found', { status: 404 })+ }) as typeof fetch)+}++/** The real chain: HTTP, provider, row mapper, store. */+async function loadCatalogueFrom(baseUrl: string): Promise<AIModel[]> {+ const provider = new OpenAIProvider({+ id: 'lu-cloud', name: 'LU Cloud', enabled: true, baseUrl, apiKey: 'test-token', isLocal: false,+ })+ const listed = await provider.listModels()+ // The rebrand LuCloudProvider.listModels does on the way out.+ const rows = listed.map((pm) => cloudModelRow({ ...pm, provider: 'lu-cloud', providerName: 'LU Cloud' }))+ useModelStore.setState({ models: rows, activeModel: rows[0].name })+ return rows+}++const composer = () =>+ render(createElement(ChatInput, { onSend: () => {}, onStop: () => {}, isGenerating: false }))+const effortButton = () => screen.queryByTestId('effort-toggle')++beforeEach(() => {+ serveCatalogue()+ useSettingsStore.setState({ settings: { ...DEFAULT_SETTINGS } })+})+afterEach(() => {+ cleanup()+ vi.restoreAllMocks()+})++describe.each(Object.entries(BASES))('a catalogue served from %s', (_label, baseUrl) => {+ it('arrives in the store with every field the composer needs', async () => {+ const [glm] = await loadCatalogueFrom(baseUrl)+ expect(glm.thinkMode).toBe('always')+ expect(glm.effortLevels).toEqual(['low', 'medium', 'high', 'max'])+ expect(glm.effortDefault).toBe('high')+ expect(glm.contextLength).toBe(1048576)+ expect(glm.supportsVision).toBe(true)+ // The picker's friendly label, which the bundle also lost.+ expect(glm.displayName).toBe('GLM 5.3 Flash')+ })++ it('THE FAILURE: the composer draws the effort control on the always-reasoner', async () => {+ await loadCatalogueFrom(baseUrl)+ composer()+ expect(effortButton()).not.toBeNull()+ expect(effortButton()!.textContent).toBe('High')+ })++ it('and draws nothing on the instruct model beside it', async () => {+ const rows = await loadCatalogueFrom(baseUrl)+ useModelStore.setState({ activeModel: rows[1].name })+ composer()+ expect(effortButton()).toBeNull()+ })++ it('and asks the server about the catalogue ONCE, never per model', async () => {+ // The per-model probe is what produced a 404 per entry and stretched one+ // listing to twenty seconds. A server that declares context_length in its+ // listing has already answered the question.+ await loadCatalogueFrom(baseUrl)+ const perModel = seen.filter((u) => /\/models\/.+/.test(u))+ expect(perModel).toEqual([])+ })+})diff --git a/src/hooks/useModels.ts b/src/hooks/useModels.tsindex 50b915fb..6f9c6609 100644--- a/src/hooks/useModels.ts+++ b/src/hooks/useModels.ts@@ -12,6 +12,7 @@ import {} from '../api/comfyui'import { parseNDJSONStream } from '../api/stream'import { log } from '../lib/logger'+import { cloudModelRow } from '../lib/cloud-model-row'import { useModelStore } from '../stores/modelStore'import { useProviderStore } from '../stores/providerStore'import { useSettingsStore } from '../stores/settingsStore'@@ -188,21 +189,11 @@ export function useModels() {contextLength: pm.contextLength, supportsTools: pm.supportsTools,}}- const prefixedName = prefixModelName(pm.provider, pm.id)- return {- name: prefixedName, model: pm.id, size: 0, type: 'text' as const,- provider: pm.provider, providerName: pm.providerName,- contextLength: pm.contextLength, supportsTools: pm.supportsTools, supportsVision: pm.supportsVision,- thinkMode: pm.thinkMode,- // The effort ladder rides along field by field, like thinkMode.- // The Ollama branch above is the standing warning: a literal that- // rebuilds the model and stops one field short is how a server- // answer dies quietly halfway to the composer.- effortLevels: pm.effortLevels,- effortDefault: pm.effortDefault,- // Friendly server label (LU Cloud) — pickers prefer it over the id.- displayName: pm.name !== pm.id ? pm.name : undefined,- } satisfies CloudModel+ // ONE place decides what a cloud row carries (lib/cloud-model-row).+ // The Ollama branch above is the standing warning: a literal that+ // rebuilds the model and stops one field short is how a server+ // answer dies quietly halfway to the composer.+ return cloudModelRow(pm) satisfies CloudModel})}))diff --git a/src/lib/cloud-model-row.ts b/src/lib/cloud-model-row.tsnew file mode 100644index 00000000..9161cfd7--- /dev/null+++ b/src/lib/cloud-model-row.ts@@ -0,0 +1,33 @@+import type { ProviderModel } from '../api/providers/types'+import type { CloudModel } from '../types/models'+import { prefixModelName } from '../api/providers/registry'++/**+ * One catalogue entry, as the model store keeps it.+ *+ * This lived inline in useModels as an object literal that rebuilt the row+ * field by field. Twice now a field has died in a literal of exactly this+ * shape: Ollama's per-model tool answer in 2026-08 (the comment above the+ * Ollama branch in useModels still carries that story), and the whole server+ * catalogue on a LAN cloud base in 2026-09. Extracted so there is ONE place+ * that decides what a model row carries, and so a test can drive the real path+ * from an HTTP response to the composer without going through the hook.+ */+export function cloudModelRow(pm: ProviderModel): CloudModel {+ return {+ name: prefixModelName(pm.provider, pm.id),+ model: pm.id,+ size: 0,+ type: 'text',+ provider: pm.provider,+ providerName: pm.providerName,+ contextLength: pm.contextLength,+ supportsTools: pm.supportsTools,+ supportsVision: pm.supportsVision,+ thinkMode: pm.thinkMode,+ effortLevels: pm.effortLevels,+ effortDefault: pm.effortDefault,+ // Friendly server label (LU Cloud). Pickers prefer it over the raw id.+ displayName: pm.name !== pm.id ? pm.name : undefined,+ }+}