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(chat): ein misslungener Start verschwindet nicht mit dem Waehler

purple71d252727a0d
diff --git a/src/api/__tests__/der-fehlstart-bleibt-stehen.test.ts b/src/api/__tests__/der-fehlstart-bleibt-stehen.test.ts
new file mode 100644
index 00000000..17eb35ba
--- /dev/null
+++ b/src/api/__tests__/der-fehlstart-bleibt-stehen.test.ts
@@ -0,0 +1,103 @@
+/**
+ * Ein misslungener Engine-Start muss den Nutzer auch dann erreichen, wenn er
+ * den Modellwaehler laengst geschlossen hat.
+ *
+ * Persona P5, 03./04.09.2026, am echten Windows-Build: Klick auf eine kaputte
+ * GGUF, zwei Sekunden spaeter den Waehler mit Escape geschlossen, so wie ein
+ * Mensch es tut. Die Antwort der Engine kam erst 12,2 bis 21,2 s nach dem
+ * Klick. In der Zwischenzeit war der Chat 7,4 s ohne Engine, die App hat zwei
+ * Prozesse gestartet und wieder abgeraeumt, und auf dem Bildschirm stand 75
+ * Sekunden lang kein einziges neues Wort. Die Meldung lebte nur im Popover,
+ * und das Popover war weg.
+ *
+ * Run: npx vitest run src/api/__tests__/der-fehlstart-bleibt-stehen.test.ts
+ */
+import { describe, it, expect, beforeEach } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { resolve } from 'node:path'
+import {
+ announceLuEngineStartFailure, luEngineStartFailureNote, LU_ENGINE_SWITCH_NOTE,
+} from '../lu-engine-switch'
+import { useLuEngineSwitchStore } from '../../stores/luEngineSwitchStore'
+
+const lies = (p: string) => readFileSync(resolve(__dirname, '..', '..', p), 'utf8')
+
+describe('die Meldung landet in der stehenden Zeile', () => {
+ beforeEach(() => {
+ useLuEngineSwitchStore.setState({ note: null, tone: 'info', generation: 0 })
+ })
+
+ it('schreibt den Fehlstart ueber das Eingabefeld, nicht nur ins Popover', () => {
+ announceLuEngineStartFailure('openai::Kaputt-Q4_K_M', new Error('header'), false)
+ const s = useLuEngineSwitchStore.getState()
+ expect(s.note).toContain('Kaputt-Q4_K_M')
+ expect(s.note).toContain('header')
+ expect(s.tone).toBe('error')
+ })
+
+ it('und gibt dieselbe Zeile zurueck, damit das Popover nicht zweimal textet', () => {
+ // Zwei Woerter fuer dieselbe Sache waeren zwei Stellen, an denen sie
+ // auseinanderlaufen koennen.
+ const zurueck = announceLuEngineStartFailure('openai::X', new Error('boom'), false)
+ expect(zurueck).toBe(luEngineStartFailureNote('openai::X', new Error('boom')))
+ expect(useLuEngineSwitchStore.getState().note).toBe(zurueck)
+ })
+
+ it('nennt den verschobenen Steckplatz mit, wenn er verschoben wurde', () => {
+ const zurueck = announceLuEngineStartFailure('openai::X', new Error('boom'), true)
+ expect(zurueck.startsWith(LU_ENGINE_SWITCH_NOTE)).toBe(true)
+ expect(zurueck).toContain('boom')
+ })
+
+ it('ein Fehler hat keine Selbstloeschuhr', () => {
+ // Sonst waere die Zeile weg, bevor der Nutzer vom Kaffee zurueck ist. Die
+ // Info-Zeile darf sich raeumen, diese nicht.
+ announceLuEngineStartFailure('openai::X', new Error('boom'), false)
+ expect(useLuEngineSwitchStore.getState().tone).toBe('error')
+ const s = lies('stores/luEngineSwitchStore.ts')
+ expect(s).toMatch(/tone === 'error'|tone !== 'error'/)
+ })
+})
+
+describe('beide Tueren schreiben aus derselben Hand', () => {
+ it('der Waehler ruft die gemeinsame Stelle und textet nicht selbst', () => {
+ const src = lies('components/models/ModelSelector.tsx')
+ expect(src).toContain('setSelectError(announceLuEngineStartFailure(model.name, e, switched))')
+ // Die alte Fassung schrieb nur in den eigenen Kasten.
+ expect(src).not.toContain('setSelectError(luEngineStartFailureNote(')
+ })
+
+ it('die Kachel ebenso', () => {
+ const src = lies('hooks/useModels.ts')
+ expect(src).toContain('announceLuEngineStartFailure(name, reason, switched)')
+ expect(src).not.toContain('`${LU_ENGINE_SWITCH_NOTE} ${line}`')
+ })
+})
+
+describe('das Aufklappmenue bleibt im Fenster', () => {
+ const src = lies('components/models/ModelSelector.tsx')
+
+ it('es misst, wie viel Platz ueber dem Ausloeser wirklich ist', () => {
+ // Ein festes max-h in vh weiss nichts davon, wo der Ausloeser sitzt.
+ expect(src).toContain('const frei = openUpward ? r.top : window.innerHeight - r.bottom')
+ expect(src).toContain('setMenuePlatz(')
+ expect(src).toContain('style={menuePlatz === null ? undefined : { maxHeight: menuePlatz }}')
+ })
+
+ it('und was nicht mehr hineinpasst, laesst sich scrollen', () => {
+ // P5: das Menue trug overflow-hidden, also half weder Mausrad noch
+ // scrollTop, und der Kopf der Meldung stand bei -149 px.
+ const menue = src.slice(src.indexOf('data-testid="model-picker-menu"'))
+ expect(menue).toContain('overflow-y-auto')
+ expect(menue.slice(0, 400)).not.toContain('overflow-hidden')
+ })
+
+ it('der Fehlerkasten hat seinen eigenen Deckel', () => {
+ const kasten = src.slice(src.indexOf('data-testid="model-picker-error"'))
+ expect(kasten.slice(0, 400)).toContain('max-h-[22vh]')
+ expect(kasten.slice(0, 400)).toContain('overflow-y-auto')
+ // Und die Zeilenumbrueche der Maschine bleiben Zeilenumbrueche, sonst
+ // klebt das ganze Protokoll zu einem Absatz zusammen.
+ expect(kasten.slice(0, 400)).toContain('whitespace-pre-wrap')
+ })
+})
diff --git a/src/api/lu-engine-switch.ts b/src/api/lu-engine-switch.ts
index 8a30527c..e11d58f4 100644
--- a/src/api/lu-engine-switch.ts
+++ b/src/api/lu-engine-switch.ts
@@ -108,6 +108,33 @@ export function luEngineStartFailureNote(modelName: string, reason: unknown): st
return `Couldn't start the LU Engine with "${displayModelName(modelName)}": ${text}`
}
+/**
+ * Write that sentence where it survives, and hand it back for the door it
+ * came through.
+ *
+ * Persona P5 measured this on the real Windows build on 03.09.2026: a click on
+ * a broken GGUF, then the picker closed after two seconds, the way a person
+ * uses it. The chat was without an engine for 7,4 seconds, two processes
+ * started and died, and for 75 seconds the page did not gain a single line of
+ * text. The failure was written into the dropdown only, and the dropdown was
+ * gone. The answer arrives 12 to 21 seconds after the click, so "the user is
+ * still looking at it" is not an assumption this app may make.
+ *
+ * The standing row above the composer is where it goes now, the same row the
+ * switch note uses, and an 'error' there has no self-clearing timer.
+ * `switched` folds in the sentence about the moved backend, because a start
+ * that failed after the slot was handed over is exactly when both facts
+ * matter.
+ */
+export function announceLuEngineStartFailure(
+ modelName: string, reason: unknown, switched: boolean,
+): string {
+ const line = luEngineStartFailureNote(modelName, reason)
+ const full = switched ? `${LU_ENGINE_SWITCH_NOTE} ${line}` : line
+ useLuEngineSwitchStore.getState().announce(full, 'error')
+ return full
+}
+
/** The shipped address of the engine. The real port is written back by
* `syncBuiltinEnginePort` as soon as it starts, exactly as it is for a
* takeover from the provider card. */
diff --git a/src/components/models/ModelSelector.tsx b/src/components/models/ModelSelector.tsx
index bc3626ff..8cca6c55 100644
--- a/src/components/models/ModelSelector.tsx
+++ b/src/components/models/ModelSelector.tsx
@@ -1,4 +1,4 @@
-import { useState, useRef, useEffect } from 'react'
+import { useState, useRef, useEffect, useLayoutEffect } from 'react'
import { useDismissOnEscape } from '../../hooks/useDismissOnEscape'
import { motion, AnimatePresence } from 'framer-motion'
import { Ban, ChevronDown, Loader2, Power, PlayCircle, Settings as SettingsIcon, Wrench, X, Cloud } from 'lucide-react'
@@ -25,7 +25,7 @@ import { isBuiltinEngineEntry, type InstalledModelLike } from '../../lib/lmstudi
import type { HandoverSlot } from '../../lib/openai-slot-handover'
import {
ensureLuEngineIsChatProvider, LU_ENGINE_SWITCH_NOTE, LU_ENGINE_SWAP_BUSY_NOTE,
- announceLuEngineSwapBusy, luEngineStartFailureNote,
+ announceLuEngineSwapBusy, announceLuEngineStartFailure,
LM_STUDIO_LOAD_BUSY_NOTE, announceLmStudioLoadBusy,
handBackChatProviderForRow, chatProviderSwitchNote, standbyBackendOf,
} from '../../api/lu-engine-switch'
@@ -621,6 +621,23 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy
const [ollamaLoaded, setOllamaLoaded] = useState<Set<string>>(new Set())
const [togglingOllama, setTogglingOllama] = useState<string | null>(null)
const ref = useRef<HTMLDivElement>(null)
+ /**
+ * Wie hoch das Aufklappmenue hoechstens werden darf, in Pixeln.
+ *
+ * Persona P5 hat am 03.09.2026 am echten Build gemessen: nach einem
+ * Fehlstart war das Menue 902 px hoch in einem 808 px hohen Fenster, der
+ * Kasten mit der Fehlermeldung begann bei -149 px, also oberhalb des
+ * Fensterrands, und weil das Menue `overflow-hidden` traegt, kam man da
+ * weder mit dem Mausrad noch mit `scrollTop` hin. Sichtbar blieb nur das
+ * rohe Maschinenprotokoll, der Satz mit dem Namen des Modells und dem
+ * Handlungsvorschlag war unerreichbar.
+ *
+ * Ein festes `max-h` in vh reicht dafuer nicht: das Menue haengt mit
+ * `bottom-full` am Ausloeser, und wie viel Platz DARUEBER ist, weiss nur
+ * der Ausloeser selbst. Also gemessen, bei jedem Oeffnen und bei jeder
+ * Groessenaenderung des Fensters.
+ */
+ const [menuePlatz, setMenuePlatz] = useState<number | null>(null)
// Keep the per-row On/Off LOAD state LIVE while the dropdown is open
// (David 2026-06-12: "on und offload button sehr delayed und nicht immer
@@ -857,12 +874,17 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy
}
setSelectError(null)
setSelectingLms(id)
+ // Der Fangzweig unten muss wissen, ob der Platz schon uebergeben war,
+ // also steht die Antwort ausserhalb des try. Die Uebergabe selbst bleibt
+ // drin, damit sie weiter mitgefangen wird.
+ let switched = false
try {
// Announced BEFORE the start is attempted and NOT into this dropdown,
// which the pick closes a few lines further down. It goes to the
// standing status row above the composer, so it survives both the
// close on success and the error banner on failure (A14 review 2).
- if (ensureLuEngineIsChatProvider()) {
+ switched = ensureLuEngineIsChatProvider()
+ if (switched) {
useLuEngineSwitchStore.getState().announce(LU_ENGINE_SWITCH_NOTE)
}
const swapped = await activateBuiltinModel(model.name)
@@ -877,7 +899,14 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy
} catch (e) {
// Shared with the Installed card, which used to swallow this failure
// whole. One sentence, one place it is written (A14 third review).
- setSelectError(luEngineStartFailureNote(model.name, e))
+ //
+ // Und in BEIDE Zeilen, nicht nur in diese hier. Persona P5 hat am
+ // 03.09.2026 am echten Build den Waehler zwei Sekunden nach dem Klick
+ // geschlossen, so wie ein Mensch es tut: die Antwort kommt erst 12 bis
+ // 21 s spaeter, sie stand nur in diesem Kasten, und der Kasten war
+ // weg. 7,4 s ohne Engine, zwei Prozessstarts, und 75 s lang keine
+ // einzige neue Textzeile auf der Seite.
+ setSelectError(announceLuEngineStartFailure(model.name, e, switched))
} finally {
setSelectingLms(null)
releaseLuEngineSwap()
@@ -995,6 +1024,24 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy
const hasOllamaModels = textModels.some(m => ('provider' in m && m.provider === 'ollama') || !('provider' in m))
textModelsEmptyRef.current = textModels.length === 0
+ // Messen, wie viel Fenster ueber (bzw. unter) dem Ausloeser noch frei ist.
+ // 18 px Abzug: 6 px Abstand des Menues zum Ausloeser plus 12 px Luft zum
+ // Fensterrand. Die Untergrenze von 200 px ist die Notbremse fuer ein sehr
+ // flaches Fenster, in dem sonst ein Menue ohne Inhalt herauskaeme.
+ useLayoutEffect(() => {
+ if (!open) return
+ const messen = () => {
+ const el = ref.current
+ if (!el) return
+ const r = el.getBoundingClientRect()
+ const frei = openUpward ? r.top : window.innerHeight - r.bottom
+ setMenuePlatz(Math.max(200, Math.round(frei - 18)))
+ }
+ messen()
+ window.addEventListener('resize', messen)
+ return () => window.removeEventListener('resize', messen)
+ }, [open, openUpward])
+
return (
<div ref={ref} className="relative">
{/* ── Trigger Button ── */}
@@ -1048,7 +1095,9 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy
<AnimatePresence>
{open && (
<motion.div
- className={`absolute w-72 rounded-lg overflow-hidden z-50 lu-elevated ${
+ data-testid="model-picker-menu"
+ style={menuePlatz === null ? undefined : { maxHeight: menuePlatz }}
+ className={`absolute w-72 rounded-lg overflow-x-hidden overflow-y-auto scrollbar-thin z-50 lu-elevated ${
openUpward ? 'bottom-full mb-1.5 right-0' : 'top-full mt-1.5 left-1/2 -translate-x-1/2'
}`}
initial={{ opacity: 0, y: openUpward ? 6 : -6, scale: 0.98 }}
@@ -1081,7 +1130,10 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy
{/* §18 — surfaced when an LM Studio auto-load (on select) failed,
so the user isn't left wondering why the model didn't switch. */}
{selectError && (
- <div className="mx-2 mt-2 px-2 py-1.5 rounded bg-red-500/10 border border-red-500/20 t-micro text-red-600/90 dark:text-red-300/90 leading-snug">
+ <div
+ data-testid="model-picker-error"
+ className="mx-2 mt-2 px-2 py-1.5 rounded bg-red-500/10 border border-red-500/20 t-micro text-red-600/90 dark:text-red-300/90 leading-snug max-h-[22vh] overflow-y-auto overflow-x-hidden scrollbar-thin whitespace-pre-wrap break-words"
+ >
{selectError}
</div>
)}
diff --git a/src/hooks/useModels.ts b/src/hooks/useModels.ts
index a37891ee..621d5a72 100644
--- a/src/hooks/useModels.ts
+++ b/src/hooks/useModels.ts
@@ -20,7 +20,7 @@ import { dropDuplicateLuEngineRows, dropStandbyRowsServedByLuEngine } from '../l
import { isBuiltinEngineEntry, type InstalledModelLike } from '../lib/lmstudio-match'
import {
ensureLuEngineIsChatProvider, LU_ENGINE_SWITCH_NOTE, LU_ENGINE_FILE_GONE,
- announceLuEngineSwapBusy, luEngineStartFailureNote,
+ announceLuEngineSwapBusy, announceLuEngineStartFailure,
standbyChatBackend, listStandbyBackendModels, handBackChatProviderForRow,
chatProviderSwitchNote,
} from '../api/lu-engine-switch'
@@ -612,9 +612,7 @@ export function useModels() {
// helper, in the status row that is drawn right above the list.
const sayItFailed = (reason: unknown) => {
if (vorherAktiv !== name) setActiveModel(vorherAktiv)
- const line = luEngineStartFailureNote(name, reason)
- useLuEngineSwitchStore.getState()
- .announce(switched ? `${LU_ENGINE_SWITCH_NOTE} ${line}` : line, 'error')
+ announceLuEngineStartFailure(name, reason, switched)
}
return activateBuiltinModel(name)
// False is not a shrug: the path could not be resolved even after a