Repository navigation
fix(codex): keep Orca-only MCP servers when refreshing the retained shared home - #24983
Conversation
…hared home The refresh for panes that outlive an update treated the old shared home's whole MCP root as owned by ~/.codex, so it deleted servers the user had added from an Orca terminal, which existed only there. Read the home's settings baseline instead, as the normal mirror does: drop only servers the last mirror copied from ~/.codex. No baseline keeps the old behaviour; an unreadable one skips the refresh. The baseline is not advanced, keeping the refresh one-way. STA-9109
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Legacy refresh reads MCP ownership from the retained baseline —
syncSystemConfigIntoLegacySharedCodexHomenow passes the retained home's own.orca-config-settings-baseline.jsonmcpServers/mcpServerRootintomergeSystemCodexConfigIntoRuntimeinstead of always forcingnew Set(), true. Orca-only servers (absent from the baseline and from~/.codex) survive, while servers the baseline recorded from~/.codexand since removed there are still dropped. - No-record and pre-ownership baselines keep prior behavior — absent or v1/v2 baselines map to
[∅, true]; an indeterminate baseline read now throws so the caller skips that pass rather than guessing. The refresh stays one-way (never advances the baseline). - Tests — new cases in
codex-config-mirror-mcp-ownership.test.tsandlegacy-shared-config-compatibility.test.tspin each branch: keep Orca-only / drop~/.codex-removed, pre-ownership guard, unreadable baseline leaves the config untouched, and settings + project/hook trust still refresh with the baseline unchanged.
The new ownership arguments mirror exactly what the managed mirror already feeds the merge (promotionPlan.mirroredMcpServers / mirroredMcpServerRoot), so the two paths stay consistent; the merge still consults the current ~/.codex ownership for the inline-root and same-name cases. I ran the affected suites (82 tests, all pass), oxlint on the changed files, and pnpm tc:node — all clean.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (1)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughLegacy shared-home refresh uses MCP ownership recorded in the runtime settings baseline when merging system configuration. If no baseline exists, it keeps the previous whole-root ownership behavior. If the baseline cannot be read, the refresh throws. Tests cover MCP server retention and removal, unchanged baseline contents, unreadable baselines, and retained-pane settings. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to Orca-only MCP servers are retained while mirrored servers continue to track system settings. If the ownership baseline cannot be read, that refresh is skipped and logged without blocking real-home startup or launch; no actionable merge risk remains. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The refresh preserves terminal-only servers, but servers newly copied from the main configuration are not added to the ownership record. Removing one later may leave its command configuration behind in older terminals. The demonstrated scope is the user's retained configuration, not a new remote access path. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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 |

ELI5
Before Orca started running Codex directly on your own
~/.codexfolder, it ran Codex on a private copy of that folder. Codex terminals that were already open before an update keep using that old copy, so Orca keeps refreshing it with your latest~/.codexsettings. That refresh was deleting MCP servers you had added from inside an Orca terminal, and the old copy was the only place those existed. Now the refresh keeps them.What Changed
Before: updating Orca on Windows while Codex terminals were open deleted MCP servers you'd added from an Orca terminal from Orca's old Codex folder (
%APPDATA%\orca\codex-runtime-home\home), the only place they existed.After: they're kept. Servers that came from
~/.codexand that you've since removed there are still removed from the old copy, and ordinary settings and project/hook trust refresh exactly as before.Mechanism: the refresh for those surviving terminals (
syncSystemConfigIntoLegacySharedCodexHome) merged with "every[mcp_servers.*]table belongs to~/.codex", so any table not in~/.codexwas dropped. The old copy already holds the record the normal mirror keeps of which MCP servers it copied from~/.codex(.orca-config-settings-baseline.json). The refresh now reads that record and passes it to the same merge the normal mirror uses, so only servers that came from~/.codexcan be removed:~/.codexand later removed there is dropped.~/.codex", so behaviour is unchanged.~/.codex).The refresh stays one-way: it reads the record but never updates it.
Why
Found by an end-to-end run of #24356: start with a build from before #24356 that has a
[mcp_servers.demo-mcp]table only in Orca's copy and a live terminal daemon, then upgrade.demo-mcpwas gone from the old copy'sconfig.toml.The refresh function predates #24356, and macOS/Linux terminals that survived the switch to the real
~/.codexhad the same behaviour. #24356 is what made it run on Windows, where the terminal daemon is built to outlive auto-updates. The fix applies to every platform; the record has the same meaning everywhere.Reusing the normal mirror's ownership record was the smallest correct option. Keeping every MCP table would bring back servers you deleted from
~/.codex. Recording ownership separately for the old copy would mean a second source of truth. The cost of not updating the record: a server added to~/.codexafter the last full mirror and then removed from~/.codexstays in the old copy. That leaves an extra entry; nothing is lost.Linked Issue
Linear: STA-9109
Visual Proof
N/A. This only changes what is written to a config file; there's nothing new on screen.
Testing
New tests in
src/main/codex/codex-config-mirror-mcp-ownership.test.tsandsrc/main/codex-accounts/legacy-shared-config-compatibility.test.ts: an Orca-only server is kept, a server removed from~/.codexis dropped, an older record without the MCP list and a missing record behave as before, an unreadable record leaves the config untouched, and settings and project/hook trust still refresh while the record stays unchanged. The three tests for the new behaviour fail onmain.pnpm tc:node,oxlint,oxfmt --check,pnpm run check:code-quality:changed: pass.src/main/codex+src/main/codex-accountson Windows: the same tests fail with and without this change (WSL, session-resume, structured-session, and app-server suites that already fail on this machine). This change adds no new failures.I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
Cross-platform: same behaviour on macOS, Linux, and Windows. SSH/WSL: not affected; this only touches the local host's old Orca copy. Backwards compatibility: older records keep their existing meaning.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)