chore: enusre the logic that creates ConfigLayerStack has access to cwd (#8353)

`load_config_layers_state()` should load config from a
`.codex/config.toml` in any folder between the `cwd` for a thread and
the project root. Though in order to do that,
`load_config_layers_state()` needs to know what the `cwd` is, so this PR
does the work to thread the `cwd` through for existing callsites.

A notable exception is the `/config` endpoint in app server for which a
`cwd` is not guaranteed to be associated with the query, so the `cwd`
param is `Option<AbsolutePathBuf>` to account for this case.

The logic to make use of the `cwd` will be done in a follow-up PR.
This commit is contained in:
Michael Bolin
2025-12-19 20:11:27 -08:00
committed by GitHub
parent f0dc6fd3c7
commit a6974087e5
12 changed files with 143 additions and 44 deletions

View File

@@ -55,8 +55,14 @@ const DEFAULT_REQUIREMENTS_TOML_FILE_UNIX: &str = "/etc/codex/requirements.toml"
/// (*) Only available on macOS via managed device profiles.
///
/// See https://developers.openai.com/codex/security for details.
///
/// When loading the config stack for a thread, there should be a `cwd`
/// associated with it such that `cwd` should be `Some(...)`. Only for
/// thread-agnostic config loading (e.g., for the app server's `/config`
/// endpoint) should `cwd` be `None`.
pub async fn load_config_layers_state(
codex_home: &Path,
cwd: Option<AbsolutePathBuf>,
cli_overrides: &[(String, TomlValue)],
overrides: LoaderOverrides,
) -> io::Result<ConfigLayerStack> {
@@ -122,6 +128,7 @@ pub async fn load_config_layers_state(
}
// TODO(mbolin): Add layers for cwd, tree, and repo config files.
let _ = cwd;
// Add a layer for runtime overrides from the CLI or UI, if any exist.
if !cli_overrides.is_empty() {