From 623eaccd5d273f2b7e3d3c070cf2182f36c46370 Mon Sep 17 00:00:00 2001 From: Chris Hayduk Date: Wed, 24 Jun 2026 09:59:31 -0400 Subject: [PATCH] plugins: invalidate caches after remote reconcile --- .../src/request_processors/plugins.rs | 1 + codex-rs/core-plugins/src/manager.rs | 4 +- codex-rs/core-plugins/src/manager_tests.rs | 43 +++++++++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/codex-rs/app-server/src/request_processors/plugins.rs b/codex-rs/app-server/src/request_processors/plugins.rs index 94af935449..d10c43f0d6 100644 --- a/codex-rs/app-server/src/request_processors/plugins.rs +++ b/codex-rs/app-server/src/request_processors/plugins.rs @@ -1632,6 +1632,7 @@ impl PluginRequestProcessor { .reconcile_remote_plugin_install(&config.plugins_config_input(), &result.plugin_id) .await .map_err(Self::plugin_install_error)?; + self.clear_plugin_related_caches(); plugins_manager.maybe_start_remote_installed_plugins_cache_refresh_after_mutation( &config.plugins_config_input(), auth.clone(), diff --git a/codex-rs/core-plugins/src/manager.rs b/codex-rs/core-plugins/src/manager.rs index 2ab8d0d837..6c81db7dc2 100644 --- a/codex-rs/core-plugins/src/manager.rs +++ b/codex-rs/core-plugins/src/manager.rs @@ -1504,7 +1504,9 @@ impl PluginsManager { Some(&config.config_layer_stack), /*enable_canonical*/ false, ) - .await + .await?; + self.clear_cache(); + Ok(()) } async fn reconcile_plugin_install_locked( diff --git a/codex-rs/core-plugins/src/manager_tests.rs b/codex-rs/core-plugins/src/manager_tests.rs index 1a6cf01834..51283c93c4 100644 --- a/codex-rs/core-plugins/src/manager_tests.rs +++ b/codex-rs/core-plugins/src/manager_tests.rs @@ -2369,6 +2369,49 @@ fn loaded_plugins_cache_invalidation_rejects_stale_load_completion() { assert_eq!(manager.cached_loaded_plugins(&cache_key), None); } +#[tokio::test] +async fn reconcile_remote_plugin_install_invalidates_loaded_plugin_cache() { + let codex_home = TempDir::new().unwrap(); + write_cached_plugin(codex_home.path(), "debug", "linear"); + write_file( + &codex_home.path().join(CONFIG_TOML_FILE), + r#"[features] +plugins = true +remote_plugin = true + +[plugins."linear@debug"] +enabled = true +"#, + ); + let config = load_config(codex_home.path(), codex_home.path()).await; + let manager = PluginsManager::new(codex_home.path().to_path_buf()); + + let before = manager.plugins_for_config(&config).await; + assert_eq!(before.plugins().len(), 1); + assert!(before.plugins()[0].is_active()); + + manager + .reconcile_remote_plugin_install( + &config, + &PluginId::new( + "linear".to_string(), + REMOTE_GLOBAL_MARKETPLACE_NAME.to_string(), + ) + .unwrap(), + ) + .await + .unwrap(); + + assert!( + !codex_home + .path() + .join("plugins/cache/debug/linear") + .exists() + ); + let after = manager.plugins_for_config(&config).await; + assert!(after.plugins().iter().all(|plugin| !plugin.is_active())); +} + #[tokio::test] async fn load_plugins_rejects_invalid_plugin_keys() { let codex_home = TempDir::new().unwrap();