feat: Allow sync with remote plugin status. (#14176)

Add forceRemoteSync to plugin/list.
When it is set to True, we will sync the local plugin status with the
remote one (backend-api/plugins/list).
This commit is contained in:
xl-openai
2026-03-10 13:32:59 -07:00
committed by Michael Bolin
parent f2d66fadd8
commit d751e68f44
14 changed files with 1042 additions and 30 deletions

View File

@@ -5303,15 +5303,53 @@ impl CodexMessageProcessor {
async fn plugin_list(&self, request_id: ConnectionRequestId, params: PluginListParams) {
let plugins_manager = self.thread_manager.plugins_manager();
let roots = params.cwds.unwrap_or_default();
let PluginListParams {
cwds,
force_remote_sync,
} = params;
let roots = cwds.unwrap_or_default();
let config = match self.load_latest_config(None).await {
let mut config = match self.load_latest_config(None).await {
Ok(config) => config,
Err(err) => {
self.outgoing.send_error(request_id, err).await;
return;
}
};
let mut remote_sync_error = None;
if force_remote_sync {
let auth = self.auth_manager.auth().await;
match plugins_manager
.sync_plugins_from_remote(&config, auth.as_ref())
.await
{
Ok(sync_result) => {
info!(
installed_plugin_ids = ?sync_result.installed_plugin_ids,
enabled_plugin_ids = ?sync_result.enabled_plugin_ids,
disabled_plugin_ids = ?sync_result.disabled_plugin_ids,
uninstalled_plugin_ids = ?sync_result.uninstalled_plugin_ids,
"completed plugin/list remote sync"
);
}
Err(err) => {
warn!(
error = %err,
"plugin/list remote sync failed; returning local marketplace state"
);
remote_sync_error = Some(err.to_string());
}
}
config = match self.load_latest_config(None).await {
Ok(config) => config,
Err(err) => {
self.outgoing.send_error(request_id, err).await;
return;
}
};
}
let data = match tokio::task::spawn_blocking(move || {
let marketplaces = plugins_manager.list_marketplaces_for_config(&config, &roots)?;
@@ -5375,7 +5413,13 @@ impl CodexMessageProcessor {
};
self.outgoing
.send_response(request_id, PluginListResponse { marketplaces: data })
.send_response(
request_id,
PluginListResponse {
marketplaces: data,
remote_sync_error,
},
)
.await;
}