diff --git a/codex-rs/app-server/README.md b/codex-rs/app-server/README.md index 1c67ea32dc..c1f19a583a 100644 --- a/codex-rs/app-server/README.md +++ b/codex-rs/app-server/README.md @@ -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."@".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. diff --git a/codex-rs/cli/src/plugin_cmd.rs b/codex-rs/cli/src/plugin_cmd.rs index 36d2322038..94756be4b7 100644 --- a/codex-rs/cli/src/plugin_cmd.rs +++ b/codex-rs/cli/src/plugin_cmd.rs @@ -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, } -impl From 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 for PluginListMarketplace { display_version: version.clone(), version, installed: plugin.installed, - enabled: plugin.enabled, + enabled, source: JsonPluginSource::Remote { id: plugin.remote_plugin_id, }, diff --git a/codex-rs/cli/tests/plugin_cli.rs b/codex-rs/cli/tests/plugin_cli.rs index ea80f55a84..bf22391185 100644 --- a/codex-rs/cli/tests/plugin_cli.rs +++ b/codex-rs/cli/tests/plugin_cli.rs @@ -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::(&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"]) diff --git a/codex-rs/config/src/types.rs b/codex-rs/config/src/types.rs index eb1afb6029..2e3ec95f99 100644 --- a/codex-rs/config/src/types.rs +++ b/codex-rs/config/src/types.rs @@ -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) } } diff --git a/codex-rs/config/src/types_tests.rs b/codex-rs/config/src/types_tests.rs index 5a78075bfe..f3bc7758cc 100644 --- a/codex-rs/config/src/types_tests.rs +++ b/codex-rs/config/src/types_tests.rs @@ -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 = diff --git a/codex-rs/core-plugins/src/manager_tests.rs b/codex-rs/core-plugins/src/manager_tests.rs index 7d00a7c702..25118f51c7 100644 --- a/codex-rs/core-plugins/src/manager_tests.rs +++ b/codex-rs/core-plugins/src/manager_tests.rs @@ -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;