fix: do not show closed agents in /agent (#11175)

This commit is contained in:
jif-oai 2026-02-09 11:25:31 +00:00 committed by GitHub
parent 753821c90f
commit 13de744296
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -771,7 +771,14 @@ impl App {
Ok(())
}
fn open_agent_picker(&mut self) {
async fn open_agent_picker(&mut self) {
let thread_ids: Vec<ThreadId> = self.thread_event_channels.keys().cloned().collect();
for thread_id in thread_ids {
if self.server.get_thread(thread_id).await.is_err() {
self.thread_event_channels.remove(&thread_id);
}
}
if self.thread_event_channels.is_empty() {
self.chat_widget
.add_info_message("No agents available yet.".to_string(), None);
@ -2160,7 +2167,7 @@ impl App {
self.chat_widget.open_approvals_popup();
}
AppEvent::OpenAgentPicker => {
self.open_agent_picker();
self.open_agent_picker().await;
}
AppEvent::SelectAgentThread(thread_id) => {
self.select_agent_thread(tui, thread_id).await?;
@ -2686,6 +2693,19 @@ mod tests {
Ok(())
}
#[tokio::test]
async fn open_agent_picker_prunes_missing_threads() -> Result<()> {
let mut app = make_test_app().await;
let thread_id = ThreadId::new();
app.thread_event_channels
.insert(thread_id, ThreadEventChannel::new(1));
app.open_agent_picker().await;
assert_eq!(app.thread_event_channels.contains_key(&thread_id), false);
Ok(())
}
async fn make_test_app() -> App {
let (chat_widget, app_event_tx, _rx, _op_rx) = make_chatwidget_manual_with_sender().await;
let config = chat_widget.config_ref().clone();