Fix MCP startup cancellation through app server (#18078)

Addresses https://github.com/openai/codex/issues/17143

Problem: TUI interrupts without an active turn stopped cancelling slow
MCP startup after routing through the app-server APIs.

Solution: Route no-active-turn interrupts through app-server as startup
cancels, acknowledge them immediately, and emit cancelled MCP startup
updates.

Testing: I manually confirmed that MCP cancellation didn't work prior to
this PR and works after the fix was in place.
This commit is contained in:
Eric Traut authored and GitHub committed 2026-04-16 00:03:50 -07:00
1 parent 48cf3ed7b0
commit 4cd85b28d2
4 files changed
+61 -17

No files matched your search

+13 -5
View File
@@ -2378,10 +2378,11 @@ impl App {
) -> Result<bool> {
match op.view() {
AppCommandView::Interrupt => {
let Some(turn_id) = self.active_turn_id_for_thread(thread_id).await else {
return Ok(true);
};
app_server.turn_interrupt(thread_id, turn_id).await?;
if let Some(turn_id) = self.active_turn_id_for_thread(thread_id).await {
app_server.turn_interrupt(thread_id, turn_id).await?;
} else {
app_server.startup_interrupt(thread_id).await?;
}
Ok(true)
}
AppCommandView::UserTurn {
@@ -11410,11 +11411,18 @@ guardian_approval = true
#[tokio::test]
async fn interrupt_without_active_turn_is_treated_as_handled() {
let mut app = make_test_app().await;
let thread_id = ThreadId::new();
let mut app_server =
crate::start_embedded_app_server_for_picker(app.chat_widget.config_ref())
.await
.expect("embedded app server");
let started = app_server
.start_thread(app.chat_widget.config_ref())
.await
.expect("thread/start should succeed");
let thread_id = started.session.thread_id;
app.enqueue_primary_thread_session(started.session, started.turns)
.await
.expect("primary thread should be registered");
let op = AppCommand::interrupt();
let handled = app