Skip to content

Commit 792baab

Browse files
committed
fix(models): clear stale native disables on all-on
1 parent b89c539 commit 792baab

2 files changed

Lines changed: 29 additions & 2 deletions

File tree

‎src/server/management/model-routes.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { randomUUID } from "node:crypto";
22
import { readFileSync } from "node:fs";
33
import type { CatalogModel } from "../../codex/catalog";
4-
import { catalogModelSlug, invalidateCodexModelsCache, nativeModelRows, uniqueCatalogModelsForPublicList } from "../../codex/catalog";
4+
import { catalogModelSlug, disabledNativeSlugs, invalidateCodexModelsCache, nativeModelRows, uniqueCatalogModelsForPublicList } from "../../codex/catalog";
55
import {
66
DEFAULT_SUBAGENT_MODELS,
77
codexAutoStartEnabled,
@@ -195,7 +195,9 @@ export async function handleModelRoutes(ctx: ManagementContext): Promise<Respons
195195
if (isVirtualComboNamespace) {
196196
disabled = disabled.filter(stored => !knownComboSelectors.has(stored));
197197
} else {
198-
const nativeIds = new Set(targets.filter(target => target.native).map(target => target.id));
198+
const nativeIds = provider === "openai"
199+
? disabledNativeSlugs({ disabledModels: disabled })
200+
: new Set<string>();
199201
disabled = disabled.filter(stored => (
200202
knownComboSelectors.has(stored)
201203
|| (!stored.startsWith(`${provider}/`) && !nativeIds.has(stored))

‎tests/model-visibility-management-api.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
22
import { existsSync, mkdirSync, rmSync } from "node:fs";
33
import { join } from "node:path";
4+
import { nativeModelRows } from "../src/codex/catalog";
45
import { loadConfig, saveConfig } from "../src/config";
56
import { handleManagementAPI } from "../src/server/management-api";
67
import { installIsolatedCodexHome, type IsolatedCodexHome } from "./helpers/isolated-codex-home";
@@ -92,6 +93,30 @@ describe("atomic model visibility management", () => {
9293
expect(refreshes).toBe(2);
9394
});
9495

96+
test("all-on clears stale native ids while preserving combo selectors", async () => {
97+
const config = loadConfig();
98+
const targets = nativeModelRows(config).map(row => ({ id: row.slug, native: true }));
99+
expect(targets.length).toBeGreaterThan(0);
100+
config.disabledModels = [
101+
targets[0]!.id,
102+
"stale-native-model",
103+
"fast-chat",
104+
"combo/free",
105+
"google-antigravity/keep",
106+
"other/keep",
107+
];
108+
saveConfig(config);
109+
110+
expect((await put({ scope: "provider", provider: "openai", targets, enabled: true })).status).toBe(200);
111+
expect(loadConfig().disabledModels).toEqual([
112+
"fast-chat",
113+
"combo/free",
114+
"google-antigravity/keep",
115+
"other/keep",
116+
]);
117+
expect(refreshes).toBe(1);
118+
});
119+
95120
test("treats a physical combo provider with no configured combos as a routed provider", async () => {
96121
saveConfig({
97122
port: 0,

0 commit comments

Comments
 (0)