fix(cli-tools): make the Codex model catalog opt-in (default off)

The catalog file grows ~60 KB per model in ~/.codex, so the Apply checkbox
now starts unchecked. The route already writes only on modelCatalog === true;
an explicit modelCatalog: false test joins the omitted-flag test.
This commit is contained in:
diegosouzapw
2026-10-17 00:10:37 -03:00
parent 5592e9c266
commit 7b273fca9f
5 changed files with 22 additions and 7 deletions

View File

@@ -1 +1 @@
- **feat(cli-tools):** applying Codex settings also writes an OmniRoute model catalog (`model_catalog_json`) so Codex's `/model` picker lists routable provider-prefixed models; fails open with a warning when Codex can't be read ([#16910](https://github.com/diegosouzapw/OmniRoute/pull/16910)) — thanks @kalfian
- **feat(cli-tools):** applying Codex settings can also write an OmniRoute model catalog (`model_catalog_json`, opt-in checkbox, off by default) so Codex's `/model` picker lists routable provider-prefixed models; fails open with a warning when Codex can't be read ([#16910](https://github.com/diegosouzapw/OmniRoute/pull/16910)) — thanks @kalfian

View File

@@ -33,7 +33,8 @@ export default function CodexToolCard({
const [modelMappings, setModelMappings] = useState<Record<string, string>>({});
const [reasoningEffort, setReasoningEffort] = useState("xhigh");
const [wireApi, setWireApi] = useState("responses");
const [writeModelCatalog, setWriteModelCatalog] = useState(true);
// Opt-in: the catalog file is ~60 KB per model (MBs with a large catalog) in ~/.codex.
const [writeModelCatalog, setWriteModelCatalog] = useState(false);
const [modalOpen, setModalOpen] = useState(false);
const [modalTarget, setModalTarget] = useState<string | null>(null); // null = default model, string = mapping key
const [modelAliases, setModelAliases] = useState({});

View File

@@ -88,6 +88,7 @@ export const cliModelConfigSchema = z.object({
/**
* Codex variant of `cliModelConfigSchema`. `modelCatalog: true` also writes an
* OmniRoute `model_catalog_json` so Codex's `/model` picker lists routable ids.
* Opt-in: omitted or `false` never writes the catalog.
*/
export const codexSettingsConfigSchema = cliModelConfigSchema.extend({
modelCatalog: z.boolean().optional(),

View File

@@ -165,6 +165,19 @@ test("POST without modelCatalog leaves Codex's catalog untouched", async () => {
assert.equal(await exists(SEEN_CODEX_HOME), false, "codex must not be spawned");
});
test("POST with modelCatalog: false leaves Codex's catalog untouched", async () => {
await freshCodexDir();
process.env.CLI_CODEX_BIN = FAKE_CODEX_OK;
const response = await post({ modelCatalog: false });
assert.equal(response.status, 200);
const body = await response.json();
assert.equal(body.catalogPath, undefined);
assert.doesNotMatch(await fs.readFile(CONFIG_PATH, "utf8"), /model_catalog_json/);
assert.equal(await exists(CATALOG_PATH), false);
assert.equal(await exists(SEEN_CODEX_HOME), false, "codex must not be spawned");
});
test("POST fails open with catalogWarning when Codex cannot dump its catalog", async () => {
await freshCodexDir();
process.env.CLI_CODEX_BIN = FAKE_CODEX_BROKEN;

View File

@@ -114,25 +114,25 @@ const renderCard = async (applyResponse: Record<string, unknown>) => {
};
describe("CodexToolCard model catalog", () => {
it("asks for the Codex model catalog by default and can opt out", async () => {
it("does not ask for the Codex model catalog by default and can opt in", async () => {
const { container, posts } = await renderCard({ success: true });
expect(catalogCheckbox(container)?.checked).toBe(true);
expect(catalogCheckbox(container)?.checked).toBe(false);
await act(async () => {
applyButton(container)!.click();
});
await waitFor(() => posts.length === 1);
expect(posts[0].modelCatalog).toBe(true);
expect(posts[0].modelCatalog).toBe(false);
await act(async () => {
catalogCheckbox(container)!.click();
});
expect(catalogCheckbox(container)?.checked).toBe(false);
expect(catalogCheckbox(container)?.checked).toBe(true);
await act(async () => {
applyButton(container)!.click();
});
await waitFor(() => posts.length === 2);
expect(posts[1].modelCatalog).toBe(false);
expect(posts[1].modelCatalog).toBe(true);
});
it("shows a warning, not an error, when Apply succeeds without the catalog", async () => {