mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
Preserve sub-agent liveness in the agent picker (#33921)
## Why Opening the agent picker could clear a successful spawn hint before the new sub-agent had emitted a turn event, making a running agent appear stopped. ## What changed - Treat active turns and matching completion events as authoritative liveness transitions while leaving an empty event store unchanged. - Remember terminal liveness so delayed activity cannot revive a stopped agent; only a new turn can mark it running again. - Ignore `Interacted` activity when deriving agent liveness. ## Testing Added coverage for empty stores, stale and current completion events, completed snapshots, delayed activity, and subsequent turns. GitOrigin-RevId: 462539d8134a5d3520dbd41edb44b3251f50ead5
This commit is contained in:
1 parent
3a06748458
commit
d4982d0a33
5 files changed
+185
-23
No files matched your search
@@ -18,8 +18,8 @@ impl App {
|
||||
pub(super) async fn open_agent_picker(&mut self, app_server: &mut AppServerSession) {
|
||||
self.backfill_loaded_subagent_threads(app_server).await;
|
||||
// V2 subagents are identified by canonical paths observed from activity events or loaded
|
||||
// thread metadata. Prefer local buffered turn state for liveness, and fall back to
|
||||
// thread/read only when no local event channel exists.
|
||||
// thread metadata. A buffered active turn is positive liveness evidence; a completed
|
||||
// snapshot is terminal evidence. An empty store does not clear a successful spawn hint.
|
||||
let path_backed_thread_ids: Vec<_> = self
|
||||
.agent_navigation
|
||||
.ordered_path_backed_subagent_threads(self.primary_thread_id)
|
||||
@@ -30,8 +30,21 @@ impl App {
|
||||
if let Some(channel) = self.thread_event_channels.get(&thread_id)
|
||||
&& channel.attachment() == ThreadEventAttachment::Live
|
||||
{
|
||||
let is_running = channel.store.lock().await.active_turn_id().is_some();
|
||||
self.agent_navigation.set_running(thread_id, is_running);
|
||||
let (has_active_turn, has_terminal_snapshot) = {
|
||||
let store = channel.store.lock().await;
|
||||
(
|
||||
store.active_turn_id().is_some(),
|
||||
store
|
||||
.turns
|
||||
.last()
|
||||
.is_some_and(|turn| !matches!(turn.status, TurnStatus::InProgress)),
|
||||
)
|
||||
};
|
||||
if has_active_turn {
|
||||
self.agent_navigation.mark_running(thread_id);
|
||||
} else if has_terminal_snapshot {
|
||||
self.agent_navigation.mark_stopped(thread_id);
|
||||
}
|
||||
} else {
|
||||
self.refresh_agent_picker_thread_liveness(app_server, thread_id)
|
||||
.await;
|
||||
@@ -241,7 +254,12 @@ impl App {
|
||||
self.agent_navigation.mark_parent_owned(thread_id);
|
||||
}
|
||||
self.agent_navigation.set_agent_path(thread_id, agent_path);
|
||||
self.agent_navigation.set_running(thread_id, is_running);
|
||||
if is_running {
|
||||
self.agent_navigation.mark_running(thread_id);
|
||||
} else {
|
||||
self.agent_navigation
|
||||
.set_running(thread_id, /*is_running*/ false);
|
||||
}
|
||||
true
|
||||
}
|
||||
Err(err) => {
|
||||
|
||||
Reference in new issue
Block a user