exec: fix config_overrides merging to ensure root flags are applied to subcommands

- Merge config_overrides from the root CLI into subcommands in run_main.
- Extend tests for config_overrides arguments ordering in config_overrides_are_applied_resume.
This commit is contained in:
pakrym-oai
2025-09-30 09:46:11 -07:00
parent 17cee69a85
commit f2eb50be9f
2 changed files with 34 additions and 2 deletions
+8 -2
View File
@@ -49,6 +49,9 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
let Cli { command, shared } = cli;
// Merge overrides from root CLI.
let mut config_overrides = shared.config_overrides.clone();
let shared = command
.as_ref()
.map(|cmd| match cmd {
@@ -56,7 +59,6 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
})
.unwrap_or(shared);
println!("shared: {shared:?}");
let SharedExecArgs {
images,
model: model_cli_arg,
@@ -73,10 +75,14 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
sandbox_mode: sandbox_mode_cli_arg,
output_schema: output_schema_path,
include_plan_tool,
config_overrides,
prompt: prompt_arg,
..
} = shared;
config_overrides
.raw_overrides
.splice(0..0, shared.config_overrides.raw_overrides);
let prompt = match prompt_arg {
Some(p) if p != "-" => p,
// Either `-` was passed or no positional arg.
@@ -19,6 +19,32 @@ async fn config_overrides_are_applied_resume() -> anyhow::Result<()> {
)
.await?;
config_overrides_are_applied_resume_inner(
&["-c", "model=o3", "prompt text"],
&[
"resume",
"--skip-git-repo-check",
"fake id",
"-c",
"model=o3",
"resume prompt text",
],
)
.await?;
config_overrides_are_applied_resume_inner(
&["-c", "model=o3", "prompt text"],
&[
"-c",
"model=o3",
"resume",
"--skip-git-repo-check",
"fake id",
"resume prompt text",
],
)
.await?;
Ok(())
}