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(settings): Add Provider laesst die Karte des eingebauten Motors stehen
purple4bb747f9ac2c
diff --git a/src/api/providers/types.ts b/src/api/providers/types.tsindex cd7dcd5b..2d52fa83 100644--- a/src/api/providers/types.ts+++ b/src/api/providers/types.ts@@ -29,6 +29,19 @@ export interface ProviderConfig {// back (Nebenbefund 1, R9 re-measure 2026-08-30). Undefined = a slot nobody// has touched here; it stays out of the list as before.disabledByUser?: boolean+ // The backend this slot pushed out when Add Provider handed it to somebody+ // else. Only the `openai` slot can carry one: it is the single slot every+ // OpenAI-protocol backend shares, so adding Jan there used to make the+ // built-in engine's card disappear without a word (Nebenbefund 3, R10+ // re-measure 2026-08-30). The providers list draws a greyed standby card for+ // it with an Enable button that hands the slot back. See+ // lib/openai-slot-handover.ts. Undefined = nothing was pushed out.+ displaced?: {+ name: string+ baseUrl: string+ isLocal: boolean+ managed?: boolean+ }}// ── Provider Presets (auto-fill URL) ───────────────────────────diff --git a/src/components/settings/ProviderConfig.tsx b/src/components/settings/ProviderConfig.tsxindex eec04ede..a3d48211 100644--- a/src/components/settings/ProviderConfig.tsx+++ b/src/components/settings/ProviderConfig.tsx@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react'import { Wifi, WifiOff, Loader2, Eye, EyeOff, ChevronDown, Plus, Power, Play } 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 { useMemoryStore } from '../../stores/memoryStore'import { getProvider } from '../../api/providers'import { PROVIDER_PRESETS } from '../../api/providers/types'@@ -155,6 +156,21 @@ export function ProviderSettings() {// only control that could bring the provider back (Nebenbefund 1, R9// re-measure). A switched-off row stays, greyed, with Enable on it.const rowIds = providerRowIds(providers) as ProviderId[]+ // The backend Add Provider pushed out of the shared `openai` slot, if any.+ // It keeps a card instead of disappearing (Nebenbefund 3, R10 re-measure).+ const standby = standbyOccupant(providers.openai)++ // 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+ // standby card in its turn.+ function handBackSlot() {+ const update = slotHandbackUpdate(providers.openai)+ if (!update) return+ setProviderConfig('openai', update)+ setStatuses(prev => ({ ...prev, openai: 'idle' }))+ setExpandedProvider('openai')+ }// Add a preset (enable a provider without disabling others)function selectPreset(preset: typeof PROVIDER_PRESETS[0]) {@@ -173,9 +189,20 @@ export function ProviderSettings() {} else if (preset.providerId === 'anthropic') {setProviderConfig('anthropic', { enabled: true, name: preset.name, baseUrl: preset.baseUrl, isLocal: false })} else {- // `managed` must be set explicitly so switching to LM Studio/vLLM clears- // the built-in flag, and re-selecting Built-in restores it.- setProviderConfig('openai', { enabled: true, name: preset.name, baseUrl: preset.baseUrl, isLocal: preset.isLocal, managed: !!preset.managed })+ // Every OpenAI-protocol backend shares the one `openai` slot, so adding+ // one pushes out whatever was in it. That used to happen in silence:+ // Add Provider, Jan, and the Built-in Engine card was gone with no word+ // about where it went (Nebenbefund 3, R10 re-measure 2026-08-30). The+ // slot remembers who it displaced now, and the list keeps a standby card+ // for it. `managed` is still set explicitly in both directions, so+ // switching to LM Studio/vLLM clears the built-in flag and re-selecting+ // Built-in restores it.+ setProviderConfig('openai', slotTakeoverUpdate(providers.openai, {+ name: preset.name,+ baseUrl: preset.baseUrl,+ isLocal: preset.isLocal,+ managed: preset.managed,+ }))}setDropdownOpen(false)@@ -471,6 +498,36 @@ export function ProviderSettings() {)})}+ {/* The backend Add Provider pushed out of the shared local slot. It used+ to vanish without a word, and the way back (Add Provider, Built-in+ Engine) was there but unlabelled. Same shape as the switched-off row+ above, with the reason written out. */}+ {standby && (+ <div className="rounded-lg border border-white/8 bg-white/[0.01] overflow-hidden">+ <div className="flex items-center gap-2 px-2 py-1.5">+ <button onClick={handBackSlot} className="group flex items-center" title="Put this backend back in the local slot">+ <Power size={10} className="text-gray-500 group-hover:text-green-400 transition-colors" />+ </button>+ <div className="flex-1 flex items-center gap-2 min-w-0">+ <span className="w-1.5 h-1.5 rounded-full shrink-0 bg-gray-600" />+ <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>+ <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"+ >+ 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>+ </div>+ )}+{/* No backend warning. With a switched-off row on screen the honestsentence names that row first, because pressing Enable on it is theshorter way back than adding a provider again. */}diff --git a/src/lib/__tests__/builtin-card-survives-add-provider.test.ts b/src/lib/__tests__/builtin-card-survives-add-provider.test.tsnew file mode 100644index 00000000..6695a3b1--- /dev/null+++ b/src/lib/__tests__/builtin-card-survives-add-provider.test.ts@@ -0,0 +1,233 @@+/**+ * Nebenbefund 3 of the R10 re-measure on the real 2.6.7 Windows build+ * (2026-08-30, ergebnis-r10-nachmessung.md). The one path found on which a+ * provider card really does vanish without a trace, and the one that fits the+ * user report R9 and R10 were both read against.+ *+ * The measured frame (r10n-q1-11-jan-hinzu.png): Settings, AI Backends, Add+ * Provider, entry "Jan" (http://localhost:1337/v1). Afterwards the list holds+ * Jan (LOCAL) and LU Cloud. The Built-in Engine card is gone, together with+ * the BUILT-IN ENGINE (EXPERT) section, and nothing on the Jan card says where+ * the built-in engine went.+ *+ * Then the sharp edge (r10n-q1-12, r10n-q1-13): switching Jan off leaves the+ * Jan card standing with its Enable button, but now there is no local backend+ * at all. The picker says "No models available" and lists none of the three+ * installed local models, although the user never switched the built-in engine+ * off.+ *+ * The way back exists and is unlabelled: Add Provider, entry "Built-in+ * Engine". Whoever wrote "the card was completely gone, no way back" almost+ * certainly walked this path, not the Disable button of R9, which measured+ * clean in R10.+ *+ * The fix reuses the mechanic R10 built for Disable, on the slot rather than+ * on a provider id: the displaced backend keeps a greyed card with an Enable+ * button that hands the slot back. It swaps rather than forgets, so the+ * backend that just came in does not vanish as silently in its turn.+ *+ * Run: npx vitest run src/lib/__tests__/builtin-card-survives-add-provider.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 {+ isDifferentBackend,+ slotTakeoverUpdate,+ slotHandbackUpdate,+ standbyOccupant,+ type HandoverSlot,+} from '../openai-slot-handover'+import { 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 LMSTUDIO = preset('lmstudio')++/** The slot as the re-measure found it before Add Provider was touched. */+const SHIPPED: HandoverSlot = { enabled: true, ...BUILTIN }++describe('THE FIX: Add Provider no longer makes the built-in card disappear', () => {+ it('the exact frame: adding Jan remembers the built-in engine it pushed out', () => {+ const update = slotTakeoverUpdate(SHIPPED, JAN)+ expect(update.name).toBe('Jan')+ expect(update.baseUrl).toBe('http://localhost:1337/v1')+ expect(update.managed).toBe(false)+ expect(update.displaced).toEqual(BUILTIN)+ })++ it('so the list still has a card to draw for the built-in engine', () => {+ const after = { ...SHIPPED, ...slotTakeoverUpdate(SHIPPED, JAN) } as HandoverSlot+ expect(standbyOccupant(after)?.name).toBe('Built-in Engine')+ })++ it('and Enable on that card hands the slot back to the built-in engine', () => {+ const after = { ...SHIPPED, ...slotTakeoverUpdate(SHIPPED, JAN) } as HandoverSlot+ const back = slotHandbackUpdate(after)!+ expect(back.name).toBe('Built-in Engine')+ expect(back.baseUrl).toBe('http://127.0.0.1:8127/v1')+ expect(back.managed).toBe(true)+ expect(back.enabled).toBe(true)+ })++ it('the handback swaps, it does not forget: Jan takes the standby card', () => {+ // R10 measured this in the other direction too: adding Built-in Engine+ // back made the Jan card disappear in its turn.+ const after = { ...SHIPPED, ...slotTakeoverUpdate(SHIPPED, JAN) } as HandoverSlot+ const restored = { ...after, ...slotHandbackUpdate(after) } as HandoverSlot+ expect(standbyOccupant(restored)?.name).toBe('Jan')+ expect(standbyOccupant(restored)?.baseUrl).toBe('http://localhost:1337/v1')+ })++ it('the sharp edge: Jan added, then Jan disabled, and the way back still stands', () => {+ // r10n-q1-12/13: the Jan card kept its Enable button, but there was no+ // local backend at all and the picker listed none of the three installed+ // local models, although nobody had switched the built-in engine off.+ const after = { ...SHIPPED, ...slotTakeoverUpdate(SHIPPED, JAN) } as HandoverSlot+ const janOff = { ...after, enabled: false, disabledByUser: true }+ // Two ways out on screen now: Enable on the Jan row it switched off,+ expect(isReturnableRow(janOff)).toBe(true)+ // and Enable on the built-in engine standing by.+ expect(standbyOccupant(janOff)?.name).toBe('Built-in Engine')+ const back = slotHandbackUpdate(janOff)!+ expect(back.name).toBe('Built-in Engine')+ expect(back.enabled).toBe(true)+ // Switching a backend off is not the same as giving up its slot, so the+ // Disable mark does not travel with the slot.+ expect(back.disabledByUser).toBe(false)+ // And Jan is not lost by taking the way back, even from the off state.+ // (`managed` is written out as an explicit false when the slot is stored,+ // where the preset simply does not carry the flag.)+ expect(back.displaced).toEqual({ ...JAN, managed: false })+ })++ it('a cloud preset takes the same slot and is remembered the same way', () => {+ // Every OpenAI-protocol backend shares this one slot, so Add Provider,+ // OpenRouter loses the built-in card exactly as Jan did.+ const openrouter = preset('openrouter')+ const update = slotTakeoverUpdate(SHIPPED, openrouter)+ expect(update.displaced).toEqual(BUILTIN)+ expect(update.isLocal).toBe(false)+ })+})++describe('NEGATIVE CONTROL: the counter-poles of R10 are untouched', () => {+ it('a fresh install owes no standby card', () => {+ expect(standbyOccupant(SHIPPED)).toBe(null)+ expect(slotHandbackUpdate(SHIPPED)).toBe(null)+ })++ it('onboarding handing the slot to Ollama leaves nothing behind', () => {+ // Onboarding.tsx writes openai { enabled: false, managed: false } without+ // anyone pressing anything. A slot that is already parked is not being+ // taken from the user, so nothing is remembered and no card is owed.+ const parked: HandoverSlot = { ...SHIPPED, enabled: false, managed: false }+ const update = slotTakeoverUpdate(parked, JAN)+ expect(update.displaced).toBeUndefined()+ expect(standbyOccupant({ ...parked, ...update } as HandoverSlot)).toBe(null)+ })++ it('the onboarding choice of an external backend leaves nothing behind either', () => {+ // BackendSelector and the onboarding wizard both write the slot directly,+ // not through Add Provider, and neither goes near this rule.+ const sel = read('src/components/onboarding/BackendSelector.tsx')+ const onb = read('src/components/onboarding/Onboarding.tsx')+ expect(sel).not.toMatch(/slotTakeoverUpdate|displaced/)+ expect(onb).not.toMatch(/slotTakeoverUpdate|displaced/)+ })++ it('re-selecting the backend that is already there changes nothing', () => {+ const update = slotTakeoverUpdate(SHIPPED, BUILTIN)+ expect(update.displaced).toBeUndefined()+ expect(isDifferentBackend(SHIPPED, BUILTIN)).toBe(false)+ })++ it('a trailing slash is not a different server', () => {+ expect(isDifferentBackend(SHIPPED, { ...BUILTIN, baseUrl: 'http://127.0.0.1:8127/v1/' })).toBe(false)+ })++ it('the Disable rule of R10 still decides the rows, and is not disturbed', () => {+ const afterAdd = {+ ollama: { enabled: false },+ openai: { enabled: true },+ anthropic: { enabled: false },+ 'lu-cloud': { enabled: true },+ }+ // The standby card is drawn beside these rows, not inside them: the slot+ // list still holds exactly the four ids it always did.+ expect(providerRowIds(afterAdd)).toEqual(['openai', 'lu-cloud'])+ })++ it('coming back to the remembered backend by another route clears the card', () => {+ // Reset AI Backends drops the whole slot to shipped values, and Add+ // Provider on the same entry writes it directly. Neither may leave a card+ // offering a way back to where the slot already is.+ const after = { ...SHIPPED, ...slotTakeoverUpdate(SHIPPED, JAN) } as HandoverSlot+ const resetish = { ...after, ...BUILTIN, enabled: true }+ expect(standbyOccupant(resetish)).toBe(null)+ })++ it('a re-enable does not throw away a standby card that is still owed', () => {+ const after = { ...SHIPPED, ...slotTakeoverUpdate(SHIPPED, JAN) } as HandoverSlot+ const janOff = { ...after, enabled: false }+ const janOnAgain = { ...janOff, ...slotTakeoverUpdate(janOff, JAN) } as HandoverSlot+ expect(standbyOccupant(janOnAgain)?.name).toBe('Built-in Engine')+ })+})++describe('the wiring, so the rule reaches the screen', () => {+ const pane = read('src/components/settings/ProviderConfig.tsx')++ it('Add Provider writes through the rule instead of overwriting the slot', () => {+ expect(pane).toMatch(/setProviderConfig\('openai', slotTakeoverUpdate\(providers\.openai, \{/)+ // The line the re-measure hit, gone.+ expect(pane).not.toMatch(+ /setProviderConfig\('openai', \{ enabled: true, name: preset\.name, baseUrl: preset\.baseUrl/,+ )+ })++ it('the pane draws the standby card, with the badge and the Enable button', () => {+ expect(pane).toMatch(/const standby = standbyOccupant\(providers\.openai\)/)+ expect(pane).toMatch(/\{standby && \(/)+ expect(pane).toMatch(/STANDBY<\/span>/)+ expect(pane).toMatch(/onClick=\{handBackSlot\}[\s\S]{0,400}>\s*Enable\s*<\/button>/)+ })++ it('the card says WHY the backend left, in English, and names the way back', () => {+ expect(pane).toMatch(/took over the local OpenAI compatible slot/)+ expect(pane).toMatch(/Press Enable to hand the slot back to/)+ })++ it('Enable on it goes through the handback rule, not through a second mechanism', () => {+ expect(pane).toMatch(/const update = slotHandbackUpdate\(providers\.openai\)/)+ expect(pane).toMatch(/setProviderConfig\('openai', update\)/)+ })++ it('NEGATIVE CONTROL: the R10 Disable card is still there, unchanged', () => {+ expect(pane).toMatch(/if \(isReturnableRow\(config\)\)/)+ expect(pane).toMatch(/DISABLED<\/span>/)+ expect(pane).toMatch(+ /setProviderConfig\(id, \{ enabled: nextEnabled, disabledByUser: !nextEnabled \}\)/,+ )+ })++ it('NEGATIVE CONTROL: no em dash anywhere in the new copy', () => {+ const start = pane.indexOf('{standby && (')+ const end = pane.indexOf('{/* No backend warning')+ expect(start).toBeGreaterThan(-1)+ expect(end).toBeGreaterThan(start)+ expect(pane.slice(start, end)).not.toMatch(/[–—]/)+ })+})diff --git a/src/lib/openai-slot-handover.ts b/src/lib/openai-slot-handover.tsnew file mode 100644index 00000000..59fd5244--- /dev/null+++ b/src/lib/openai-slot-handover.ts@@ -0,0 +1,143 @@+/**+ * What happens to the backend that was in the `openai` slot when Add Provider+ * puts another one there.+ *+ * Nebenbefund 3 of the R10 re-measure on the 2.6.7 Windows build+ * (2026-08-30), and the only path found on which a provider card really does+ * disappear without a trace:+ *+ * Settings, AI Backends, Add Provider, entry "Jan"+ * (http://localhost:1337/v1). Afterwards the providers list holds Jan+ * (LOCAL) and LU Cloud. The Built-in Engine card is gone, together with the+ * BUILT-IN ENGINE (EXPERT) section. Nothing on the Jan card says where the+ * built-in engine went.+ *+ * And then the sharp edge: switching Jan off leaves the Jan card standing with+ * its Enable button, but now there is no local backend at all. The picker says+ * "No models available" and lists none of the three installed local models,+ * although the user never switched the built-in engine off.+ *+ * The way back exists and is unlabelled: Add Provider, entry "Built-in+ * Engine". That is what the user who wrote "the card was completely gone, no+ * way back" almost certainly missed. R9's Disable button, which the report was+ * first read against, is clean.+ *+ * Why the card vanishes at all: `ProviderId` is a fixed set of four slots and+ * every OpenAI-protocol backend lives in the single `openai` one. The list+ * holds one local OpenAI-compatible backend at a time, which is a design+ * decision, not a bug. Losing the previous one without a word is the bug.+ *+ * The answer reuses the mechanic R10 built for Disable: the backend that was+ * pushed out keeps a card, greyed, with an Enable button that hands the slot+ * back. It is remembered as `displaced` ON the slot config, so it survives a+ * restart the same way the slot itself does, and the handback swaps rather+ * than forgets, so the backend the user just added does not vanish silently in+ * its turn either.+ *+ * Deliberately NOT touched, these are the counter-poles from R10 and their+ * tests must stay green:+ * - a fresh install: nothing was ever pushed out, so there is no extra card,+ * - onboarding handing the slot to Ollama: it parks the slot disabled without+ * anyone pressing anything, and a slot that was already off is not being+ * taken away from the user. Only an ENABLED occupant is remembered.+ */++import type { ProviderConfig } from '../api/providers/types'++/** The part of a backend that is enough to put it back where it was. */+export interface SlotOccupant {+ name: string+ baseUrl: string+ isLocal: boolean+ managed?: boolean+}++/** The part of the `openai` slot this decision reads. */+export interface HandoverSlot extends SlotOccupant {+ enabled: boolean+ /** The occupant this one pushed out, kept so it has a card and a way back. */+ displaced?: SlotOccupant+}++/** Trailing slashes and case are not a different server. */+function sameUrl(a: string, b: string): boolean {+ const norm = (u: string) => (u || '').trim().replace(/\/+$/, '').toLowerCase()+ return norm(a) === norm(b)+}++/** Is the incoming backend a different one from what the slot holds. */+export function isDifferentBackend(slot: SlotOccupant, incoming: SlotOccupant): boolean {+ if (!sameUrl(slot.baseUrl, incoming.baseUrl)) return true+ if (slot.name !== incoming.name) return true+ return !!slot.managed !== !!incoming.managed+}++/**+ * The patch Add Provider writes into the `openai` slot, including the memory+ * of who was pushed out.+ *+ * `displaced` is only written when there was something to lose: a DIFFERENT+ * backend that was switched ON. Re-selecting what is already there changes+ * nothing, and a slot the user (or onboarding) had already parked is not being+ * taken from anybody.+ */+export function slotTakeoverUpdate(+ slot: HandoverSlot,+ incoming: SlotOccupant,+): Partial<ProviderConfig> {+ const base = {+ enabled: true,+ name: incoming.name,+ baseUrl: incoming.baseUrl,+ isLocal: incoming.isLocal,+ // Must be set explicitly in both directions: left at true the model list+ // would keep reading the bundled GGUFs while the URL points elsewhere.+ managed: !!incoming.managed,+ // Taking the slot on purpose is not the same as the user switching this+ // backend off, so the Disable mark never survives a takeover.+ disabledByUser: false,+ }+ if (!slot.enabled || !isDifferentBackend(slot, incoming)) {+ // Nothing was lost, so nothing new is remembered. Whatever was already+ // remembered stays remembered: re-enabling a slot must not quietly drop a+ // standby card that is still owed.+ return base+ }+ return {+ ...base,+ displaced: {+ name: slot.name,+ baseUrl: slot.baseUrl,+ isLocal: slot.isLocal,+ managed: slot.managed,+ },+ }+}++/** The standby card the providers list owes, or null when it owes none. */+export function standbyOccupant(slot: HandoverSlot): SlotOccupant | null {+ const d = slot.displaced+ if (!d) return null+ // A slot that has come back to the remembered backend by some other route+ // (Reset AI Backends, Add Provider on the same entry) owes no card.+ if (!isDifferentBackend(slot, d)) return null+ return d+}++/**+ * The patch Enable on the standby card writes: the remembered backend goes+ * back into the slot, and the one it displaces takes its place on standby.+ *+ * The swap is what keeps this honest in both directions. Handing the slot back+ * to the built-in engine used to make the added provider disappear exactly as+ * silently as the built-in engine had disappeared before it.+ */+export function slotHandbackUpdate(slot: HandoverSlot): Partial<ProviderConfig> | null {+ const back = standbyOccupant(slot)+ if (!back) return null+ // `enabled: true` on the synthetic slot, so the swap remembers the outgoing+ // backend even when it was sitting switched off. That is the state the+ // re-measure ended in: Jan added, then Jan disabled, and no local backend+ // left at all. Handing the slot back there must not also lose Jan.+ return slotTakeoverUpdate({ ...slot, enabled: true, displaced: undefined }, back)+}