From 7a6b35a80e264f19ea49aee4b25cdb4ce63f055f Mon Sep 17 00:00:00 2001 From: Nadia Rodionova <273119990+sosidudku1@users.noreply.github.com> Date: Wed, 18 Nov 2026 06:06:46 +0300 Subject: [PATCH 1/2] fix(desktop): show local-as-last-resort as Off when the config has no value (ATO-1643) Since v0.7.0 the agent leaves the local model out of the fallback chain unless llm.fallback.appendLocal is true. The desktop read an unset value as on, so Settings > Fallback showed On with the local model in the chain and the turn gate promised a fallback the agent never runs. Both places now treat unset as off, like DEFAULT_APPEND_LOCAL. --- desktop/renderer/renderer.js | 6 +- .../fallback-append-local-default.test.mjs | 67 +++++++++++++++++++ 2 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 desktop/test/fallback-append-local-default.test.mjs diff --git a/desktop/renderer/renderer.js b/desktop/renderer/renderer.js index 7871fc6c2..5477680e2 100644 --- a/desktop/renderer/renderer.js +++ b/desktop/renderer/renderer.js @@ -24590,12 +24590,12 @@ function localTurnGate() { ? 'no local model is selected — open Models (/local) to pick and download one' : (bswDownloadProgress(modelId) || 'not downloaded — open Models (/local) and press Enter on it to download'); const subject = modelId === null ? status : 'local model ' + modelId + ' is ' + status; - // resolveFallbackChain: the configured chain (or just the active id), with local-llama appended unless appendLocal is false. + // resolveFallbackChain: the configured chain (or just the active id), with local-llama appended only when appendLocal is true (agent default off, ATO-1643). const ids = new Set(providers.map((p) => p.id)); const fb = llm.fallback || {}; const requested = (fb.chain && fb.chain.length) ? fb.chain : [llm.activeTextProvider]; const chain = [llm.activeTextProvider].concat(requested.filter((id) => ids.has(id) && id !== llm.activeTextProvider)); - if (fb.appendLocal !== false) { const local = providers.find((p) => p.kind === 'llama-server'); if (local && !chain.includes(local.id)) chain.push(local.id); } + if (fb.appendLocal === true) { const local = providers.find((p) => p.kind === 'llama-server'); if (local && !chain.includes(local.id)) chain.push(local.id); } const length = chain.filter((id, i) => ids.has(id) && chain.indexOf(id) === i).length; if (length > 1) return {kind:'notice', text: subject + ' — running this turn through the fallback chain'}; return {kind:'block', text: subject}; @@ -27777,7 +27777,7 @@ function llmFallbackView() { const llm = llmBlock(); const providers = llmProviders(); const fb = llm.fallback || {}; - const appendLocal = fb.appendLocal === undefined ? true : !!fb.appendLocal; + const appendLocal = fb.appendLocal === true; // unset = off, like the agent's DEFAULT_APPEND_LOCAL (ATO-1643) const explicitChain = Array.isArray(fb.chain) ? fb.chain.filter((x) => typeof x === 'string') : []; const configured = new Set(providers.map((p) => p.id)); const activeId = llmActiveTextId(); diff --git a/desktop/test/fallback-append-local-default.test.mjs b/desktop/test/fallback-append-local-default.test.mjs new file mode 100644 index 000000000..027b31105 --- /dev/null +++ b/desktop/test/fallback-append-local-default.test.mjs @@ -0,0 +1,67 @@ +// ATO-1643: since v0.7.0 the agent does not append the local model to the +// fallback chain unless llm.fallback.appendLocal is true (DEFAULT_APPEND_LOCAL +// = false in src/llm/fallback/fallback-config.ts). The desktop used to read an +// unset value as on: Settings › Fallback showed "On" with the local model in +// the chain, and the turn gate promised a fallback the agent never runs. +// +// renderer.js is read as text; llmFallbackView runs in a vm context with its +// neighbours stubbed. No deps, no build. +import { test } from "node:test"; +import assert from "node:assert/strict"; +import { readFileSync } from "node:fs"; +import vm from "node:vm"; + +const source = readFileSync(new URL("../renderer/renderer.js", import.meta.url), "utf8"); + +function fn(name) { + const at = source.indexOf("\nfunction " + name + "("); + assert.ok(at >= 0, name + " is a top-level function in renderer.js"); + return source.slice(at + 1, source.indexOf("\n}\n", at) + 2); +} + +const providers = [ + { id: "openrouter", kind: "openrouter", model: "m1" }, + { id: "local-llama", kind: "llama-server", model: "q" }, +]; + +function viewFor(fallback) { + const llm = { activeTextProvider: "openrouter", providers }; + if (fallback !== undefined) llm.fallback = fallback; + const c = vm.createContext({ + llmBlock: () => llm, + llmProviders: () => providers, + llmActiveTextId: () => "openrouter", + }); + vm.runInContext(fn("llmFallbackView") + "globalThis.llmFallbackView = llmFallbackView;", c); + return c.llmFallbackView(); +} + +test("no llm.fallback block: local is Off and not in the chain", () => { + const v = viewFor(undefined); + assert.equal(v.appendLocal, false); + assert.deepEqual(v.links.map((l) => l.providerId), ["openrouter"]); + assert.ok(v.addableProviderIds.includes("local-llama")); +}); + +test("fallback block without appendLocal: still Off", () => { + const v = viewFor({ chain: ["openrouter"] }); + assert.equal(v.appendLocal, false); + assert.ok(!v.links.some((l) => l.isAppendedLocal)); +}); + +test("appendLocal true: On, local appended last", () => { + const v = viewFor({ appendLocal: true }); + assert.equal(v.appendLocal, true); + assert.deepEqual(v.links.map((l) => l.providerId), ["openrouter", "local-llama"]); + assert.equal(v.links[1].isAppendedLocal, true); +}); + +test("appendLocal false: Off", () => { + assert.equal(viewFor({ appendLocal: false }).appendLocal, false); +}); + +test("turn gate appends local only when appendLocal is true", () => { + const gate = fn("localTurnGate"); + assert.ok(gate.includes("fb.appendLocal === true"), "localTurnGate treats unset as off"); + assert.ok(!gate.includes("fb.appendLocal !== false"), "the old unset-means-on check is gone"); +}); From 304408676db2a9878332f2c62bbc2fa7cf706592 Mon Sep 17 00:00:00 2001 From: Nadia Rodionova <273119990+sosidudku1@users.noreply.github.com> Date: Fri, 20 Nov 2026 15:21:25 +0300 Subject: [PATCH 2/2] Build the fallback links in the test's realm before comparing (ATO-1643) --- desktop/test/fallback-append-local-default.test.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/test/fallback-append-local-default.test.mjs b/desktop/test/fallback-append-local-default.test.mjs index 027b31105..fe5990741 100644 --- a/desktop/test/fallback-append-local-default.test.mjs +++ b/desktop/test/fallback-append-local-default.test.mjs @@ -39,7 +39,7 @@ function viewFor(fallback) { test("no llm.fallback block: local is Off and not in the chain", () => { const v = viewFor(undefined); assert.equal(v.appendLocal, false); - assert.deepEqual(v.links.map((l) => l.providerId), ["openrouter"]); + assert.deepEqual(Array.from(v.links, (l) => l.providerId), ["openrouter"]); assert.ok(v.addableProviderIds.includes("local-llama")); }); @@ -52,7 +52,7 @@ test("fallback block without appendLocal: still Off", () => { test("appendLocal true: On, local appended last", () => { const v = viewFor({ appendLocal: true }); assert.equal(v.appendLocal, true); - assert.deepEqual(v.links.map((l) => l.providerId), ["openrouter", "local-llama"]); + assert.deepEqual(Array.from(v.links, (l) => l.providerId), ["openrouter", "local-llama"]); assert.equal(v.links[1].isAppendedLocal, true); });