mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:31:09 +00:00
Preserve session config when switching thread permission profiles (#45981)
## Why Permission profile changes reloaded configuration without the thread's session overrides, so profiles defined at thread start could be unavailable to `thread/settings/update`. ## What changed Reload permission configuration with the thread's merged, enabled `SessionFlags` layers, the effective working directory, and the requested profile. Preserve sandbox executable paths through `ConfigManager`. ## Testing Add regression coverage for switching away from and back to session-defined and disk-defined profiles, including top-level profile selection. Add a config manager test for merging session layers, excluding disabled layers, and retaining filesystem access to the exec wrapper directory. GitOrigin-RevId: b0271e28a90cd55d3faf5fdf5f044d768395b0b6
This commit is contained in:
1 parent
d7104e268b
commit
7b6dd0c7b8
5 files changed
+191
-19
No files matched your search
@@ -281,6 +281,45 @@ impl ConfigManager {
|
||||
.await
|
||||
}
|
||||
|
||||
/// Reload sources using the task's session flags before materializing config.
|
||||
pub(crate) async fn load_permission_config_for_thread(
|
||||
&self,
|
||||
thread_config: &Config,
|
||||
cwd: AbsolutePathBuf,
|
||||
permission_profile: String,
|
||||
) -> std::io::Result<Config> {
|
||||
let mut session_flags = TomlValue::Table(Default::default());
|
||||
for layer in thread_config.config_layer_stack.layers_low_to_high() {
|
||||
if matches!(layer.name, codex_config::ConfigLayerSource::SessionFlags) {
|
||||
codex_config::merge_toml_values(&mut session_flags, &layer.config);
|
||||
}
|
||||
}
|
||||
let overrides = session_flags
|
||||
.as_table()
|
||||
.ok_or_else(|| {
|
||||
std::io::Error::new(
|
||||
std::io::ErrorKind::InvalidData,
|
||||
"session flags must be a table",
|
||||
)
|
||||
})?
|
||||
.iter()
|
||||
.map(|(key, value)| (key.clone(), value.clone()))
|
||||
.collect::<Vec<_>>();
|
||||
self.load_with_cli_overrides(
|
||||
&overrides,
|
||||
/*request_overrides*/ None,
|
||||
ConfigOverrides {
|
||||
cwd: Some(cwd.to_path_buf()),
|
||||
default_permissions: Some(permission_profile),
|
||||
codex_linux_sandbox_exe: self.arg0_paths.codex_linux_sandbox_exe.clone(),
|
||||
main_execve_wrapper_exe: self.arg0_paths.main_execve_wrapper_exe.clone(),
|
||||
..Default::default()
|
||||
},
|
||||
Some(cwd.to_path_buf()),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
#[instrument(level = "trace", skip_all)]
|
||||
pub(crate) async fn load_with_cli_overrides(
|
||||
&self,
|
||||
|
||||
Reference in new issue
Block a user