A desktop coding agent with free access to frontier models.
TypeScript
fix: restrict catalog announcements to visible providers
Task Builderbb7a8b37ef48
diff --git a/apps/app/src/react-app/infra/provider-list-query.ts b/apps/app/src/react-app/infra/provider-list-query.tsindex 9747065e..8373202d 100644--- a/apps/app/src/react-app/infra/provider-list-query.ts+++ b/apps/app/src/react-app/infra/provider-list-query.ts@@ -2,6 +2,7 @@ import { useQuery, type QueryClient } from "@tanstack/react-query";import type { Client, ModelRef, ProviderListItem } from "../../app/types";import { unwrap } from "../../app/lib/opencode";+import { isSupportedModelProvider } from "../../app/lib/provider-catalog";import { dispatchNewProviders, markProvidersSeen } from "../../app/lib/provider-events";import type { ProviderListResponse } from "@opencode-ai/sdk/v2/client";import { resolveModelDisplayName } from "../../app/utils";@@ -146,8 +147,10 @@ function connectedProviderSnapshotKey(input: {function dispatchConnectedProviderChanges(key: string,- next: ConnectedProviderSnapshot,+ snapshot: ConnectedProviderSnapshot,) {+ // Discovery should only advertise providers that the model picker exposes.+ const next = snapshot.filter((provider) => isSupportedModelProvider(provider.id));const observed = observedProviderModels.get(key);if (!observed) {// Startup can briefly return an empty catalog. The first populateddiff --git a/apps/app/tests/renderer-bounded-caches.test.ts b/apps/app/tests/renderer-bounded-caches.test.tsindex da3649de..dd74ee2d 100644--- a/apps/app/tests/renderer-bounded-caches.test.ts+++ b/apps/app/tests/renderer-bounded-caches.test.ts@@ -128,7 +128,7 @@ test("provider discovery stays quiet through startup, metadata refreshes, and reconst client = createClient(server.url.toString(), "/tmp/catalog-regression");const input = { client, baseUrl: server.url.toString(), directory: "/tmp/catalog-regression" };const modelIds = Array.from({ length: 41 }, (_, index) => "model-" + index);- const baseline = [{ id: "catalog-provider", modelIds }];+ const baseline = [{ id: "lpr_catalog-provider", modelIds }];const refresh = async (entries: Array<{ id: string; modelIds: string[] }>, revision = 0) => {response = providerCatalog(entries, revision);await fetchProviderList(input);@@ -136,7 +136,7 @@ test("provider discovery stays quiet through startup, metadata refreshes, and retry {await refresh([]);await refresh(baseline);- expect(readSeenProviderIds().has("catalog-provider")).toBe(true);+ expect(readSeenProviderIds().has("lpr_catalog-provider")).toBe(true);await refresh(baseline, 1);expect(discoveries).toHaveLength(0);@@ -147,7 +147,7 @@ test("provider discovery stays quiet through startup, metadata refreshes, and reawait refresh(baseline, 2);expect(discoveries).toHaveLength(0);- const expanded = [{ id: "catalog-provider", modelIds: [...modelIds, "new-model"] }];+ const expanded = [{ id: "lpr_catalog-provider", modelIds: [...modelIds, "new-model"] }];await refresh(expanded, 3);expect(discoveries).toHaveLength(1);expect(discoveries[0]).toMatchObject({ newProviderCount: 0, newModelCount: 1, source: "models_refresh" });@@ -157,7 +157,7 @@ test("provider discovery stays quiet through startup, metadata refreshes, and reawait refresh(expanded);expect(discoveries).toHaveLength(1);- const newProvider = { id: "second-provider", modelIds: ["second-a", "second-b"] };+ const newProvider = { id: "lpr_second-provider", modelIds: ["second-a", "second-b"] };await refresh([...expanded, newProvider]);expect(discoveries).toHaveLength(2);expect(discoveries[1]).toMatchObject({ newProviderCount: 1, newModelCount: 2 });@@ -165,6 +165,10 @@ test("provider discovery stays quiet through startup, metadata refreshes, and reawait refresh([...expanded, newProvider], 5);expect(discoveries).toHaveLength(2);+ const hiddenProvider = { id: "opencode", modelIds: Array.from({ length: 69 }, (_, index) => "hidden-model-" + index) };+ await refresh([...expanded, newProvider, hiddenProvider]);+ expect(discoveries).toHaveLength(2);+clearProviderListQueries(new QueryClient());await refresh([...expanded, newProvider]);expect(discoveries).toHaveLength(2);diff --git a/evals/specs/provider-catalog-notifications.e2e.test.ts b/evals/specs/provider-catalog-notifications.e2e.test.tsindex 9d626efa..aa552a4e 100644--- a/evals/specs/provider-catalog-notifications.e2e.test.ts+++ b/evals/specs/provider-catalog-notifications.e2e.test.ts@@ -13,7 +13,7 @@ function providerNotifications(value: unknown) {test("catalog refreshes announce new models once and keep metadata updates and reconnects quiet", async ({ world, user, step, evidence }) => {const notifications = async () => providerNotifications(await control(world.app, "notifications.list"));const models = () => readAvailableModels(world.app);- await eventually(models, {+ const baseline = await eventually(models, {within: 60_000,label: "baseline catalog available",until: (rows) => rows.some((model) => model.id === world.modelIds[0]),@@ -42,11 +42,17 @@ test("catalog refreshes announce new models once and keep metadata updates and r});await user.press("Escape");await world.updateCatalog(world.modelIds, 1);- await eventually(async () => (await models()).some((model) => model.id === world.modelIds[0]), {- within: 60_000, label: "provider reconnected", until: (value) => value === true,+ const restored = await eventually(models, {+ within: 60_000, label: "provider reconnected", until: (rows) => rows.some((model) => model.id === world.modelIds[0]),});+ const before = new Set(baseline.map((model) => model.providerName + "/" + model.id));+ const after = new Set(restored.map((model) => model.providerName + "/" + model.id));+ const added = [...after].filter((id) => !before.has(id));+ const removed = [...before].filter((id) => !after.has(id));const entries = await notifications();- evidence.recordAssertionEvidence("Reconnecting does not announce the same provider and models", "The existing model disappeared and returned; notifications=" + JSON.stringify(entries), entries.length === 0);+ evidence.recordAssertionEvidence("Reconnecting does not announce the same provider and models", "Restored catalog additions=" + JSON.stringify(added) + "; removals=" + JSON.stringify(removed) + "; notifications=" + JSON.stringify(entries), entries.length === 0 && added.length === 0 && removed.length === 0);+ expect(added).toHaveLength(0);+ expect(removed).toHaveLength(0);expect(entries).toHaveLength(0);await user.press("Escape");});diff --git a/evals/worlds/chat.ts b/evals/worlds/chat.tsindex e7e81628..8439c8b6 100644--- a/evals/worlds/chat.ts+++ b/evals/worlds/chat.ts@@ -516,6 +516,7 @@ export async function providerCatalogNotifications(seed: Seed) {name: "Catalog Notification Models",npm: "@ai-sdk/openai-compatible",options: { baseURL: "http://127.0.0.1:9/v1", apiKey: "local-catalog-fixture" },+ whitelist: ids,models: Object.fromEntries(ids.map((id) => [id, {name: id + " revision " + revision,limit: { context: 100_000, output: 10_000 },@@ -526,6 +527,7 @@ export async function providerCatalogNotifications(seed: Seed) {name: "Catalog Control Models",npm: "@ai-sdk/openai-compatible",options: { baseURL: "http://127.0.0.1:9/v1", apiKey: "local-catalog-control" },+ whitelist: ["catalog-control-model"],models: { "catalog-control-model": { name: "Catalog control model" } },},},@@ -544,8 +546,14 @@ export async function providerCatalogNotifications(seed: Seed) {method: "PATCH", headers, body: JSON.stringify({ opencode: JSON.parse(configJson) }),});if (!patched.ok) return "config patch failed: " + patched.status;+ const configResponse = await fetch(base + "/opencode/config", { headers });+ if (!configResponse.ok) return "config read failed: " + configResponse.status;+ const currentConfig = await configResponse.json();+ const otherDisabledProviders = Array.isArray(currentConfig.disabled_providers)+ ? currentConfig.disabled_providers.filter((id: unknown): id is string => typeof id === "string" && id !== providerId)+ : [];const disabledResult = await fetch(base + "/runtime-config/disabled-providers", {- method: "POST", headers, body: JSON.stringify({ providers: disabled ? [providerId] : [] }),+ method: "POST", headers, body: JSON.stringify({ providers: disabled ? [...otherDisabledProviders, providerId] : otherDisabledProviders }),});if (!disabledResult.ok) return "disabled provider update failed: " + disabledResult.status;const reloaded = await fetch(base + "/engine/reload", { method: "POST", headers });