mirror of
https://github.com/openai/codex.git
synced 2026-04-30 17:36:40 +00:00
fix: tui freeze when sub-agents are present (#14816)
The issue was due to a circular `Drop` schema where the embedded app-server wait for some listeners that wait for this app-server them-selves. The fix is an explicit cleaning **Repro:** * Start codex * Ask it to spawn a sub-agent * Close Codex * It takes 5s to exit
This commit is contained in:
@@ -196,6 +196,29 @@ impl ThreadStateManager {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn clear_all_listeners(&self) {
|
||||
let thread_states = {
|
||||
let state = self.state.lock().await;
|
||||
state
|
||||
.threads
|
||||
.iter()
|
||||
.map(|(thread_id, thread_entry)| (*thread_id, thread_entry.state.clone()))
|
||||
.collect::<Vec<_>>()
|
||||
};
|
||||
|
||||
for (thread_id, thread_state) in thread_states {
|
||||
let mut thread_state = thread_state.lock().await;
|
||||
tracing::debug!(
|
||||
thread_id = %thread_id,
|
||||
listener_generation = thread_state.listener_generation,
|
||||
had_listener = thread_state.cancel_tx.is_some(),
|
||||
had_active_turn = thread_state.active_turn_snapshot().is_some(),
|
||||
"clearing thread listener during app-server shutdown"
|
||||
);
|
||||
thread_state.clear_listener();
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) async fn unsubscribe_connection_from_thread(
|
||||
&self,
|
||||
thread_id: ThreadId,
|
||||
|
||||
Reference in New Issue
Block a user