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(providers): Hinweis wenn LU Engine aus der Anbieterliste verschwindet
purpled1f93ea502ca
diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsxindex 6bb232af..2f3a61eb 100644--- a/src/components/chat/ChatView.tsx+++ b/src/components/chat/ChatView.tsx@@ -13,6 +13,7 @@ import { RAGPanel } from './RAGPanel'import { DocsButton } from './DocsButton'import { RetrievalErrorBar } from './RetrievalErrorBar'import { LuEngineSwitchBar } from './LuEngineSwitchBar'+import { EngineMissingBar } from './EngineMissingBar'import { useDocsAvailability } from '../../hooks/useDocsAvailability'import { AgentModeToggle } from './AgentModeToggle'import { FlashChatNotice } from './FlashChatNotice'@@ -773,7 +774,7 @@ export function ChatView() {// No plan lives here. The prompt window is the prompt window// (David, 2026-08-22): the plan band sits in the session strip// above, next to the other standing status controls.- composerAbove={<><LuEngineSwitchBar /><RetrievalErrorBar /><LoopBar onStop={stopGeneration} /><GoalBar /><GroupCostHint /></>}+ composerAbove={<><LuEngineSwitchBar /><EngineMissingBar /><RetrievalErrorBar /><LoopBar onStop={stopGeneration} /><GoalBar /><GroupCostHint /></>}composerActions={<>{/* Documents (RAG), shown in both modes since A9. Indiff --git a/src/components/chat/EngineMissingBar.tsx b/src/components/chat/EngineMissingBar.tsxnew file mode 100644index 00000000..12008869--- /dev/null+++ b/src/components/chat/EngineMissingBar.tsx@@ -0,0 +1,71 @@+/**+ * "LU Engine is missing from your providers."+ *+ * R13D Nebenfund 1 (3.0.1 box-gruen r13d, 2026-09-21): add two custom local+ * OpenAI-compatible providers in a row and remove both again, and LU Engine+ * falls out of the `openai` slot entirely, with no card and no restart+ * bringing it back. Root cause and the pure read of the slot both live in+ * `lib/builtin-engine-presence.ts`; this bar is only the composer-side+ * notice, same place RetrievalErrorBar and LuEngineSwitchBar already stand.+ *+ * Opus review, first round: `isBuiltinEngineMissing` alone is a false+ * positive for a customer who picked a different local backend on purpose+ * (onboarding, the startup backend selector, Start LM Studio Server), and+ * the notice used to claim "Local chat will not answer until it is back",+ * which is false whenever that other backend is the one actually holding+ * the slot. Fixed by reading `providerStore.engineOptedOut` (set only by+ * those deliberate pick UIs) and by dropping the claim about local chat+ * failing: this notice is about LU ENGINE specifically being gone, not+ * about whether local chat works at all.+ *+ * Shown only in Local mode: in Cloud mode the local slot is not on the path+ * the user's messages take, so the notice would be true but pointless there.+ * The Settings, AI Backends, Providers list carries the same check without+ * that gate, since the provider list itself is wrong regardless of mode.+ *+ * No Restore button here: the action that fixes this (`selectPreset` in+ * `ProviderConfig.tsx`, which also asks before a key loss) is local to that+ * component, not a handful of lines to reuse from outside it. The Settings+ * banner carries the button; this one names the path instead.+ *+ * Dismissal is session-only, not persisted: it resets the moment the engine+ * is back, so it never hides a standing problem across a restart.+ */+import { useState } from 'react'+import { AlertTriangle } from 'lucide-react'+import { Hinweis } from '../ui/Hinweis'+import { useProviderStore } from '../../stores/providerStore'+import { useSettingsStore } from '../../stores/settingsStore'+import { isBuiltinEngineMissing } from '../../lib/builtin-engine-presence'++export function EngineMissingBar() {+ const openaiSlot = useProviderStore((s) => s.providers.openai)+ const engineOptedOut = useProviderStore((s) => s.engineOptedOut)+ const appMode = useSettingsStore((s) => s.settings.appMode)+ const missing = appMode === 'local' && isBuiltinEngineMissing(openaiSlot, engineOptedOut)+ const [dismissed, setDismissed] = useState(false)+ // Reset the dismissal the moment the condition itself changes, adjusted+ // during render rather than in an effect (react-hooks/set-state-in-effect):+ // this is the "state that resets when a prop changes" case the React docs+ // call out, not a cascading-render trap. It keeps a dismissed notice from+ // hiding a DIFFERENT missing-engine episode than the one the user dismissed.+ const [wasMissing, setWasMissing] = useState(missing)+ if (missing !== wasMissing) {+ setWasMissing(missing)+ if (!missing) setDismissed(false)+ }++ if (!missing || dismissed) return null++ return (+ <div data-testid="engine-missing-bar" className="mx-3 mb-1.5">+ <Hinweis+ ton="fehler"+ icon={<AlertTriangle size={11} className="shrink-0 mt-0.5" />}+ onDismiss={() => setDismissed(true)}+ >+ LU Engine is missing from your providers. Add Provider, then LU Engine, in Settings, AI Backends, to use the app's own built-in engine again. We are fixing the cause in the next update.+ </Hinweis>+ </div>+ )+}diff --git a/src/components/chat/__tests__/engine-missing-bar.test.ts b/src/components/chat/__tests__/engine-missing-bar.test.tsnew file mode 100644index 00000000..f3919cb1--- /dev/null+++ b/src/components/chat/__tests__/engine-missing-bar.test.ts@@ -0,0 +1,89 @@+/**+ * @vitest-environment jsdom+ *+ * The composer-side half of the R13D Nebenfund 1 notice (see+ * lib/builtin-engine-presence.ts and EngineMissingBar.tsx): when LU Engine+ * has fallen out of the `openai` slot and the app is in Local mode, the line+ * where the user actually notices, above the chat input, has to say so.+ *+ * Run: npx vitest run src/components/chat/__tests__/engine-missing-bar.test.ts+ */+import { describe, it, expect, beforeEach, afterEach } from 'vitest'+import { createElement } from 'react'+import { render, screen, cleanup, fireEvent } from '@testing-library/react'+import type { ProviderConfig } from '../../../api/providers/types'+import { DEFAULT_SETTINGS } from '../../../lib/constants'++const { EngineMissingBar } = await import('../EngineMissingBar')+const { useProviderStore } = await import('../../../stores/providerStore')+const { useSettingsStore } = await import('../../../stores/settingsStore')++const openaiSlot = (extra: Partial<ProviderConfig>): ProviderConfig =>+ ({ id: 'openai', name: 'x', enabled: true, baseUrl: 'http://x', apiKey: '', isLocal: true, ...extra })++function setOpenai(config: ProviderConfig) {+ useProviderStore.setState((s) => ({ providers: { ...s.providers, openai: config } }))+}++beforeEach(() => {+ useSettingsStore.setState({ settings: { ...DEFAULT_SETTINGS, appMode: 'local' } })+ // Opus review: reset the opted-out flag so an earlier test's write cannot+ // leak into this one through the persisted singleton store.+ useProviderStore.setState({ engineOptedOut: false })+})+afterEach(cleanup)++describe('EngineMissingBar', () => {+ it('says nothing while LU Engine holds the slot', () => {+ setOpenai(openaiSlot({ managed: true, name: 'LU Engine' }))+ render(createElement(EngineMissingBar))+ expect(screen.queryByTestId('engine-missing-bar')).toBeNull()+ })++ it('names the way back when LU Engine is gone, in Local mode', () => {+ setOpenai(openaiSlot({ managed: false, name: 'Jan' }))+ render(createElement(EngineMissingBar))+ const bar = screen.getByTestId('engine-missing-bar')+ expect(bar.textContent).toContain('LU Engine is missing from your providers')+ expect(bar.textContent).toContain('Add Provider, then LU Engine')+ // Opus review, Blocker 2: must never claim local chat is broken, a+ // working local backend (Jan, here) can be the one holding the slot.+ expect(bar.textContent).not.toContain('Local chat will not answer')+ })++ // Opus review, Blocker 1: the exact same slot shape is what a customer+ // leaves behind by picking Ollama or LM Studio on purpose. Without+ // engineOptedOut this fired for every one of them, at every launch.+ it('NEGATIVE CONTROL: says nothing when the customer opted for a different backend on purpose (engineOptedOut)', () => {+ setOpenai(openaiSlot({ managed: false, name: 'Ollama-adjacent slot' }))+ useProviderStore.setState({ engineOptedOut: true })+ render(createElement(EngineMissingBar))+ expect(screen.queryByTestId('engine-missing-bar')).toBeNull()+ })++ it('is silent in Cloud mode even though the slot is really empty: the local slot is not on that path', () => {+ useSettingsStore.setState({ settings: { ...DEFAULT_SETTINGS, appMode: 'cloud' } })+ setOpenai(openaiSlot({ managed: false, name: 'Jan' }))+ render(createElement(EngineMissingBar))+ expect(screen.queryByTestId('engine-missing-bar')).toBeNull()+ })++ it('the X dismisses it', () => {+ setOpenai(openaiSlot({ managed: false, name: 'Jan' }))+ render(createElement(EngineMissingBar))+ expect(screen.getByTestId('engine-missing-bar')).toBeTruthy()+ fireEvent.click(screen.getByLabelText('Dismiss'))+ expect(screen.queryByTestId('engine-missing-bar')).toBeNull()+ })++ // NEGATIVE CONTROL: LU Engine parked on standby is not "gone", it has a+ // card and a way back already, so nothing should be drawn here either.+ it('NEGATIVE CONTROL: LU Engine only parked on standby draws nothing', () => {+ setOpenai(openaiSlot({+ managed: false, name: 'Jan',+ displaced: { name: 'LU Engine', baseUrl: 'http://127.0.0.1:8127/v1', isLocal: true, managed: true },+ }))+ render(createElement(EngineMissingBar))+ expect(screen.queryByTestId('engine-missing-bar')).toBeNull()+ })+})diff --git a/src/components/models/ModelSelector.tsx b/src/components/models/ModelSelector.tsxindex 1ba2282c..f2f577b3 100644--- a/src/components/models/ModelSelector.tsx+++ b/src/components/models/ModelSelector.tsx@@ -224,7 +224,14 @@ function LmStudioServerHint({ onStarted }: { onStarted: () => void }) {// end (Nebenbefund 4, R8 re-measure). Same call the// BackendSelector makes, no LM-Studio-only path.const update = lmStudioSlotUpdate(useProviderStore.getState().providers.openai)- if (update) useProviderStore.getState().setProviderConfig('openai', update)+ if (update) {+ useProviderStore.getState().setProviderConfig('openai', update)+ // Opus review, R13D follow-up: this click is the deliberate+ // pick `adoptionReplacesBuiltinEngine` already warns about+ // above, not an eviction bug, so the missing-engine notice+ // must not fire because of it. See lib/builtin-engine-presence.ts.+ if (update.managed === false) useProviderStore.getState().setEngineOptedOut(true)+ }onStarted()break}diff --git a/src/components/onboarding/BackendSelector.tsx b/src/components/onboarding/BackendSelector.tsxindex 84410ea5..877c2d67 100644--- a/src/components/onboarding/BackendSelector.tsx+++ b/src/components/onboarding/BackendSelector.tsx@@ -40,7 +40,7 @@ export function BackendSelector({ open, backends, onClose }: Props) {// Pre-checked: the common case is "saw it once, don't bug me again". User can// uncheck if they want it to re-appear on next launch.const [dontShowAgain, setDontShowAgain] = useState(true)- const { setProviderConfig, setHideBackendSelector } = useProviderStore()+ const { setProviderConfig, setHideBackendSelector, setEngineOptedOut } = useProviderStore()// 2.5.7: the `openai` slot holds the app-managed built-in engine by default.// When it does, this modal offers *alternatives* — skipping keeps the// built-in engine, and picking one switches away from it (clears `managed`).@@ -83,6 +83,11 @@ export function BackendSelector({ open, backends, onClose }: Props) {isLocal: true,managed: false,})+ // Opus review, R13D follow-up: a deliberate pick in this dialog, not+ // an eviction bug, so the missing-engine notice must not read this as+ // LU Engine having fallen out from under the customer. See+ // lib/builtin-engine-presence.ts.+ setEngineOptedOut(true)}dismiss()diff --git a/src/components/onboarding/BackendsStep.tsx b/src/components/onboarding/BackendsStep.tsxindex 3ef385f4..dfeec51a 100644--- a/src/components/onboarding/BackendsStep.tsx+++ b/src/components/onboarding/BackendsStep.tsx@@ -72,7 +72,7 @@ export function BackendsStep({ skin, scan, fleet, setStep, nextStepAfterBackendslmstudioOfflineDetected, lmstudioModelCount, runDetection, stopDetection,} = scanconst { ollama, ollamaDo, lmstudio, lmstudioDo, secondsOf } = fleet- const { setProviderConfig } = useProviderStore()+ const { setProviderConfig, setEngineOptedOut } = useProviderStore()return (<>@@ -363,6 +363,11 @@ export function BackendsStep({ skin, scan, fleet, setStep, nextStepAfterBackendsisLocal: true,managed: false,})+ // Opus review, R13D follow-up: the assistant just+ // installed and wired LM Studio on purpose, so the+ // missing-engine notice must not read this as an+ // eviction. See lib/builtin-engine-presence.ts.+ setEngineOptedOut(true)} else if (s.status === 'error') {clearInterval(poll)lmstudioDo({ type: 'fail', error: withInstallerOutput('Installing LM Studio did not finish.', lastLog(s.logs)) })diff --git a/src/components/onboarding/Onboarding.tsx b/src/components/onboarding/Onboarding.tsxindex a3ef31e2..354cb2e2 100644--- a/src/components/onboarding/Onboarding.tsx+++ b/src/components/onboarding/Onboarding.tsx@@ -90,7 +90,7 @@ export function Onboarding() {// heruntergeladen wurde. Deshalb steht die Liste hier und nicht dort.const [pulledModels, setPulledModels] = useState<string[]>([])const { settings, updateSettings } = useSettingsStore()- const { setProviderConfig } = useProviderStore()+ const { setProviderConfig, setEngineOptedOut } = useProviderStore()const isDark = settings.theme === 'dark'const skin = onboardingSkin(isDark)@@ -177,6 +177,11 @@ export function Onboarding() {// `lib/onboarding-provider-gate.ts` dem Assistenten stellt.setProviderConfig('ollama', { enabled: true, disabledByUser: false })setProviderConfig('openai', { enabled: false, managed: false })+ // Opus review, R13D follow-up: a deliberate pick here, not an eviction+ // bug, so the missing-engine notice must not read this as LU Engine+ // having fallen out from under the customer. See+ // lib/builtin-engine-presence.ts.+ setEngineOptedOut(true)} else {const backend = detectedBackends.find(b => b.id === selectedBackend)const preset = backend && PROVIDER_PRESETS.find(p => p.id === backend.id)@@ -185,6 +190,8 @@ export function Onboarding() {enabled: true, name: backend.name, baseUrl: backend.baseUrl,isLocal: true, managed: false,})+ // Same reasoning as the Ollama branch above: a deliberate pick.+ setEngineOptedOut(true)}}setStep(nextStepAfterBackends())diff --git a/src/components/settings/ProviderConfig.tsx b/src/components/settings/ProviderConfig.tsxindex c8215dec..e01f4eec 100644--- a/src/components/settings/ProviderConfig.tsx+++ b/src/components/settings/ProviderConfig.tsx@@ -1,5 +1,5 @@import { useState, useEffect, useRef } from 'react'-import { Wifi, WifiOff, Loader2, Eye, EyeOff, ChevronDown, Plus, Power, Play, Trash2 } from 'lucide-react'+import { Wifi, WifiOff, Loader2, Eye, EyeOff, ChevronDown, Plus, Power, Play, Trash2, X, AlertTriangle } from 'lucide-react'import { useProviderStore, deobfuscate } from '../../stores/providerStore'import { providerRowIds, isReturnableRow } from '../../lib/provider-visibility'import {@@ -22,8 +22,9 @@ import { useBuiltinEngineStatus } from '../../hooks/useBuiltinEngineStatus'import { reachVerdict, liveSlotStatus, type SlotStatus } from '../../lib/builtin-slot-status'import type { ProviderId, ProviderConfig } from '../../api/providers/types'import { disabledSlotNote } from '../../lib/disabled-slot-note'-import { HINWEIS_TEXT, PUNKT_FARBE } from '../../lib/hinweis'+import { HINWEIS_TEXT, HINWEIS_ZEILE, PUNKT_FARBE } from '../../lib/hinweis'import { parkApiKeyForBackend, restoreParkedApiKeyForBackend } from '../../lib/parked-key'+import { isBuiltinEngineMissing } from '../../lib/builtin-engine-presence'const isTauri = typeof window !== 'undefined' && !!window.__TAURI_INTERNALS__@@ -107,7 +108,7 @@ export function providerSlotView(id: ProviderId, config: ProviderConfig): SlotVitype LmStudioServerInfo = { lms_present: boolean; running: boolean }export function ProviderSettings() {- const { providers, setProviderConfig, setProviderApiKey, getProviderApiKey } = useProviderStore()+ const { providers, setProviderConfig, setProviderApiKey, getProviderApiKey, engineOptedOut } = useProviderStore()const [dropdownOpen, setDropdownOpen] = useState(false)const [testing, setTesting] = useState<ProviderId | null>(null)const [statuses, setStatuses] = useState<Record<string, SlotStatus>>({})@@ -125,6 +126,30 @@ export function ProviderSettings() {// See wouldLoseApiKeyOnRestart below for why this exists.const [showKeyLossWarning, setShowKeyLossWarning] = useState(false)const [expandedProvider, setExpandedProvider] = useState<ProviderId | null>(null)+ // R13D Nebenfund 1: LU Engine can fall out of the `openai` slot entirely+ // (see lib/builtin-engine-presence.ts for the read and the root cause).+ // Dismissal is session-only, not persisted: a restart re-checks the slot+ // and shows the notice again while the engine is still missing, so a+ // dismissed notice never hides a standing problem across restarts. It also+ // resets the moment the engine is back, so dismissing today's notice does+ // not silently swallow tomorrow's.+ const [engineNoticeDismissed, setEngineNoticeDismissed] = useState(false)+ // Opus review: `managed: false` with no `displaced` record is also the+ // shape a customer who picked Ollama or LM Studio on purpose leaves+ // behind (onboarding, the startup backend selector, Start LM Studio+ // Server). `engineOptedOut` is how those are told apart from the R13D+ // eviction bug; see lib/builtin-engine-presence.ts.+ const engineMissing = isBuiltinEngineMissing(providers.openai, engineOptedOut)+ // Reset the dismissal the moment the condition itself changes, adjusted+ // during render rather than in an effect (react-hooks/set-state-in-effect):+ // this is the "state that resets when a prop changes" case the React docs+ // call out, not a cascading-render trap. It keeps a dismissed notice from+ // hiding a DIFFERENT missing-engine episode than the one the user dismissed.+ const [engineWasMissing, setEngineWasMissing] = useState(engineMissing)+ if (engineMissing !== engineWasMissing) {+ setEngineWasMissing(engineMissing)+ if (!engineMissing) setEngineNoticeDismissed(false)+ }// Bug (g) state, LM-Studio-on-disk-but-server-off detection.@@ -482,6 +507,32 @@ export function ProviderSettings() {return (<div className="space-y-2">+ {engineMissing && !engineNoticeDismissed && (+ <div+ role="alert"+ data-testid="engine-missing-notice"+ className={`${HINWEIS_ZEILE} ${HINWEIS_TEXT.fehler} px-1`}+ >+ <AlertTriangle size={11} className="shrink-0 mt-0.5" />+ <span className="flex-1 min-w-0">+ LU Engine is missing from your providers. Restore it below to use the app's own built-in engine again. We are fixing the cause in the next update.+ </span>+ <button+ onClick={() => selectPreset(PROVIDER_PRESETS.find(p => p.id === 'builtin')!)}+ className="lu-control self-center shrink-0"+ >+ Restore LU Engine+ </button>+ <button+ onClick={() => setEngineNoticeDismissed(true)}+ className="self-center shrink-0 rounded p-[1px] opacity-70 hover:opacity-100 transition-opacity"+ aria-label="Dismiss"+ title="Dismiss"+ >+ <X size={11} />+ </button>+ </div>+ )}{/* Providers List: enabled rows, plus the ones the user switched off */}{rowIds.map(id => {const config = providers[id]diff --git a/src/components/settings/__tests__/engine-missing-notice.test.ts b/src/components/settings/__tests__/engine-missing-notice.test.tsnew file mode 100644index 00000000..26b7f594--- /dev/null+++ b/src/components/settings/__tests__/engine-missing-notice.test.ts@@ -0,0 +1,170 @@+/**+ * @vitest-environment jsdom+ *+ * R13D Nebenfund 1 (3.0.1 box-gruen r13d, 2026-09-21): two custom local+ * OpenAI-compatible providers added and removed again can take LU Engine+ * out of the provider list entirely, with no card and no restart bringing+ * it back. Root cause lives in the single-slot memory of+ * `lib/openai-slot-handover.ts` and is not reworked here (owner's+ * instruction: notice only, no rebuild of the slot logic for 3.0.1). This+ * proves the notice: it shows exactly when LU Engine is really gone, the X+ * dismisses it, Restore calls the same path Add Provider, LU Engine uses,+ * and the normal state draws nothing at all.+ *+ * Run: npx vitest run src/components/settings/__tests__/engine-missing-notice.test.ts+ */+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'+import { createElement } from 'react'+import { render, screen, cleanup, act, fireEvent } from '@testing-library/react'+import type { ProviderConfig, ProviderId } from '../../../api/providers/types'++const checkConnection = vi.fn()+const listModels = vi.fn()++vi.mock('../../../api/backend', () => ({+ backendCall: vi.fn(async () => ({})),+ isTauri: () => false,+ isMacOS: () => false,+ openExternal: vi.fn(),+ secretGet: vi.fn().mockRejectedValue(new Error('no keychain here')),+ secretSet: vi.fn(),+ secretDelete: vi.fn(),+}))+vi.mock('../../../api/builtin-ensure', () => ({+ readBuiltinSlotStatus: vi.fn(async () => null),+ diagnoseBuiltinEngine: vi.fn(async () => ({ ok: false, reason: '' })),+}))+vi.mock('../../../api/providers', async () => {+ const actual = await vi.importActual<typeof import('../../../api/providers')>('../../../api/providers')+ return { ...actual, getProvider: () => ({ checkConnection, listModels }) }+})++const { ProviderSettings } = await import('../ProviderConfig')+const { useProviderStore } = await import('../../../stores/providerStore')++const aus = (id: ProviderId, name: string, baseUrl: string, extra: Partial<ProviderConfig> = {}): ProviderConfig =>+ ({ id, name, enabled: false, baseUrl, apiKey: '', isLocal: false, ...extra })++function baseline(openai: ProviderConfig, engineOptedOut = false) {+ useProviderStore.setState({+ providers: {+ ollama: aus('ollama', 'Ollama', 'http://localhost:11434'),+ openai,+ anthropic: aus('anthropic', 'Anthropic', 'https://api.anthropic.com'),+ 'lu-cloud': aus('lu-cloud', 'LU Cloud', 'https://lu-labs.ai/api/inference/v1'),+ },+ // Opus review: a stale opt-out from an earlier test in this file (or a+ // stale value the persisted singleton store carried in from elsewhere)+ // must not leak between cases, the same reason `providers` is reset here.+ engineOptedOut,+ })+}++beforeEach(() => {+ checkConnection.mockReset()+ checkConnection.mockResolvedValue(true)+ listModels.mockReset()+ listModels.mockResolvedValue([])+})+afterEach(cleanup)++async function open() {+ const utils = render(createElement(ProviderSettings))+ await act(async () => { await new Promise((r) => setTimeout(r, 0)) })+ return utils+}++describe('the LU Engine missing notice in Settings, AI Backends, Providers', () => {+ it('is drawn when LU Engine occupies the slot and nothing is on standby: NOTHING', async () => {+ baseline({ id: 'openai', name: 'LU Engine', enabled: true, baseUrl: 'http://127.0.0.1:8127/v1', apiKey: '', isLocal: true, managed: true })+ await open()+ expect(screen.queryByTestId('engine-missing-notice')).toBeNull()+ })++ it('is drawn when LU Engine is entirely gone: no occupant, no standby card', async () => {+ baseline({ id: 'openai', name: 'Jan', enabled: true, baseUrl: 'http://localhost:1337/v1', apiKey: '', isLocal: true, managed: false })+ await open()+ const notice = screen.getByTestId('engine-missing-notice')+ expect(notice.textContent).toContain('LU Engine is missing from your providers')+ expect(notice.textContent).toContain('We are fixing the cause in the next update')+ // Opus review, Blocker 2: the notice must never claim local chat is+ // broken, since a working local backend can be sitting right there in+ // the slot Jan occupies here.+ expect(notice.textContent).not.toContain('Local chat will not answer')+ })++ // Opus review, Blocker 1: the exact same slot shape (managed: false, no+ // displaced) is what a customer leaves behind by picking Ollama or LM+ // Studio on purpose in onboarding, the startup selector, or Start LM+ // Studio Server. Without engineOptedOut this used to be a false positive+ // shown to every one of those customers, at every single launch.+ it('NEGATIVE CONTROL: is NOT drawn when the customer opted for a different backend on purpose (engineOptedOut)', async () => {+ baseline({ id: 'openai', name: 'Ollama-adjacent slot', enabled: false, baseUrl: 'http://127.0.0.1:8127/v1', apiKey: '', isLocal: true, managed: false }, true)+ await open()+ expect(screen.queryByTestId('engine-missing-notice')).toBeNull()+ })++ it('is NOT drawn when LU Engine is only parked on standby: it has a way back already', async () => {+ baseline({+ id: 'openai', name: 'Jan', enabled: true, baseUrl: 'http://localhost:1337/v1', apiKey: '', isLocal: true, managed: false,+ displaced: { name: 'LU Engine', baseUrl: 'http://127.0.0.1:8127/v1', isLocal: true, managed: true },+ })+ await open()+ expect(screen.queryByTestId('engine-missing-notice')).toBeNull()+ })++ it('the X dismisses it for the running session', async () => {+ baseline({ id: 'openai', name: 'Jan', enabled: true, baseUrl: 'http://localhost:1337/v1', apiKey: '', isLocal: true, managed: false })+ await open()+ expect(screen.getByTestId('engine-missing-notice')).toBeTruthy()+ fireEvent.click(screen.getByLabelText('Dismiss'))+ expect(screen.queryByTestId('engine-missing-notice')).toBeNull()+ })++ it('Restore LU Engine hands the slot back through the SAME path (selectPreset) the Add Provider dropdown uses, and the notice clears', async () => {+ baseline({ id: 'openai', name: 'Jan', enabled: true, baseUrl: 'http://localhost:1337/v1', apiKey: '', isLocal: true, managed: false })+ await open()+ await act(async () => { fireEvent.click(screen.getByRole('button', { name: 'Restore LU Engine' })) })+ expect(screen.queryByTestId('engine-missing-notice')).toBeNull()+ const openai = useProviderStore.getState().providers.openai+ expect(openai.managed).toBe(true)+ expect(openai.name).toBe('LU Engine')+ expect(openai.baseUrl).toBe('http://127.0.0.1:8127/v1')+ // The backend that was occupying the slot is remembered on standby, the+ // same swap every other takeover does, Jan is not just thrown away.+ expect(openai.displaced?.name).toBe('Jan')+ })++ // Opus review, Blocker 3: the button called applyPreset directly, which+ // skips selectPreset's key-loss warning. A customer whose own provider+ // carries an API key that cannot be parked in the OS keychain would lose+ // it on the next restart with nobody asking first. Proven here by reading+ // the wiring: the Restore button must go through the SAME function name+ // the "Add Provider, LU Engine" dropdown entry uses, not a second path+ // that happens to look similar.+ it('the wiring goes through selectPreset, not a second path that skips its key-loss check', async () => {+ const { readFileSync } = await import('node:fs')+ const { resolve, dirname } = await import('node:path')+ const { fileURLToPath } = await import('node:url')+ const pane = readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../ProviderConfig.tsx'), 'utf8')+ const bannerStart = pane.indexOf('data-testid="engine-missing-notice"')+ const bannerEnd = pane.indexOf('{/* Providers List')+ expect(bannerStart).toBeGreaterThan(-1)+ expect(bannerEnd).toBeGreaterThan(bannerStart)+ const banner = pane.slice(bannerStart, bannerEnd)+ expect(banner).toMatch(/onClick=\{\(\) => selectPreset\(PROVIDER_PRESETS\.find\(p => p\.id === 'builtin'\)!\)\}/)+ expect(banner).not.toContain('applyPreset(')+ })++ // NEGATIVE CONTROL: two providers on the screen, one occupant and one+ // standby card, and neither one is LU Engine, is the one state where the+ // notice really is owed.+ it('NEGATIVE CONTROL: two custom providers on screen, LU Engine in neither, the notice shows', async () => {+ baseline({+ id: 'openai', name: 'LM Studio', enabled: true, baseUrl: 'http://localhost:1234/v1', apiKey: '', isLocal: true, managed: false,+ displaced: { name: 'Jan', baseUrl: 'http://localhost:1337/v1', isLocal: true, managed: false },+ })+ await open()+ expect(screen.getByTestId('engine-missing-notice')).toBeTruthy()+ })+})diff --git a/src/lib/__tests__/builtin-engine-presence.test.ts b/src/lib/__tests__/builtin-engine-presence.test.tsnew file mode 100644index 00000000..a207ff85--- /dev/null+++ b/src/lib/__tests__/builtin-engine-presence.test.ts@@ -0,0 +1,85 @@+import { describe, it, expect } from 'vitest'+import { isBuiltinEngineMissing } from '../builtin-engine-presence'++describe('isBuiltinEngineMissing', () => {+ it('is false when LU Engine occupies the slot', () => {+ expect(isBuiltinEngineMissing({ managed: true })).toBe(false)+ })++ it('is true when a custom provider occupies the slot and nothing is on standby', () => {+ expect(isBuiltinEngineMissing({ managed: false })).toBe(true)+ expect(isBuiltinEngineMissing({ managed: false, displaced: undefined })).toBe(true)+ })++ it('is false when LU Engine is only parked on standby', () => {+ expect(isBuiltinEngineMissing({ managed: false, displaced: { managed: true } })).toBe(false)+ })++ it('is true when a different backend is parked on standby, not LU Engine', () => {+ // Two custom providers in a row: the second takeover overwrote the+ // standby memory that used to hold LU Engine (R13D Nebenfund 1), so the+ // slot now remembers only the first custom provider, e.g. Jan.+ expect(isBuiltinEngineMissing({ managed: false, displaced: { managed: false } })).toBe(true)+ expect(isBuiltinEngineMissing({ managed: false, displaced: {} })).toBe(true)+ })++ it('is true for a missing or empty slot, independent of any other provider being active', () => {+ // Cloud mode active (lu-cloud enabled) says nothing about the openai+ // slot itself: this check reads only the slot it is given, never a+ // global mode flag, so a caller gating on cloud mode does that itself.+ expect(isBuiltinEngineMissing(undefined)).toBe(true)+ expect(isBuiltinEngineMissing(null)).toBe(true)+ expect(isBuiltinEngineMissing({})).toBe(true)+ })+})++// Opus review, first round: `managed: false` with no `displaced` record is+// not proof of the R13D eviction bug. Five write paths in the app leave the+// `openai` slot in exactly that shape ON PURPOSE, because the customer+// picked a different local backend for himself. `optedOut` is how the+// caller tells this function which situation it is looking at; see+// providerStore.engineOptedOut and its five call sites.+describe('isBuiltinEngineMissing, the optedOut parameter (Opus review, first round)', () => {+ // The resulting `openai` slot shape each of the five deliberate-pick call+ // sites leaves behind. None of them write `displaced`, which is exactly+ // why the bare two-argument check could not tell them apart from R13D.+ const deliberatePickShapes = [+ { label: 'Onboarding.tsx:179, Ollama chosen', slot: { managed: false } },+ { label: 'Onboarding.tsx:184, a detected backend chosen', slot: { managed: false, displaced: undefined } },+ { label: 'BackendsStep.tsx:359, LM Studio installed by the assistant', slot: { managed: false } },+ { label: 'BackendSelector.tsx:79, startup selector dialog', slot: { managed: false } },+ { label: 'ModelSelector.tsx:227, Start LM Studio Server', slot: { managed: false } },+ ]++ it('is false for every one of the five deliberate pick paths once optedOut is set, as the app itself sets it', () => {+ const results = deliberatePickShapes.map((c) => isBuiltinEngineMissing(c.slot, true))+ expect(results).toEqual([false, false, false, false, false])+ // Negative control with numbers: exactly 0 of the 5 read as missing once+ // opted out is true, and exactly 5 of 5 would read as missing without it+ // (the false-positive this review caught).+ expect(results.filter((r) => r === true)).toHaveLength(0)+ const withoutOptOut = deliberatePickShapes.map((c) => isBuiltinEngineMissing(c.slot, false))+ expect(withoutOptOut.filter((r) => r === true)).toHaveLength(5)+ })++ it('the R13D eviction chain still reads as missing: optedOut stays false because Add Provider never sets it', () => {+ // Two custom providers added in a row, both removed again: the slot the+ // silent-eviction bug leaves behind, see the tests above this describe+ // block. No pick UI ran, so engineOptedOut was never set to true.+ const r13dSlot = { managed: false, displaced: { managed: false } }+ expect(isBuiltinEngineMissing(r13dSlot, false)).toBe(true)+ })++ it('a stale opt-out does not survive LU Engine actually coming back: the caller reads providerStore.engineOptedOut fresh, this function just trusts what it is given', () => {+ // This function itself has no memory; the reset-on-return behaviour is+ // providerStore.setProviderConfig's job (see its own tests). Documented+ // here so a reader of this file is not surprised the function itself+ // does not special-case `slot.managed === true` against `optedOut`.+ expect(isBuiltinEngineMissing({ managed: true }, true)).toBe(false)+ expect(isBuiltinEngineMissing({ managed: true }, false)).toBe(false)+ })++ it('optedOut defaults to false: the old, single-argument call sites keep meaning exactly what they meant before', () => {+ expect(isBuiltinEngineMissing({ managed: false })).toBe(true)+ })+})diff --git a/src/lib/builtin-engine-presence.ts b/src/lib/builtin-engine-presence.tsnew file mode 100644index 00000000..b5365aa0--- /dev/null+++ b/src/lib/builtin-engine-presence.ts@@ -0,0 +1,59 @@+/**+ * Whether the built-in LU Engine provider has fallen out of the provider+ * list entirely, WITHOUT the customer having chosen that.+ *+ * R13D Nebenfund 1 (3.0.1 box-gruen r13d, 2026-09-21): add two custom local+ * OpenAI-compatible providers in a row and remove both again, and the LU+ * Engine card is gone from Settings, AI Backends, Providers, with no card+ * anywhere and no restart bringing it back. Root cause lives in+ * `lib/openai-slot-handover.ts`: the shared `openai` slot remembers only ONE+ * displaced backend (`ProviderConfig.displaced`, a single object, not a+ * stack). `slotTakeoverUpdate` overwrites that single memory on every+ * takeover, so the SECOND custom provider's takeover discards LU Engine's+ * `displaced` record, not the later removal. This function does not fix that+ * (see the comment above for the real cause); it only lets the app notice+ * and say so, per the owner's instruction: no rework of the slot logic for+ * 3.0.1, just a clear, dismissible notice with a way back.+ *+ * Opus review, first round (2026-09-21): reading `managed`/`displaced` alone+ * is a false positive for every customer who never had LU Engine in the+ * first place, or who chose a different local backend on purpose. Five+ * pick UIs write `managed: false` with no `displaced` record onto the+ * `openai` slot, the EXACT same shape the silent-eviction bug leaves behind+ * (onboarding's Ollama and detected-backend choices, the startup backend+ * selector, "Start LM Studio Server" in the model picker): the provider+ * config alone cannot tell "evicted by the bug" from "picked on purpose"+ * apart. `providerStore.engineOptedOut` is the difference: set only by+ * those dedicated pick UIs (not by Add Provider, which is the path the bug+ * actually runs through), and cleared automatically the moment `managed:+ * true` is written back onto the slot. When the caller does not pass it,+ * this stays exactly the check it was before that flag existed, so every+ * unit test written against a bare slot keeps meaning what it always meant.+ *+ * "im Zweifel enger feuern" (owner's instruction): `optedOut` defaults to+ * `false` only for backward compatibility with the slot-only signature. Both+ * call sites in the app (ProviderConfig.tsx, EngineMissingBar.tsx) pass the+ * real flag, so in the running app a missed notice is the only kind of+ * mistake this can make, never a false one.+ */++/** The parts of the `openai` slot this check reads. Matches the shape of+ * `ProviderConfig` and `HandoverSlot` without importing either, so this+ * stays a plain, dependency-free function. */+export interface EngineSlotView {+ managed?: boolean+ displaced?: {+ managed?: boolean+ }+}++export function isBuiltinEngineMissing(+ slot: EngineSlotView | undefined | null,+ optedOut = false,+): boolean {+ if (!slot) return true+ if (slot.managed) return false+ if (slot.displaced?.managed) return false+ if (optedOut) return false+ return true+}diff --git a/src/stores/__tests__/engine-opted-out-wiring.test.ts b/src/stores/__tests__/engine-opted-out-wiring.test.tsnew file mode 100644index 00000000..19675463--- /dev/null+++ b/src/stores/__tests__/engine-opted-out-wiring.test.ts@@ -0,0 +1,68 @@+/**+ * Opus review, first round, Blocker 1: the five call sites that write+ * `managed: false` onto the `openai` slot as a DELIBERATE customer pick must+ * mark `providerStore.engineOptedOut`, or the missing-engine notice+ * (lib/builtin-engine-presence.ts) is a false positive for every one of+ * them. Pinned by reading the source, the same way+ * builtin-card-survives-add-provider.test.ts pins ProviderConfig.tsx's own+ * wiring: this is app wiring across several component files, not pure logic+ * a unit test can exercise without mounting each surface.+ *+ * Run: npx vitest run src/stores/__tests__/engine-opted-out-wiring.test.ts+ */+import { readFileSync } from 'node:fs'+import { resolve, dirname } from 'node:path'+import { fileURLToPath } from 'node:url'+import { describe, it, expect } from 'vitest'++const here = dirname(fileURLToPath(import.meta.url))+const read = (p: string) => readFileSync(resolve(here, p), 'utf8')++describe('the five deliberate-pick call sites mark engineOptedOut', () => {+ it('Onboarding.tsx: choosing Ollama at first setup', () => {+ const src = read('../../components/onboarding/Onboarding.tsx')+ const at = src.indexOf("setProviderConfig('openai', { enabled: false, managed: false })")+ expect(at, 'the Ollama branch write').toBeGreaterThan(-1)+ const nextLines = src.slice(at, at + 350)+ expect(nextLines).toContain('setEngineOptedOut(true)')+ })++ it('Onboarding.tsx: choosing a detected OpenAI-compatible backend at first setup', () => {+ const src = read('../../components/onboarding/Onboarding.tsx')+ const at = src.indexOf("isLocal: true, managed: false,\n })\n // Same reasoning")+ expect(at, 'the detected-backend branch write').toBeGreaterThan(-1)+ expect(src.slice(at, at + 200)).toContain('setEngineOptedOut(true)')+ })++ it('BackendsStep.tsx: the assistant installs and wires LM Studio', () => {+ const src = read('../../components/onboarding/BackendsStep.tsx')+ const at = src.indexOf("name: 'LM Studio',\n baseUrl: 'http://localhost:1234/v1'")+ expect(at, 'the LM Studio install write').toBeGreaterThan(-1)+ expect(src.slice(at, at + 600)).toContain('setEngineOptedOut(true)')+ })++ it('BackendSelector.tsx: the startup dialog, a non-Ollama backend chosen', () => {+ const src = read('../../components/onboarding/BackendSelector.tsx')+ const at = src.indexOf('managed: false,\n })\n // Opus review')+ expect(at, 'the selector dialog write').toBeGreaterThan(-1)+ expect(src.slice(at, at + 400)).toContain('setEngineOptedOut(true)')+ })++ it('ModelSelector.tsx: Start LM Studio Server', () => {+ const src = read('../../components/models/ModelSelector.tsx')+ const at = src.indexOf('lmStudioSlotUpdate(useProviderStore.getState().providers.openai)')+ expect(at, 'the Start LM Studio Server click').toBeGreaterThan(-1)+ const body = src.slice(at, at + 700)+ expect(body).toContain("if (update.managed === false) useProviderStore.getState().setEngineOptedOut(true)")+ })++ // NEGATIVE CONTROL: the Add Provider dropdown (ProviderConfig.tsx's+ // selectPreset/applyPreset) is the path the R13D eviction bug actually+ // runs through, and it must NOT mark engineOptedOut, or a customer who+ // adds a second custom provider after already losing LU Engine would have+ // that loss wrongly certified as "on purpose" too.+ it('NEGATIVE CONTROL: ProviderConfig.tsx never calls setEngineOptedOut', () => {+ const src = read('../../components/settings/ProviderConfig.tsx')+ expect(src).not.toContain('setEngineOptedOut')+ })+})diff --git a/src/stores/__tests__/engine-opted-out.test.ts b/src/stores/__tests__/engine-opted-out.test.tsnew file mode 100644index 00000000..a4329b90--- /dev/null+++ b/src/stores/__tests__/engine-opted-out.test.ts@@ -0,0 +1,61 @@+/**+ * Opus review, first round, Blocker 1: `providerStore.engineOptedOut` is the+ * flag that tells a deliberate customer pick apart from the R13D silent+ * eviction bug, both of which leave the same `{ managed: false }` shape on+ * the `openai` slot (see lib/builtin-engine-presence.ts). This proves the+ * store half: the setter writes it, and `setProviderConfig` clears it again+ * the moment LU Engine is really back on the slot.+ *+ * The five call sites themselves (Onboarding.tsx, BackendsStep.tsx,+ * BackendSelector.tsx, ModelSelector.tsx) are pinned by source-text+ * assertions in engine-opted-out-wiring.test.ts, one file up from the store+ * so the source-reading helper does not need to walk out of stores/.+ *+ * Run: npx vitest run src/stores/__tests__/engine-opted-out.test.ts+ */+import { describe, it, expect, vi, beforeEach } from 'vitest'++vi.mock('../../api/providers/client-cache', () => ({ clearProviderCache: vi.fn() }))++import { useProviderStore } from '../providerStore'++beforeEach(() => {+ useProviderStore.setState({ engineOptedOut: false })+})++describe('providerStore.engineOptedOut', () => {+ it('starts false', () => {+ expect(useProviderStore.getState().engineOptedOut).toBe(false)+ })++ it('setEngineOptedOut writes the flag', () => {+ useProviderStore.getState().setEngineOptedOut(true)+ expect(useProviderStore.getState().engineOptedOut).toBe(true)+ })++ it('setProviderConfig clears a stale opt-out the moment LU Engine is written back onto the slot (managed: true)', () => {+ useProviderStore.getState().setEngineOptedOut(true)+ useProviderStore.getState().setProviderConfig('openai', {+ enabled: true, name: 'LU Engine', baseUrl: 'http://127.0.0.1:8127/v1', isLocal: true, managed: true,+ })+ expect(useProviderStore.getState().engineOptedOut).toBe(false)+ })++ // NEGATIVE CONTROL: a write to the openai slot that does NOT set+ // managed: true (an ordinary Disable, a Test click's status update, or a+ // takeover by yet another custom provider) must leave a recorded opt-out+ // standing, otherwise the flag would clear itself on the very next+ // unrelated write and stop meaning anything.+ it('NEGATIVE CONTROL: a write that does not set managed: true leaves the opt-out standing', () => {+ useProviderStore.getState().setEngineOptedOut(true)+ useProviderStore.getState().setProviderConfig('openai', { enabled: false })+ expect(useProviderStore.getState().engineOptedOut).toBe(true)+ })++ // NEGATIVE CONTROL: a write to a DIFFERENT slot must not touch the flag.+ it('NEGATIVE CONTROL: writing to the ollama slot leaves the openai opt-out alone', () => {+ useProviderStore.getState().setEngineOptedOut(true)+ useProviderStore.getState().setProviderConfig('ollama', { enabled: true })+ expect(useProviderStore.getState().engineOptedOut).toBe(true)+ })+})diff --git a/src/stores/providerStore.ts b/src/stores/providerStore.tsindex b687d46b..2294952c 100644--- a/src/stores/providerStore.ts+++ b/src/stores/providerStore.ts@@ -165,6 +165,22 @@ interface ProviderState {* AppShell never re-shows the modal on startup even if multiple backends are* running. User can still add / remove providers via Settings → Providers. */hideBackendSelector: boolean+ /**+ * Persisted: the customer picked a different local backend for the `openai`+ * slot ON PURPOSE, through one of the dedicated pick UIs (onboarding's+ * backend step, the startup backend selector, "Start LM Studio Server" in+ * the model picker), not through Add Provider taking the slot from LU+ * Engine. Opus review, R13D Nebenfund 1 follow-up (2026-09-21): the missing+ *-engine notice (lib/builtin-engine-presence.ts) must not fire for a+ * customer who never had, or never wanted, LU Engine in the first place.+ * Those pick UIs write `managed: false` with no `displaced` record, the+ * exact same shape the silent-eviction bug leaves behind, so the provider+ * config alone cannot tell the two apart; this flag is the difference.+ * Reset to false automatically the moment `managed: true` is written back+ * onto the `openai` slot (Built-in chosen again, Restore, or a full Reset),+ * so a LATER real eviction is still caught.+ */+ engineOptedOut: booleansetProviderConfig: (id: ProviderId, updates: Partial<ProviderConfig>) => voidsetProviderApiKey: (id: ProviderId, key: string) => void@@ -178,6 +194,10 @@ interface ProviderState {* cloud-enabled is account state owned by useCloudAuth, not backend config. */resetProvidersToDefaults: () => voidsetHideBackendSelector: (hide: boolean) => void+ /** Marks (or clears) the deliberate opt-out above. The five pick UIs call+ * this with `true`; nothing else needs to call it with `false`, since+ * `setProviderConfig` clears it on its own the moment LU Engine is back. */+ setEngineOptedOut: (optedOut: boolean) => void/** H5: load provider keys from the OS keychain (Win/macOS), migrating any* existing localStorage key into the vault. No-op / fallback elsewhere.* Call once at app startup, before the first provider client is built. */@@ -191,8 +211,10 @@ export const useProviderStore = create<ProviderState>()((set, get) => ({providers: DEFAULT_PROVIDERS,hideBackendSelector: false,+ engineOptedOut: false,setHideBackendSelector: (hide) => set({ hideBackendSelector: hide }),+ setEngineOptedOut: (optedOut) => set({ engineOptedOut: optedOut }),setProviderConfig: (id, updates) => {const before = get().providers[id]@@ -210,6 +232,13 @@ export const useProviderStore = create<ProviderState>()(// it used to get: Jan takes the slot, lu-llama-server keeps PID and// model in RAM until the app is restarted. See lib/builtin-slot-eviction.if (id === 'openai') onLocalSlotChanged(before, get().providers.openai)+ // LU Engine is back on the slot on purpose (Built-in chosen again,+ // Restore, a full Reset): whatever opt-out was recorded no longer+ // describes the customer's current choice, so a LATER real eviction+ // is not silently swallowed by a stale flag.+ if (id === 'openai' && updates.managed === true && get().engineOptedOut) {+ set({ engineOptedOut: false })+ }},setProviderApiKey: (id, key) => {@@ -417,6 +446,7 @@ export const useProviderStore = create<ProviderState>()(})) as Record<ProviderId, ProviderConfig>,hideBackendSelector: state.hideBackendSelector,+ engineOptedOut: state.engineOptedOut,}),})