Purge legacy ocw-managed sections from ~/.codex/config.toml on onboard#57
Merged
Conversation
… on onboard Before the rebrand, `ocw onboard --codex` wrote: - `[mcp_servers.ocw]` with `command = "ocw"` and `args = ["mcp"]` - `[otel]` block with `# Managed by ocw — do not edit this block manually` After the rebrand, `tj onboard --codex` correctly appends `[mcp_servers.tj]`, but it left the legacy `ocw`-managed sections in place. The result was a Codex config carrying both blocks — and the orphan `[mcp_servers.ocw]` points at a binary that no longer exists, so Codex would try to spawn a non-existent MCP server on every launch. Fix: `_codex_purge_legacy_ocw()` strips both legacy section trees unconditionally on every `tj onboard --codex`. If the purge actually changed anything, the cleaned file is persisted immediately — so the "already configured" early-return path no longer leaves stale `ocw` sections sitting in the file forever. The `[otel]` block is only stripped when it carries the `# Managed by ocw` comment, so tj-managed (or user-authored) `[otel]` blocks are preserved. Found while running tests/manual-pre-release-testing.md (Codex CLI block). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Found while running `tests/manual-pre-release-testing.md` — the Codex CLI integration block.
Before the rebrand, the legacy `ocw onboard --codex` wrote two blocks to `~/.codex/config.toml`:
```toml
[otel]
Managed by ocw — do not edit this block manually
log_user_prompt = false
[mcp_servers.ocw]
Managed by ocw — gives Codex access to OCW observability tools
command = "ocw"
args = ["mcp"]
```
After the rebrand, `tj onboard --codex` correctly appends the new `[mcp_servers.tj]` block but does not touch the legacy `ocw` sections. The result is a Codex config carrying both blocks side by side. The orphan `[mcp_servers.ocw]` points at `command = "ocw"`, a binary that no longer exists — so Codex will try (and fail) to spawn a phantom MCP server on every launch.
Re-running `tj onboard --codex` doesn't help: the "already has `[otel]` and `[mcp_servers.tj]` sections" early-return triggers and the legacy sections persist forever.
Fix
New helper `_codex_purge_legacy_ocw()`:
Wired into `_onboard_codex` right after reading the existing config: if anything was purged, the cleaned file is persisted immediately — so the "already configured" early-return path no longer carries the legacy sections forward.
Test plan
Manual verification (after merge)
For users who already onboarded pre-rebrand, the next `tj onboard --codex` will silently clean up their config. Sanity check after merge:
```bash
tj onboard --codex # any args
grep -E "Managed by ocw|mcp_servers\.ocw" ~/.codex/config.toml # should be empty
```
🤖 Filed via Claude Code while testing