mirror of
https://github.com/openai/codex.git
synced 2026-11-24 23:20:47 +00:00
Honor explicit plugin disablement without a global default (#63468)
## Why Without `plugins._default`, the activation policy ignored a plugin's explicit `enabled = false`. The CLI also reported remote plugin enablement directly from the marketplace, so its output could disagree with the effective state. ## What changed Apply per-plugin enablement before falling back to `plugins._default.enabled`. The `codex plugin list` command now applies that policy to remote plugins, so an installed plugin can appear as disabled while retaining its installation and account settings. Plugins disabled at their source stay disabled. ## Testing Cover explicit disablement without a global default in config and remote plugin loading tests, and check that the CLI reports the plugin as installed and disabled in both JSON and table output. GitOrigin-RevId: ab9f5a5b36150d7350c2d11a8421f9e14524a1ad
This commit is contained in:
@@ -548,8 +548,9 @@ Plugin summaries returned by `plugin/list`, `plugin/installed`, `plugin/read`,
|
||||
and `plugin/share/list` report effective `enabled` state. When
|
||||
`plugins._default.enabled` is configured, an explicit
|
||||
`plugins."<plugin-name>@<marketplace-name>".enabled` overrides that default;
|
||||
a plugin disabled at its source remains disabled. Omitting the default preserves
|
||||
existing source and account enablement. Other plugin settings, including remembered
|
||||
a plugin disabled at its source remains disabled. When `_default` is absent,
|
||||
an explicit `enabled: false` still disables the plugin without changing its
|
||||
installation or account settings. Other plugin settings, including remembered
|
||||
tool approvals, inherit the activation default unless `enabled` is explicitly set.
|
||||
`plugin/search` retains its discovery behavior: results report `enabled: false`
|
||||
while preserving their installation state.
|
||||
|
||||
@@ -5,6 +5,7 @@ use anyhow::ensure;
|
||||
use clap::Parser;
|
||||
use codex_app_server_protocol::PluginAuthPolicy;
|
||||
use codex_app_server_protocol::PluginInstallPolicy;
|
||||
use codex_config::types::PluginsConfigToml;
|
||||
use codex_core::config::Config;
|
||||
use codex_core::config::ConfigOverrides;
|
||||
use codex_core::config::LoaderOverrides;
|
||||
@@ -293,12 +294,9 @@ pub async fn run_plugin_list(overrides: &CliConfigOverrides, args: ListPluginsAr
|
||||
path: Some(marketplace.path),
|
||||
}
|
||||
})
|
||||
.chain(
|
||||
remote_listing
|
||||
.marketplaces
|
||||
.into_iter()
|
||||
.map(PluginListMarketplace::from),
|
||||
)
|
||||
.chain(remote_listing.marketplaces.into_iter().map(|marketplace| {
|
||||
PluginListMarketplace::from_remote(marketplace, &plugins_input.plugins)
|
||||
}))
|
||||
.filter(|marketplace| {
|
||||
args.marketplace_name
|
||||
.as_ref()
|
||||
@@ -439,14 +437,15 @@ struct PluginListMarketplace {
|
||||
plugins: Vec<PluginListEntry>,
|
||||
}
|
||||
|
||||
impl From<RemoteMarketplace> for PluginListMarketplace {
|
||||
fn from(marketplace: RemoteMarketplace) -> Self {
|
||||
impl PluginListMarketplace {
|
||||
fn from_remote(marketplace: RemoteMarketplace, plugin_policy: &PluginsConfigToml) -> Self {
|
||||
Self {
|
||||
plugins: marketplace
|
||||
.plugins
|
||||
.into_iter()
|
||||
.map(|plugin| {
|
||||
let version = plugin.local_version.or(plugin.version);
|
||||
let enabled = plugin.enabled && plugin_policy.allows_plugin(&plugin.id);
|
||||
PluginListEntry {
|
||||
plugin_id: plugin.id,
|
||||
name: plugin.name,
|
||||
@@ -454,7 +453,7 @@ impl From<RemoteMarketplace> for PluginListMarketplace {
|
||||
display_version: version.clone(),
|
||||
version,
|
||||
installed: plugin.installed,
|
||||
enabled: plugin.enabled,
|
||||
enabled,
|
||||
source: JsonPluginSource::Remote {
|
||||
id: plugin.remote_plugin_id,
|
||||
},
|
||||
|
||||
@@ -1357,6 +1357,19 @@ async fn remote_plugin_listing_replaces_local_curated_catalog() -> Result<()> {
|
||||
sample@openai-curated-remote installed, enabled 1.2.3 b1234567-89ab-4cde-8f01-234567890abc
|
||||
");
|
||||
|
||||
let config_path = fixture.home.path().join(CONFIG_TOML_FILE);
|
||||
let mut config = std::fs::read_to_string(&config_path)?;
|
||||
config.push_str(&format!("\n[plugins.\"{PLUGIN_KEY}\"]\nenabled = false\n"));
|
||||
std::fs::write(config_path, config)?;
|
||||
let mut expected: Value = serde_json::from_str(&listed)?;
|
||||
expected["installed"][0]["enabled"] = json!(false);
|
||||
let disabled = fixture
|
||||
.success(&["plugin", "list", "--available", "--json"])
|
||||
.await?;
|
||||
assert_eq!(serde_json::from_str::<Value>(&disabled)?, expected);
|
||||
let table = fixture.success(&["plugin", "list"]).await?;
|
||||
assert!(table.contains("installed, disabled"), "{table}");
|
||||
|
||||
fixture.server.reset().await;
|
||||
let listed = fixture
|
||||
.success(&["plugin", "list", "-m", "openai-curated", "--json"])
|
||||
|
||||
@@ -1180,16 +1180,13 @@ pub struct PluginsConfigToml {
|
||||
|
||||
impl PluginsConfigToml {
|
||||
/// Whether configuration permits a source-enabled plugin to remain active.
|
||||
/// Without `_default`, preserve legacy source and account enablement.
|
||||
/// Otherwise, an explicit enablement setting overrides the configured default.
|
||||
/// Only plugins without an explicit `enabled` setting inherit `_default`.
|
||||
pub fn allows_plugin(&self, plugin_id: &str) -> bool {
|
||||
let Some(default) = &self.default else {
|
||||
return true;
|
||||
};
|
||||
self.plugins
|
||||
.get(plugin_id)
|
||||
.and_then(|plugin| plugin.enabled)
|
||||
.unwrap_or(default.enabled)
|
||||
.or(self.default.as_ref().map(|default| default.enabled))
|
||||
.unwrap_or(true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,9 +49,8 @@ auto_provision = true
|
||||
]
|
||||
.map(|plugin_id| config.allows_plugin(plugin_id)),
|
||||
match default_enabled {
|
||||
None => [true, true, true, true, true, true, true],
|
||||
None | Some(true) => [true, true, true, true, true, false, true],
|
||||
Some(false) => [false, false, false, false, true, false, false],
|
||||
Some(true) => [true, true, true, true, true, false, true],
|
||||
},
|
||||
);
|
||||
let round_trip: PluginsConfigToml =
|
||||
|
||||
@@ -1389,9 +1389,6 @@ async fn remote_installed_plugin_preserves_configured_mcp_server_policy() {
|
||||
r#"[features]
|
||||
plugins = true
|
||||
|
||||
[plugins."linear@openai-curated-remote"]
|
||||
enabled = false
|
||||
|
||||
[plugins."linear@openai-curated-remote".mcp_servers.linear]
|
||||
enabled = false
|
||||
default_tools_approval_mode = "approve"
|
||||
@@ -3447,11 +3444,11 @@ async fn plugin_defaults_resolve_remote_enablement_and_separate_cache_entries()
|
||||
"[plugins._default]\nenabled = false\n[plugins.\"sample@openai-curated-remote\".mcp_servers.example]\ndefault_tools_approval_mode = 'approve'",
|
||||
Vec::new(),
|
||||
),
|
||||
// Without the new default, legacy remote account enablement still wins.
|
||||
(
|
||||
"[plugins.\"sample@openai-curated-remote\"]\nenabled = false",
|
||||
vec![other, sample],
|
||||
vec![other],
|
||||
),
|
||||
("", vec![other, sample]),
|
||||
] {
|
||||
write_file(&config_path, policy);
|
||||
let config = load_config(codex_home.path(), codex_home.path()).await;
|
||||
|
||||
Reference in New Issue
Block a user