mirror of
https://github.com/openai/codex.git
synced 2026-11-17 22:10:37 +00:00
Avoid duplicate cached app list update notifications (#33640)
## What changed - Emit one final `app/list/updated` notification for an initial cached `app/list` request so other initialized clients can refresh. - Suppress duplicate notifications for unchanged cached continuation pages. - Preserve progressive update notifications for `forceRefetch: true` requests. ## Testing - Cover notification behavior for cached initial and paginated requests. GitOrigin-RevId: 54f2d25a0adf6e0707402328b4c81fa5f950cf9a
This commit is contained in:
@@ -1845,7 +1845,7 @@ When `threadId` is provided, app feature gating (`Feature::Apps`) is evaluated u
|
||||
|
||||
`app/list` returns after both accessible apps and directory apps are loaded. Set `forceRefetch: true` to bypass app caches and fetch fresh data from sources. Cache entries are only replaced when those refetches succeed.
|
||||
|
||||
The server also emits `app/list/updated` notifications whenever either source (accessible apps or directory apps) finishes loading. Each notification includes the latest merged app list.
|
||||
The server also emits `app/list/updated` notifications when newly loaded accessible or directory apps change the merged app list. Each notification includes the latest merged app list. An initial cached `app/list` still emits one final notification so other initialized clients can refresh their app list, while reading an unchanged cached continuation page does not emit a duplicate notification; `forceRefetch: true` preserves the existing progressive notifications while fresh data loads.
|
||||
|
||||
```json
|
||||
{
|
||||
|
||||
@@ -244,19 +244,23 @@ impl AppsRequestProcessor {
|
||||
let mut all_loaded = false;
|
||||
let mut codex_apps_ready = true;
|
||||
let mut last_notified_apps = None;
|
||||
let mut sent_app_list_update = false;
|
||||
|
||||
if accessible_connectors.is_some() || all_connectors.is_some() {
|
||||
let merged = connectors::with_app_enabled_state(
|
||||
merge_loaded_apps(all_connectors.as_deref(), accessible_connectors.as_deref()),
|
||||
&config,
|
||||
);
|
||||
if should_send_app_list_updated_notification(
|
||||
if !force_refetch {
|
||||
last_notified_apps = Some(merged);
|
||||
} else if should_send_app_list_updated_notification(
|
||||
merged.as_slice(),
|
||||
accessible_loaded,
|
||||
all_loaded,
|
||||
) {
|
||||
send_app_list_updated_notification(outgoing, merged.clone()).await;
|
||||
last_notified_apps = Some(merged);
|
||||
sent_app_list_update = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,10 +317,16 @@ impl AppsRequestProcessor {
|
||||
merged.as_slice(),
|
||||
accessible_loaded,
|
||||
all_loaded,
|
||||
) && last_notified_apps.as_ref() != Some(&merged)
|
||||
) && (last_notified_apps.as_ref() != Some(&merged)
|
||||
|| (!force_refetch
|
||||
&& start == 0
|
||||
&& accessible_loaded
|
||||
&& all_loaded
|
||||
&& !sent_app_list_update))
|
||||
{
|
||||
send_app_list_updated_notification(outgoing, merged.clone()).await;
|
||||
last_notified_apps = Some(merged.clone());
|
||||
sent_app_list_update = true;
|
||||
}
|
||||
|
||||
if accessible_loaded && all_loaded {
|
||||
|
||||
@@ -1168,6 +1168,7 @@ async fn list_apps_paginates_results() -> Result<()> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
mcp.clear_message_buffer();
|
||||
|
||||
let second_request = mcp
|
||||
.send_apps_list_request(AppsListParams {
|
||||
@@ -1208,6 +1209,16 @@ async fn list_apps_paginates_results() -> Result<()> {
|
||||
assert_eq!(second_page, expected_second);
|
||||
assert!(second_cursor.is_none());
|
||||
|
||||
let duplicate_update = timeout(
|
||||
Duration::from_millis(150),
|
||||
read_app_list_updated_notification(&mut mcp),
|
||||
)
|
||||
.await;
|
||||
assert!(
|
||||
duplicate_update.is_err(),
|
||||
"cached app/list page emitted a duplicate full-list update"
|
||||
);
|
||||
|
||||
server_handle.abort();
|
||||
Ok(())
|
||||
}
|
||||
@@ -1581,6 +1592,40 @@ async fn list_apps_force_refetch_patches_updates_from_cached_snapshots() -> Resu
|
||||
assert_eq!(refetch_data, expected_final);
|
||||
assert!(refetch_next_cursor.is_none());
|
||||
|
||||
mcp.clear_message_buffer();
|
||||
let cached_request = mcp
|
||||
.send_apps_list_request(AppsListParams {
|
||||
limit: None,
|
||||
cursor: None,
|
||||
thread_id: None,
|
||||
force_refetch: false,
|
||||
})
|
||||
.await?;
|
||||
let cached_response: JSONRPCResponse = timeout(
|
||||
DEFAULT_TIMEOUT,
|
||||
mcp.read_stream_until_response_message(RequestId::Integer(cached_request)),
|
||||
)
|
||||
.await??;
|
||||
let AppsListResponse {
|
||||
data: cached_data,
|
||||
next_cursor: cached_next_cursor,
|
||||
} = to_response(cached_response)?;
|
||||
assert_eq!(cached_data, expected_final);
|
||||
assert!(cached_next_cursor.is_none());
|
||||
|
||||
let cached_update = read_app_list_updated_notification(&mut mcp).await?;
|
||||
assert_eq!(cached_update.data, expected_final);
|
||||
|
||||
let duplicate_update = timeout(
|
||||
Duration::from_millis(150),
|
||||
read_app_list_updated_notification(&mut mcp),
|
||||
)
|
||||
.await;
|
||||
assert!(
|
||||
duplicate_update.is_err(),
|
||||
"cached initial app/list emitted more than one full-list update"
|
||||
);
|
||||
|
||||
server_handle.abort();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user