plugins: invalidate caches after remote reconcile

This commit is contained in:
Chris Hayduk
2026-06-24 09:59:31 -04:00
parent 4ff4b95dd5
commit 623eaccd5d
3 changed files with 47 additions and 1 deletions
@@ -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(),
+3 -1
View File
@@ -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(
@@ -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();