mirror of
https://github.com/openai/codex.git
synced 2026-05-02 18:37:01 +00:00
## Problem The introduction of `notify_sandbox_state_change()` in #7112 caused a regression where the blocking call in `Session::new()` waits for all MCP servers to fully initialize before returning. This prevents the TUI event loop from starting, resulting in `McpStartupUpdateEvent` messages being emitted but never consumed or displayed. As a result, the app appears to hang during startup, and users do not see the expected "Booting MCP server: {name}" status line. Issue: [#7827](https://github.com/openai/codex/issues/7827) ## Solution This change moves sandbox state notification into each MCP server's background initialization task. The notification is sent immediately after the server transitions to the Ready state. This approach: - Avoids blocking `Session::new()`, allowing the TUI event loop to start promptly. - Ensures each MCP server receives its sandbox state before handling any tool calls. - Restores the display of "Booting MCP server" status lines during startup. ## Key Changes - Added `ManagedClient::notify_sandbox_state()` method. - Passed sandbox_state to `McpConnectionManager::initialize()`. - Sends sandbox state notification in the background task after the server reaches Ready status. - Removed blocking notify_sandbox_state_change() methods. - Added a chatwidget snapshot test for the "Booting MCP server" status line. ## Regression Details Regression was bisected to #7112, which introduced the blocking behavior. --------- Co-authored-by: Michael Bolin <bolinfest@gmail.com> Co-authored-by: Michael Bolin <mbolin@openai.com>
This commit is contained in:
@@ -27,6 +27,8 @@ use codex_core::protocol::ExecCommandSource;
|
||||
use codex_core::protocol::ExecPolicyAmendment;
|
||||
use codex_core::protocol::ExitedReviewModeEvent;
|
||||
use codex_core::protocol::FileChange;
|
||||
use codex_core::protocol::McpStartupStatus;
|
||||
use codex_core::protocol::McpStartupUpdateEvent;
|
||||
use codex_core::protocol::Op;
|
||||
use codex_core::protocol::PatchApplyBeginEvent;
|
||||
use codex_core::protocol::PatchApplyEndEvent;
|
||||
@@ -2417,6 +2419,28 @@ fn status_widget_active_snapshot() {
|
||||
assert_snapshot!("status_widget_active", terminal.backend());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mcp_startup_header_booting_snapshot() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(None);
|
||||
chat.show_welcome_banner = false;
|
||||
|
||||
chat.handle_codex_event(Event {
|
||||
id: "mcp-1".into(),
|
||||
msg: EventMsg::McpStartupUpdate(McpStartupUpdateEvent {
|
||||
server: "alpha".into(),
|
||||
status: McpStartupStatus::Starting,
|
||||
}),
|
||||
});
|
||||
|
||||
let height = chat.desired_height(80);
|
||||
let mut terminal = ratatui::Terminal::new(ratatui::backend::TestBackend::new(80, height))
|
||||
.expect("create terminal");
|
||||
terminal
|
||||
.draw(|f| chat.render(f.area(), f.buffer_mut()))
|
||||
.expect("draw chat widget");
|
||||
assert_snapshot!("mcp_startup_header_booting", terminal.backend());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn background_event_updates_status_header() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(None);
|
||||
|
||||
Reference in New Issue
Block a user