Ignore stale refresh responses in agents overview tests (#51064)

## Why

Aborting a refresh task cannot retract a response already queued for delivery. The test helper could consume that stale response and return before the replacement refresh completed.

## What changed

Make `finish_overview_refresh` skip responses whose request ID does not match the active refresh. Extend the lifecycle test to queue an invalidated response before removing a task, exercising the wait for the replacement refresh.

GitOrigin-RevId: 97341681682e8dce9a9512fbcc1d5c0351b084f5
This commit is contained in:
jif
2026-10-05 09:51:15 +00:00
committed by copyberry
parent cacdc46619
commit c8949e55c2
2 changed files with 16 additions and 0 deletions
@@ -957,6 +957,18 @@ async fn lifecycle_removes_background_and_current_tasks_without_losing_the_dashb
// Canceling pagination must allow automatic refill to finish after removing the last task.
app.agents_overview.initialized = true;
app.agents_overview.view_state.lock().unwrap().loading = true;
// An invalidated refresh can already be queued when the lifecycle action
// aborts its task. It must not satisfy the wait for the replacement refresh.
app.app_event_tx
.send(AppEvent::AgentsOverviewThreadsLoaded {
request_id,
result: Ok(AgentsOverviewThreadRefresh {
threads: HashMap::new(),
last_messages: HashMap::new(),
recent_seed_complete: true,
discovery: None,
}),
});
Box::pin(app.handle_event(&mut tui, &mut app_server, confirmed)).await?;
if app.agents_overview.request_id.is_some() {
finish_overview_refresh(&mut app, &app_server, &mut rx).await;
@@ -664,6 +664,10 @@ async fn finish_overview_refresh(
if let AppEvent::AgentsOverviewThreadsLoaded { request_id, result } =
events.recv().await.expect("overview event")
{
// Aborting a refresh task cannot retract an already queued response.
if app.agents_overview.request_id != Some(request_id) {
continue;
}
assert!(result.is_ok(), "{result:?}");
app.apply_agents_overview_thread_refresh(app_server, request_id, result);
return;