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): eine stehende Engine gibt der aktiven Kachel ihren Use-Knopf zurueck
purple039e85092ae8
diff --git a/src/components/models/ModelCard.tsx b/src/components/models/ModelCard.tsxindex e2f42fa1..144c7c5b 100644--- a/src/components/models/ModelCard.tsx+++ b/src/components/models/ModelCard.tsx@@ -27,6 +27,17 @@ interface Props {* path the tile click takes.*/onUse?: () => void+ /**+ * Die LU Engine bedient gerade gar nichts.+ *+ * Persona P2, 04.09.2026: nach einem `Stop-Process` auf den Engine-Prozess+ * behielt genau das Modell, das lief, sein ACTIVE und verlor seinen+ * Use-Knopf, 40 bzw. 90 Sekunden lang unveraendert, waehrend das+ * Einstellungsfenster den Tod schon nach 2 Sekunden meldete. Nach einem+ * Absturz war ausgerechnet das zuletzt benutzte Modell das einzige, das man+ * von hier aus nicht neu starten konnte.+ */+ engineStopped?: boolean/** While that swap runs. The engine can take seconds to load a cold GGUF. */useBusy?: boolean}@@ -37,7 +48,7 @@ const TYPE_CONFIG = {video: { label: 'Video', icon: Video, color: 'text-green-400' },}-export function ModelCard({ model, isActive, onSelect, onDelete, onInfo, canDelete = true, onUse, useBusy = false }: Props) {+export function ModelCard({ model, isActive, onSelect, onDelete, onInfo, canDelete = true, onUse, useBusy = false, engineStopped = false }: Props) {const typeInfo = TYPE_CONFIG[model.type] || TYPE_CONFIG.textconst TypeIcon = typeInfo.iconconst [menu, setMenu] = useState<{ x: number; y: number } | null>(null)@@ -99,7 +110,7 @@ export function ModelCard({ model, isActive, onSelect, onDelete, onInfo, canDeleloading the GGUF, so the button stays for as long as its own swapruns. Dropping it there would take the Loading state off screen atthe exact moment it is the answer to "did that work". */}- {onUse && (!isActive || useBusy) && (+ {onUse && (!isActive || useBusy || engineStopped) && (<buttononClick={(e) => { e.stopPropagation(); if (!useBusy) onUse() }}disabled={useBusy}diff --git a/src/components/models/ModelManager.tsx b/src/components/models/ModelManager.tsxindex 20c0df82..e7177e5d 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, LU_ENGINE_GROUP } from '../../lib/lu-engine-rows'import { isBuiltinEngineEntry } from '../../lib/lmstudio-match'+import { useBuiltinEngineStatus, engineIsIdle } from '../../hooks/useBuiltinEngineStatus'import { LuEngineSwitchBar } from '../chat/LuEngineSwitchBar'import type { InstalledModelLike } from '../../lib/lmstudio-match'import type { ModelCategory, AIModel } from '../../types/models'@@ -69,6 +70,8 @@ export function ModelManager() {// reload a GGUF that can be several gigabytes and come back healthy, and a// button that looks idle through all of that gets pressed again.const [usingModel, setUsingModel] = useState<string | null>(null)+ // Dieselbe Frage, die das Einstellungsfenster stellt, und dieselbe Antwort.+ const engineRuht = engineIsIdle(useBuiltinEngineStatus())const [pullOpen, setPullOpen] = useState(false)const [infoOpen, setInfoOpen] = useState(false)// Gesetzt wird das aus `{ name, ...await showModel(name) }` (unten in@@ -471,6 +474,9 @@ export function ModelManager() {: undefined}useBusy={usingModel === model.name}+ // Steht die Engine, darf auch die aktive Zeile+ // wieder gestartet werden (Persona P2).+ engineStopped={engineRuht}onDelete={() => setConfirmDelete(model.name)}onInfo={() => handleInfo(model.name)}canDelete={diff --git a/src/components/models/__tests__/installed-tile-has-a-use-button.test.ts b/src/components/models/__tests__/installed-tile-has-a-use-button.test.tsindex 16b54281..fce4f7c3 100644--- a/src/components/models/__tests__/installed-tile-has-a-use-button.test.ts+++ b/src/components/models/__tests__/installed-tile-has-a-use-button.test.ts@@ -20,6 +20,9 @@ import { createElement } from 'react'import { render, screen, cleanup, act, fireEvent } from '@testing-library/react'const activateBuiltinModel = vi.fn(async () => true)+/** Was die Engine gerade tut. Ueberschreibbar, siehe den Fall zum toten+ * Prozess weiter unten. */+const engineStatus = vi.fn(async () => ({ running: true, healthy: true, port: 8127 }))vi.mock('../../../api/backend', () => ({isTauri: () => true,@@ -59,7 +62,7 @@ vi.mock('../../../api/engine', async () => {listBundledModels: vi.fn(async () => []),customModelDirs: vi.fn(async () => []),isManagedBuiltinActive: () => true,- bundledEngineStatus: vi.fn(async () => ({ running: true, healthy: true, port: 8127 })),+ bundledEngineStatus: (...a: unknown[]) => engineStatus(...(a as [])),bundledEmbedStatus: vi.fn(async () => ({ running: true, healthy: true, port: 8128 })),startBundledEmbed: vi.fn(),activateBuiltinModel: (...a: unknown[]) => activateBuiltinModel(...(a as [])),@@ -112,6 +115,8 @@ function useButtonFor(name: string): HTMLElement | null {beforeEach(() => {activateBuiltinModel.mockReset()activateBuiltinModel.mockResolvedValue(true)+ engineStatus.mockReset()+ engineStatus.mockResolvedValue({ running: true, healthy: true, port: 8127 })__resetLuEngineSwapLockForTests()useProviderStore.getState().resetProvidersToDefaults()useProviderStore.getState().setProviderConfig('openai', {@@ -167,6 +172,26 @@ describe('the Use button the 2.6.8 notes promise on the Installed tile', () => {// Modellnamen. Fuer einen Kunden, der LU Engine benutzt und mit OpenAI// nichts zu tun hat, ist das verwirrend." Es ist unser Steckplatzname,// nicht seiner.+ // Persona P2, 04.09.2026: nach `Stop-Process` auf den Engine-Prozess behielt+ // genau das Modell, das lief, sein ACTIVE und verlor seinen Use-Knopf, 40+ // bzw. 90 s lang unveraendert, waehrend das Einstellungsfenster den Tod+ // schon nach 2 s meldete. Nach einem Absturz war ausgerechnet das zuletzt+ // benutzte Modell das einzige, das man von hier aus nicht neu starten+ // konnte.+ it('gibt der aktiven Zeile ihren Use-Knopf zurueck, wenn die Engine steht', async () => {+ engineStatus.mockResolvedValue({ running: false, healthy: false, port: 8127 })+ await openInstalled()+ expect(useButtonFor(ACTIVE)).not.toBeNull()+ })++ // NEGATIVKONTROLLE: laeuft die Engine, bleibt es beim alten Verhalten. Der+ // Knopf auf der Zeile, die gerade bedient wird, waere sonst ein Angebot,+ // etwas zu starten, das laeuft.+ it('und nimmt ihn wieder weg, solange die Engine laeuft', async () => {+ await openInstalled()+ expect(useButtonFor(ACTIVE)).toBeNull()+ })+it('nennt kein Modell mit dem Steckplatz-Praefix', async () => {await openInstalled()expect(document.body.textContent).not.toContain('openai::')diff --git a/src/components/settings/BuiltinEngineSettings.tsx b/src/components/settings/BuiltinEngineSettings.tsxindex 0e2900e6..58408b7c 100644--- a/src/components/settings/BuiltinEngineSettings.tsx+++ b/src/components/settings/BuiltinEngineSettings.tsx@@ -5,12 +5,12 @@// (same path the model picker uses); when stopped, the next start picks the// values up automatically.-import { useEffect, useRef, useState } from 'react'+import { useRef, useState } from 'react'import { Loader2, AlertTriangle, Check, Zap } from 'lucide-react'import { useSettingsStore } from '../../stores/settingsStore'-import { bundledEngineStatus, swapBundledModel, ENGINE_PORT, type EngineStatus } from '../../api/engine'+import { bundledEngineStatus, swapBundledModel, ENGINE_PORT } from '../../api/engine'+import { useBuiltinEngineStatus } from '../../hooks/useBuiltinEngineStatus'import { enginePortLine } from '../../lib/engine-port'-import { isTauri } from '../../api/backend'import type { BuiltinEngineTuning } from '../../types/settings'import { formatCount } from '../../lib/formatters'@@ -44,24 +44,10 @@ function modelNameFromPath(path: string | null): string | null {* is wrong about a process that is gone is worse than no display: it is the* answer to "why does chat not work" and it is the wrong answer.*/-export const SIDECAR_GONE_EVENT = 'lu-sidecar-gone'--/**- * The fallback poll, for the case where the event never lands.- *- * The event is the fast path and normally does the whole job. This is the belt:- * an event lost in a reload, a listener that failed to register, a sidecar the- * watch has not reached yet. Three seconds keeps the worst case inside the five- * the requirement names, and the call behind it is the same status read the- * panel already makes on mount.- */-export const ENGINE_STATUS_POLL_MS = 3_000-export function BuiltinEngineSettings() {const tuning = useSettingsStore((s) => s.settings.builtinEngine)const updateSettings = useSettingsStore((s) => s.updateSettings)- const [status, setStatus] = useState<EngineStatus | null>(null)const [dirty, setDirty] = useState(false)const [busy, setBusy] = useState(false)const [applied, setApplied] = useState(false)@@ -69,33 +55,11 @@ export function BuiltinEngineSettings() {// A restart this panel started reads the status itself when it is done, and// a poll landing in the middle of it would show the gap as "not running".+ // Die Schleife selbst steht in hooks/useBuiltinEngineStatus, weil die+ // Models-Seite dieselbe Frage stellen muss (Persona P2, 04.09.2026).const busyRef = useRef(false)busyRef.current = busy-- useEffect(() => {- if (!isTauri()) return- let alive = true- const read = () => {- if (busyRef.current) return- bundledEngineStatus()- .then((s) => { if (alive) setStatus(s) })- .catch(() => { if (alive) setStatus(null) })- }- read()- const timer = setInterval(read, ENGINE_STATUS_POLL_MS)- // The fast path: Rust's watch reaps the dead handle and says so, and this- // asks again the moment it hears it, instead of waiting out the poll.- let unlisten: (() => void) | null = null- void import('@tauri-apps/api/event')- .then(({ listen }) => listen(SIDECAR_GONE_EVENT, () => read()))- .then((off) => { if (alive) unlisten = off; else off() })- .catch(() => {})- return () => {- alive = false- clearInterval(timer)- unlisten?.()- }- }, [])+ const { status, setStatus } = useBuiltinEngineStatus(() => busyRef.current)const patch = (p: Partial<BuiltinEngineTuning>) => {updateSettings({ builtinEngine: { ...tuning, ...p } })diff --git a/src/components/settings/__tests__/engine-status-follows-a-dead-sidecar.test.ts b/src/components/settings/__tests__/engine-status-follows-a-dead-sidecar.test.tsindex 94daf996..9b35751d 100644--- a/src/components/settings/__tests__/engine-status-follows-a-dead-sidecar.test.ts+++ b/src/components/settings/__tests__/engine-status-follows-a-dead-sidecar.test.ts@@ -43,8 +43,12 @@ vi.mock('@tauri-apps/api/event', () => ({},}))-const { BuiltinEngineSettings, ENGINE_STATUS_POLL_MS, SIDECAR_GONE_EVENT } =- await import('../BuiltinEngineSettings')+const { BuiltinEngineSettings } = await import('../BuiltinEngineSettings')+// Die Schleife wohnt seit dem 04.09.2026 im Hook, weil die Models-Seite+// dieselbe Frage stellen muss (Persona P2). Das Fenster hier bleibt der Ort,+// an dem sie geprueft wird, aber die Namen kommen von dort.+const { ENGINE_STATUS_POLL_MS, SIDECAR_GONE_EVENT } =+ await import('../../../hooks/useBuiltinEngineStatus')const RUNNING = { running: true, healthy: true, port: 8127, model_path: 'C:\\m\\Phi-4-mini-instruct-Q4_K_M.gguf', ctx: 8192 }const DEAD = { running: false, healthy: false, port: 8127, model_path: null, ctx: null }diff --git a/src/hooks/useBuiltinEngineStatus.ts b/src/hooks/useBuiltinEngineStatus.tsnew file mode 100644index 00000000..3f982645--- /dev/null+++ b/src/hooks/useBuiltinEngineStatus.ts@@ -0,0 +1,89 @@+/**+ * Was die LU Engine gerade wirklich tut, live.+ *+ * Bis 04.09.2026 stand diese Schleife nur im Einstellungsfenster, und die+ * Models-Seite hatte davon nichts. Persona P2 hat gemessen, was das kostet:+ * nach `Stop-Process` auf den Engine-Prozess meldete das Einstellungsfenster+ * binnen 2 Sekunden "Engine not running", waehrend die Kachel des Modells,+ * das gerade lief, 40 bzw. 90 Sekunden lang unveraendert ACTIVE zeigte und+ * ihren Use-Knopf verloren hatte. Nach einem Absturz war ausgerechnet das+ * zuletzt benutzte Modell das einzige, das man von der Models-Seite aus nicht+ * neu starten konnte.+ *+ * Also fragen beide dieselbe Stelle. Der schnelle Weg ist das Ereignis, das+ * Rust schickt, sobald seine Wache den toten Griff einsammelt; der Takt+ * darunter ist der Guertel fuer ein Ereignis, das in einem Neuladen verloren+ * geht.+ */+import { useEffect, useRef, useState } from 'react'+import { bundledEngineStatus, type EngineStatus } from '../api/engine'+import { isTauri } from '../api/backend'++/** Rust meldet den eingesammelten toten Griff hierunter. */+export const SIDECAR_GONE_EVENT = 'lu-sidecar-gone'++/**+ * Der Rueckfall-Takt, fuer den Fall, dass das Ereignis nie ankommt.+ *+ * Drei Sekunden haelt den schlechtesten Fall innerhalb der fuenf, die die+ * Anforderung nennt, und der Aufruf dahinter ist derselbe Statusabruf, den+ * beide Seiten beim Aufbauen ohnehin machen.+ */+export const ENGINE_STATUS_POLL_MS = 3_000++export interface EngineStatusView {+ status: EngineStatus | null+ /** Ob ueberhaupt schon einmal eine Antwort da war. Vorher ist `status`+ * null, weil nichts gefragt wurde, und nicht, weil nichts laeuft. */+ geantwortet: boolean+ setStatus: (s: EngineStatus | null) => void+}++/**+ * @param pausiert Solange das wahr ist, wird nicht gefragt. Das+ * Einstellungsfenster startet die Engine selbst neu und liest danach selbst;+ * ein Takt mitten hinein zeigte die Luecke als "not running".+ */+export function useBuiltinEngineStatus(pausiert?: () => boolean): EngineStatusView {+ const [status, setStatus] = useState<EngineStatus | null>(null)+ const [geantwortet, setGeantwortet] = useState(false)+ const pausiertRef = useRef(pausiert)+ pausiertRef.current = pausiert++ useEffect(() => {+ if (!isTauri()) return+ let alive = true+ const read = () => {+ if (pausiertRef.current?.()) return+ bundledEngineStatus()+ .then((s) => { if (alive) { setStatus(s); setGeantwortet(true) } })+ .catch(() => { if (alive) { setStatus(null); setGeantwortet(true) } })+ }+ read()+ const timer = setInterval(read, ENGINE_STATUS_POLL_MS)+ let unlisten: (() => void) | null = null+ void import('@tauri-apps/api/event')+ .then(({ listen }) => listen(SIDECAR_GONE_EVENT, () => read()))+ .then((off) => { if (alive) unlisten = off; else off() })+ .catch(() => {})+ return () => {+ alive = false+ clearInterval(timer)+ unlisten?.()+ }+ }, [])++ return { status, geantwortet, setStatus }+}++/**+ * Bedient die Engine dieses Modell gerade NICHT.+ *+ * Vor der ersten Antwort falsch: dass noch niemand gefragt hat, ist kein+ * Beweis, dass nichts laeuft, und ein Use-Knopf, der eine halbe Sekunde lang+ * aufblitzt, ist ein Flackern.+ */+export function engineIsIdle(view: EngineStatusView): boolean {+ if (!view.geantwortet) return false+ return !view.status?.running+}