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.

fix(settings): kanonischen isLmStudioProvider statt eigenem includes()

purple2bee6bad20c0
diff --git a/src/components/settings/SettingsPage.tsx b/src/components/settings/SettingsPage.tsx
index d843119d..cd8dff87 100644
--- a/src/components/settings/SettingsPage.tsx
+++ b/src/components/settings/SettingsPage.tsx
@@ -67,6 +67,7 @@ import { CivitaiApiKeySetting } from './CivitaiApiKeySetting'
import { HfTokenSetting } from './HfTokenSetting'
import { HINWEIS_TEXT, PUNKT_FARBE } from '../../lib/hinweis'
import { ContentPolicySettings } from './ContentPolicySettings'
+import { isLmStudioProvider } from '../../lib/hf-to-provider'
// ── User profile picture (Appearance) ───────────────────────────
// Self-contained like HfDownloadPathSetting. Stores the picture as a
@@ -2539,6 +2540,30 @@ export function ProbeBadge({ probe, switchedOff }: { probe: BackendProbe; switch
)
}
+/**
+ * R8-Nachzug (LM-Studio-Adresse, 2026-09-18): Rust besitzt keinen eigenen
+ * Speicherplatz fuer die LM-Studio-Basis (anders als Ollama/ComfyUI, die es
+ * selbst startet), also liest der Aufrufer seinen eigenen Provider-Store und
+ * reicht die konfigurierte Adresse als Befehlsargument durch, statt ein
+ * zweites AppState-Feld nur fuer einen Wert zu pflegen, den Rust ohnehin nie
+ * selbst setzt. Als eigene, exportierte Funktion, damit der Argumentname
+ * `lmStudioBase` (Tauri wandelt ihn nach camelCase fuer `lm_studio_base`,
+ * siehe health.rs) und die Erkennung beider Schreibweisen ("LM Studio",
+ * "LMStudio") direkt getestet werden koennen, ohne die ganze Komponente zu
+ * rendern (B3/F5-Nachbesserung, review-w2rust.md).
+ *
+ * Nutzt den kanonischen Helfer `isLmStudioProvider` (statt eines eigenen
+ * `includes('lm studio')`), der auch einen Slot-Namen wie "LMStudio" erkennt,
+ * genau wie modelStore.ts und ModelSelector.tsx es bereits tun. Eine zweite,
+ * engere Wahrheit fuer denselben Begriff haette denselben Bug fuer diese
+ * Schreibweise offen gelassen.
+ */
+export function lmStudioBaseArg(
+ openaiSlot: { name?: string; baseUrl?: string } | undefined,
+): { lmStudioBase: string | undefined } {
+ return { lmStudioBase: isLmStudioProvider(openaiSlot?.name) ? openaiSlot?.baseUrl : undefined }
+}
+
function TroubleshootSection() {
const [report, setReport] = useState<SystemHealthReport | null>(null)
const [loading, setLoading] = useState(false)
@@ -2550,17 +2575,8 @@ function TroubleshootSection() {
setLoading(true)
setHinweis(null)
try {
- // R8-Nachzug (LM-Studio-Adresse, 2026-09-18): Rust besitzt keinen
- // eigenen Speicherplatz fuer die LM-Studio-Basis (anders als Ollama/
- // ComfyUI, die es selbst startet), also liest der Aufrufer seinen
- // eigenen Provider-Store und reicht die konfigurierte Adresse als
- // Befehlsargument durch, statt ein zweites AppState-Feld nur fuer
- // einen Wert zu pflegen, den Rust ohnehin nie selbst setzt.
const openaiSlot = useProviderStore.getState().providers.openai
- const lmStudioBase = openaiSlot?.name?.toLowerCase().includes('lm studio')
- ? openaiSlot.baseUrl
- : undefined
- const r = await backendCall<SystemHealthReport>('system_health', { lmStudioBase })
+ const r = await backendCall<SystemHealthReport>('system_health', lmStudioBaseArg(openaiSlot))
setReport(r)
} catch (e) {
setHinweis(troubleshootHinweis(e, isTauri()))
diff --git a/src/components/settings/__tests__/lm-studio-probe-argument.test.ts b/src/components/settings/__tests__/lm-studio-probe-argument.test.ts
new file mode 100644
index 00000000..8b557565
--- /dev/null
+++ b/src/components/settings/__tests__/lm-studio-probe-argument.test.ts
@@ -0,0 +1,47 @@
+/**
+ * B3/F5-Nachbesserung (review-w2rust.md, 2026-09-18): system_health's
+ * lm_studio_base command argument only ever gets filled correctly if the
+ * frontend both (a) names the key exactly `lmStudioBase` -- Tauri converts
+ * this to `lm_studio_base` on the Rust side, see health.rs -- and (b)
+ * recognises the openai slot as LM Studio for BOTH spellings the provider
+ * presets and the store allow ("LM Studio", "LMStudio"). Neither of those two
+ * facts was pinned by a test before this file: the Rust-side test only
+ * exercises the pure function, tsc only checks that `invoke(command, args)`
+ * accepts a generic record, and the existing SettingsPage tests never touch
+ * this argument at all.
+ *
+ * Run: npx vitest run src/components/settings/__tests__/lm-studio-probe-argument.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { lmStudioBaseArg } from '../SettingsPage'
+
+describe('lmStudioBaseArg names the key lmStudioBase and reads both LM Studio spellings', () => {
+ it('uses the exact key "lmStudioBase", not a snake_case or misspelled one', () => {
+ const args = lmStudioBaseArg({ name: 'LM Studio', baseUrl: 'http://192.168.1.20:1234/v1' })
+ expect(Object.keys(args)).toEqual(['lmStudioBase'])
+ })
+
+ it('fills lmStudioBase from the openai slot\'s baseUrl when its name is "LM Studio"', () => {
+ const args = lmStudioBaseArg({ name: 'LM Studio', baseUrl: 'http://192.168.1.20:1234/v1' })
+ expect(args.lmStudioBase).toBe('http://192.168.1.20:1234/v1')
+ })
+
+ it('also recognises the no-space spelling "LMStudio"', () => {
+ const args = lmStudioBaseArg({ name: 'LMStudio', baseUrl: 'http://10.0.0.5:1234/v1' })
+ expect(args.lmStudioBase).toBe('http://10.0.0.5:1234/v1')
+ })
+
+ it('is case-insensitive on both spellings', () => {
+ expect(lmStudioBaseArg({ name: 'lm studio', baseUrl: 'http://a:1234/v1' }).lmStudioBase).toBe('http://a:1234/v1')
+ expect(lmStudioBaseArg({ name: 'lmstudio', baseUrl: 'http://b:1234/v1' }).lmStudioBase).toBe('http://b:1234/v1')
+ })
+
+ it('omits the base for any other provider name, never guesses one', () => {
+ expect(lmStudioBaseArg({ name: 'OpenRouter', baseUrl: 'https://openrouter.ai/api/v1' }).lmStudioBase).toBeUndefined()
+ expect(lmStudioBaseArg({ name: 'Locally Uncensored Engine', baseUrl: 'http://127.0.0.1:8127/v1' }).lmStudioBase).toBeUndefined()
+ })
+
+ it('omits the base when the openai slot is missing entirely', () => {
+ expect(lmStudioBaseArg(undefined).lmStudioBase).toBeUndefined()
+ })
+})