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): Disable auf dem Slot-Inhaber gibt den Slot zurueck

purpleb46c69f35251
diff --git a/src/components/settings/ProviderConfig.tsx b/src/components/settings/ProviderConfig.tsx
index 2c9881c5..14dd3291 100644
--- a/src/components/settings/ProviderConfig.tsx
+++ b/src/components/settings/ProviderConfig.tsx
@@ -273,6 +273,22 @@ export function ProviderSettings() {
// back on clears the mark, and the row is a normal row again.
function toggleProvider(id: ProviderId) {
const nextEnabled = !providers[id].enabled
+ // Nebenbefund (c), R11 re-measure: Disable on the backend that had taken
+ // the shared local slot left the machine with NO local backend at all. Jan
+ // went to DISABLED, the built-in engine stayed on STANDBY carrying the now
+ // untrue sentence "Jan took over the local slot", and the chat fell back to
+ // "Select Model". Switching a backend off is not a wish to be left without
+ // one: the engine that was waiting for exactly this slot takes it back, and
+ // the backend that is leaving takes the standby card in its place. That is
+ // the same swap Enable does, only pressed from the other side.
+ if (!nextEnabled && id === 'openai') {
+ const handback = slotHandbackUpdate(providers.openai)
+ if (handback) {
+ setProviderConfig('openai', handback)
+ setStatuses(prev => ({ ...prev, openai: 'idle' }))
+ return
+ }
+ }
setProviderConfig(id, { enabled: nextEnabled, disabledByUser: !nextEnabled })
setStatuses(prev => ({ ...prev, [id]: 'idle' }))
if (nextEnabled) setExpandedProvider(id)
@@ -612,11 +628,23 @@ export function ProviderSettings() {
Enable
</button>
</div>
- <p className="px-2 pb-1.5 text-[0.55rem] text-gray-600 leading-snug">
- {providers.openai.name} took over the local OpenAI compatible slot, which holds one
- backend at a time. Press Enable to hand the slot back to {standby.name}.
- {' '}{providers.openai.name} then waits here in its place.
- </p>
+ {/* The sentence has to describe the state that is really on screen.
+ Disable on the slot holder hands the slot back now, so it cannot
+ produce a switched-off holder any more, but onboarding still parks
+ this slot without anyone pressing anything, and then the takeover
+ wording would be a lie. */}
+ {providers.openai.enabled ? (
+ <p className="px-2 pb-1.5 text-[0.55rem] text-gray-600 leading-snug">
+ {providers.openai.name} took over the local OpenAI compatible slot, which holds one
+ backend at a time. Press Enable to hand the slot back to {standby.name}.
+ {' '}{providers.openai.name} then waits here in its place.
+ </p>
+ ) : (
+ <p className="px-2 pb-1.5 text-[0.55rem] text-gray-600 leading-snug">
+ {providers.openai.name} holds the local OpenAI compatible slot and is switched off,
+ so no local backend is running. Press Enable to give the slot back to {standby.name}.
+ </p>
+ )}
</div>
)}
diff --git a/src/lib/__tests__/disable-hands-the-slot-back.test.ts b/src/lib/__tests__/disable-hands-the-slot-back.test.ts
new file mode 100644
index 00000000..43abb418
--- /dev/null
+++ b/src/lib/__tests__/disable-hands-the-slot-back.test.ts
@@ -0,0 +1,133 @@
+/**
+ * Nebenbefund (c) of the R11 re-measure on the real 2.6.7 Windows build
+ * (2026-08-30, ergebnis-r11-nachmessung.md, Beleg r11n-shot-14-s2-jan-disabled):
+ *
+ * "Disable auf dem Slot-Inhaber gibt den Slot nicht zurueck. Nach Disable auf
+ * Jan stand Jan auf DISABLED und die eingebaute Engine BLIEB auf STANDBY,
+ * mit dem inzwischen falschen Satz 'Jan took over the local OpenAI
+ * compatible slot'. Ergebnis: gar kein lokales Backend, der Chat zeigte
+ * Select Model."
+ *
+ * The picker caught it honestly (R10's "No models available" text with an Open
+ * Settings jump), so it was never a dead end. It was still the wrong answer to
+ * the question the user asked. Switching a backend off is not a wish to be left
+ * without one, and an engine was standing right there waiting for this exact
+ * slot.
+ *
+ * So Disable on the slot holder now performs the same swap Enable performs,
+ * pressed from the other side: the waiting engine takes the slot back, and the
+ * backend that is leaving takes the standby card. No new mechanic and no new
+ * stored state, `slotHandbackUpdate` is the one that already does this.
+ *
+ * Run: npx vitest run src/lib/__tests__/disable-hands-the-slot-back.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 { slotTakeoverUpdate, slotHandbackUpdate, standbyOccupant, type HandoverSlot } from '../openai-slot-handover'
+import { noChatBackendEnabled, providerRowIds, isReturnableRow } from '../provider-visibility'
+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 SHIPPED: HandoverSlot = { enabled: true, ...BUILTIN }
+/** The measured state: Add Provider, entry Jan, on top of the built-in engine. */
+const JAN_IN_SLOT = { ...SHIPPED, ...slotTakeoverUpdate(SHIPPED, JAN) } as HandoverSlot
+
+/** The provider list around that slot, as the box had it. */
+const listWith = (openai: HandoverSlot) => ({
+ ollama: { enabled: false },
+ openai,
+ anthropic: { enabled: false },
+ 'lu-cloud': { enabled: true },
+})
+
+/** What the Disable button used to write on any row. */
+const OLD_DISABLE_PATCH = { enabled: false, disabledByUser: true }
+
+describe('THE FIX: Disable on the slot holder gives the slot back', () => {
+ it('the measured press leaves a local backend running instead of none', () => {
+ const before = listWith(JAN_IN_SLOT)
+ expect(noChatBackendEnabled(before, 'local')).toBe(false)
+
+ // what it did: Jan off, built-in still only remembered, nothing local left
+ const oldWay = listWith({ ...JAN_IN_SLOT, ...OLD_DISABLE_PATCH } as HandoverSlot)
+ expect(noChatBackendEnabled(oldWay, 'local')).toBe(true)
+
+ // what it does: the waiting engine takes the slot
+ const patch = slotHandbackUpdate(JAN_IN_SLOT)!
+ const newWay = listWith({ ...JAN_IN_SLOT, ...patch } as HandoverSlot)
+ expect(newWay.openai.name).toBe('Built-in Engine')
+ expect(newWay.openai.managed).toBe(true)
+ expect(newWay.openai.enabled).toBe(true)
+ expect(noChatBackendEnabled(newWay, 'local')).toBe(false)
+ })
+
+ it('and the backend that was switched off is not lost either', () => {
+ const after = { ...JAN_IN_SLOT, ...slotHandbackUpdate(JAN_IN_SLOT)! } as HandoverSlot
+ expect(standbyOccupant(after)?.name).toBe('Jan')
+ })
+
+ it('the standby sentence can no longer claim a takeover that is switched off', () => {
+ const pane = read('src/components/settings/ProviderConfig.tsx')
+ // the takeover wording is now bound to the slot actually being on
+ expect(pane).toMatch(/\{providers\.openai\.enabled \? \([\s\S]{0,400}took over the local OpenAI compatible slot/)
+ // and the other state has a sentence of its own that says what is true
+ expect(pane).toMatch(/holds the local OpenAI compatible slot and is switched off,\s*\n?\s*so no local backend is running/)
+ })
+
+ it('the wiring: the Disable button routes through the handback', () => {
+ const pane = read('src/components/settings/ProviderConfig.tsx')
+ expect(pane).toMatch(/if \(!nextEnabled && id === 'openai'\) \{\s*\n\s*const handback = slotHandbackUpdate\(providers\.openai\)/)
+ expect(pane).toMatch(/setProviderConfig\('openai', handback\)/)
+ })
+})
+
+describe('NEGATIVE CONTROL: everything the R10 and R11 rounds settled', () => {
+ it('a slot with nobody waiting still goes to the greyed DISABLED row', () => {
+ // Fresh install, built-in engine in the slot, nothing displaced: there is
+ // no engine to hand anything back to, so Disable stays Disable.
+ expect(slotHandbackUpdate(SHIPPED)).toBeNull()
+ const off = { ...SHIPPED, ...OLD_DISABLE_PATCH } as HandoverSlot
+ expect(isReturnableRow(off)).toBe(true)
+ expect(providerRowIds(listWith(off))).toContain('openai')
+ })
+
+ it('the plain Disable path is untouched for every other slot', () => {
+ const pane = read('src/components/settings/ProviderConfig.tsx')
+ expect(pane).toMatch(/setProviderConfig\(id, \{ enabled: nextEnabled, disabledByUser: !nextEnabled \}\)/)
+ // the handback branch is reached only on the shared slot, and only downwards
+ expect(pane).not.toMatch(/if \(id === 'openai'\) \{\s*\n\s*const handback/)
+ })
+
+ it('onboarding still parks the slot its own way, without a handback', () => {
+ const onboarding = read('src/components/onboarding/Onboarding.tsx')
+ expect(onboarding).toMatch(/setProviderConfig\('openai', \{ enabled: false, managed: false \}\)/)
+ expect(onboarding).not.toMatch(/slotHandbackUpdate/)
+ })
+
+ it('Enable on the standby card still swaps, it did not become a second Disable', () => {
+ const patch = slotHandbackUpdate(JAN_IN_SLOT)!
+ expect(patch.enabled).toBe(true)
+ expect(patch.disabledByUser).toBe(false)
+ })
+
+ it('no em dash in the new copy', () => {
+ const pane = read('src/components/settings/ProviderConfig.tsx')
+ const i = pane.indexOf('The sentence has to describe the state')
+ const j = pane.indexOf('{/* No backend warning', i)
+ expect(i).toBeGreaterThan(-1)
+ expect(pane.slice(i, j)).not.toMatch(/[–—]/)
+ })
+})