Skip to content

feat: add layered --profile-v2 config files#17141

Merged
jif-oai merged 32 commits into
mainfrom
jif/profile-v2
May 14, 2026
Merged

feat: add layered --profile-v2 config files#17141
jif-oai merged 32 commits into
mainfrom
jif/profile-v2

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai commented Apr 8, 2026

Why

--profile-v2 <name> gives launchers and runtime entry points a named profile config without making each profile duplicate the base user config. The base $CODEX_HOME/config.toml still loads first, then $CODEX_HOME/<name>.config.toml layers above it and becomes the active writable user config for that session.

That keeps shared defaults, plugin/MCP setup, and managed/user constraints in one place while letting a named profile override only the pieces that need to differ.

What Changed

  • Added the shared --profile-v2 <name> runtime option with validated plain names, now represented by ProfileV2Name.
  • Extended config layer state so the base user config and selected profile config are both User layers; APIs expose the active user layer and merged effective user config.
  • Threaded profile selection through runtime entry points: codex, codex exec, codex review, codex resume, codex fork, and codex debug prompt-input.
  • Made user-facing config writes go to the selected profile file when active, including TUI/settings persistence, app-server config writes, and MCP/app tool approval persistence.
  • Made plugin, marketplace, MCP, hooks, and config reload paths read from the merged user config so base and profile layers both participate.
  • Updated app-server config layer schemas to mark profile-backed user layers.

Limits

--profile-v2 is still rejected for config-management subcommands such as feature, MCP, and marketplace edits. Those paths remain tied to the base config.toml until they have explicit profile-selection semantics.

Some adjacent background writes may still update base or global state rather than the selected profile:

  • marketplace auto-upgrade metadata
  • automatic MCP dependency installs from skills
  • remote plugin sync or uninstall config edits
  • personality migration marker/default writes

Verification

Added targeted coverage for profile name validation, layer ordering/merging, selected-profile writes, app-server config writes, session hot reload, plugin config merging, hooks/config fixture updates, and MCP/app approval persistence.

@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented Apr 8, 2026

@codex review

Copy link
Copy Markdown
Contributor

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Config::load_default_with_cli_overrides(cli_kv_overrides.clone()).map_err(|e| {

P1 Badge Preserve profile-v2 path in fallback config load

When ConfigBuilder fails, app-server falls back via Config::load_default_with_cli_overrides(...), which drops loader_overrides.user_config_path. Later ConfigEditsBuilder::for_config(&config) resolves to $CODEX_HOME/config.toml, so sessions started with --profile-v2 can persist edits (e.g. skills/tool approvals) into the wrong file after an invalid selected config.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jif-oai jif-oai requested a review from a team as a code owner April 21, 2026 12:25
@jif-oai jif-oai changed the title feat: profile v2 feat: add layered profile-v2 config files Apr 21, 2026
jif-oai and others added 5 commits April 21, 2026 18:40
# Conflicts:
#	codex-rs/app-server/src/config_manager_service.rs
#	codex-rs/tui/src/app/tests.rs
Co-authored-by: Codex <noreply@openai.com>
Comment thread codex-rs/config/src/state.rs Outdated
Comment thread codex-rs/config/src/state.rs
Comment thread codex-rs/config/src/state.rs
Comment thread codex-rs/app-server/src/config_manager.rs Outdated
Comment thread codex-rs/app-server/src/config_manager.rs
Comment thread codex-rs/cli/src/main.rs
Comment thread codex-rs/config/src/loader/layer_io.rs Outdated
Comment thread codex-rs/core/src/config/mod.rs Outdated
jif-oai and others added 5 commits April 30, 2026 17:37
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
jif-oai added 2 commits May 8, 2026 17:42
# Conflicts:
#	codex-rs/app-server-protocol/src/protocol/v2.rs
#	codex-rs/config/src/state.rs
#	codex-rs/core/src/mcp_tool_call_tests.rs
#	codex-rs/core/src/session/mod.rs
#	codex-rs/tui/src/app/event_dispatch.rs
Comment thread codex-rs/cli/src/main.rs
Comment thread codex-rs/tui/src/app/tests.rs
Copy link
Copy Markdown
Collaborator

@bolinfest bolinfest left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly small issues which you can take or leave, though one thing I do feel is important is using ProfileV2Name instead of String wherever appropriate.

I realize now that in some of my comments, String may be used because it is still referring to profile v1, so I guess those can't be converted right now. (Or maybe we do and run the risk of breaking folks who decided to create profiles in config.toml that have names with characters we don't allow, which I think is acceptable.)

Comment thread codex-rs/utils/cli/src/shared_options.rs Outdated
Comment thread codex-rs/config/src/state.rs Outdated
Comment thread codex-rs/cli/src/main.rs Outdated
Comment thread codex-rs/config/src/state.rs Outdated
Comment thread codex-rs/config/src/state.rs Outdated
@@ -261,49 +323,92 @@ impl ConfigLayerStack {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docstring needs to be updated to explain what happens when there are multiple user layers?

Comment thread codex-rs/core/src/config/edit.rs Outdated
Comment thread codex-rs/core/src/config/mod.rs Outdated
Comment thread codex-rs/core/src/session/mod.rs
Comment thread codex-rs/config/src/state.rs
Comment thread codex-rs/exec/src/lib.rs Outdated
# Conflicts:
#	codex-rs/app-server/tests/suite/v2/config_rpc.rs
#	codex-rs/cli/src/main.rs
#	codex-rs/config/src/loader/mod.rs
#	codex-rs/core/src/config/mod.rs
#	codex-rs/core/src/mcp_tool_call_tests.rs
#	codex-rs/exec/src/lib.rs
#	codex-rs/tui/src/lib.rs
@jif-oai jif-oai changed the title feat: add layered profile-v2 config files feat: add layered --profile-v2 config files May 14, 2026
@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented May 14, 2026

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@jif-oai jif-oai merged commit deedf3b into main May 14, 2026
31 checks passed
@jif-oai jif-oai deleted the jif/profile-v2 branch May 14, 2026 13:16
@github-actions github-actions Bot locked and limited conversation to collaborators May 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants