mirror of
https://github.com/openai/codex.git
synced 2026-11-18 23:02:23 +00:00
Condense TUI startup warnings (#42609)
## What changed - Coalesce configuration, skill, sandbox, and MCP startup diagnostics into a single summary below the session header, including MCP and sign-in counts. - Keep the complete warning text in the transcript and update the summary's transcript shortcut when key bindings change. - Continue rendering warnings that arrive after work begins as inline history entries. - Hide the MCP startup status row before a turn while preserving the configured interrupt shortcut. ## Testing - Add coverage for warning ordering and deduplication, transcript details, MCP sign-in counts, resumed sessions, runtime warnings, reflow, backtracking, and interruption without a visible status row. GitOrigin-RevId: 009657cf04f1d3a52270cf096eebf9db7513c040
This commit is contained in:
1 parent
ed391d4dd2
commit
32c303c197
31 files changed
+728
-69
No files matched your search
@@ -935,6 +935,29 @@ async fn live_app_server_strict_review_required_notification_renders_message() {
|
||||
assert!(chat.bottom_pane.is_task_running());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn config_warning_during_turn_remains_inline() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
handle_turn_started(&mut chat, "turn-1");
|
||||
chat.handle_server_notification(
|
||||
ServerNotification::ConfigWarning(ConfigWarningNotification {
|
||||
summary: "Invalid configuration; using defaults.".into(),
|
||||
details: Some("Check the project configuration.".into()),
|
||||
path: None,
|
||||
range: None,
|
||||
}),
|
||||
/*replay_kind*/ None,
|
||||
);
|
||||
let cells = drain_insert_history(&mut rx);
|
||||
insta::assert_snapshot!(
|
||||
"runtime_config_warning",
|
||||
cells
|
||||
.iter()
|
||||
.map(|lines| lines_to_single_string(lines))
|
||||
.collect::<String>()
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn live_app_server_config_warning_prefixes_summary() {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
@@ -949,7 +972,7 @@ async fn live_app_server_config_warning_prefixes_summary() {
|
||||
/*replay_kind*/ None,
|
||||
);
|
||||
|
||||
let cells = drain_insert_history(&mut rx);
|
||||
let cells = drain_insert_history_transcript(&mut rx);
|
||||
assert_eq!(cells.len(), 1, "expected one warning history cell");
|
||||
let rendered = lines_to_single_string(&cells[0]);
|
||||
assert!(
|
||||
|
||||
@@ -330,11 +330,24 @@ pub(crate) async fn make_chatwidget_manual_with_sender() -> (
|
||||
|
||||
pub(super) fn drain_insert_history(
|
||||
rx: &mut tokio::sync::mpsc::UnboundedReceiver<AppEvent>,
|
||||
) -> Vec<Vec<ratatui::text::Line<'static>>> {
|
||||
drain_insert_history_with(rx, |cell| cell.display_lines(/*width*/ 80))
|
||||
}
|
||||
|
||||
pub(super) fn drain_insert_history_transcript(
|
||||
rx: &mut tokio::sync::mpsc::UnboundedReceiver<AppEvent>,
|
||||
) -> Vec<Vec<ratatui::text::Line<'static>>> {
|
||||
drain_insert_history_with(rx, |cell| cell.transcript_lines(/*width*/ 80))
|
||||
}
|
||||
|
||||
fn drain_insert_history_with(
|
||||
rx: &mut tokio::sync::mpsc::UnboundedReceiver<AppEvent>,
|
||||
render: impl Fn(&dyn HistoryCell) -> Vec<ratatui::text::Line<'static>>,
|
||||
) -> Vec<Vec<ratatui::text::Line<'static>>> {
|
||||
let mut out = Vec::new();
|
||||
while let Ok(ev) = rx.try_recv() {
|
||||
if let AppEvent::InsertHistoryCell(cell) = ev {
|
||||
let mut lines = cell.display_lines(/*width*/ 80);
|
||||
let mut lines = render(cell.as_ref());
|
||||
if !cell.is_stream_continuation() && !out.is_empty() && !lines.is_empty() {
|
||||
lines.insert(0, "".into());
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use super::helpers::drain_insert_history_transcript as drain_insert_history;
|
||||
use super::*;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
@@ -134,6 +135,8 @@ async fn mcp_startup_header_booting_snapshot() {
|
||||
|
||||
notify_mcp_status(&mut chat, "alpha", McpServerStartupState::Starting);
|
||||
|
||||
assert!(chat.bottom_pane.is_task_running());
|
||||
assert!(!chat.bottom_pane.status_indicator_visible());
|
||||
let height = chat.desired_height(/*width*/ 80);
|
||||
let mut terminal = ratatui::Terminal::new(ratatui::backend::TestBackend::new(80, height))
|
||||
.expect("create terminal");
|
||||
@@ -146,6 +149,55 @@ async fn mcp_startup_header_booting_snapshot() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn mcp_startup_updates_preserve_streaming_status_suppression() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.set_mcp_startup_expected_servers(["alpha".into(), "beta".into()]);
|
||||
handle_turn_started(&mut chat, "turn-1");
|
||||
chat.on_agent_message_delta("Partial response\n".into());
|
||||
chat.on_commit_tick();
|
||||
assert!(!chat.bottom_pane.status_indicator_visible());
|
||||
|
||||
notify_mcp_status(&mut chat, "alpha", McpServerStartupState::Ready);
|
||||
assert!(chat.bottom_pane.is_task_running());
|
||||
assert!(!chat.bottom_pane.status_indicator_visible());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn mcp_startup_summary_distinguishes_initial_resume_from_task_switch() {
|
||||
use AppServerTurnStatus::Completed;
|
||||
use AppServerTurnStatus::InProgress;
|
||||
use ReplayKind::ResumeInitialMessages;
|
||||
use ReplayKind::ThreadSnapshot;
|
||||
|
||||
for (replay_kind, status, compact) in [
|
||||
(ResumeInitialMessages, Completed, true),
|
||||
(ResumeInitialMessages, InProgress, false),
|
||||
(ThreadSnapshot, Completed, false),
|
||||
] {
|
||||
let (mut chat, mut rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
chat.replay_thread_turns(
|
||||
vec![app_server_turn(
|
||||
"previous-turn",
|
||||
status,
|
||||
/*duration_ms*/ None,
|
||||
/*error*/ None,
|
||||
)],
|
||||
replay_kind,
|
||||
);
|
||||
while rx.try_recv().is_ok() {}
|
||||
chat.set_mcp_startup_expected_servers(["alpha".into()]);
|
||||
notify_mcp_status_error(&mut chat, "alpha", "connection failed");
|
||||
let mut compact_cells = Vec::new();
|
||||
while let Ok(event) = rx.try_recv() {
|
||||
if let AppEvent::InsertHistoryCell(cell) = event {
|
||||
compact_cells.push(cell.as_any().is::<history_cell::StartupWarningsCell>());
|
||||
}
|
||||
}
|
||||
assert_eq!(compact_cells, vec![compact; 2]);
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn mcp_startup_complete_does_not_clear_running_task() {
|
||||
let (mut chat, _rx, _op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
|
||||
@@ -257,6 +309,7 @@ async fn pending_mcp_startup_does_not_unblock_external_review() {
|
||||
chat.thread_id = Some(ThreadId::new());
|
||||
|
||||
handle_entered_review_mode(&mut chat, "current changes");
|
||||
assert!(chat.bottom_pane.status_indicator_visible());
|
||||
chat.queue_user_message("queued follow-up".into());
|
||||
|
||||
assert!(chat.review.is_review_mode);
|
||||
@@ -270,6 +323,7 @@ async fn pending_mcp_startup_does_not_unblock_external_review() {
|
||||
|
||||
chat.finish_mcp_startup(Vec::new(), Vec::new());
|
||||
assert!(chat.bottom_pane.is_task_running());
|
||||
assert!(chat.bottom_pane.status_indicator_visible());
|
||||
assert_eq!(chat.input_queue.queued_user_messages.len(), 1);
|
||||
assert_no_submit_op(&mut op_rx);
|
||||
}
|
||||
@@ -450,7 +504,14 @@ async fn mcp_startup_failure_restores_running_status_header() {
|
||||
"MCP client for `alpha` failed to start: handshake failed",
|
||||
);
|
||||
notify_mcp_status(&mut chat, "beta", McpServerStartupState::Ready);
|
||||
let _ = drain_insert_history(&mut rx);
|
||||
let warnings = super::helpers::drain_insert_history(&mut rx);
|
||||
insta::assert_snapshot!(
|
||||
"runtime_mcp_warning",
|
||||
warnings
|
||||
.iter()
|
||||
.map(|lines| lines_to_single_string(lines))
|
||||
.collect::<String>()
|
||||
);
|
||||
|
||||
assert!(chat.bottom_pane.is_task_running());
|
||||
assert!(chat.bottom_pane.status_indicator_visible());
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
---
|
||||
source: tui/src/chatwidget/tests/app_server.rs
|
||||
expression: "cells.iter().map(|lines| lines_to_single_string(lines)).collect::<String>()"
|
||||
---
|
||||
⚠ Invalid configuration; using defaults.: Check the project configuration.
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
---
|
||||
source: tui/src/chatwidget/tests/mcp_startup.rs
|
||||
expression: "warnings.iter().map(|lines| lines_to_single_string(lines)).collect::<String>()"
|
||||
---
|
||||
⚠ MCP client for `alpha` failed to start: handshake failed
|
||||
|
||||
⚠ MCP startup incomplete (failed: alpha)
|
||||
Reference in new issue
Block a user