orca icon indicating copy to clipboard operation
orca copied to clipboard

fix(codex): migrate deprecated codex_hooks in CRLF configs

Open huhuhulululu opened this issue 5 months ago • 1 comments

Summary

On Windows, a ~/.codex/config.toml authored with CRLF line endings never gets its deprecated codex_hooks feature flag migrated to the new hooks key in Orca's managed runtime config.

normalizeDeprecatedCodexHookFeatureFlag splits the config on \n, which leaves a trailing \r on every line of a CRLF file. The section-header and [features] detection regexes are anchored [ \t]*…$, so a [features]\r line fails to match — no [features] section is detected, and the migration silently no-ops. The deprecated key is then mirrored into Orca's runtime config unchanged, so Codex 0.133 keeps warning and the hook flag is not honored under the new key.

This is an isolated inconsistency: the rest of the same file already tolerates CRLF — getTomlTableHeader uses \s* (which includes \r), and getProjectTrustLevel explicitly allows [ \t\r]*. Only these two header regexes were missed.

Fix: allow an optional trailing \r before $ in both regexes. LF configs are unaffected; the user's real config is never rewritten (only Orca's runtime mirror).

Reproduced: a system config built with ['[features]', 'codex_hooks = true'].join('\r\n') leaves codex_hooks in the runtime mirror before the fix, and is correctly migrated to hooks after.

Screenshots

No visual change. This is a pure config-parsing fix in src/main.

Testing

  • [x] pnpm lint — passes (only a pre-existing unrelated useGitStatusPolling.ts exhaustive-deps warning)
  • [x] pnpm typecheck — passes (node + cli + web, exit 0)
  • [x] pnpm test — src/main/codex suite: 15 files / 289 tests pass; the new CRLF test fails on pre-fix code and passes after
  • [ ] pnpm build — not run locally (native/electron toolchain); change is a pure regex fix with no native or build surface
  • [x] Added a CRLF regression test next to the existing LF migration test; it is red before the fix and green after.

AI Review Report

Reviewed with an AI coding agent. The agent independently traced the whole file's line-ending handling before proposing the fix, to confirm the bug is isolated (not a systemic CRLF rewrite) and the fix matches existing in-file behavior.

  • Cross-platform (macOS / Linux / Windows): Positive. This is a Windows/CRLF correctness fix; LF (mac/Linux) behavior is byte-for-byte unchanged. The fix mirrors the CRLF tolerance already present in getProjectTrustLevel in the same file.
  • SSH / remote / local: No impact. Reads a local config file; identical across local/remote/SSH modes.
  • Agent / integration / git-provider: Scoped to the Codex config mirror; no other agent or provider code touched. Provider-neutral.
  • Performance: No impact — same single pass, one optional \r? in two regexes.
  • UI: No visual change.
  • Security: Neutral. No widening of accepted input beyond tolerating a trailing CR on header lines; the user's real ~/.codex/config.toml is never modified.

Security Audit

  • Input handling: Input is a local user config file. The change only lets a [features]\r header be recognized; it does not broaden what sections/keys are accepted or written. Parsing stays bounded and pure.
  • Command execution / paths / auth / secrets / IPC: None touched. No follow-up needed.

Notes

Windows/CRLF-specific behavior. No new platform branches were added — the fix is a regex tolerance consistent with the rest of the file.

huhuhulululu avatar Jun 30 '26 01:06 huhuhulululu

Review Change Stack

📝 Walkthrough

Walkthrough

Two regexes in codex-config-mirror.ts that detect TOML section headers are updated to allow an optional trailing \r, making the feature-section normalization logic tolerant of Windows CRLF line endings. A new Vitest test case is added to verify that when a system config.toml uses \r\n line endings and contains codex_hooks = true, syncSystemConfigIntoManagedCodexHome() produces a runtime config with hooks = true under [features] and leaves the system config unmodified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the CRLF Codex hook migration fix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The description includes all required sections and provides clear testing, review, security, and cross-platform notes.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot] avatar Jun 30 '26 01:06 coderabbitai[bot]

Thanks @huhuhulululu — this CRLF fix is already on main: config-toml-deprecated-hook-flag.ts accepts \r?$ on header lines and codex-config-mirror.test.ts covers CRLF configs. Closing as superseded.

nwparker avatar Oct 25 '26 20:10 nwparker