mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +00:00
Add local status line provider configuration (#61211)
## What changed Add `tui.status_line_provider` to select `"default"` or an MCP provider identified by `server` and `tool`. Replace provider identities as a unit across configuration layers so partial overrides cannot inherit half an identity. Ignore this setting from project configuration and packaged defaults when computing effective values and origins, while retaining strict validation. Preserve relative path resolution when an ignored provider value is malformed. Carry the selection into TUI local settings and refresh it on configuration reload. Use the client's configuration home when rebuilding settings for remote sessions. ## Testing Add coverage for provider precedence, incomplete profile overrides, malformed values and diagnostics, relative path resolution, and local preference preservation when resuming remote sessions. GitOrigin-RevId: 0777d754d46cf009569ff0c90fd7426f8b7650bf
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use serde_json::Value as JsonValue;
|
||||
use std::borrow::Cow;
|
||||
use toml::Value as TomlValue;
|
||||
|
||||
/// Provenance for one layer in the effective Codex configuration.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
@@ -27,7 +29,40 @@ pub enum ConfigLayerSource {
|
||||
LegacyManagedConfigTomlFromMdm,
|
||||
}
|
||||
|
||||
pub(crate) fn without_status_line_provider(config: &TomlValue) -> Cow<'_, TomlValue> {
|
||||
let mut values = Cow::Borrowed(config);
|
||||
if config
|
||||
.get("tui")
|
||||
.and_then(|tui| tui.get("status_line_provider"))
|
||||
.is_some()
|
||||
&& let Some(table) = values.to_mut().as_table_mut()
|
||||
&& let Some(tui) = table.get_mut("tui").and_then(TomlValue::as_table_mut)
|
||||
{
|
||||
tui.remove("status_line_provider");
|
||||
if tui.is_empty() {
|
||||
table.remove("tui");
|
||||
}
|
||||
}
|
||||
values
|
||||
}
|
||||
|
||||
impl ConfigLayerSource {
|
||||
/// Project settings and packaged defaults cannot select a status line provider.
|
||||
pub(crate) fn effective_values<'a>(&self, config: &'a TomlValue) -> Cow<'a, TomlValue> {
|
||||
match self {
|
||||
Self::PackagedDefaults { .. } | Self::Project { .. } => {
|
||||
without_status_line_provider(config)
|
||||
}
|
||||
Self::User { .. }
|
||||
| Self::SessionFlags
|
||||
| Self::System { .. }
|
||||
| Self::EnterpriseManaged { .. }
|
||||
| Self::Mdm { .. }
|
||||
| Self::LegacyManagedConfigTomlFromFile { .. }
|
||||
| Self::LegacyManagedConfigTomlFromMdm => Cow::Borrowed(config),
|
||||
}
|
||||
}
|
||||
|
||||
/// A setting from a layer with a higher precedence overrides a setting
|
||||
/// from a layer with a lower precedence.
|
||||
pub fn precedence(&self) -> i16 {
|
||||
|
||||
Reference in New Issue
Block a user