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): die Fehlerzeile am Engine-Wechsel laeuft nicht mehr von selbst weg

purpleb00e378c88db
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
index abfa34dd..a1c6e6eb 100644
--- 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
@@ -115,6 +115,50 @@ describe('the line survives the pick that caused it', () => {
expect(screen.queryByTestId('lu-engine-switch-note')).toBeNull()
})
+ // A14 fourth review: the self-clear was armed for both tones, so the one
+ // line the user has to ACT on faded out on the same twelve second clock as
+ // the harmless switch note. He looks up from the keyboard, the chat backend
+ // has changed hands, nothing is listening at the other end, and the screen
+ // says nothing at all.
+ it('leaves a failed start standing past the span the switch line gets', () => {
+ vi.useFakeTimers()
+ render(createElement(LuEngineSwitchBar))
+ act(() => { useLuEngineSwitchStore.getState().announce('Couldn\'t start the LU Engine with "x": boom', 'error') })
+ act(() => { vi.advanceTimersByTime(LU_ENGINE_SWITCH_NOTE_MS * 3) })
+ const line = screen.getByTestId('lu-engine-switch-note')
+ expect(line, 'the error has to survive its own timeout').toBeTruthy()
+ expect(line.getAttribute('data-tone')).toBe('error')
+ // And no timer was armed at all, so nothing is waiting to clear it later.
+ expect(vi.getTimerCount(), 'an error must not be on a clock').toBe(0)
+ })
+
+ // NEGATIVE CONTROL in the same frame: the harmless line still goes away by
+ // itself. Turning the self-clear off for everything would leave the switch
+ // note standing over the composer for the rest of the session.
+ it('but the plain switch line on the same clock still clears itself', () => {
+ vi.useFakeTimers()
+ render(createElement(LuEngineSwitchBar))
+ act(() => { pickAnLuEngineModel() })
+ act(() => { vi.advanceTimersByTime(LU_ENGINE_SWITCH_NOTE_MS + 10) })
+ expect(screen.queryByTestId('lu-engine-switch-note')).toBeNull()
+ })
+
+ it('and the standing error still goes when the user dismisses it', async () => {
+ render(createElement(LuEngineSwitchBar))
+ await act(async () => { useLuEngineSwitchStore.getState().announce('boom', 'error') })
+ await act(async () => { screen.getByLabelText('Dismiss').click() })
+ expect(screen.queryByTestId('lu-engine-switch-note')).toBeNull()
+ })
+
+ it('and the next announcement replaces it rather than queueing behind it', async () => {
+ render(createElement(LuEngineSwitchBar))
+ await act(async () => { useLuEngineSwitchStore.getState().announce('boom', 'error') })
+ await act(async () => { pickAnLuEngineModel() })
+ const line = screen.getByTestId('lu-engine-switch-note')
+ expect(line.textContent).toContain('Switched your chat provider')
+ expect(line.getAttribute('data-tone')).toBe('info')
+ })
+
it('is a polite live region that stays mounted, so it is really announced', async () => {
const { container } = render(createElement(LuEngineSwitchBar))
const region = container.querySelector('[role="status"]')
diff --git a/src/stores/luEngineSwitchStore.ts b/src/stores/luEngineSwitchStore.ts
index 55981cbc..77b24345 100644
--- a/src/stores/luEngineSwitchStore.ts
+++ b/src/stores/luEngineSwitchStore.ts
@@ -17,8 +17,9 @@
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. */
+/** How long an INFO 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. An error line is not on this clock, see announce(). */
export const LU_ENGINE_SWITCH_NOTE_MS = 12_000
/**
@@ -61,6 +62,17 @@ export const useLuEngineSwitchStore = create<LuEngineSwitchState>((set, get) =>
cancelPending()
const generation = get().generation + 1
set({ note, tone, generation })
+ // A14 fourth review: the self-clear was armed for both tones, so a failed
+ // engine start faded out after twelve seconds exactly like the harmless
+ // switch line. The two are not the same kind of sentence. The switch line
+ // reports something the user asked for and can be forgotten; the error
+ // reports a chat backend that has already changed hands with nothing
+ // listening at the other end, and the way out of it is work the user has
+ // to do (hand the slot back, unload the Ollama model that took the VRAM).
+ // A message that asks for an action must not walk away before the action.
+ // So an error stands until it is dismissed by hand or replaced by the next
+ // announcement, and the bar carries a Dismiss button for exactly that.
+ if (tone === 'error') return
pending = setTimeout(() => {
pending = null
if (get().generation === generation) set({ note: null, tone: 'info' })