mirror of
https://github.com/openai/codex.git
synced 2026-11-21 22:50:37 +00:00
Refresh plugin recommendations after installed state changes (#62610)
## Why Recommendation lookups poll the plugin service for a tooling-state marker even when the cached catalog can still be reused. Install flows and installed-plugin snapshots already give Codex signals to refresh recommendations. ## What changed Remove tooling-state polling and refresh recommendations on the next lookup after a known install event or a change to the installed plugin inventory or enabled state. Invalidate all product SKUs for the affected plugin service and account scope. If the account changes while a remote install prompt is open, invalidate both account scopes when the user accepts. Concurrent lookups share a catalog fetch. If a refresh fails, keep serving the last successful result when available and retry on the next lookup. ## Testing Cover invalidation across accounts, backends, and product SKUs, retention of the last catalog after a failed refresh, and isolation from fetches that complete after invalidation. Update the remote install integration test to exercise the next turn without waiting for the poll interval. GitOrigin-RevId: 5d2ba84d1118e9346308bf6225543e0e174f8125
This commit is contained in:
committed by
copyberry
parent
6633c6e09a
commit
6a8a81166a
@@ -117,7 +117,6 @@ const REMOTE_INSTALLED_PLUGINS_FETCH_TIMEOUT: Duration = Duration::from_secs(60)
|
||||
// Allow 20,000 installed plugins without unbounded cursor history.
|
||||
const MAX_REMOTE_INSTALLED_PLUGIN_PAGES: usize = 100;
|
||||
const RECOMMENDED_PLUGINS_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
const TOOLING_STATE_TIMEOUT: Duration = Duration::from_millis(250);
|
||||
const REMOTE_PLUGIN_LIST_PAGE_LIMIT: u32 = 200;
|
||||
const MAX_RECOMMENDED_PLUGINS: usize = 50;
|
||||
const MAX_RECOMMENDED_PLUGIN_NAME_LEN: usize = 64;
|
||||
@@ -491,10 +490,13 @@ pub struct RecommendedPlugin {
|
||||
pub display_name: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq)]
|
||||
pub enum RecommendedPluginsMode {
|
||||
#[default]
|
||||
Legacy,
|
||||
Endpoint { plugins: Vec<RecommendedPlugin> },
|
||||
Endpoint {
|
||||
plugins: Vec<RecommendedPlugin>,
|
||||
},
|
||||
}
|
||||
|
||||
pub fn is_valid_remote_plugin_id(plugin_id: &str) -> bool {
|
||||
@@ -905,11 +907,6 @@ struct RemotePluginListResponse {
|
||||
pagination: RemotePluginPagination,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct PluginToolingStateResponse {
|
||||
tooling_changed_at: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Deserialize)]
|
||||
struct RecommendedPluginsResponse {
|
||||
enabled: bool,
|
||||
@@ -1160,31 +1157,6 @@ pub fn invalidate_cached_remote_plugin_catalog_scopes(
|
||||
}
|
||||
}
|
||||
|
||||
#[instrument(
|
||||
name = "plugins.recommendations.read_tooling_marker",
|
||||
level = "info",
|
||||
skip_all
|
||||
)]
|
||||
pub(crate) async fn fetch_tooling_changed_at(
|
||||
config: &RemotePluginServiceConfig,
|
||||
auth: Option<&CodexAuth>,
|
||||
) -> Result<Option<String>, RemotePluginCatalogError> {
|
||||
let auth = ensure_chatgpt_auth(auth)?;
|
||||
let base_url = config.chatgpt_base_url.trim_end_matches('/');
|
||||
let url = format!("{base_url}/ps/plugins/tooling-state/turtle");
|
||||
let poll = async {
|
||||
let request = authenticated_request(config, Method::GET, &url, auth).await?;
|
||||
let response: PluginToolingStateResponse = send_and_decode(request, &url).await?;
|
||||
Ok(response.tooling_changed_at)
|
||||
};
|
||||
tokio::time::timeout(TOOLING_STATE_TIMEOUT, poll)
|
||||
.await
|
||||
.unwrap_or_else(|_| {
|
||||
tracing::debug!("timed out reading recommendation tooling state");
|
||||
Ok(None)
|
||||
})
|
||||
}
|
||||
|
||||
#[instrument(
|
||||
name = "plugins.recommendations.fetch_catalog",
|
||||
level = "info",
|
||||
|
||||
Reference in New Issue
Block a user