diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index 4bacaad6af..eaf26ac608 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -123,20 +123,15 @@ use codex_protocol::config_types::Settings; use codex_protocol::config_types::WindowsSandboxLevel; use codex_protocol::items::AgentMessageContent; use codex_protocol::items::AgentMessageItem; -#[cfg(test)] use codex_protocol::models::ContentItem; use codex_protocol::models::MessagePhase; -#[cfg(test)] use codex_protocol::models::ResponseItem; use codex_protocol::models::local_image_label_text; use codex_protocol::parse_command::ParsedCommand; use codex_protocol::plan_tool::PlanItemArg as UpdatePlanItemArg; use codex_protocol::plan_tool::StepStatus as UpdatePlanItemStatus; -#[cfg(test)] use codex_protocol::protocol::AGENT_INBOX_KIND; -#[cfg(test)] use codex_protocol::protocol::AGENT_INBOX_MESSAGE_PREFIX; -#[cfg(test)] use codex_protocol::protocol::AgentInboxPayload; #[cfg(test)] use codex_protocol::protocol::AgentMessageDeltaEvent; @@ -455,7 +450,6 @@ fn is_unified_exec_source(source: ExecCommandSource) -> bool { ) } -#[cfg(test)] fn agent_inbox_message_from_item(item: &ResponseItem) -> Option<(Option, String)> { match item { ResponseItem::FunctionCallOutput { output, .. } => { @@ -6502,7 +6496,6 @@ impl ChatWidget { | ServerNotification::ThreadStatusChanged(_) | ServerNotification::ThreadArchived(_) | ServerNotification::ThreadUnarchived(_) - | ServerNotification::RawResponseItemCompleted(_) | ServerNotification::CommandExecOutputDelta(_) | ServerNotification::McpToolCallProgress(_) | ServerNotification::McpServerStatusUpdated(_) @@ -6516,6 +6509,15 @@ impl ChatWidget { | ServerNotification::WindowsWorldWritableWarning(_) | ServerNotification::WindowsSandboxSetupCompleted(_) | ServerNotification::AccountLoginCompleted(_) => {} + ServerNotification::RawResponseItemCompleted(notification) => { + if let Some((sender, message)) = agent_inbox_message_from_item(¬ification.item) { + let hint = sender.map(|sender| format!("from {sender}")); + self.add_to_history(history_cell::new_info_event( + format!("Agent message: {message}"), + hint, + )); + } + } } } diff --git a/codex-rs/tui/src/chatwidget/tests.rs b/codex-rs/tui/src/chatwidget/tests.rs index 83786aec52..cb1dbb5632 100644 --- a/codex-rs/tui/src/chatwidget/tests.rs +++ b/codex-rs/tui/src/chatwidget/tests.rs @@ -64,6 +64,7 @@ use codex_app_server_protocol::PluginMarketplaceEntry; use codex_app_server_protocol::PluginReadResponse; use codex_app_server_protocol::PluginSource; use codex_app_server_protocol::PluginSummary; +use codex_app_server_protocol::RawResponseItemCompletedNotification; use codex_app_server_protocol::ReasoningSummaryTextDeltaNotification; use codex_app_server_protocol::ServerNotification; use codex_app_server_protocol::SkillSummary; @@ -466,6 +467,40 @@ async fn thread_snapshot_replay_deduplicates_agent_inbox_compatibility_items() { ); } +#[tokio::test] +async fn live_raw_response_item_completed_renders_agent_inbox_message() { + let (mut chat, mut rx, _ops) = make_chatwidget_manual(/*model_override*/ None).await; + + let sender = + ThreadId::from_string("019cbff7-558b-77d3-8653-8238ab5361ec").expect("valid thread id"); + let message = "Please review the latest diff"; + + chat.handle_server_notification( + ServerNotification::RawResponseItemCompleted(RawResponseItemCompletedNotification { + thread_id: ThreadId::new().to_string(), + turn_id: "turn-1".to_string(), + item: agent_inbox_function_call_output(sender, message), + }), + /*replay_kind*/ None, + ); + + let cells = drain_insert_history(&mut rx); + assert_eq!( + cells.len(), + 1, + "expected live agent inbox item to render one history row" + ); + let rendered = lines_to_single_string(&cells[0]); + assert!( + rendered.contains("Agent message: Please review the latest diff"), + "expected rendered agent inbox message, got {rendered:?}" + ); + assert!( + rendered.contains("from 019cbff7"), + "expected rendered sender hint, got {rendered:?}" + ); +} + #[tokio::test] async fn replayed_user_message_preserves_text_elements_and_local_images() { let (mut chat, mut rx, _ops) = make_chatwidget_manual(/*model_override*/ None).await;