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): der Umschalt-Hinweis steht ueber dem Composer, nicht im Dropdown

purple196c5f637868
diff --git a/src/components/chat/ChatView.tsx b/src/components/chat/ChatView.tsx
index b2bb64a8..7e260201 100644
--- a/src/components/chat/ChatView.tsx
+++ b/src/components/chat/ChatView.tsx
@@ -10,6 +10,7 @@ import { ChatInput } from './ChatInput'
import { RAGPanel } from './RAGPanel'
import { DocsButton } from './DocsButton'
import { RetrievalErrorBar } from './RetrievalErrorBar'
+import { LuEngineSwitchBar } from './LuEngineSwitchBar'
import { useDocsAvailability } from '../../hooks/useDocsAvailability'
import { AgentModeToggle } from './AgentModeToggle'
import { AgentWorkspaceBadge } from './AgentWorkspaceBadge'
@@ -397,7 +398,7 @@ export function ChatView() {
// No plan lives here. The prompt window is the prompt window
// (David, 2026-08-22): the plan band sits under the header row
// above, next to the other standing status controls.
- composerAbove={<><RetrievalErrorBar /><LoopBar onStop={stopGeneration} /><GoalBar /><GroupCostHint /></>}
+ composerAbove={<><LuEngineSwitchBar /><RetrievalErrorBar /><LoopBar onStop={stopGeneration} /><GoalBar /><GroupCostHint /></>}
composerActions={
<>
{/* Documents (RAG), shown in both modes since A9. In
diff --git a/src/components/chat/CodexView.tsx b/src/components/chat/CodexView.tsx
index 025e2455..43bda7ef 100644
--- a/src/components/chat/CodexView.tsx
+++ b/src/components/chat/CodexView.tsx
@@ -18,6 +18,7 @@ import { PluginsDropdown } from './PluginsDropdown'
import { CodexModeDropdown } from './CodexModeDropdown'
import { ModelSelector } from '../models/ModelSelector'
import { GoalBar } from './GoalBar'
+import { LuEngineSwitchBar } from './LuEngineSwitchBar'
import { LoopBar } from './LoopBar'
import { useSettingsStore } from '../../stores/settingsStore'
import { useModelStore } from '../../stores/modelStore'
@@ -569,7 +570,7 @@ export function CodexView() {
// No plan lives here. The prompt window is the prompt window
// (David, 2026-08-22): the plan and its Approve-and-run card sit
// at the bottom of the Explorer column on the right.
- composerAbove={<><LoopBar onStop={stopCodex} /><GoalBar /></>}
+ composerAbove={<><LuEngineSwitchBar /><LoopBar onStop={stopCodex} /><GoalBar /></>}
// Ask / Bypass / Plan sits here, in the CODE composer only (plan
// C1). ChatInput stays surface-neutral, so the Chat tab inherits
// nothing from it. Plugins used to ride along here and now lives in
diff --git a/src/components/chat/LuEngineSwitchBar.tsx b/src/components/chat/LuEngineSwitchBar.tsx
new file mode 100644
index 00000000..8866cc5a
--- /dev/null
+++ b/src/components/chat/LuEngineSwitchBar.tsx
@@ -0,0 +1,30 @@
+/**
+ * The one line that says a model pick moved the chat backend.
+ *
+ * Same shape and same place as RetrievalErrorBar: above the composer, where
+ * standing statements live, so it survives the dropdown closing under it. Not
+ * an alarm colour, because nothing went wrong: the user asked for this by
+ * picking an LU Engine model, he just has to be told what it cost him.
+ */
+import { X } from 'lucide-react'
+import { useLuEngineSwitchStore } from '../../stores/luEngineSwitchStore'
+
+export function LuEngineSwitchBar() {
+ const note = useLuEngineSwitchStore((s) => s.note)
+ if (!note) return null
+ return (
+ <div
+ data-testid="lu-engine-switch-note"
+ className="mx-3 mb-1.5 flex items-start gap-2 px-2 py-1 rounded-md bg-white/5 border border-white/10 text-[0.62rem] text-gray-600 dark:text-gray-300"
+ >
+ <span className="flex-1 leading-snug">{note}</span>
+ <button
+ onClick={() => useLuEngineSwitchStore.getState().dismiss()}
+ className="shrink-0 text-gray-500 hover:text-gray-700 dark:hover:text-gray-200"
+ aria-label="Dismiss"
+ >
+ <X size={11} />
+ </button>
+ </div>
+ )
+}
diff --git a/src/components/chat/__tests__/lu-engine-switch-note-is-visible.test.ts b/src/components/chat/__tests__/lu-engine-switch-note-is-visible.test.ts
new file mode 100644
index 00000000..4da20302
--- /dev/null
+++ b/src/components/chat/__tests__/lu-engine-switch-note-is-visible.test.ts
@@ -0,0 +1,163 @@
+/**
+ * @vitest-environment jsdom
+ *
+ * A14 review, point 2: "Switched your chat provider to the LU Engine for this
+ * model." was written into the model picker's own dropdown, and the pick
+ * closes that dropdown. On the success path the line was drawn and unmounted
+ * in the same frame, so nobody ever read it; on the failure path it was
+ * suppressed by the error rendered beside it, which is the one moment the user
+ * most needs to know his chat backend has already moved.
+ *
+ * It lives above the composer now, in the standing status row, and it is
+ * announced BEFORE the engine start is attempted. What is proven here is that
+ * the sentence is on screen in a component that is NOT the dropdown, that it
+ * outlives the dropdown, and that an error does not silence it.
+ *
+ * Run: npx vitest run src/components/chat/__tests__/lu-engine-switch-note-is-visible.test.ts
+ */
+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'
+import { createElement } from 'react'
+import { render, screen, cleanup, act } from '@testing-library/react'
+
+vi.mock('../../../api/providers/registry', () => ({ clearProviderCache: vi.fn() }))
+vi.mock('../../../api/backend', () => ({
+ isTauri: () => false,
+ backendCall: vi.fn(async () => null),
+ secretGet: vi.fn().mockRejectedValue(new Error('no vault')),
+ secretSet: vi.fn(),
+ secretDelete: vi.fn(),
+}))
+
+const { LuEngineSwitchBar } = await import('../LuEngineSwitchBar')
+const { useLuEngineSwitchStore, LU_ENGINE_SWITCH_NOTE_MS } = await import('../../../stores/luEngineSwitchStore')
+const { ensureLuEngineIsChatProvider, LU_ENGINE_SWITCH_NOTE } = await import('../../../api/lu-engine-switch')
+const { useProviderStore } = await import('../../../stores/providerStore')
+
+/** What the picker and the Use button do, in the order they do it: hand the
+ * slot over, announce, and only then try to start the engine. */
+function pickAnLuEngineModel(): boolean {
+ const switched = ensureLuEngineIsChatProvider()
+ if (switched) useLuEngineSwitchStore.getState().announce(LU_ENGINE_SWITCH_NOTE)
+ return switched
+}
+
+beforeEach(() => {
+ useLuEngineSwitchStore.setState({ note: null, generation: 0 })
+ useProviderStore.getState().resetProvidersToDefaults()
+ useProviderStore.getState().setProviderConfig('openai', { enabled: false, managed: false })
+})
+afterEach(() => { cleanup(); vi.useRealTimers() })
+
+describe('the line survives the pick that caused it', () => {
+ it('stands in the composer row, which is not the dropdown', async () => {
+ render(createElement(LuEngineSwitchBar))
+ // Nothing to say before the pick.
+ expect(screen.queryByTestId('lu-engine-switch-note')).toBeNull()
+ await act(async () => { pickAnLuEngineModel() })
+ expect(screen.getByTestId('lu-engine-switch-note').textContent)
+ .toContain('Switched your chat provider to the LU Engine for this model.')
+ })
+
+ it('is still there after the dropdown that triggered it is gone', async () => {
+ // The dropdown unmounting is exactly what used to take the sentence with
+ // it. Rendering the bar on its own IS that situation.
+ const dropdown = render(createElement(LuEngineSwitchBar))
+ await act(async () => { pickAnLuEngineModel() })
+ dropdown.unmount()
+ render(createElement(LuEngineSwitchBar))
+ expect(screen.getByTestId('lu-engine-switch-note')).toBeTruthy()
+ })
+
+ it('an engine that fails to start does not silence it', async () => {
+ render(createElement(LuEngineSwitchBar))
+ await act(async () => {
+ pickAnLuEngineModel()
+ // The start blows up right after the announcement, the way a missing
+ // GGUF or a blocked port does.
+ try { throw new Error('llama-server exited before it could serve') } catch { /* the caller shows this elsewhere */ }
+ })
+ expect(screen.getByTestId('lu-engine-switch-note')).toBeTruthy()
+ // And the slot really did move, which is why the sentence has to stand.
+ expect(useProviderStore.getState().providers.openai.managed).toBe(true)
+ })
+
+ it('clears itself after a while instead of standing forever', async () => {
+ vi.useFakeTimers()
+ render(createElement(LuEngineSwitchBar))
+ act(() => { pickAnLuEngineModel() })
+ expect(screen.getByTestId('lu-engine-switch-note')).toBeTruthy()
+ act(() => { vi.advanceTimersByTime(LU_ENGINE_SWITCH_NOTE_MS + 10) })
+ expect(screen.queryByTestId('lu-engine-switch-note')).toBeNull()
+ })
+
+ it('can be dismissed by hand', async () => {
+ render(createElement(LuEngineSwitchBar))
+ await act(async () => { pickAnLuEngineModel() })
+ await act(async () => { screen.getByLabelText('Dismiss').click() })
+ expect(screen.queryByTestId('lu-engine-switch-note')).toBeNull()
+ })
+
+ // NEGATIVE CONTROL: picking a model while the LU Engine ALREADY holds the
+ // chat moved nothing, so there is nothing to announce. A line there would be
+ // a claim about a switch that never happened.
+ it('says nothing when the engine already held the chat', async () => {
+ useProviderStore.getState().setProviderConfig('openai', { enabled: true, managed: true, name: 'LU Engine' })
+ render(createElement(LuEngineSwitchBar))
+ await act(async () => { expect(pickAnLuEngineModel()).toBe(false) })
+ expect(screen.queryByTestId('lu-engine-switch-note')).toBeNull()
+ })
+
+ // NEGATIVE CONTROL: an older announcement's timer must not clear a newer
+ // line. Two picks in a row would otherwise leave the second one blank.
+ it('a second pick is not cut short by the first pick timer', () => {
+ vi.useFakeTimers()
+ render(createElement(LuEngineSwitchBar))
+ act(() => { useLuEngineSwitchStore.getState().announce('first') })
+ act(() => { vi.advanceTimersByTime(LU_ENGINE_SWITCH_NOTE_MS - 100) })
+ act(() => { useLuEngineSwitchStore.getState().announce('second') })
+ act(() => { vi.advanceTimersByTime(200) })
+ expect(screen.getByTestId('lu-engine-switch-note').textContent).toContain('second')
+ })
+})
+
+// ── Where the bar is mounted ────────────────────────────────────────────────
+//
+// The behaviour above proves the bar draws the sentence and outlives the
+// dropdown. It cannot prove the bar is on screen at all, because ChatView and
+// CodexView pull the whole chat stack and the repo has no render harness for
+// them (the same reason model-selector-lms.test.ts tests helpers). So the
+// mount points are pinned by reading the source, which is the weaker proof and
+// is labelled as such: it catches the bar being dropped from a composer, not a
+// composer that fails to render.
+describe('the bar is wired into every surface that can trigger it', () => {
+ const read = async (p: string) => {
+ const { readFileSync } = await import('node:fs')
+ const { resolve, dirname } = await import('node:path')
+ const { fileURLToPath } = await import('node:url')
+ return readFileSync(resolve(dirname(fileURLToPath(import.meta.url)), p), 'utf8')
+ }
+
+ it('sits above the chat composer', async () => {
+ const src = await read('../ChatView.tsx')
+ expect(src).toMatch(/composerAbove=\{<><LuEngineSwitchBar \/>/)
+ })
+
+ it('sits above the code composer, which has the same picker', async () => {
+ const src = await read('../CodexView.tsx')
+ expect(src).toMatch(/composerAbove=\{<><LuEngineSwitchBar \/>/)
+ })
+
+ it('and on the Models page, where Use can trigger it too', async () => {
+ const src = await read('../../models/DiscoverModels.tsx')
+ expect(src).toContain('<LuEngineSwitchBar />')
+ })
+
+ // NEGATIVE CONTROL: the sentence must not be written into the dropdown any
+ // more. Leaving a second copy there is how the two versions drift apart, and
+ // the dropdown copy is the one that is never read.
+ it('is no longer drawn inside the dropdown that closes on the pick', async () => {
+ const src = await read('../../models/ModelSelector.tsx')
+ expect(src).not.toContain('setSwitchNote')
+ expect(src).toContain('useLuEngineSwitchStore.getState().announce(LU_ENGINE_SWITCH_NOTE)')
+ })
+})
diff --git a/src/components/chat/__tests__/plan-done-vs-applied.test.ts b/src/components/chat/__tests__/plan-done-vs-applied.test.ts
index 01afc3cb..ada9d874 100644
--- a/src/components/chat/__tests__/plan-done-vs-applied.test.ts
+++ b/src/components/chat/__tests__/plan-done-vs-applied.test.ts
@@ -73,7 +73,11 @@ describe('the plan moved into the panel (C2)', () => {
// C1 had put the plan APPROVAL card here (a button plus the plan text the
// user is approving). It went down into the panel too on 2026-08-22: the
// prompt window is the prompt window.
- expect(src).toMatch(/composerAbove=\{<><LoopBar onStop=\{stopCodex\} \/><GoalBar \/><\/>\}/)
+ // Matched on what must be there rather than on the exact list: A14 added
+ // the LU Engine switch line to this row, and pinning the literal would
+ // turn every future status line into a failure of THIS claim. The claim is
+ // that no plan lives here, and the two lines below are the whole of it.
+ expect(src).toMatch(/composerAbove=\{<>.*<LoopBar onStop=\{stopCodex\} \/><GoalBar \/><\/>\}/)
expect(src).not.toMatch(/PlanBar/)
expect(src).not.toMatch(/PlanApprovalBar/)
})
diff --git a/src/components/models/DiscoverModels.tsx b/src/components/models/DiscoverModels.tsx
index edd9c8fa..f0b32019 100644
--- a/src/components/models/DiscoverModels.tsx
+++ b/src/components/models/DiscoverModels.tsx
@@ -29,6 +29,8 @@ import type { InstalledModelLike } from '../../lib/lmstudio-match'
import { findInstalledForDiscoverModel } from '../../lib/discover-installed'
import { isBuiltinEngineEntry } from '../../lib/lmstudio-match'
import { ensureLuEngineIsChatProvider, LU_ENGINE_SWITCH_NOTE } from '../../api/lu-engine-switch'
+import { useLuEngineSwitchStore } from '../../stores/luEngineSwitchStore'
+import { LuEngineSwitchBar } from '../chat/LuEngineSwitchBar'
import { resolveTextDownloadTarget } from '../../lib/text-download-target'
import { hfUrlToOllamaRef, hfUrlToLmStudioSubdir, parseHfUrl, extractGgufQuant, isShardedOrIncompatibleGguf } from '../../lib/hf-to-provider'
import { GlassCard } from '../ui/GlassCard'
@@ -241,7 +243,6 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
const name = entry?.name
if (!name || usingModel) return
setInstallError(null)
- setSwitchNote(null)
setUsingModel(name)
try {
if (isBuiltinEngineEntry(entry)) {
@@ -250,7 +251,9 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
// FIRST: diagnoseBuiltinEngine answers nothing at all for a slot that
// is not ours, so the old order would repair nothing and then activate
// a model no request routes to.
- if (ensureLuEngineIsChatProvider()) setSwitchNote(LU_ENGINE_SWITCH_NOTE)
+ if (ensureLuEngineIsChatProvider()) {
+ useLuEngineSwitchStore.getState().announce(LU_ENGINE_SWITCH_NOTE)
+ }
const diagnosis = await diagnoseBuiltinEngine({ repair: true, preferModel: name })
if (!diagnosis.ok && diagnosis.reason) setInstallError(diagnosis.reason)
}
@@ -265,8 +268,6 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
const [installingBundle, setInstallingBundle] = useState<string | null>(null)
const [installError, setInstallError] = useState<string | null>(null)
- // A14: the pick moved the chat backend. Not an error, so its own quiet line.
- const [switchNote, setSwitchNote] = useState<string | null>(null)
// Confirmation gate for multi-part (sharded) downloads — these sets routinely
// run hundreds of GB across many files, so we never start them silently.
const [confirmDownload, setConfirmDownload] = useState<{ name: string; files: HfGgufFile[]; targetDir: string; totalGB: number; note?: string } | null>(null)
@@ -767,15 +768,10 @@ export function DiscoverModels({ category, search = '', searchSubmitToken = 0 }:
</div>
)}
- {/* A14: the pick took the chat backend with it, and says so. */}
- {switchNote && (
- <div data-testid="lu-engine-switch-note" className="flex items-center gap-2 p-3 rounded-lg bg-white/5 border border-white/10 text-gray-600 dark:text-gray-300 text-sm">
- <span className="flex-1">{switchNote}</span>
- <button onClick={() => setSwitchNote(null)} className="text-gray-500 hover:text-gray-300 shrink-0" aria-label="Dismiss">
- <X size={14} />
- </button>
- </div>
- )}
+ {/* A14: the pick took the chat backend with it, and says so. The same
+ bar the composer shows, from the same store, so the sentence cannot
+ drift into two versions of itself. */}
+ <LuEngineSwitchBar />
{/* Install error banner */}
{installError && (
diff --git a/src/components/models/ModelSelector.tsx b/src/components/models/ModelSelector.tsx
index 1e3c853e..1655d0e0 100644
--- a/src/components/models/ModelSelector.tsx
+++ b/src/components/models/ModelSelector.tsx
@@ -21,6 +21,7 @@ import { cloudTeaserModels } from '../../lib/cloud-teaser-models'
import { splitLuEngineRows, LU_ENGINE_GROUP } from '../../lib/lu-engine-rows'
import { isBuiltinEngineEntry, type InstalledModelLike } from '../../lib/lmstudio-match'
import { ensureLuEngineIsChatProvider, LU_ENGINE_SWITCH_NOTE } from '../../api/lu-engine-switch'
+import { useLuEngineSwitchStore } from '../../stores/luEngineSwitchStore'
import type { AIModel } from '../../types/models'
// ── Local-mode cloud discovery (2.5.8): an "LU Cloud" section at the list's
@@ -545,10 +546,6 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy
// inline "loading…" state on the row and blocks a second click.
const [selectingLms, setSelectingLms] = useState<string | null>(null)
const [selectError, setSelectError] = useState<string | null>(null)
- // A14: the one line that says the pick moved the chat backend. Not an error,
- // so it does not share the red banner: the switch is what the user asked for
- // by pressing Use, he just has to be told it happened.
- const [switchNote, setSwitchNote] = useState<string | null>(null)
// VRAM load state for Ollama rows — parity with `lmsLoaded` above, so
// every LOCAL model shows a clear on/off load toggle (not just LM Studio).
// Sourced from /api/ps on dropdown open.
@@ -743,10 +740,15 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy
|| isBuiltinEngineEntry(model as unknown as InstalledModelLike)) {
if (selectingLms || togglingLms) return
setSelectError(null)
- setSwitchNote(null)
setSelectingLms(id)
try {
- if (ensureLuEngineIsChatProvider()) setSwitchNote(LU_ENGINE_SWITCH_NOTE)
+ // 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()) {
+ useLuEngineSwitchStore.getState().announce(LU_ENGINE_SWITCH_NOTE)
+ }
const swapped = await activateBuiltinModel(model.name)
if (swapped) {
// Raw store set — the useModels wrapper would fire a second
@@ -939,11 +941,6 @@ export function ModelSelector({ openUpward = false, surface = 'chat', answeredBy
</div>
)}
- {switchNote && !selectError && (
- <div data-testid="lu-engine-switch-note" className="mx-2 mt-2 px-2 py-1.5 rounded bg-white/5 border border-white/10 text-[0.6rem] text-gray-600 dark:text-gray-300 leading-snug">
- {switchNote}
- </div>
- )}
{/* Scrollable model list */}
<div className="py-1 max-h-[280px] overflow-y-auto scrollbar-thin">
diff --git a/src/stores/luEngineSwitchStore.ts b/src/stores/luEngineSwitchStore.ts
new file mode 100644
index 00000000..e232c62a
--- /dev/null
+++ b/src/stores/luEngineSwitchStore.ts
@@ -0,0 +1,44 @@
+/**
+ * "Switched your chat provider to the LU Engine for this model."
+ *
+ * A14 review, point 2: the sentence was written into the model picker's own
+ * dropdown, and the pick closes that dropdown. So on the one path where it
+ * mattered, the success path, the line was drawn and unmounted in the same
+ * frame and nobody ever read it. On the failure path it was suppressed by the
+ * error beside it, although a failed start is exactly when the user most needs
+ * to know his chat backend has already moved.
+ *
+ * It lives outside the dropdown now, in the standing status row above the
+ * composer, next to the other lines that survive an action (RetrievalErrorBar,
+ * LoopBar, GoalBar). Announced BEFORE the engine start is attempted, so it
+ * stands whether the start succeeds or fails, and in the failure case it
+ * stands beside the error rather than instead of it.
+ */
+
+import { create } from 'zustand'
+
+/** How long the line stays before it clears itself. Long enough to read twice,
+ * short enough that it is gone by the time the user sends his next message. */
+export const LU_ENGINE_SWITCH_NOTE_MS = 12_000
+
+interface LuEngineSwitchState {
+ note: string | null
+ /** Bumped on every announcement, so a timer belonging to an older one cannot
+ * clear a newer line. Same reason the slot-eviction timer keeps one. */
+ generation: number
+ announce: (note: string) => void
+ dismiss: () => void
+}
+
+export const useLuEngineSwitchStore = create<LuEngineSwitchState>((set, get) => ({
+ note: null,
+ generation: 0,
+ announce: (note) => {
+ const generation = get().generation + 1
+ set({ note, generation })
+ setTimeout(() => {
+ if (get().generation === generation) set({ note: null })
+ }, LU_ENGINE_SWITCH_NOTE_MS)
+ },
+ dismiss: () => set({ note: null, generation: get().generation + 1 }),
+}))