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(settings): ein angelegter Anbieter laesst sich wieder entfernen

purple171e458d86fb
diff --git a/src/components/settings/ProviderConfig.tsx b/src/components/settings/ProviderConfig.tsx
index a3d48211..2c9881c5 100644
--- a/src/components/settings/ProviderConfig.tsx
+++ b/src/components/settings/ProviderConfig.tsx
@@ -1,8 +1,16 @@
-import { useState, useEffect } from 'react'
-import { Wifi, WifiOff, Loader2, Eye, EyeOff, ChevronDown, Plus, Power, Play } from 'lucide-react'
+import { useState, useEffect, useRef } from 'react'
+import { Wifi, WifiOff, Loader2, Eye, EyeOff, ChevronDown, Plus, Power, Play, Trash2 } from 'lucide-react'
import { useProviderStore } from '../../stores/providerStore'
import { providerRowIds, isReturnableRow } from '../../lib/provider-visibility'
-import { slotTakeoverUpdate, slotHandbackUpdate, standbyOccupant } from '../../lib/openai-slot-handover'
+import {
+ slotTakeoverUpdate,
+ slotHandbackUpdate,
+ standbyOccupant,
+ occupantIsRemovable,
+ standbyIsRemovable,
+ slotRemoveOccupantUpdate,
+ slotForgetStandbyUpdate,
+} from '../../lib/openai-slot-handover'
import { useMemoryStore } from '../../stores/memoryStore'
import { getProvider } from '../../api/providers'
import { PROVIDER_PRESETS } from '../../api/providers/types'
@@ -160,6 +168,56 @@ export function ProviderSettings() {
// It keeps a card instead of disappearing (Nebenbefund 3, R10 re-measure).
const standby = standbyOccupant(providers.openai)
+ // Remove, armed by a second click on the same button (Nebenbefund (b), R11
+ // re-measure). The house has one confirmation and this is it: the Reset
+ // button, the Cloud switch and the message delete all arm and wait for a
+ // second click, and none of them opens a dialog. Which button is armed has to
+ // be part of the state, because the occupant card and the standby card each
+ // have one and arming one must not arm the other.
+ const [armedRemove, setArmedRemove] = useState<'occupant' | 'standby' | null>(null)
+ const armTimer = useRef<number | null>(null)
+ useEffect(() => () => { if (armTimer.current) window.clearTimeout(armTimer.current) }, [])
+
+ function disarmRemove() {
+ if (armTimer.current) window.clearTimeout(armTimer.current)
+ armTimer.current = null
+ setArmedRemove(null)
+ }
+
+ // First click arms and writes nothing, second click within 4 s does it. Same
+ // window as the Reset button, so the two behave alike.
+ function armOrRun(which: 'occupant' | 'standby', run: () => void) {
+ if (armedRemove !== which) {
+ if (armTimer.current) window.clearTimeout(armTimer.current)
+ setArmedRemove(which)
+ armTimer.current = window.setTimeout(() => setArmedRemove(null), 4000)
+ return
+ }
+ disarmRemove()
+ run()
+ }
+
+ // Remove on the backend that holds the shared local slot: the slot goes back
+ // to what it held before the takeover, and the removed backend is forgotten
+ // instead of parked on standby. Offered only where `displaced` knows a state
+ // to return to, so the app's own engine and the three other slots have no
+ // Remove at all.
+ function removeOccupant() {
+ const update = slotRemoveOccupantUpdate(providers.openai)
+ if (!update) return
+ setProviderConfig('openai', update)
+ setStatuses(prev => ({ ...prev, openai: 'idle' }))
+ setExpandedProvider('openai')
+ }
+
+ // Remove on the standby card: forget the backend waiting there. The slot
+ // itself is not touched.
+ function removeStandby() {
+ const update = slotForgetStandbyUpdate(providers.openai)
+ if (!update) return
+ setProviderConfig('openai', update)
+ }
+
// Hand the `openai` slot back to the backend on standby. Same effect the
// Reset button has for this one slot, without resetting anything else, and
// it swaps rather than forgets: the backend now leaving the slot takes the
@@ -435,6 +493,25 @@ export function ProviderSettings() {
>
Disable
</button>
+ {/* Remove, for a backend the user put into the shared local
+ slot on top of another one. The slot goes back to what it
+ held before, which is the only thing "remove" can mean
+ here, and the reason it is not offered anywhere else. */}
+ {id === 'openai' && occupantIsRemovable(providers.openai) && (
+ <button
+ data-testid="provider-remove"
+ onClick={() => armOrRun('occupant', removeOccupant)}
+ title={`Remove ${view.label} and put ${standby?.name} back in the local slot`}
+ className={`flex items-center gap-1 px-2 py-0.5 rounded border text-[0.6rem] transition-colors ${
+ armedRemove === 'occupant'
+ ? 'bg-red-500/15 border-red-500/30 text-red-300 font-medium'
+ : 'bg-white/5 border-white/8 text-gray-400 hover:text-red-300 hover:border-red-500/20'
+ }`}
+ >
+ <Trash2 size={10} />
+ {armedRemove === 'occupant' ? 'Click again to remove' : 'Remove'}
+ </button>
+ )}
{/* Bug (g): only render when this is the LM Studio provider AND
we have positive evidence that the binary is on disk but the
server isn't up. The same Tauri command is idempotent so
@@ -513,6 +590,21 @@ export function ProviderSettings() {
<span className="text-[0.65rem] text-gray-500 font-medium truncate">{standby.name}</span>
<span className="text-[0.5rem] px-1 py-0.5 rounded bg-white/5 text-gray-500 shrink-0">STANDBY</span>
</div>
+ {standbyIsRemovable(providers.openai) && (
+ <button
+ data-testid="standby-remove"
+ onClick={() => armOrRun('standby', removeStandby)}
+ title={`Forget ${standby.name} and stop offering it here`}
+ className={`shrink-0 flex items-center gap-1 px-2 py-0.5 rounded border text-[0.6rem] transition-colors ${
+ armedRemove === 'standby'
+ ? 'bg-red-500/15 border-red-500/30 text-red-300 font-medium'
+ : 'bg-white/5 border-white/8 text-gray-500 hover:text-red-300 hover:border-red-500/20'
+ }`}
+ >
+ <Trash2 size={10} />
+ {armedRemove === 'standby' ? 'Click again to remove' : 'Remove'}
+ </button>
+ )}
<button
onClick={handBackSlot}
className="shrink-0 px-2 py-0.5 rounded bg-green-500/10 border border-green-500/20 text-[0.6rem] text-green-300 hover:text-green-200 hover:bg-green-500/15 transition-colors"
diff --git a/src/lib/__tests__/added-provider-can-be-removed.test.ts b/src/lib/__tests__/added-provider-can-be-removed.test.ts
new file mode 100644
index 00000000..f180a17e
--- /dev/null
+++ b/src/lib/__tests__/added-provider-can-be-removed.test.ts
@@ -0,0 +1,184 @@
+/**
+ * Nebenbefund (b) of the R11 re-measure on the real 2.6.7 Windows build
+ * (2026-08-30, ergebnis-r11-nachmessung.md):
+ *
+ * "Ein angelegter Anbieter laesst sich ueber die Oberflaeche nicht mehr
+ * entfernen. Die Jan-Karte bietet aufgeklappt nur Endpoint, Test und
+ * Disable [...] Kein Remove, kein Delete, kein Papierkorb, auch nicht im
+ * Standby- und nicht im Disabled-Zustand. Der einzige Rueckweg ist
+ * Reset AI Backends to defaults."
+ *
+ * The agent had to press exactly that Reset to restore the machine, which also
+ * throws away every other backend the user set up.
+ *
+ * What "remove" can mean here is decided by the shape of the store: `ProviderId`
+ * is four fixed slots and none of them is a row that could be deleted. What the
+ * user added is a BACKEND he put into the shared `openai` slot on top of
+ * whatever was there, and R11 already taught that slot to remember what it
+ * displaced. So Remove is the handover read backwards: put the slot back the
+ * way it was before the takeover and forget the backend that leaves. It is
+ * offered where, and only where, such a memory exists, which keeps the built-in
+ * engine and the three other slots out of reach.
+ *
+ * Run: npx vitest run src/lib/__tests__/added-provider-can-be-removed.test.ts
+ */
+import { describe, it, expect } from 'vitest'
+import { readFileSync } from 'node:fs'
+import { fileURLToPath } from 'node:url'
+import { dirname, resolve } from 'node:path'
+
+import {
+ occupantIsRemovable,
+ standbyIsRemovable,
+ slotRemoveOccupantUpdate,
+ slotForgetStandbyUpdate,
+ slotTakeoverUpdate,
+ slotHandbackUpdate,
+ standbyOccupant,
+ type HandoverSlot,
+} from '../openai-slot-handover'
+import { PROVIDER_PRESETS } from '../../api/providers/types'
+
+const here = dirname(fileURLToPath(import.meta.url))
+const repo = resolve(here, '../../..')
+const read = (rel: string) => readFileSync(resolve(repo, rel), 'utf8')
+
+const preset = (id: string) => {
+ const p = PROVIDER_PRESETS.find((x) => x.id === id)!
+ return { name: p.name, baseUrl: p.baseUrl, isLocal: p.isLocal, managed: p.managed }
+}
+
+const BUILTIN = preset('builtin')
+const JAN = preset('jan')
+const LMSTUDIO = preset('lmstudio')
+
+/** The slot as it ships. */
+const SHIPPED: HandoverSlot = { enabled: true, ...BUILTIN }
+/** The slot after the measured path: Add Provider, entry Jan. */
+const JAN_IN_SLOT: HandoverSlot = {
+ enabled: true,
+ ...JAN,
+ ...slotTakeoverUpdate(SHIPPED, JAN),
+} as HandoverSlot
+
+describe('THE FIX: a backend put into the local slot can be taken off again', () => {
+ it('the measured state offers a Remove, and it names a way back', () => {
+ expect(standbyOccupant(JAN_IN_SLOT)?.name).toBe('Built-in Engine')
+ expect(occupantIsRemovable(JAN_IN_SLOT)).toBe(true)
+ })
+
+ it('Remove puts the slot back exactly as it stood before the takeover', () => {
+ const update = slotRemoveOccupantUpdate(JAN_IN_SLOT)!
+ expect(update.name).toBe('Built-in Engine')
+ expect(update.baseUrl).toBe(BUILTIN.baseUrl)
+ expect(update.managed).toBe(true)
+ expect(update.isLocal).toBe(true)
+ expect(update.enabled).toBe(true)
+ // and nothing is left half switched off from an earlier Disable
+ expect(update.disabledByUser).toBe(false)
+ })
+
+ it('Remove FORGETS, where Enable swaps: no card is owed afterwards', () => {
+ const after = { ...JAN_IN_SLOT, ...slotRemoveOccupantUpdate(JAN_IN_SLOT)! } as HandoverSlot
+ expect(after.displaced).toBeUndefined()
+ expect(standbyOccupant(after)).toBeNull()
+ // the Enable next to it still swaps, which is the whole difference
+ const swapped = { ...JAN_IN_SLOT, ...slotHandbackUpdate(JAN_IN_SLOT)! } as HandoverSlot
+ expect(standbyOccupant(swapped)?.name).toBe('Jan')
+ })
+
+ it('the backend that is only waiting can be forgotten too', () => {
+ // After Enable: Built-in Engine holds the slot, Jan waits beside it. The
+ // wish to be rid of Jan is the same wish, and this is where it is pressed.
+ const swapped = { ...JAN_IN_SLOT, ...slotHandbackUpdate(JAN_IN_SLOT)! } as HandoverSlot
+ expect(standbyIsRemovable(swapped)).toBe(true)
+ const after = { ...swapped, ...slotForgetStandbyUpdate(swapped)! } as HandoverSlot
+ expect(standbyOccupant(after)).toBeNull()
+ // and the slot itself was not touched
+ expect(after.name).toBe('Built-in Engine')
+ expect(after.enabled).toBe(true)
+ })
+
+ it('a second added backend is removable in its turn', () => {
+ const lm = { ...JAN_IN_SLOT, ...slotTakeoverUpdate(JAN_IN_SLOT, LMSTUDIO) } as HandoverSlot
+ expect(occupantIsRemovable(lm)).toBe(true)
+ expect(slotRemoveOccupantUpdate(lm)!.name).toBe('Jan')
+ })
+})
+
+describe('NEGATIVE CONTROL: what must stay un-removable', () => {
+ it('the shipped slot has no Remove, because there is nothing to go back to', () => {
+ expect(occupantIsRemovable(SHIPPED)).toBe(false)
+ expect(slotRemoveOccupantUpdate(SHIPPED)).toBeNull()
+ expect(standbyIsRemovable(SHIPPED)).toBe(false)
+ expect(slotForgetStandbyUpdate(SHIPPED)).toBeNull()
+ })
+
+ it("the app's own engine is never the thing that gets removed", () => {
+ // Built-in Engine back in the slot, Jan waiting: pressing Remove on the
+ // built-in row would leave the slot with no floor under it and re-open the
+ // hole R10 closed.
+ const swapped = { ...JAN_IN_SLOT, ...slotHandbackUpdate(JAN_IN_SLOT)! } as HandoverSlot
+ expect(swapped.managed).toBe(true)
+ expect(occupantIsRemovable(swapped)).toBe(false)
+ expect(slotRemoveOccupantUpdate(swapped)).toBeNull()
+ })
+
+ it('and it is not forgotten while it waits on standby either', () => {
+ // Jan in the slot, Built-in Engine on standby: that card IS the way back.
+ expect(standbyOccupant(JAN_IN_SLOT)?.managed).toBe(true)
+ expect(standbyIsRemovable(JAN_IN_SLOT)).toBe(false)
+ expect(slotForgetStandbyUpdate(JAN_IN_SLOT)).toBeNull()
+ })
+
+ it('the R10 and R11 mechanics are unchanged by all of this', () => {
+ // takeover still remembers
+ expect(slotTakeoverUpdate(SHIPPED, JAN).displaced?.name).toBe('Built-in Engine')
+ // a slot that was already off is still not remembered as displaced
+ expect(slotTakeoverUpdate({ ...SHIPPED, enabled: false }, JAN).displaced).toBeUndefined()
+ // and handback still returns the swap patch
+ expect(slotHandbackUpdate(JAN_IN_SLOT)!.name).toBe('Built-in Engine')
+ })
+})
+
+describe('the wiring, so the button reaches the screen', () => {
+ const pane = read('src/components/settings/ProviderConfig.tsx')
+
+ it('the Remove button sits on the card and goes through the rule', () => {
+ expect(pane).toMatch(/data-testid="provider-remove"/)
+ expect(pane).toMatch(/id === 'openai' && occupantIsRemovable\(providers\.openai\)/)
+ expect(pane).toMatch(/const update = slotRemoveOccupantUpdate\(providers\.openai\)/)
+ // and the standby card carries the same offer
+ expect(pane).toMatch(/data-testid="standby-remove"/)
+ expect(pane).toMatch(/standbyIsRemovable\(providers\.openai\)/)
+ expect(pane).toMatch(/const update = slotForgetStandbyUpdate\(providers\.openai\)/)
+ })
+
+ it("it asks in the house's click-again pattern, not with a dialog", () => {
+ expect(pane).toMatch(/armedRemove === 'occupant' \? 'Click again to remove' : 'Remove'/)
+ expect(pane).toMatch(/armedRemove === 'standby' \? 'Click again to remove' : 'Remove'/)
+ // first click writes nothing, second one inside the window does it
+ expect(pane).toMatch(/if \(armedRemove !== which\) \{/)
+ expect(pane).toMatch(/window\.setTimeout\(\(\) => setArmedRemove\(null\), 4000\)/)
+ // no second confirmation surface was added for this
+ const removeBlock = pane.slice(pane.indexOf('function armOrRun'), pane.indexOf('function handBackSlot'))
+ expect(removeBlock).not.toMatch(/Modal|confirm\(/)
+ })
+
+ it('NEGATIVE CONTROL: no em dash in the new copy', () => {
+ const between = (a: string, b: string) => {
+ const i = pane.indexOf(a)
+ expect(i).toBeGreaterThan(-1)
+ const j = pane.indexOf(b, i)
+ expect(j).toBeGreaterThan(i)
+ return pane.slice(i, j)
+ }
+ for (const block of [
+ between('const [armedRemove', 'function handBackSlot'),
+ between('{/* Remove, for a backend', '{/* Bug (g)'),
+ between('{standbyIsRemovable', 'onClick={handBackSlot}'),
+ ]) {
+ expect(block).not.toMatch(/[–—]/)
+ }
+ })
+})
diff --git a/src/lib/openai-slot-handover.ts b/src/lib/openai-slot-handover.ts
index 59fd5244..257864e2 100644
--- a/src/lib/openai-slot-handover.ts
+++ b/src/lib/openai-slot-handover.ts
@@ -141,3 +141,71 @@ export function slotHandbackUpdate(slot: HandoverSlot): Partial<ProviderConfig>
// left at all. Handing the slot back there must not also lose Jan.
return slotTakeoverUpdate({ ...slot, enabled: true, displaced: undefined }, back)
}
+
+/**
+ * Whether the backend SITTING IN the slot may be removed, and whether the one
+ * waiting beside it may be.
+ *
+ * Nebenbefund (b) of the R11 re-measure (2026-08-30): a provider added through
+ * Add Provider could not be taken off the list again. The card offers Endpoint,
+ * Test and Disable, and nothing else, in every state, so the only way back to
+ * the shipped list was `Reset AI Backends to defaults`, which also throws away
+ * every other backend the user had set up.
+ *
+ * Remove is not a new mechanic, it is the handover read the other way round.
+ * The four slot ids (`ollama`, `openai`, `anthropic`, `lu-cloud`) are the fixed
+ * shape of the store and none of them can be deleted; what a user really added
+ * is a BACKEND placed into the shared `openai` slot on top of something else,
+ * and removing it means putting the slot back the way it was before the
+ * takeover. That is exactly what `displaced` remembers, so Remove is offered
+ * where, and only where, there is a remembered state to return to:
+ *
+ * - on the occupant, when it is not the app's own engine. The built-in engine
+ * is the floor everybody else stands on; removing it would leave the slot
+ * with nothing to fall back to and re-open the hole R10 closed.
+ * - on the standby card, for the same reason in the other direction: after a
+ * handback the added backend is the one waiting there, and forgetting it is
+ * the same wish as removing it. The built-in engine on standby is never
+ * forgotten, because that card IS the way back.
+ */
+export function occupantIsRemovable(slot: HandoverSlot): boolean {
+ if (slot.managed) return false
+ return standbyOccupant(slot) !== null
+}
+
+/** True when the backend on the standby card may be forgotten. */
+export function standbyIsRemovable(slot: HandoverSlot): boolean {
+ const waiting = standbyOccupant(slot)
+ return !!waiting && !waiting.managed
+}
+
+/**
+ * The patch Remove on the occupant writes: the slot goes back to the state it
+ * was in before the takeover, and the backend that is leaving is forgotten
+ * rather than parked.
+ *
+ * That is the whole difference to Enable on the standby card, which swaps. A
+ * user who presses Remove is not asking for a card in the other corner.
+ */
+export function slotRemoveOccupantUpdate(slot: HandoverSlot): Partial<ProviderConfig> | null {
+ const back = standbyOccupant(slot)
+ if (!back || !occupantIsRemovable(slot)) return null
+ return {
+ enabled: true,
+ name: back.name,
+ baseUrl: back.baseUrl,
+ isLocal: back.isLocal,
+ managed: !!back.managed,
+ // The slot is being handed back on purpose, so it carries neither the
+ // Disable mark nor a memory of the backend that just left.
+ disabledByUser: false,
+ displaced: undefined,
+ }
+}
+
+/** The patch Remove on the standby card writes: forget the backend waiting
+ * there, and leave the occupant of the slot alone. */
+export function slotForgetStandbyUpdate(slot: HandoverSlot): Partial<ProviderConfig> | null {
+ if (!standbyIsRemovable(slot)) return null
+ return { displaced: undefined }
+}