From 6ae5dcb2552dac86cd19d9b6ca2df3057afedc5d Mon Sep 17 00:00:00 2001 From: Eric Traut Date: Sat, 28 Mar 2026 01:01:23 -0600 Subject: [PATCH] codex: address PR review feedback (#16041) --- .../src/app/app_server_adapter.rs | 7 +++++-- codex-rs/tui_app_server/src/chatwidget.rs | 21 +++++++++---------- .../tui_app_server/src/chatwidget/tests.rs | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/codex-rs/tui_app_server/src/app/app_server_adapter.rs b/codex-rs/tui_app_server/src/app/app_server_adapter.rs index 7f649c17e7..c4fa723bd5 100644 --- a/codex-rs/tui_app_server/src/app/app_server_adapter.rs +++ b/codex-rs/tui_app_server/src/app/app_server_adapter.rs @@ -21,6 +21,7 @@ use crate::exec_command::split_command_string; use codex_app_server_client::AppServerEvent; use codex_app_server_protocol::AuthMode; use codex_app_server_protocol::JSONRPCErrorError; +use codex_app_server_protocol::McpServerStartupState; use codex_app_server_protocol::ServerNotification; use codex_app_server_protocol::ServerRequest; #[cfg(test)] @@ -147,8 +148,10 @@ impl App { self.pending_app_server_requests .resolve_notification(¬ification.request_id); } - ServerNotification::McpServerStatusUpdated(_) => { - if self.chat_widget.needs_mcp_startup_expected_servers() { + ServerNotification::McpServerStatusUpdated(notification) => { + if notification.status == McpServerStartupState::Starting + && self.chat_widget.needs_mcp_startup_expected_servers() + { let enabled_config_mcp_servers: Vec = self .chat_widget .config_ref() diff --git a/codex-rs/tui_app_server/src/chatwidget.rs b/codex-rs/tui_app_server/src/chatwidget.rs index 53a2c5d39c..5944fe06e6 100644 --- a/codex-rs/tui_app_server/src/chatwidget.rs +++ b/codex-rs/tui_app_server/src/chatwidget.rs @@ -799,8 +799,8 @@ pub(crate) struct ChatWidget { mcp_startup_status: Option>, /// Expected MCP servers for the current startup round, seeded from enabled local config. mcp_startup_expected_servers: Option>, - /// MCP startup is a one-time app boot sequence; ignore straggling status updates after settle. - mcp_startup_complete: bool, + /// After startup settles, ignore late terminal updates until a new startup round begins. + mcp_startup_ignore_updates_until_next_start: bool, connectors_cache: ConnectorsCacheState, connectors_partial_snapshot: Option, connectors_prefetch_in_flight: bool, @@ -2792,8 +2792,11 @@ impl ChatWidget { status: McpStartupStatus, complete_when_settled: bool, ) { - if self.mcp_startup_complete { - return; + if self.mcp_startup_ignore_updates_until_next_start { + if !matches!(status, McpStartupStatus::Starting) { + return; + } + self.mcp_startup_ignore_updates_until_next_start = false; } let mut startup_status = self.mcp_startup_status.take().unwrap_or_default(); if let McpStartupStatus::Failed { error } = &status { @@ -2867,7 +2870,7 @@ impl ChatWidget { } pub(crate) fn needs_mcp_startup_expected_servers(&self) -> bool { - !self.mcp_startup_complete && self.mcp_startup_expected_servers.is_none() + self.mcp_startup_expected_servers.is_none() } pub(crate) fn set_mcp_startup_expected_servers(&mut self, server_names: I) @@ -2899,17 +2902,13 @@ impl ChatWidget { self.mcp_startup_status = None; self.mcp_startup_expected_servers = None; - self.mcp_startup_complete = true; + self.mcp_startup_ignore_updates_until_next_start = true; self.update_task_running_state(); self.maybe_send_next_queued_input(); self.request_redraw(); } pub(crate) fn finish_mcp_startup_after_lag(&mut self) { - if self.mcp_startup_complete { - return; - } - let Some(current) = &self.mcp_startup_status else { return; }; @@ -4673,7 +4672,7 @@ impl ChatWidget { mcp_startup_status: None, pending_turn_copyable_output: None, mcp_startup_expected_servers: None, - mcp_startup_complete: false, + mcp_startup_ignore_updates_until_next_start: false, connectors_cache: ConnectorsCacheState::default(), connectors_partial_snapshot: None, connectors_prefetch_in_flight: false, diff --git a/codex-rs/tui_app_server/src/chatwidget/tests.rs b/codex-rs/tui_app_server/src/chatwidget/tests.rs index 2ce9f92e7b..31164ca824 100644 --- a/codex-rs/tui_app_server/src/chatwidget/tests.rs +++ b/codex-rs/tui_app_server/src/chatwidget/tests.rs @@ -2074,7 +2074,7 @@ async fn make_chatwidget_manual( agent_turn_running: false, mcp_startup_status: None, mcp_startup_expected_servers: None, - mcp_startup_complete: false, + mcp_startup_ignore_updates_until_next_start: false, connectors_cache: ConnectorsCacheState::default(), connectors_partial_snapshot: None, plugin_install_apps_needing_auth: Vec::new(),