Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ impl AccountRequestProcessor {
thread_manager
.plugins_manager()
.set_auth_mode(auth.as_ref().map(CodexAuth::api_auth_mode));
thread_manager
.plugins_manager()
.clear_remote_installed_plugins_cache();
thread_manager
.plugins_manager()
.clear_recommended_plugins_cache();
Expand Down
57 changes: 35 additions & 22 deletions codex-rs/app-server/src/request_processors/plugins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,17 @@ impl PluginRequestProcessor {
self.thread_manager.skills_service().clear_cache();
}

fn clear_plugin_share_related_caches(&self, config: &Config, auth: Option<CodexAuth>) {
self.clear_plugin_related_caches();
let plugins_manager = self.thread_manager.plugins_manager();
plugins_manager.invalidate_remote_installed_plugin_snapshot();
plugins_manager.maybe_start_remote_installed_plugins_cache_refresh_after_mutation(
&config.plugins_config_input(),
auth,
Some(self.effective_plugins_changed_callback()),
);
}

async fn load_latest_config(
&self,
fallback_cwd: Option<PathBuf>,
Expand Down Expand Up @@ -658,11 +669,12 @@ impl PluginRequestProcessor {
// TODO(remote plugins): Remove this once remote plugins are ready and vertical plugins are
// served directly from the normal remote catalog.
if include_vertical && !config.features.enabled(Feature::RemotePlugin) {
match codex_core_plugins::remote::fetch_openai_curated_remote_collection_marketplace(
&remote_plugin_service_config,
auth.as_ref(),
)
.await
match plugins_manager
.fetch_openai_curated_remote_collection_marketplace_for_config(
&plugins_input,
auth.as_ref(),
)
.await
{
Ok(Some(remote_marketplace)) => {
data.push(remote_marketplace_to_info(remote_marketplace));
Expand Down Expand Up @@ -699,13 +711,14 @@ impl PluginRequestProcessor {
remote_sources.push(RemoteMarketplaceSource::SharedWithMe);
}
if !remote_sources.is_empty() {
match codex_core_plugins::remote::fetch_remote_marketplaces(
&remote_plugin_service_config,
auth.as_ref(),
&remote_sources,
/*global_catalog_cache_path*/ Some(config.codex_home.as_path()),
)
.await
match plugins_manager
.fetch_remote_marketplaces_for_config(
&plugins_input,
auth.as_ref(),
&remote_sources,
/*global_catalog_cache_path*/ Some(config.codex_home.as_path()),
)
.await
{
Ok(remote_marketplaces) => {
for remote_marketplace in remote_marketplaces
Expand Down Expand Up @@ -1262,7 +1275,7 @@ impl PluginRequestProcessor {
.await
.map_err(|err| remote_plugin_catalog_error_to_jsonrpc(err, "save remote plugin share"))?;
let remote_plugin_id = result.remote_plugin_id;
self.clear_plugin_related_caches();
self.clear_plugin_share_related_caches(&config, auth);
Ok(PluginShareSaveResponse {
remote_plugin_id,
share_url: result.share_url.unwrap_or_default(),
Expand Down Expand Up @@ -1301,7 +1314,7 @@ impl PluginRequestProcessor {
.map_err(|err| {
remote_plugin_catalog_error_to_jsonrpc(err, "update remote plugin share targets")
})?;
self.clear_plugin_related_caches();
self.clear_plugin_share_related_caches(&config, auth);
Ok(PluginShareUpdateTargetsResponse {
principals: result
.principals
Expand Down Expand Up @@ -1400,7 +1413,7 @@ impl PluginRequestProcessor {
)
.await
.map_err(|err| remote_plugin_catalog_error_to_jsonrpc(err, "delete remote plugin share"))?;
self.clear_plugin_related_caches();
self.clear_plugin_share_related_caches(&config, auth);
Ok(PluginShareDeleteResponse {})
}

Expand Down Expand Up @@ -1636,13 +1649,13 @@ impl PluginRequestProcessor {
remote_plugin_catalog_error_to_jsonrpc(err, "install remote plugin")
})?;

self.thread_manager
.plugins_manager()
.maybe_start_remote_installed_plugins_cache_refresh_after_mutation(
&config.plugins_config_input(),
auth.clone(),
Some(self.effective_plugins_changed_callback()),
);
let plugins_manager = self.thread_manager.plugins_manager();
plugins_manager.clear_remote_installed_plugins_cache();
plugins_manager.maybe_start_remote_installed_plugins_cache_refresh_after_mutation(
&config.plugins_config_input(),
auth.clone(),
Some(self.effective_plugins_changed_callback()),
);

let plugin_metadata = self
.thread_manager
Expand Down
32 changes: 21 additions & 11 deletions codex-rs/app-server/tests/suite/v2/plugin_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ use wiremock::matchers::header;
use wiremock::matchers::method;
use wiremock::matchers::path;
use wiremock::matchers::query_param;
use wiremock::matchers::query_param_is_missing;

// Plugin install tests wait on connector discovery after the install response path
// starts, which is noticeably slower on Windows CI.
Expand Down Expand Up @@ -2231,22 +2232,31 @@ async fn mount_remote_plugin_detail_with_options(
}

async fn mount_empty_remote_installed_plugins(server: &MockServer) {
Mock::given(method("GET"))
.and(path("/backend-api/ps/plugins/installed"))
.and(query_param("scope", "GLOBAL"))
.and(header("authorization", "Bearer chatgpt-token"))
.and(header("chatgpt-account-id", "account-123"))
.respond_with(ResponseTemplate::new(200).set_body_string(
r#"{
let body = r#"{
"plugins": [],
"pagination": {
"limit": 50,
"next_page_token": null
}
}"#,
))
.mount(server)
.await;
}"#;
for scope in [Some("GLOBAL"), None] {
let request = Mock::given(method("GET"))
.and(path("/backend-api/ps/plugins/installed"))
.and(header("authorization", "Bearer chatgpt-token"))
.and(header("chatgpt-account-id", "account-123"))
.and(header("oai-product-sku", "codex"));
let request = match scope {
Some(scope) => request.and(query_param("scope", scope)),
None => request
.and(query_param_is_missing("scope"))
.and(query_param("includeDownloadUrls", "true"))
.and(query_param("limit", "1000")),
};
request
.respond_with(ResponseTemplate::new(200).set_body_string(body))
.mount(server)
.await;
}
}

async fn mount_remote_plugin_install(server: &MockServer, remote_plugin_id: &str) {
Expand Down
Loading
Loading