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:
Alex Zamoshchin
2026-11-19 22:16:30 +00:00
committed by copyberry
parent 6633c6e09a
commit 6a8a81166a
8 changed files with 494 additions and 294 deletions
@@ -389,17 +389,6 @@ async fn mount_remote_calendar_recommendation(
server: &wiremock::MockServer,
installed: Arc<AtomicBool>,
) {
let installed_for_marker = Arc::clone(&installed);
Mock::given(method("GET"))
.and(path("/ps/plugins/tooling-state/turtle"))
.respond_with(move |_: &wiremock::Request| {
let marker = installed_for_marker
.load(Ordering::SeqCst)
.then_some("1700000000000");
ResponseTemplate::new(200).set_body_json(json!({ "tooling_changed_at": marker }))
})
.mount(server)
.await;
Mock::given(method("GET"))
.and(path("/ps/plugins/suggested/codex"))
.and(query_param("scope", "GLOBAL"))
@@ -1664,8 +1653,6 @@ async fn run_remote_plugin_install_refresh_case(refreshed_tools: RefreshedAppsTo
.codex
.refresh_runtime_config(current_config, test.config.clone())
.await;
// Let the one-second marker poll window expire before the next turn.
tokio::time::sleep(Duration::from_secs(1)).await;
test.submit_turn("check whether Calendar is still installed")
.await?;
let requests = mock.requests();