Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Avoid rendering sub-agent activity twice in the TUI (#39049)

Benjamin Carlsson1a8bac9405a2
diff --git a/codex-rs/tui/src/chatwidget/protocol.rs b/codex-rs/tui/src/chatwidget/protocol.rs
index 9619a2f935..94dc682134 100644
--- a/codex-rs/tui/src/chatwidget/protocol.rs
+++ b/codex-rs/tui/src/chatwidget/protocol.rs
@@ -361,7 +361,6 @@ impl ChatWidget {
reasoning_effort,
agents_states,
}),
- item @ ThreadItem::SubAgentActivity { .. } => self.on_sub_agent_activity(item),
ThreadItem::EnteredReviewMode { review, .. } if !from_replay => {
self.enter_review_mode_with_hint(review, /*from_replay*/ false);
}
diff --git a/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__app_server_sub_agent_activity_renders_once.snap b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__app_server_sub_agent_activity_renders_once.snap
new file mode 100644
index 0000000000..5cda26aecf
--- /dev/null
+++ b/codex-rs/tui/src/chatwidget/snapshots/codex_tui__chatwidget__tests__app_server_sub_agent_activity_renders_once.snap
@@ -0,0 +1,5 @@
+---
+source: tui/src/chatwidget/tests.rs
+expression: rendered
+---
+• Interacted with `/root/researcher`
diff --git a/codex-rs/tui/src/chatwidget/tests/app_server.rs b/codex-rs/tui/src/chatwidget/tests/app_server.rs
index 13ddcbbff6..8d599b6173 100644
--- a/codex-rs/tui/src/chatwidget/tests/app_server.rs
+++ b/codex-rs/tui/src/chatwidget/tests/app_server.rs
@@ -928,6 +928,41 @@ async fn live_app_server_command_output_delta_transcript_snapshot() {
);
}
+#[tokio::test]
+async fn live_app_server_sub_agent_activity_renders_once() {
+ let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
+ let activity = AppServerThreadItem::SubAgentActivity {
+ id: "activity-1".to_string(),
+ kind: codex_app_server_protocol::SubAgentActivityKind::Interacted,
+ agent_thread_id: ThreadId::new().to_string(),
+ agent_path: "/root/researcher".to_string(),
+ };
+
+ chat.handle_server_notification(
+ ServerNotification::ItemStarted(ItemStartedNotification {
+ thread_id: "thread-1".to_string(),
+ turn_id: "turn-1".to_string(),
+ started_at_ms: 0,
+ item: activity.clone(),
+ }),
+ /*replay_kind*/ None,
+ );
+ chat.handle_server_notification(
+ ServerNotification::ItemCompleted(ItemCompletedNotification {
+ thread_id: "thread-1".to_string(),
+ turn_id: "turn-1".to_string(),
+ completed_at_ms: 0,
+ item: activity,
+ }),
+ /*replay_kind*/ None,
+ );
+
+ let cells = drain_insert_history(&mut rx);
+ assert_eq!(cells.len(), 1);
+ let rendered = lines_to_single_string(&cells[0]);
+ assert_chatwidget_snapshot!("app_server_sub_agent_activity_renders_once", rendered);
+}
+
#[tokio::test]
async fn live_app_server_collab_wait_items_render_history() {
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;