Prefer foreground status during MCP startup

This commit is contained in:
Charlie Marsh
2026-06-29 22:06:58 -04:00
parent 1bbbad1bca
commit 7e8bcfc24d
2 changed files with 21 additions and 3 deletions
@@ -888,10 +888,11 @@ impl ChatWidget {
/// Computes the compact runtime status label used by word-based status items.
///
/// Startup takes precedence over normal task states, and idle state renders
/// as `Ready` regardless of the last active status bucket.
/// Startup takes precedence when it is the only active work. Foreground tasks keep their
/// normal status while MCP startup continues in the background, and idle state renders as
/// `Ready` regardless of the last active status bucket.
pub(super) fn run_state_status_text(&self) -> String {
if self.mcp_startup_status.is_some() {
if self.mcp_startup_status.is_some() && !self.bottom_pane.is_foreground_task_running() {
return "Starting".to_string();
}
@@ -165,6 +165,23 @@ async fn background_mcp_startup_completion_does_not_finish_review_task() {
assert!(chat.mcp_startup_status.is_some());
}
#[tokio::test]
async fn foreground_review_status_takes_precedence_over_background_mcp_startup() {
let (mut chat, _rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
chat.config.tui_status_line = Some(vec!["run-state".to_string()]);
chat.config.tui_terminal_title = Some(vec!["run-state".to_string()]);
chat.set_mcp_startup_expected_servers(["alpha".to_string(), "beta".to_string()]);
notify_mcp_status(&mut chat, "alpha", McpServerStartupState::Starting);
submit_review_with_args(&mut chat, &mut op_rx, "check regressions");
notify_mcp_status(&mut chat, "beta", McpServerStartupState::Starting);
assert_eq!(
(status_line_text(&chat), chat.last_terminal_title.clone(),),
(Some("Working".to_string()), Some("Working".to_string()),)
);
}
#[tokio::test]
async fn mcp_startup_can_complete_after_review_submission() {
let (mut chat, _rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;