fix(#1643): filter destroyed-agent targets from dashboard schedule view
This commit is contained in:
parent
8b991b2cc5
commit
e08122a206
4 changed files with 117 additions and 8 deletions
|
|
@ -18,12 +18,24 @@ use super::{AppState, error_response};
|
|||
/// so the frontend can render without an extra translation layer.
|
||||
pub(super) async fn api_schedules(State(state): State<AppState>) -> Response {
|
||||
match state.coord.scheduled_prompts.list() {
|
||||
Ok(rows) => axum::Json(
|
||||
rows.into_iter()
|
||||
Ok(rows) => {
|
||||
let mut wire: Vec<hive_sh4re::WireSchedule> = rows
|
||||
.into_iter()
|
||||
.map(crate::manager_server::schedule_to_wire_public)
|
||||
.collect::<Vec<_>>(),
|
||||
)
|
||||
.into_response(),
|
||||
.collect();
|
||||
// Drop ghost targets (agents that no longer exist) so the
|
||||
// table never shows dead columns. Uses the reliable async
|
||||
// roster snapshot here on the request path.
|
||||
let live: std::collections::HashSet<String> = state
|
||||
.coord
|
||||
.containers_snapshot()
|
||||
.await
|
||||
.into_iter()
|
||||
.map(|c| c.name)
|
||||
.collect();
|
||||
crate::manager_server::filter_ghost_schedule_targets(&mut wire, &live);
|
||||
axum::Json(wire).into_response()
|
||||
}
|
||||
Err(e) => error_response(&format!("scheduled_prompts list: {e:#}")),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue