Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
fix(desktop): stop session-collaboration spawn from spending the un opted-in default model
yexisu1c7d292102fe
diff --git a/apps/desktop/electron/main/services/session-collaboration.ts b/apps/desktop/electron/main/services/session-collaboration.tsindex 6595c48d7..dc2e30b6d 100644--- a/apps/desktop/electron/main/services/session-collaboration.ts+++ b/apps/desktop/electron/main/services/session-collaboration.ts@@ -284,8 +284,13 @@ export function createSessionCollaborationService(deps: SessionCollaborationDepecheckCurrent(host, input.signal);const models = listReadyPluginModels(listed.providers, settings);const requested = text(data, "modelKey", false);- const chosen = requested ? models.find((item) => item.key === requested)- : models.find((item) => item.availableForSubagents) ?? models.find((item) => item.isDefault);+ // No isDefault fallback here: naming a default the user never+ // opted into delegation would spend a model the Task gate+ // refuses (issue #1183). Omitting modelKey must fall back to the+ // spawn path's own inheritance, not to an un opted-in default.+ const chosen = requested+ ? models.find((item) => item.key === requested)+ : models.find((item) => item.availableForSubagents);if (!chosen) fail("MODEL_NOT_CONFIGURED", "No matching configured model is available");// A worker the agent starts is AI-driven delegation, so naming a model here// needs that model's own `availableForSubagents` opt-in — the gate `Task.model`diff --git a/apps/desktop/test/session-collaboration-service.test.mjs b/apps/desktop/test/session-collaboration-service.test.mjsindex 7bb640534..2c7a64613 100644--- a/apps/desktop/test/session-collaboration-service.test.mjs+++ b/apps/desktop/test/session-collaboration-service.test.mjs@@ -331,3 +331,32 @@ test("spawn without a model key still prefers an enabled model over the defaultassert.equal(spawns.length, 1);assert.equal(spawns[0].params.modelId, "delegable-model");});++test("spawn without a model key never selects an un opted-in default model (#1183)", async () => {+ // No model carries availableForSubagents, so the old isDefault fallback+ // silently spent the default model for delegation.+ const providers = [+ {+ id: "provider-a",+ name: "Provider A",+ enabled: true,+ authKind: "none",+ models: [{ id: "default-model" }, { id: "private-model" }],+ },+ ];+ const stored = sessionMessage({ id: "spawn-message", status: "completed", kind: "task" });+ const host = createHost("host-1", (method) => {+ if (method === "providers.list") return { providers };+ if (method === "settings.get") {+ return { defaultProviderId: "provider-a", defaultModelId: "default-model" };+ }+ if (method === "session.collaboration.spawn") return { message: stored };+ return { messages: [] };+ });++ await assert.rejects(+ invokeSpawn(spawnService(host), { task: "Review the diff" }),+ { code: "MODEL_NOT_CONFIGURED" },+ );+ assert.deepEqual(methodCalls(host, "session.collaboration.spawn"), []);+});