fix(codex): align ccsxp history with native codex

This commit is contained in:
Tam Nhu Tran committed 2026-04-24 15:24:12 -04:00
1 parent 02dae9c5cf
commit 8ffda0268d
3 files changed
+135 -32

No files matched your search

@@ -377,10 +377,7 @@ process.exit(0);
expect(result.status).toBe(0);
const calls = readLoggedCodexCalls(codexArgsLogPath);
expect(calls[1]).toEqual(
expect.arrayContaining([
'mcp_servers.ccs_browser.enabled=true',
'fix failing tests',
])
expect.arrayContaining(['mcp_servers.ccs_browser.enabled=true', 'fix failing tests'])
);
} finally {
if (originalCcsHome !== undefined) {
@@ -523,28 +520,27 @@ process.exit(0);
if (process.platform === 'win32') return;
const freshCodexHome = path.join(tmpHome, 'fresh-codex-home');
const result = runCcs(['default', '--target', 'codex', '--effort', 'high', 'fix failing tests'], {
...process.env,
CI: '1',
NO_COLOR: '1',
CCS_HOME: tmpHome,
CCS_CODEX_PATH: fakeCodexPath,
CCS_TEST_CODEX_ARGS_OUT: codexArgsLogPath,
CCS_TEST_CODEX_ENV_OUT: codexEnvLogPath,
CCS_TEST_CODEX_VERSION: 'codex-cli 9.9.9-test',
CODEX_HOME: freshCodexHome,
});
const result = runCcs(
['default', '--target', 'codex', '--effort', 'high', 'fix failing tests'],
{
...process.env,
CI: '1',
NO_COLOR: '1',
CCS_HOME: tmpHome,
CCS_CODEX_PATH: fakeCodexPath,
CCS_TEST_CODEX_ARGS_OUT: codexArgsLogPath,
CCS_TEST_CODEX_ENV_OUT: codexEnvLogPath,
CCS_TEST_CODEX_VERSION: 'codex-cli 9.9.9-test',
CODEX_HOME: freshCodexHome,
}
);
expect(result.status).toBe(0);
expect(fs.existsSync(freshCodexHome)).toBe(true);
expect(fs.statSync(freshCodexHome).isDirectory()).toBe(true);
expect(readLoggedCodexCalls(codexArgsLogPath)).toEqual([
['-c', 'model="gpt-5"', '--version'],
[
'-c',
'model_reasoning_effort="high"',
'fix failing tests',
],
['-c', 'model_reasoning_effort="high"', 'fix failing tests'],
]);
const loggedEnv = readLoggedCodexEnv(codexEnvLogPath);
expect(loggedEnv).toHaveLength(2);
@@ -570,13 +566,13 @@ process.exit(0);
const result = runCcs(
['default', '--target', 'codex', '--effort', 'high', 'fix failing tests'],
{
...process.env,
CI: '1',
NO_COLOR: '1',
CCS_HOME: tmpHome,
CCS_CODEX_PATH: fakeCodexPath,
CCS_TEST_CODEX_ARGS_OUT: codexArgsLogPath,
CODEX_HOME: invalidCodexHome,
...process.env,
CI: '1',
NO_COLOR: '1',
CCS_HOME: tmpHome,
CCS_CODEX_PATH: fakeCodexPath,
CCS_TEST_CODEX_ARGS_OUT: codexArgsLogPath,
CODEX_HOME: invalidCodexHome,
}
);
@@ -661,6 +657,67 @@ process.exit(0);
expect(readLoggedCodexCalls(codexArgsLogPath)).toEqual([['--version']]);
});
it('pins ccsxp Codex history to native default instead of inherited CODEX_HOME', () => {
if (process.platform === 'win32') return;
const inheritedCodexHome = path.join(tmpHome, 'inherited-codex-home');
const result = runCcsxpAlias(['--version'], {
...process.env,
CI: '1',
NO_COLOR: '1',
CCS_HOME: tmpHome,
CCS_CODEX_PATH: fakeCodexPath,
CCS_TEST_CODEX_ENV_OUT: codexEnvLogPath,
CCS_TEST_CODEX_VERSION: 'codex-cli 9.9.9-test',
CODEX_HOME: inheritedCodexHome,
});
expect(result.status).toBe(0);
expect(readLoggedCodexEnv(codexEnvLogPath)).toEqual([
{
CODEX_HOME: path.join(os.homedir(), '.codex'),
CODEX_CI: undefined,
CODEX_MANAGED_BY_BUN: undefined,
CODEX_THREAD_ID: undefined,
ANTHROPIC_BASE_URL: undefined,
CCS_BROWSER_USER_DATA_DIR: undefined,
CCS_BROWSER_PROFILE_DIR: undefined,
CCS_BROWSER_DEVTOOLS_WS_URL: undefined,
},
]);
});
it('honors CCSXP_CODEX_HOME for intentionally separate ccsxp history', () => {
if (process.platform === 'win32') return;
const explicitCodexHome = path.join(tmpHome, 'explicit-ccsxp-codex-home');
const result = runCcsxpAlias(['--version'], {
...process.env,
CI: '1',
NO_COLOR: '1',
CCS_HOME: tmpHome,
CCS_CODEX_PATH: fakeCodexPath,
CCS_TEST_CODEX_ENV_OUT: codexEnvLogPath,
CCS_TEST_CODEX_VERSION: 'codex-cli 9.9.9-test',
CODEX_HOME: path.join(tmpHome, 'inherited-codex-home'),
CCSXP_CODEX_HOME: explicitCodexHome,
});
expect(result.status).toBe(0);
expect(readLoggedCodexEnv(codexEnvLogPath)).toEqual([
{
CODEX_HOME: explicitCodexHome,
CODEX_CI: undefined,
CODEX_MANAGED_BY_BUN: undefined,
CODEX_THREAD_ID: undefined,
ANTHROPIC_BASE_URL: undefined,
CCS_BROWSER_USER_DATA_DIR: undefined,
CCS_BROWSER_PROFILE_DIR: undefined,
CCS_BROWSER_DEVTOOLS_WS_URL: undefined,
},
]);
});
it('fails with a clean CLI error when ccsxp receives a malformed --target flag', () => {
if (process.platform === 'win32') return;
@@ -740,11 +797,7 @@ process.exit(0);
expect(result.status).toBe(0);
expect(readLoggedCodexCalls(codexArgsLogPath)).toEqual([
['-c', 'model="gpt-5"', '--version'],
[
'-c',
'model_reasoning_effort="high"',
'fix failing tests',
],
['-c', 'model_reasoning_effort="high"', 'fix failing tests'],
]);
});