mirror of
https://github.com/openai/codex.git
synced 2026-11-16 22:00:36 +00:00
Track MCP-only startup tasks
This commit is contained in:
@@ -596,6 +596,8 @@ pub(crate) struct ChatWidget {
|
||||
/// as "running" while this is populated, even if no agent turn is currently
|
||||
/// executing.
|
||||
mcp_startup_status: Option<HashMap<String, McpStartupStatus>>,
|
||||
/// Whether the active MCP startup round began while no other task was running.
|
||||
mcp_startup_started_while_idle: bool,
|
||||
/// Expected MCP servers for the current startup round, seeded from enabled local config.
|
||||
mcp_startup_expected_servers: Option<HashSet<String>>,
|
||||
/// After startup settles, ignore stale updates until enough notifications confirm a new round.
|
||||
|
||||
@@ -158,6 +158,7 @@ impl ChatWidget {
|
||||
task_complete_pending: false,
|
||||
unified_exec_processes: Vec::new(),
|
||||
mcp_startup_status: None,
|
||||
mcp_startup_started_while_idle: false,
|
||||
mcp_startup_expected_servers: None,
|
||||
mcp_startup_ignore_updates_until_next_start: false,
|
||||
mcp_startup_allow_terminal_only_next_round: false,
|
||||
|
||||
@@ -42,6 +42,7 @@ impl ChatWidget {
|
||||
return;
|
||||
}
|
||||
|
||||
let mcp_startup_was_inactive = self.mcp_startup_status.is_none();
|
||||
let mut activated_pending_round = false;
|
||||
let startup_status = if self.mcp_startup_ignore_updates_until_next_start {
|
||||
// Ignore-mode buffers the next plausible round so stale post-finish
|
||||
@@ -106,6 +107,9 @@ impl ChatWidget {
|
||||
}
|
||||
}
|
||||
}
|
||||
if mcp_startup_was_inactive {
|
||||
self.mcp_startup_started_while_idle = !self.bottom_pane.is_task_running();
|
||||
}
|
||||
self.mcp_startup_status = Some(startup_status);
|
||||
self.update_task_running_state();
|
||||
|
||||
@@ -202,6 +206,7 @@ impl ChatWidget {
|
||||
|
||||
let mcp_startup_owned_status = self.status_header_is_mcp_startup_owned();
|
||||
self.mcp_startup_status = None;
|
||||
self.mcp_startup_started_while_idle = false;
|
||||
self.mcp_startup_ignore_updates_until_next_start = true;
|
||||
self.mcp_startup_allow_terminal_only_next_round = false;
|
||||
self.mcp_startup_pending_next_round.clear();
|
||||
@@ -220,6 +225,7 @@ impl ChatWidget {
|
||||
self.mcp_startup_allow_terminal_only_next_round = false;
|
||||
self.mcp_startup_pending_next_round.clear();
|
||||
self.mcp_startup_pending_next_round_saw_starting = false;
|
||||
self.mcp_startup_started_while_idle = false;
|
||||
if self.mcp_startup_status.is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,8 @@ impl ChatWidget {
|
||||
|
||||
fn slash_command_blocked_by_active_task(&self, cmd: SlashCommand) -> bool {
|
||||
if cmd == SlashCommand::Review {
|
||||
let mcp_startup_is_only_task = self.mcp_startup_status.is_some()
|
||||
let mcp_startup_is_only_task = self.mcp_startup_started_while_idle
|
||||
&& self.mcp_startup_status.is_some()
|
||||
&& !self.turn_lifecycle.agent_turn_running
|
||||
&& !self.input_queue.user_turn_pending_start
|
||||
&& !self.has_queued_follow_up_messages()
|
||||
|
||||
@@ -300,6 +300,28 @@ async fn queued_prompt_blocks_review_during_mcp_startup() {
|
||||
assert_eq!(chat.bottom_pane.composer_text(), "/review");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn compact_task_blocks_review_when_mcp_startup_arrives() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.dispatch_command(SlashCommand::Compact);
|
||||
assert!(chat.bottom_pane.is_task_running());
|
||||
assert_matches!(rx.try_recv(), Ok(AppEvent::CodexOp(Op::Compact)));
|
||||
notify_mcp_status(&mut chat, "alpha", McpServerStartupState::Starting);
|
||||
|
||||
chat.bottom_pane
|
||||
.set_composer_text("/review".to_string(), Vec::new(), Vec::new());
|
||||
chat.handle_key_event(KeyEvent::new(KeyCode::Esc, KeyModifiers::NONE));
|
||||
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
|
||||
chat.handle_key_event(KeyEvent::new(KeyCode::Enter, KeyModifiers::NONE));
|
||||
|
||||
let error = drain_insert_history(&mut rx)
|
||||
.into_iter()
|
||||
.map(|lines| lines_to_single_string(&lines))
|
||||
.collect::<String>();
|
||||
assert!(error.contains("'/review' is disabled while a task is in progress."));
|
||||
assert_eq!(chat.bottom_pane.composer_text(), "/review");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn mcp_startup_dedupes_same_round_duplicate_failure_warning() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
|
||||
Reference in New Issue
Block a user