mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-11-18 07:58:27 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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({});
|
||||
|
||||
@@ -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(),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user