Repository navigation
feat(codex): write in-Codex setting changes back to ~/.codex config - #7960
Conversation
The runtime CODEX_HOME config mirror rewrites config.toml from ~/.codex on every launch and background rate-limit fetch, so settings the user changes inside Orca-launched Codex (/model, /approvals) silently revert. Diff the runtime config against a baseline of what Orca last mirrored; any allowlisted top-level key that changed is a value Codex persisted for the user and is promoted into ~/.codex/config.toml before the mirror pass, so it survives. - Baseline snapshot (.orca-config-settings-baseline.json) advances only after a successful mirror; missing/corrupt baseline skips promotion for one pass so stale pre-upgrade values are never promoted. - ~/.codex stays source of truth: an outside edit to the same key since the baseline wins over the in-Codex change. - Allowlist covers exactly what the Codex TUI persists: model, model_reasoning_effort, approval_policy, sandbox_mode. Keys inside tables ([profiles.*]) and multiline values are never touched. Co-authored-by: Orca <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughThis PR introduces a config settings promotion mechanism for Codex. A new module defines an allowlist of top-level scalar settings and implements baseline snapshotting, diff-based promotion of runtime changes into the system-level 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
Clean auto-merge, no conflicts. Brought in from main: - feat(codex): write in-Codex setting changes back to ~/.codex config (#7960) — codex-config-mirror.ts, config-settings-promotion.ts - Separate pane identity from liveness in the tab-agent resolver, fixes OMP tab flicker (#7860) — pane-agent-owner.ts, use-tab-agent.ts - fix(sidebar): only show projects scrollbar when the list overflows (#7845) Perf-branch structure preserved (clean auto-merge; pty-connection.ts auto-merged without conflict). Gates: typecheck 0 errors; lint 0 errors; ipc/pty + daemon + codex + terminal-pane + lib + runtime + shared + pane-manager suites all pass (9015 + 2120 tests, 0 failed). Co-authored-by: Orca <[email protected]>
…tablyai#7960) Co-authored-by: Orca <[email protected]>
Problem
Config flow between
~/.codexand Orca's managed runtimeCODEX_HOMEis one-way. The mirror (syncSystemConfigIntoManagedCodexHome) rewrites the runtimeconfig.tomlfrom~/.codexon every launch and on background rate-limit fetches, preserving only[hooks.state.*]and[projects.*]. So a/modelor/approvalschange made inside Orca-launched Codex silently reverts — sometimes mid-session, when a rate-limit fetch re-mirrors while Codex is still running.This is the settings half of the same one-way problem #7896 fixed for hook approvals, using the same design.
Fix
Three-way merge built into the mirror itself, so all call sites (launch prep, rate-limit fetch, hook install/refresh) get it for free:
.orca-config-settings-baseline.json).~/.codex/config.toml(surgical line upsert, comments/format preserved) before the mirror pass, so the same pass mirrors it right back.~/.codexstays source of truth — if the same key was also edited in~/.codexsince the baseline, the outside edit wins. Missing/corrupt baseline (first launch after upgrade) skips promotion for one pass, so stale pre-upgrade runtime values are never promoted.Allowlist is exactly what the Codex TUI persists:
model,model_reasoning_effort,approval_policy,sandbox_mode. Keys inside tables ([profiles.*]) and multiline values are never touched; key deletions are not promoted. Grow the list deliberately — every key on it gets silently written into the user's real config.Verification
syncSystemConfigIntoManagedCodexHome: promote + steady-state byte-equality, multi-key promotion, no-baseline/corrupt-baseline upgrade passes, outside-edit-wins conflict, key insertion preserving comments, config creation for users with no~/.codex/config.toml, deletion not promoted, allowlist/table/multiline exclusions, CRLF preservation.HOME+ORCA_USER_DATA_PATH, production mirror code via tsx): mirrored a system config → drove the real Codex TUI/modelpicker → Codex wrote top-levelmodel = "gpt-5.5"+model_reasoning_effort = "medium"→ next mirror pass promoted both into the sandboxed~/.codex/config.toml, inserted cleanly into the preamble before[features]→ third pass byte-identical (steady state). Real~/.codexuntouched (auth.json hash-verified).src/main/codex+src/main/codex-accountssuites green (350 passed),pnpm typecheck, oxlint, max-lines ratchet all green.Out of scope
[profiles.*]: when a profile is active Codex writes there; promotion safely no-ops (documented limitation).Made with Orca 🐋