Files
OmniRoute/tests/unit/codex-config-hooks-migration.test.ts
Diego Rodrigues de Sa e Souza d6ce094a60 fix(api): migrate deprecated Codex [features].codex_hooks to [features].hooks (#4342)
Codex renamed the `codex_hooks` feature flag to `hooks`; recent Codex CLI
versions ignore the old key and warn. When OmniRoute rewrites an existing
config.toml (configure/reset Codex provider) it now renames
[features].codex_hooks -> [features].hooks, preserving the value and never
clobbering an already-present `hooks`, then drops the deprecated key. The
migration is a no-op when the flag is absent and runs on both the POST and
DELETE config paths.

Reported-by: Bian-Sh (https://github.com/decolua/9router/issues/1327)

Co-authored-by: Bian-Sh <24520547+Bian-Sh@users.noreply.github.com>
2026-06-20 10:54:42 -03:00

33 lines
1.5 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
// Regression for port-from-9router#1327: Codex deprecated the `[features].codex_hooks`
// flag in favor of `[features].hooks`. The codex-settings generator parses an existing
// config.toml and writes it back but never migrated the deprecated key, so users with an
// old config kept a key recent Codex CLI versions ignore.
const { migrateCodexFeatureFlags } = await import("../../src/shared/utils/codexConfig.ts");
test("#1327: renames deprecated [features].codex_hooks to [features].hooks", () => {
const parsed = { _root: {}, _sections: { features: { codex_hooks: true } } };
migrateCodexFeatureFlags(parsed);
assert.deepEqual(parsed._sections.features, { hooks: true });
});
test("#1327: keeps an existing hooks value and removes the deprecated key", () => {
const parsed = { _root: {}, _sections: { features: { codex_hooks: true, hooks: false } } };
migrateCodexFeatureFlags(parsed);
assert.deepEqual(parsed._sections.features, { hooks: false });
});
test("#1327: leaves a config that already uses hooks untouched", () => {
const parsed = { _root: {}, _sections: { features: { hooks: true } } };
migrateCodexFeatureFlags(parsed);
assert.deepEqual(parsed._sections.features, { hooks: true });
});
test("#1327: no-op when there is no [features] section", () => {
const parsed = { _root: { model: "x" }, _sections: {} };
migrateCodexFeatureFlags(parsed);
assert.deepEqual(parsed._sections, {});
});