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(models): keep revoked models out of the service pane
xjx9dd77756a85b
diff --git a/apps/desktop/electron/main/ipc/provider-ipc.ts b/apps/desktop/electron/main/ipc/provider-ipc.tsindex 806387b91..acc8b04f1 100644--- a/apps/desktop/electron/main/ipc/provider-ipc.ts+++ b/apps/desktop/electron/main/ipc/provider-ipc.ts@@ -445,6 +445,9 @@ export function registerProviderIpc({};return {...info,+ // Catalog enrichment must not turn a configured-only row into+ // evidence that the endpoint still serves it.+ source: model.source ?? info.source,modelId: model.modelId,displayName: info.displayName || modelConfig.name,providerId: provider?.id ?? "",diff --git a/apps/desktop/src/components/settings/ModelSelectionPanes.tsx b/apps/desktop/src/components/settings/ModelSelectionPanes.tsxindex 9756c1bc5..31a92cf8a 100644--- a/apps/desktop/src/components/settings/ModelSelectionPanes.tsx+++ b/apps/desktop/src/components/settings/ModelSelectionPanes.tsx@@ -245,14 +245,19 @@ export function ModelSelectionPanes({// The returned list is short and already local, so filtering is client-side:// no host search and no debounced IPC round trip.const visibleRows = useMemo(() => {+ // The service pane follows a live answer. Configured-only rows remain in+ // the chosen pane, including hand-typed IDs absent from discovery.+ const availableRows = discovery.source === "remote"+ ? rows.filter((row) => row.info && row.info.source !== "user")+ : rows;const needle = modelQuery.trim().toLowerCase();- if (!needle) return rows;- return rows.filter(+ if (!needle) return availableRows;+ return availableRows.filter((row) =>row.id.toLowerCase().includes(needle) ||row.displayName.toLowerCase().includes(needle),);- }, [modelQuery, rows]);+ }, [modelQuery, rows, discovery.source]);const selected = useMemo(() => new Set(models.map((binding) => binding.id.toLowerCase())),diff --git a/apps/desktop/test/provider-model-list-refresh.test.mjs b/apps/desktop/test/provider-model-list-refresh.test.mjsnew file mode 100644index 000000000..f70e742ac--- /dev/null+++ b/apps/desktop/test/provider-model-list-refresh.test.mjs@@ -0,0 +1,85 @@+import assert from "node:assert/strict";+import { register } from "node:module";+import { fileURLToPath } from "node:url";+import test from "node:test";+import { createElement } from "react";+import { renderToStaticMarkup } from "react-dom/server";+import { createInstance } from "i18next";+import { I18nextProvider } from "react-i18next";+import { createServer } from "vite";++register(new URL("./helpers/ts-import-hooks.mjs", import.meta.url));+const { registerProviderIpc } = await import("../electron/main/ipc/provider-ipc.ts");+const { ModelsDevCatalog } = await import("../electron/main/models-dev-catalog.ts");+const { bindingForCustomModel, IPC } = await import("@pi-desktop/shared");++// Run the real IPC discovery and settings picker; mock only HTTP and host persistence.+test("refresh removes revoked service rows and preserves configured chat bindings", async (t) => {+ const row = {+ id: "relay", name: "Relay", vendorKey: "custom", enabled: true,+ authKind: "none", hasSecret: false, apiStyle: "chat_completions",+ baseUrl: "https://relay.example/v1",+ models: ["gpt-6-sol", "claude-sonnet-4-5"].map(bindingForCustomModel),+ };+ row.models[1] = { ...row.models[1], alias: "Saved alias", contextWindow: 190_000, contextWindowSource: "user" };+ let served = ["claude-sonnet-4-5", "gpt-6-sol"];+ const originalFetch = globalThis.fetch;+ globalThis.fetch = async () => new Response(JSON.stringify({+ data: served.map((id) => ({ id })),+ }), { headers: { "content-type": "application/json" } });+ t.after(() => { globalThis.fetch = originalFetch; });+ const catalog = new ModelsDevCatalog({+ catalogPath: fileURLToPath(new URL("../resources/models.dev/api.json", import.meta.url)),+ });+ assert.equal(await catalog.ensureLoaded(), true);+ const handlers = new Map();+ registerProviderIpc({+ registrar: { handle: (channel, handler) => handlers.set(channel, handler) },+ getHost: () => ({ call: async (method) => {+ if (method === "providers.list") return { providers: [row] };+ if (method === "providers.get") return { provider: row };+ return {};+ } }),+ modelsDevCatalog: catalog, vendorOAuth: {}, logger: { app() {} },+ enrichProvider: (provider) => provider,+ listRuntimeProviders: async () => [row], enrichProviderList: (result) => result,+ bindingForModel: () => undefined,+ });+ const server = await createServer({+ root: fileURLToPath(new URL("..", import.meta.url)), configFile: false,+ logLevel: "silent", server: { middlewareMode: true, hmr: false, ws: false },+ esbuild: { jsx: "automatic" }, appType: "custom",+ optimizeDeps: { noDiscovery: true, include: [] },+ });+ t.after(() => server.close());+ const { ModelSelectionPanes, useModelSelection } = await server.ssrLoadModule(+ "/src/components/settings/ModelSelectionPanes.tsx",+ );+ const { composerModelsForProvider } = await server.ssrLoadModule("/src/lib/composer-models.ts");+ const i18n = createInstance();+ await i18n.init({ lng: "en", resources: { en: { translation: {} } } });+ let discovery;+ let persisted;+ function Picker() {+ const selection = useModelSelection(discovery, row.models, () => {});+ persisted = selection.bindingsToPersist;+ return createElement(ModelSelectionPanes, { discovery, selection, listTitle: "Service models" });+ }+ const render = () => renderToStaticMarkup(createElement(I18nextProvider, { i18n }, createElement(Picker)));+ const ids = (html, className) => [...html.matchAll(new RegExp(`<span class="${className}[^"]*">([^<]*)</span>`, "g"))].map((match) => match[1]);+ const refresh = async () => {+ const result = await handlers.get(IPC.invoke.providersListModels)({ providerId: row.id, source: "refresh" });+ discovery = { status: "ready", ...result };+ return render();+ };+ assert.deepEqual(ids(await refresh(), "provider-models-row-id"), served);+ served = ["gpt-6-sol", "new-model"];+ const html = await refresh();+ assert.deepEqual(ids(html, "provider-models-row-id"), served);+ assert.deepEqual(persisted, row.models);+ assert.deepEqual(ids(html, "provider-chosen-row-id"), ["gpt-6-sol", "claude-sonnet-4-5"]);+ assert.deepEqual(composerModelsForProvider(row, discovery.models).map((model) => model.modelId), ["gpt-6-sol", "claude-sonnet-4-5"]);+ // Offline/manual fallbacks must still expose configured entries for editing.+ discovery = { ...discovery, source: "fallback", models: [] };+ assert.deepEqual(ids(render(), "provider-models-row-id"), ["gpt-6-sol", "claude-sonnet-4-5"]);+});diff --git a/docs/spec/03-runtime/13-model-catalog-and-selection.md b/docs/spec/03-runtime/13-model-catalog-and-selection.mdindex 8610a7595..7e12192d3 100644--- a/docs/spec/03-runtime/13-model-catalog-and-selection.md+++ b/docs/spec/03-runtime/13-model-catalog-and-selection.md@@ -136,7 +136,12 @@ The answer also replaces the previous one. A probe that no longer publishes amodel drops that model's row, so the pane stops painting a model the endpointretired and a hand-typed id stops inheriting its old limits; a row whose sourceis not discovery — the user's own — is never dropped this way, and a configured-binding stays visible even when the service stops listing it. Cached rows carry+binding stays visible in the chosen-model pane even when the service stops+listing it. After a live refresh, the service-model pane displays only rows+actually served, excluding configured-only rows marked `source: "user"`.+Catalog enrichment preserves that origin independently of published metadata;+cache, catalog and manual fallbacks still expose configured rows for editing.+Cached rows carryno endpoint of their own, so a save that moves the base URL or the wire formatdrops the answer the previous endpoint produced, and the next probe records thenew one. A failed or empty probe is not an answer: it never reaches the cache,diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.mdindex eaa650762..f73288324 100644--- a/docs/spec/06-delivery/04-e2e-test-plan.md+++ b/docs/spec/06-delivery/04-e2e-test-plan.md@@ -1243,6 +1243,11 @@ identify the platform validation still needed.during the edit debounce after a URL becomes valid. Automatic discovery oncredential edits is unchanged. The same control is present for bothcredential kinds because both dialogs render the shared picker.+- **Revocation regression**: Configure two served models, revoke one upstream,+ add another, then Fetch list. The left service pane shows the current served+ pair, including when the revoked ID has a published catalog record. The right+ chosen pane retains both saved bindings and their overrides; refresh does not+ delete configuration. A manual/offline fallback still exposes configured IDs.- **Specs linked**: `03-runtime/13-model-catalog-and-selection.md`,`04-ux/06-settings-ia.md`, `04-ux/08-component-spec.md`- **Acceptance**: B (multi-model provider configuration)