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:
Ian MacLeod authored and copyberry committed 2026-09-03 20:25:59 +00:00
1 parent ed391d4dd2
commit 32c303c197
31 files changed
+728 -69

No files matched your search

+8 -1
View File
@@ -70,7 +70,11 @@ impl App {
}
AppEvent::CloseMisalignmentReview => self.chat_widget.show_misalignment_policy_precaution(),
AppEvent::SkillsListLoaded { ref cwd, .. }
| AppEvent::PluginMentionsLoaded { ref cwd, .. }
if cwds_differ(cwd, self.config.cwd.as_path()) =>
{
self.skill_load_warnings.startup_complete = true;
}
AppEvent::PluginMentionsLoaded { ref cwd, .. }
if cwds_differ(cwd, self.config.cwd.as_path()) => {}
AppEvent::NewSession { name } => {
self.start_fresh_session_with_summary_hint(
@@ -1147,6 +1151,7 @@ impl App {
result.map_err(|err| color_eyre::eyre::eyre!(err)),
"failed to load skills on startup",
);
self.skill_load_warnings.startup_complete = true;
}
AppEvent::StartFileSearch(query) => {
self.file_search.on_user_query(query.clone());
@@ -2973,9 +2978,11 @@ impl App {
} => {
self.apply_keymap_capture(context, action, key, intent)
.await;
self.merge_startup_warnings(tui, &history_cell::StartupWarningsCell::default());
}
AppEvent::KeymapCleared { context, action } => {
self.apply_keymap_clear(context, action).await;
self.merge_startup_warnings(tui, &history_cell::StartupWarningsCell::default());
}
AppEvent::GenerateRecap { thread_id } => {
if self.current_displayed_thread_id() == Some(thread_id) {
+11
View File
@@ -22,6 +22,14 @@ pub(super) struct ThreadUsageStatusHistory {
impl App {
pub(super) fn insert_history_cell(&mut self, tui: &mut tui::Tui, cell: Box<dyn HistoryCell>) {
if let Some(warnings) = cell
.as_any()
.downcast_ref::<history_cell::StartupWarningsCell>()
{
self.merge_startup_warnings(tui, warnings);
return;
}
let is_session_header = cell.as_any().is::<history_cell::SessionInfoCell>();
let cell: Arc<dyn HistoryCell> = cell.into();
if let Some(Overlay::Transcript(t)) = &mut self.overlay {
t.insert_cell(cell.clone());
@@ -62,6 +70,9 @@ impl App {
// A committed cell can unblock a settled /usage card that was waiting
// behind a transient active cell or a provisional stream tail.
self.chat_widget.request_pending_usage_output_insertion();
if is_session_header {
self.merge_startup_warnings(tui, &history_cell::StartupWarningsCell::default());
}
}
pub(super) fn finish_thread_usage_refresh(
+11 -1
View File
@@ -801,8 +801,18 @@ impl App {
}
Err(err) if self.recover_transport_error(&err) => {}
Err(err) => {
let warnings = self
.transcript_cells
.iter()
.find_map(|cell| {
cell.as_any()
.downcast_ref::<history_cell::StartupWarningsCell>()
})
.filter(|cell| cell.pending_header)
.map(|cell| format!("\n\nStartup warnings:\n{}", cell.messages.join("\n")))
.unwrap_or_default();
return Err(color_eyre::eyre::eyre!(
"Failed to start a fresh session through the app server: {err}"
"Failed to start a fresh session through the app server: {err}{warnings}"
));
}
}
+5 -1
View File
@@ -127,7 +127,11 @@ impl App {
let startup_started_at = Instant::now();
let (app_event_tx, mut app_event_rx) = unbounded_channel();
let app_event_tx = AppEventSender::new(app_event_tx);
emit_project_config_warnings(&app_event_tx, &config);
if let Some(message) = project_config_warning(&config) {
app_event_tx.send(AppEvent::InsertHistoryCell(Box::new(
history_cell::StartupWarningsCell::new(vec![message]),
)));
}
emit_system_bwrap_warning(&app_event_tx, &config);
tui.set_notification_settings(
local_settings.tui.notification_settings.method,
+22 -22
View File
@@ -17,6 +17,8 @@ struct SkillLoadWarningKey {
#[derive(Debug, Default)]
pub(super) struct SkillLoadWarningState {
active: HashSet<SkillLoadWarningKey>,
// Both session attachment and the background startup fetch can finish the initial load.
pub(super) startup_complete: bool,
}
impl SkillLoadWarningState {
@@ -45,28 +47,24 @@ impl SkillLoadWarningState {
}
}
pub(super) fn emit_skill_load_warnings(app_event_tx: &AppEventSender, errors: &[SkillErrorInfo]) {
pub(super) fn skill_load_warning_messages(errors: &[SkillErrorInfo]) -> Vec<String> {
if errors.is_empty() {
return;
return Vec::new();
}
let error_count = errors.len();
app_event_tx.send(AppEvent::InsertHistoryCell(Box::new(
crate::history_cell::new_warning_event(format!(
"Skipped loading {error_count} skill(s) due to invalid SKILL.md files."
)),
)));
for error in errors {
let path = error.path.display();
let message = error.message.as_str();
app_event_tx.send(AppEvent::InsertHistoryCell(Box::new(
crate::history_cell::new_warning_event(format!("{path}: {message}")),
)));
}
let mut messages = vec![format!(
"Skipped loading {error_count} skill(s) due to invalid SKILL.md files."
)];
messages.extend(
errors
.iter()
.map(|error| format!("{}: {}", error.path.display(), error.message)),
);
messages
}
pub(super) fn emit_project_config_warnings(app_event_tx: &AppEventSender, config: &Config) {
pub(super) fn project_config_warning(config: &Config) -> Option<String> {
let mut disabled_folders = Vec::new();
for layer in config.config_layer_stack.all_layers_low_to_high() {
@@ -83,7 +81,7 @@ pub(super) fn emit_project_config_warnings(app_event_tx: &AppEventSender, config
}
if disabled_folders.is_empty() {
return;
return None;
}
let mut message = concat!(
@@ -97,9 +95,7 @@ pub(super) fn emit_project_config_warnings(app_event_tx: &AppEventSender, config
message.push_str(&format!(" {reason}\n"));
}
app_event_tx.send(AppEvent::InsertHistoryCell(Box::new(
history_cell::new_warning_event(message),
)));
Some(message)
}
pub(super) fn emit_system_bwrap_warning(app_event_tx: &AppEventSender, config: &Config) {
@@ -110,7 +106,7 @@ pub(super) fn emit_system_bwrap_warning(app_event_tx: &AppEventSender, config: &
};
app_event_tx.send(AppEvent::InsertHistoryCell(Box::new(
history_cell::new_warning_event(message),
history_cell::StartupWarningsCell::new(vec![message]),
)));
}
@@ -424,7 +420,11 @@ mod tests {
let (tx, mut rx) = unbounded_channel();
let app_event_tx = AppEventSender::new(tx);
emit_skill_load_warnings(&app_event_tx, errors);
for message in skill_load_warning_messages(errors) {
app_event_tx.send(AppEvent::InsertHistoryCell(Box::new(
history_cell::new_warning_event(message),
)));
}
let mut rendered = Vec::new();
while let Ok(AppEvent::InsertHistoryCell(cell)) = rx.try_recv() {
+68
View File
@@ -0,0 +1,68 @@
//! Coalesces startup diagnostics directly below the session splash.
use super::*;
use crate::history_cell::StartupWarningsCell;
impl App {
pub(super) fn merge_startup_warnings(
&mut self,
tui: &mut tui::Tui,
incoming: &StartupWarningsCell,
) {
let existing = self
.transcript_cells
.iter()
.position(|cell| cell.as_any().is::<StartupWarningsCell>());
let mut warnings = existing
.map(|index| self.transcript_cells.remove(index))
.and_then(|cell| cell.as_any().downcast_ref::<StartupWarningsCell>().cloned())
.unwrap_or_default();
for message in &incoming.messages {
if !warnings.messages.contains(message) {
warnings.messages.push(message.clone());
}
}
warnings
.other_sources
.extend(incoming.other_sources.iter().cloned());
warnings
.mcp_servers
.extend(incoming.mcp_servers.iter().cloned());
// The final MCP summary must retain the individual diagnostics' sign-in subset.
warnings
.sign_in_servers
.extend(incoming.sign_in_servers.iter().cloned());
if warnings.messages.is_empty() {
return;
}
warnings.transcript_hint = crate::keymap::primary_binding(&self.keymap.app.open_transcript)
.map(|binding| binding.display_label());
let header = self
.transcript_cells
.iter()
.rposition(|cell| cell.as_any().is::<history_cell::SessionInfoCell>());
warnings.pending_header = header.is_none() && self.chat_widget.thread_id().is_none();
let ready_to_render = !warnings.pending_header;
self.transcript_cells
.insert(header.map_or(0, |index| index + 1), Arc::new(warnings));
if let Some(Overlay::Transcript(overlay)) = &mut self.overlay {
overlay.replace_cells(self.transcript_cells.clone());
}
if self.backtrack.overlay_preview_active {
self.apply_backtrack_selection_internal(self.backtrack.nth_user_message);
}
if ready_to_render {
if let Some(buffer) = self.initial_history_replay_buffer.as_mut() {
buffer.retained_lines.clear();
buffer.render_from_transcript_tail = true;
return;
}
self.schedule_immediate_resize_reflow(tui);
if let Err(error) =
self.maybe_run_resize_reflow(tui, tui.terminal.last_known_screen_size)
{
tracing::warn!(%error, "failed to refresh startup warnings");
}
}
}
}
+18 -2
View File
@@ -40,6 +40,8 @@ mod safety_buffering;
mod session_lifecycle_requests;
mod session_summary;
mod startup;
#[path = "tests/startup_warnings_tests.rs"]
mod startup_warnings_tests;
#[path = "tests/stream_animation_tests.rs"]
mod stream_animation_tests;
#[path = "tests/thread_usage.rs"]
@@ -4847,7 +4849,9 @@ async fn primary_thread_ignores_child_mcp_startup_notifications() {
let mut rendered_cells = Vec::new();
while let Ok(event) = app_event_rx.try_recv() {
if let AppEvent::InsertHistoryCell(cell) = event {
rendered_cells.push(lines_to_single_string(&cell.display_lines(/*width*/ 120)));
rendered_cells.push(lines_to_single_string(
&cell.transcript_lines(/*width*/ 120),
));
}
}
let rendered = rendered_cells.join("\n");
@@ -4964,12 +4968,24 @@ async fn active_side_thread_renders_live_mcp_startup_notifications() {
app.handle_thread_event_now(event);
}
let mut tui = crate::tui::test_support::make_test_tui().expect("test tui");
let mut rendered_cells = Vec::new();
while let Ok(event) = app_event_rx.try_recv() {
if let AppEvent::InsertHistoryCell(cell) = event {
rendered_cells.push(lines_to_single_string(&cell.display_lines(/*width*/ 120)));
rendered_cells.push(lines_to_single_string(
&cell.transcript_lines(/*width*/ 120),
));
app.insert_history_cell(&mut tui, cell);
}
}
let inline = app
.transcript_cells
.iter()
.flat_map(|cell| cell.display_lines(/*width*/ 120))
.map(|line| line.to_string())
.collect::<Vec<_>>()
.join("\n");
assert!(inline.contains("1 MCP startup issue"));
let rendered = rendered_cells.join("\n");
assert!(app.chat_widget.side_conversation_active());
assert_eq!(rendered.matches("sentry is not logged in").count(), 1);
+2 -2
View File
@@ -86,9 +86,9 @@ async fn subagent_mcp_startup_settles_while_cached_servers_remain_deferred() {
}
insta::assert_snapshot!(visible_startup_states.join("\n"), @r"
eager: • Booting MCP server: eager
eager: idle
deferred: • Booting MCP server: deferred
eager: idle
deferred: idle
deferred: idle
");
}
@@ -0,0 +1,9 @@
---
source: tui/src/app/tests/startup_warnings_tests.rs
expression: lines_to_single_string(&warnings.transcript_lines(40))
---
⚠ MCP alpha: connection unavailable
⚠ MCP beta: connection unavailable
⚠ MCP gamma: connection unavailable
⚠ MCP startup incomplete (failed: alpha,
beta, gamma)
@@ -0,0 +1,7 @@
---
source: tui/src/app/tests/startup_warnings_tests.rs
expression: warnings.display_lines(100)
---
[
Line::from(Span::from("⚠ 3 MCP startup issues (2 need sign-in) · ctrl + t for details").yellow().dim()),
]
@@ -0,0 +1,7 @@
---
source: tui/src/app/tests/startup_warnings_tests.rs
expression: "app.transcript_cells[1].display_lines(100)"
---
[
Line::from(Span::from("⚠ 4 startup issues (3 MCP; 2 need sign-in) · ctrl + t for details").yellow().dim()),
]
+13 -4
View File
@@ -1240,6 +1240,13 @@ async fn owned_subagent_approval_before_thread_started_is_preserved() -> Result<
async fn startup_thread_start_failure_returns_error() {
let (mut app, _app_event_rx, _op_rx) = make_test_app_with_channels().await;
app.pending_startup_thread_start = true;
let mut tui = crate::tui::test_support::make_test_tui().expect("test tui");
app.insert_history_cell(
&mut tui,
Box::new(history_cell::StartupWarningsCell::new(vec![
"Skill manifest is invalid.".to_string(),
])),
);
let mut app_server = Box::pin(crate::start_embedded_app_server_for_picker(
app.chat_widget.config_ref(),
@@ -1251,10 +1258,12 @@ async fn startup_thread_start_failure_returns_error() {
.await
.expect_err("startup thread failure should exit instead of leaving chat unconfigured");
assert!(
err.to_string()
.contains("Failed to start a fresh session through the app server: boom")
);
insta::assert_snapshot!(err.to_string(), @"
Failed to start a fresh session through the app server: boom
Startup warnings:
Skill manifest is invalid.
");
assert!(!app.pending_startup_thread_start);
assert_eq!(app.primary_thread_id, None);
}
@@ -0,0 +1,211 @@
//! Startup diagnostic ordering, aggregation, and transcript coverage.
use super::*;
use crate::history_cell::StartupWarningsCell;
use codex_app_server_protocol::McpServerStartupFailureReason;
use pretty_assertions::assert_eq;
use tokio::sync::mpsc::UnboundedReceiver;
fn insert_warnings(app: &mut App, tui: &mut tui::Tui, messages: &[&str]) {
app.insert_history_cell(
tui,
Box::new(StartupWarningsCell::new(
messages.iter().map(|message| (*message).into()).collect(),
)),
);
}
fn insert_splash(app: &mut App, tui: &mut tui::Tui) {
let session = test_thread_session(ThreadId::new(), app.config.cwd.to_path_buf());
app.insert_history_cell(
tui,
Box::new(history_cell::new_session_info(
&app.config,
&app.local_settings,
"gpt-test",
&session,
/*is_first_event*/ false,
/*tooltip_override*/ None,
/*auth_plan*/ None,
/*show_fast_status*/ false,
)),
);
}
fn drain_history(app: &mut App, tui: &mut tui::Tui, events: &mut UnboundedReceiver<AppEvent>) {
while let Ok(event) = events.try_recv() {
if let AppEvent::InsertHistoryCell(cell) = event {
app.insert_history_cell(tui, cell);
}
}
}
#[tokio::test]
async fn startup_warnings_preserve_stream_repair_and_backtrack_selection() -> Result<()> {
let mut app = crate::app::test_support::make_test_app().await;
let mut tui = crate::tui::test_support::make_test_tui()?;
app.chat_widget.handle_thread_session(test_thread_session(
ThreadId::new(),
app.config.cwd.to_path_buf(),
));
app.transcript_cells = vec![Arc::new(UserHistoryCell {
message: "Selected prompt".into(),
text_elements: Vec::new(),
local_image_paths: Vec::new(),
remote_image_urls: Vec::new(),
})];
app.transcript_reflow.mark_resize_requested_during_stream();
insert_warnings(&mut app, &mut tui, &["First warning"]);
assert!(app.transcript_reflow.take_stream_finish_reflow_needed());
// Recreate the insertion case with a backtracking overlay already open.
app.transcript_cells.remove(0);
app.backtrack.overlay_preview_active = true;
app.open_transcript_overlay(&mut tui);
app.apply_backtrack_selection_internal(/*nth_user_message*/ 0);
insert_warnings(&mut app, &mut tui, &["Second warning"]);
let area = Rect::new(
/*x*/ 0, /*y*/ 0, /*width*/ 80, /*height*/ 12,
);
let mut buffer = Buffer::empty(area);
let Some(Overlay::Transcript(overlay)) = app.overlay.as_mut() else {
panic!("expected transcript")
};
overlay.render(area, &mut buffer);
let highlighted = area
.positions()
.filter(|position| {
buffer[*position]
.style()
.add_modifier
.contains(ratatui::style::Modifier::REVERSED)
})
.map(|position| buffer[position].symbol())
.collect::<String>();
assert!(highlighted.contains("Selected prompt"), "{highlighted}");
Ok(())
}
#[tokio::test]
async fn mcp_startup_summary_counts_servers_and_sign_in_subset() -> Result<()> {
let (mut app, mut events, _op_rx) = make_test_app_with_channels().await;
let mut tui = crate::tui::test_support::make_test_tui()?;
app.chat_widget
.set_mcp_startup_expected_servers(["alpha", "beta", "gamma"].map(str::to_owned));
insert_splash(&mut app, &mut tui);
let sign_in = Some(McpServerStartupFailureReason::ReauthenticationRequired);
for (name, failure_reason) in [("alpha", sign_in), ("beta", sign_in), ("gamma", None)] {
app.chat_widget.handle_server_notification(
ServerNotification::McpServerStatusUpdated(McpServerStatusUpdatedNotification {
thread_id: None,
name: name.into(),
status: McpServerStartupState::Failed,
error: Some(format!("MCP {name}: connection unavailable")),
failure_reason,
}),
/*replay_kind*/ None,
);
}
drain_history(&mut app, &mut tui, &mut events);
assert_eq!(app.transcript_cells.len(), 2);
let warnings = &app.transcript_cells[1];
insta::assert_debug_snapshot!("mcp_startup_summary", warnings.display_lines(/*width*/ 100));
insta::assert_snapshot!(
"mcp_startup_details",
lines_to_single_string(&warnings.transcript_lines(/*width*/ 40))
);
insert_warnings(&mut app, &mut tui, &["Skill manifest is invalid."]);
insta::assert_debug_snapshot!(
"mixed_startup_summary",
app.transcript_cells[1].display_lines(/*width*/ 100)
);
Ok(())
}
#[tokio::test]
async fn startup_warnings_wait_for_splash_and_coalesce_with_full_details() -> Result<()> {
let mut app = crate::app::test_support::make_test_app().await;
let mut tui = crate::tui::test_support::make_test_tui()?;
let first = "Skill manifest is invalid.";
insert_warnings(&mut app, &mut tui, &[first]);
let pending = &app.transcript_cells[0];
assert!(pending.display_lines(/*width*/ 80).is_empty());
insert_splash(&mut app, &mut tui);
insert_warnings(&mut app, &mut tui, &[first, "MCP alpha failed to start."]);
assert_eq!(app.transcript_cells.len(), 2);
let header = app.transcript_cells[0].as_any();
assert!(header.is::<history_cell::SessionInfoCell>());
let display = app.transcript_cells[1].display_lines(/*width*/ 80);
let transcript = app.transcript_cells[1].transcript_lines(/*width*/ 80);
insta::assert_snapshot!(format!("display:\n{}\n\ntranscript:\n{}", lines_to_single_string(&display), lines_to_single_string(&transcript)), @"
display:
⚠ 2 startup issues · ctrl + t for details
transcript:
⚠ Skill manifest is invalid.
⚠ MCP alpha failed to start.
");
app.keymap.app.open_transcript = vec![crate::key_hint::plain(crossterm::event::KeyCode::F(12))];
app.merge_startup_warnings(&mut tui, &StartupWarningsCell::default());
insta::assert_snapshot!(lines_to_single_string(&app.transcript_cells[1].display_lines(/*width*/ 80)), @"⚠ 2 startup issues · f12 for details");
app.keymap.app.open_transcript.clear();
app.merge_startup_warnings(&mut tui, &StartupWarningsCell::default());
insta::assert_snapshot!(lines_to_single_string(&app.transcript_cells[1].display_lines(/*width*/ 80)), @"⚠ 2 startup issues");
Ok(())
}
#[tokio::test]
async fn startup_skill_load_order_preserves_runtime_error_recurrence() -> Result<()> {
for background_first in [false, true] {
let (mut app, mut events, _op_rx) = make_test_app_with_channels().await;
let mut tui = crate::tui::test_support::make_test_tui()?;
let mut server = start_config_write_test_app_server(&app).await?;
let cwd = app.config.cwd.to_path_buf();
let response = SkillsListResponse {
data: vec![codex_app_server_protocol::SkillsListEntry {
cwd: cwd.clone(),
skills: vec![],
errors: vec![SkillErrorInfo {
path: PathBuf::from("bad/SKILL.md"),
message: "invalid description".into(),
}],
}],
};
// Session attachment and the background startup request may finish in either order.
for background in [background_first, !background_first] {
if background {
app.handle_event(
&mut tui,
&mut server,
AppEvent::SkillsListLoaded {
cwd: cwd.clone(),
result: Ok(response.clone()),
},
)
.await?;
} else {
app.handle_skills_list_result(Ok(response.clone()), "initial session refresh");
}
}
drain_history(&mut app, &mut tui, &mut events);
assert_eq!(app.transcript_cells.len(), 1);
assert!(app.transcript_cells[0].as_any().is::<StartupWarningsCell>());
app.handle_skills_list_result(Ok(SkillsListResponse { data: vec![] }), "clean refresh");
app.handle_skills_list_result(Ok(response), "runtime refresh");
drain_history(&mut app, &mut tui, &mut events);
assert_eq!(app.transcript_cells.len(), 3);
let runtime = app.transcript_cells[1..]
.iter()
.flat_map(|cell| cell.display_lines(/*width*/ 120))
.collect::<Vec<_>>();
insta::allow_duplicates! {
insta::assert_snapshot!(lines_to_single_string(&runtime), @"
⚠ Skipped loading 1 skill(s) due to invalid SKILL.md files.
⚠ bad/SKILL.md: invalid description
");
}
server.shutdown().await?;
}
Ok(())
}
+13 -1
View File
@@ -1686,7 +1686,19 @@ impl App {
let cwd = self.chat_widget.config_ref().cwd.clone();
let errors = errors_for_cwd(&cwd, &response);
let errors = self.skill_load_warnings.newly_active_errors(&errors);
emit_skill_load_warnings(&self.app_event_tx, &errors);
let warnings = skill_load_warning_messages(&errors);
if self.skill_load_warnings.startup_complete {
for warning in warnings {
self.chat_widget.add_warning_message(warning);
}
} else {
self.app_event_tx.send(AppEvent::InsertHistoryCell(Box::new(
// The per-file diagnostics already identify every affected skill.
history_cell::StartupWarningsCell::new(
warnings.into_iter().skip(/*n*/ 1).collect(),
),
)));
}
self.chat_widget.handle_skills_list_response(response);
}
+4 -1
View File
@@ -209,9 +209,12 @@ impl App {
}
self.cancel_pending_key_chord();
self.keymap = keymap;
self.merge_startup_warnings(tui, &history_cell::StartupWarningsCell::default());
self.restore_runtime_theme_from_config();
self.runtime_working_directory_override = Some(cwd.to_path_buf());
emit_project_config_warnings(&self.app_event_tx, &self.config);
if let Some(message) = project_config_warning(&self.config) {
self.chat_widget.add_warning_message(message);
}
let message = format!("Working directory changed to: {}", cwd.display());
self.chat_widget.add_info_message(message, /*hint*/ None);
if !self.config.bypass_hook_trust {