Refactor plugin loading to async (#17747)

Simplifies skills migration.
This commit is contained in:
pakrym-oai
2026-04-13 21:52:56 -07:00
committed by GitHub
parent ff584c5a4b
commit 3b24a9a532
23 changed files with 308 additions and 209 deletions
@@ -5328,7 +5328,11 @@ impl CodexMessageProcessor {
&self,
config: &Config,
) -> Result<(), JSONRPCErrorError> {
let configured_servers = self.thread_manager.mcp_manager().configured_servers(config);
let configured_servers = self
.thread_manager
.mcp_manager()
.configured_servers(config)
.await;
let mcp_servers = match serde_json::to_value(configured_servers) {
Ok(value) => value,
Err(err) => {
@@ -5388,7 +5392,8 @@ impl CodexMessageProcessor {
let configured_servers = self
.thread_manager
.mcp_manager()
.configured_servers(&config);
.configured_servers(&config)
.await;
let Some(server) = configured_servers.get(&name) else {
let error = JSONRPCErrorError {
code: INVALID_REQUEST_ERROR_CODE,
@@ -5490,7 +5495,9 @@ impl CodexMessageProcessor {
return;
}
};
let mcp_config = config.to_mcp_config(self.thread_manager.plugins_manager().as_ref());
let mcp_config = config
.to_mcp_config(self.thread_manager.plugins_manager().as_ref())
.await;
let auth = self.auth_manager.auth().await;
tokio::spawn(async move {
@@ -6315,10 +6322,12 @@ impl CodexMessageProcessor {
continue;
}
};
let effective_skill_roots = plugins_manager.effective_skill_roots_for_layer_stack(
&config_layer_stack,
config.features.enabled(Feature::Plugins),
);
let effective_skill_roots = plugins_manager
.effective_skill_roots_for_layer_stack(
&config_layer_stack,
config.features.enabled(Feature::Plugins),
)
.await;
let skills_input = codex_core::skills::SkillsLoadInput::new(
cwd_abs,
effective_skill_roots,
@@ -6544,26 +6553,16 @@ impl CodexMessageProcessor {
plugin_name,
marketplace_path,
};
let config_for_read = config.clone();
let outcome = match tokio::task::spawn_blocking(move || {
plugins_manager.read_plugin_for_config(&config_for_read, &request)
})
.await
let outcome = match plugins_manager
.read_plugin_for_config(&config, &request)
.await
{
Ok(Ok(outcome)) => outcome,
Ok(Err(err)) => {
Ok(outcome) => outcome,
Err(err) => {
self.send_marketplace_error(request_id, err, "read plugin details")
.await;
return;
}
Err(err) => {
self.send_internal_error(
request_id,
format!("failed to read plugin details: {err}"),
)
.await;
return;
}
};
let app_summaries =
plugin_app_helpers::load_plugin_app_summaries(&config, &outcome.plugin.apps).await;
@@ -6704,7 +6703,8 @@ impl CodexMessageProcessor {
self.clear_plugin_related_caches();
let plugin_mcp_servers = load_plugin_mcp_servers(result.installed_path.as_path());
let plugin_mcp_servers =
load_plugin_mcp_servers(result.installed_path.as_path()).await;
if !plugin_mcp_servers.is_empty() {
if let Err(err) = self.queue_mcp_server_refresh_for_config(&config).await {
@@ -6717,7 +6717,7 @@ impl CodexMessageProcessor {
.await;
}
let plugin_apps = load_plugin_apps(result.installed_path.as_path());
let plugin_apps = load_plugin_apps(result.installed_path.as_path()).await;
let auth = self.auth_manager.auth().await;
let apps_needing_auth = if plugin_apps.is_empty()
|| !config.features.apps_enabled_for_auth(