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:
Matthew Zeng
2026-11-23 23:39:54 +00:00
committed by copyberry
parent 56bb44c05c
commit d4af2452f7
6 changed files with 30 additions and 24 deletions
+8 -9
View File
@@ -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,
},
+13
View File
@@ -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"])