Add /mcp login <name> to the TUI (#49290)

## What changed

Allow users with an active session to start MCP OAuth sign-in through `/mcp login <name>`. Request login through the app server, open the authorization URL in the browser, and display success or failure in the originating thread.

Guard overlapping start requests and track login attempts per server so stale retry completions do not overwrite current results. Skip opening the browser when the attempt has already completed, and retain results across thread switches and session refreshes.

## Testing

Add command dispatch coverage and regression tests for overlapping starts, stale retry completions, rejected starts, independent server logins, and result retention across thread switches and session refreshes.

GitOrigin-RevId: aeec2dbee566660f9aa26ef23039196ef3ca49d6
This commit is contained in:
Nick Steele
2026-09-29 16:00:05 +00:00
committed by copyberry
parent 65c3f40bef
commit 4773a132c3
23 changed files with 546 additions and 12 deletions
+10
View File
@@ -655,6 +655,9 @@ pub(crate) struct App {
/// Invalidates in-flight full rate-limit reads when a newer rolling hard stop arrives.
rate_limit_hard_stop_generation: u64,
rate_limit_refresh_state: rate_limit_refresh::RateLimitRefreshState,
pending_mcp_login_start: Option<PendingMcpLoginStart>,
// Latest accepted attempt per server; stale retry completions must not update the UI.
active_mcp_login_ids: HashMap<String, String>,
// Serialize plugin enablement writes per plugin so stale completions cannot
// overwrite a newer toggle, even if the plugin is toggled from different
// cwd contexts.
@@ -668,6 +671,13 @@ pub(crate) struct App {
_test_codex_home: Option<tempfile::TempDir>,
}
struct PendingMcpLoginStart {
request_id: String,
name: String,
thread_id: ThreadId,
completions: Vec<codex_app_server_protocol::McpServerOauthLoginCompletedNotification>,
}
#[derive(Debug, Clone, PartialEq)]
struct RuntimePermissionProfileOverride {
permission_profile: PermissionProfile,
@@ -184,6 +184,12 @@ pub(super) fn server_notification_thread_target(
}
ServerNotification::Warning(notification) => notification.thread_id.as_deref(),
ServerNotification::GuardianWarning(notification) => Some(notification.thread_id.as_str()),
ServerNotification::McpServerOauthLoginCompleted(notification) => {
match notification.thread_id.as_deref() {
Some(thread_id) => Some(thread_id),
None => return ServerNotificationThreadTarget::AppScoped,
}
}
ServerNotification::McpServerStatusUpdated(notification) => {
match notification.thread_id.as_deref() {
Some(thread_id) => Some(thread_id),
@@ -192,7 +198,6 @@ pub(super) fn server_notification_thread_target(
}
ServerNotification::ProjectChanged(_)
| ServerNotification::SkillsChanged(_)
| ServerNotification::McpServerOauthLoginCompleted(_)
| ServerNotification::AccountUpdated(_)
| ServerNotification::GatewayOAuthChanged(_)
| ServerNotification::AccountRateLimitsUpdated(_)
+19
View File
@@ -278,6 +278,25 @@ impl App {
ServerNotification::McpServerStatusUpdated(_) => {
self.refresh_mcp_startup_expected_servers_from_config();
}
ServerNotification::McpServerOauthLoginCompleted(notification) => {
// The start response identifies the new attempt. Hold completions until then
// so a replacement's cancellation cannot appear as a fresh login failure.
if let Some(pending) = self.pending_mcp_login_start.as_mut()
&& pending.name == notification.name
{
pending.completions.push(notification.clone());
return;
}
if notification.login_id.is_some() {
if notification.login_id.as_ref()
!= self.active_mcp_login_ids.get(&notification.name)
{
return;
}
self.active_mcp_login_ids.remove(&notification.name);
}
}
ServerNotification::AccountRateLimitsUpdated(notification) => {
let workspace_hard_stop = matches!(
notification.rate_limits.rate_limit_reached_type,
@@ -24,6 +24,7 @@ use codex_app_server_protocol::MarketplaceRemoveParams;
use codex_app_server_protocol::MarketplaceRemoveResponse;
use codex_app_server_protocol::MarketplaceUpgradeParams;
use codex_app_server_protocol::MarketplaceUpgradeResponse;
use codex_app_server_protocol::McpServerOauthLoginParams;
use codex_app_server_protocol::RequestId;
use crate::hooks_rpc::fetch_hooks_list;
@@ -39,6 +40,33 @@ const WORKSPACE_HEADLINE_FETCH_TIMEOUT: std::time::Duration =
std::time::Duration::from_millis(/*millis*/ 2000);
impl App {
pub(super) fn start_mcp_login(
&self,
app_server: &AppServerSession,
request_id: String,
name: String,
thread_id: ThreadId,
) {
let request_handle = app_server.request_handle();
let app_event_tx = self.app_event_tx.clone();
tokio::spawn(async move {
let result = request_handle
.request_typed(ClientRequest::McpServerOauthLogin {
request_id: RequestId::String(request_id.clone()),
params: McpServerOauthLoginParams {
name,
thread_id: Some(thread_id.to_string()),
client_registration: None,
scopes: None,
timeout_secs: None,
},
})
.await
.map_err(|error| error.to_string());
app_event_tx.send(AppEvent::McpLoginStarted { request_id, result });
});
}
pub(super) fn fetch_mcp_inventory(
&mut self,
app_server: &AppServerSession,
+75
View File
@@ -1534,6 +1534,81 @@ impl App {
AppEvent::FetchMcpInventory { detail, thread_id } => {
self.fetch_mcp_inventory(app_server, detail, thread_id);
}
AppEvent::StartMcpLogin { name, thread_id } => {
if self.pending_mcp_login_start.is_some() {
self.chat_widget.add_info_message(
"MCP sign-in is starting. Wait for it to finish before trying again.".to_string(),
/*hint*/ None,
);
return Ok(AppRunControl::Continue);
}
let request_id = format!("mcp-login-{}", uuid::Uuid::new_v4());
self.pending_mcp_login_start = Some(PendingMcpLoginStart {
request_id: request_id.clone(),
name: name.clone(),
thread_id,
completions: Vec::new(),
});
self.start_mcp_login(app_server, request_id, name, thread_id);
}
AppEvent::McpLoginStarted { request_id, result } => {
if let Some(pending) = self
.pending_mcp_login_start
.take_if(|pending| pending.request_id == request_id)
{
match result {
Ok(response) => {
// Track the latest attempt per server: unrelated OAuth logins can
// remain open while a user retries this server.
if let Some(login_id) = response.login_id.as_ref() {
self.active_mcp_login_ids
.insert(pending.name.clone(), login_id.clone());
}
let completed = pending.completions.iter().any(|completion| {
completion.login_id == response.login_id
&& completion.name == pending.name
});
if !completed {
self.open_url_in_browser(response.authorization_url);
}
}
Err(error) => {
self.enqueue_thread_notification(
pending.thread_id,
ServerNotification::McpServerOauthLoginCompleted(
codex_app_server_protocol::McpServerOauthLoginCompletedNotification {
name: pending.name,
thread_id: Some(pending.thread_id.to_string()),
login_id: None,
success: false,
error: Some(error),
},
),
).await?;
}
}
// A rejected start leaves the old attempt current. A successful replacement
// has changed its ID, so the old cancellation is discarded here.
for completion in pending.completions {
if completion.login_id.is_some() {
if completion.login_id.as_ref()
!= self.active_mcp_login_ids.get(&completion.name)
{
continue;
}
self.active_mcp_login_ids.remove(&completion.name);
}
if let Some(thread_id) = completion.thread_id.as_deref()
.and_then(|id| ThreadId::from_string(id).ok())
{
self.enqueue_thread_notification(
thread_id,
ServerNotification::McpServerOauthLoginCompleted(completion),
).await?;
}
}
}
}
AppEvent::McpInventoryLoaded {
result,
detail,
@@ -10,7 +10,7 @@ Transcript row 34: content behind the menu
› /model choose what model and reasoning effort to use
/memories configure memory use and generation
/mention mention a file
/mcp list configured MCP tools; use /mcp verbose for details
/mcp list MCP tools; use /mcp verbose or /mcp login <name>
› /m
+2
View File
@@ -881,6 +881,8 @@ See the Codex keymap documentation for supported actions and examples."
startup_pending_protected_request: false,
rate_limit_hard_stop_generation: 0,
rate_limit_refresh_state: Default::default(),
pending_mcp_login_start: None,
active_mcp_login_ids: HashMap::new(),
pending_plugin_enabled_writes: HashMap::new(),
pending_hook_enabled_writes: HashMap::new(),
recap: recap::RecapState::default(),
+2
View File
@@ -114,6 +114,8 @@ pub(crate) async fn make_test_app() -> App {
startup_pending_protected_request: false,
rate_limit_hard_stop_generation: 0,
rate_limit_refresh_state: Default::default(),
pending_mcp_login_start: None,
active_mcp_login_ids: HashMap::new(),
pending_plugin_enabled_writes: HashMap::new(),
pending_hook_enabled_writes: HashMap::new(),
recap: recap::RecapState::default(),
+7
View File
@@ -1,5 +1,8 @@
//! App-level orchestration tests for the TUI.
#[path = "tests/mcp_login_tests.rs"]
mod mcp_login_tests;
#[path = "tests/daybreak_tests.rs"]
mod daybreak_tests;
#[path = "tests/math_interruption_tests.rs"]
@@ -6090,6 +6093,8 @@ async fn make_test_app() -> Box<App> {
startup_pending_protected_request: false,
rate_limit_hard_stop_generation: 0,
rate_limit_refresh_state: Default::default(),
pending_mcp_login_start: None,
active_mcp_login_ids: HashMap::new(),
pending_plugin_enabled_writes: HashMap::new(),
pending_hook_enabled_writes: HashMap::new(),
recap: recap::RecapState::default(),
@@ -6207,6 +6212,8 @@ pub(super) async fn make_test_app_with_channels() -> (
startup_pending_protected_request: false,
rate_limit_hard_stop_generation: 0,
rate_limit_refresh_state: Default::default(),
pending_mcp_login_start: None,
active_mcp_login_ids: HashMap::new(),
pending_plugin_enabled_writes: HashMap::new(),
pending_hook_enabled_writes: HashMap::new(),
recap: recap::RecapState::default(),
@@ -0,0 +1,301 @@
//! Regression coverage for overlapping starts, replacement attempts, and thread-scoped results.
use super::*;
use codex_app_server_protocol::McpServerOauthLoginCompletedNotification;
use codex_app_server_protocol::McpServerOauthLoginResponse;
use pretty_assertions::assert_eq;
#[tokio::test]
async fn overlapping_mcp_login_preserves_first_start() {
let (mut app, mut events, _op_rx) = make_test_app_with_channels().await;
while events.try_recv().is_ok() {}
let mut server = crate::start_embedded_app_server_for_picker(app.chat_widget.config_ref())
.await
.unwrap();
let mut tui = crate::tui::test_support::make_test_tui().unwrap();
let thread_id = ThreadId::new();
app.pending_mcp_login_start = Some(PendingMcpLoginStart {
request_id: "first".into(),
name: "enterprise".into(),
thread_id,
completions: Vec::new(),
});
app.handle_event(
&mut tui,
&mut server,
AppEvent::StartMcpLogin {
name: "typo".into(),
thread_id,
},
)
.await
.unwrap();
assert_eq!(
app.pending_mcp_login_start.as_ref().unwrap().request_id,
"first"
);
assert_snapshot!("overlapping_mcp_login", next_history_message(&mut events));
app.handle_event(
&mut tui,
&mut server,
AppEvent::McpLoginStarted {
request_id: "first".into(),
result: Err("first start failed".into()),
},
)
.await
.unwrap();
let snapshot = app.thread_event_channels[&thread_id]
.store
.lock()
.await
.snapshot();
for event in snapshot.events {
app.handle_thread_event_replay(event);
}
assert!(next_history_message(&mut events).contains("first start failed"));
assert!(app.pending_mcp_login_start.is_none());
server.shutdown().await.unwrap();
}
#[tokio::test]
async fn mcp_login_retry_suppresses_old_completion_and_late_browser_open() {
let (mut app, mut events, _op_rx) = make_test_app_with_channels().await;
while events.try_recv().is_ok() {}
let mut server = crate::start_embedded_app_server_for_picker(app.chat_widget.config_ref())
.await
.unwrap();
let mut tui = crate::tui::test_support::make_test_tui().unwrap();
let thread_id = ThreadId::new();
app.primary_thread_id = Some(thread_id);
app.active_thread_id = Some(thread_id);
app.active_mcp_login_ids
.insert("enterprise".into(), "old".into());
app.active_mcp_login_ids
.insert("other".into(), "other-login".into());
app.pending_mcp_login_start = Some(PendingMcpLoginStart {
request_id: "retry".into(),
name: "enterprise".into(),
thread_id,
completions: Vec::new(),
});
for (login_id, success) in [("old", false), ("new", true)] {
app.handle_app_server_event(
&server,
codex_app_server_client::AppServerEvent::ServerNotification(Box::new(
ServerNotification::McpServerOauthLoginCompleted(
McpServerOauthLoginCompletedNotification {
name: "enterprise".into(),
thread_id: Some(thread_id.to_string()),
login_id: Some(login_id.into()),
success,
error: (!success).then(|| "Enterprise sign-in failed.".into()),
},
),
)),
)
.await;
}
assert!(events.try_recv().is_err());
app.handle_event(
&mut tui,
&mut server,
AppEvent::McpLoginStarted {
request_id: "retry".into(),
result: Ok(McpServerOauthLoginResponse {
authorization_url: String::new(),
login_id: Some("new".into()),
}),
},
)
.await
.unwrap();
let snapshot = app.thread_event_channels[&thread_id]
.store
.lock()
.await
.snapshot();
assert_eq!(snapshot.events.len(), 1);
for event in snapshot.events {
app.handle_thread_event_replay(event);
}
assert_snapshot!(
"mcp_login_retry_completion",
next_history_message(&mut events)
);
assert!(events.try_recv().is_err());
// A cancellation delivered after the replacement response is stale as well.
app.handle_app_server_event(
&server,
codex_app_server_client::AppServerEvent::ServerNotification(Box::new(
ServerNotification::McpServerOauthLoginCompleted(
McpServerOauthLoginCompletedNotification {
name: "enterprise".into(),
thread_id: Some(thread_id.to_string()),
login_id: Some("old".into()),
success: false,
error: Some("Enterprise sign-in failed.".into()),
},
),
)),
)
.await;
assert_eq!(
app.thread_event_channels[&thread_id]
.store
.lock()
.await
.snapshot()
.events
.len(),
1
);
// Retrying one server must not discard a different server's outstanding OAuth result.
app.handle_app_server_event(
&server,
codex_app_server_client::AppServerEvent::ServerNotification(Box::new(
ServerNotification::McpServerOauthLoginCompleted(
McpServerOauthLoginCompletedNotification {
name: "other".into(),
thread_id: Some(thread_id.to_string()),
login_id: Some("other-login".into()),
success: true,
error: None,
},
),
)),
)
.await;
let snapshot = app.thread_event_channels[&thread_id]
.store
.lock()
.await
.snapshot();
assert_eq!(snapshot.events.len(), 2);
app.handle_thread_event_replay(snapshot.events.last().unwrap().clone());
assert!(next_history_message(&mut events).contains("Signed in to other."));
server.shutdown().await.unwrap();
}
#[tokio::test]
async fn mcp_login_results_survive_thread_switch_and_session_refresh() {
for success in [true, false] {
let (mut app, mut events, _op_rx) = make_test_app_with_channels().await;
while events.try_recv().is_ok() {}
let server = crate::start_embedded_app_server_for_picker(app.chat_widget.config_ref())
.await
.unwrap();
let origin = ThreadId::new();
app.primary_thread_id = Some(origin);
app.active_thread_id = Some(ThreadId::new());
app.active_mcp_login_ids
.insert("enterprise".into(), "login".into());
app.handle_app_server_event(
&server,
codex_app_server_client::AppServerEvent::ServerNotification(Box::new(
ServerNotification::McpServerOauthLoginCompleted(
McpServerOauthLoginCompletedNotification {
name: "enterprise".into(),
thread_id: Some(origin.to_string()),
login_id: Some("login".into()),
success,
error: (!success).then(|| "Enterprise sign-in failed.".into()),
},
),
)),
)
.await;
assert!(events.try_recv().is_err());
let snapshot = {
let mut store = app.thread_event_channels[&origin].store.lock().await;
store.rebase_buffer_after_session_refresh();
store.snapshot()
};
assert_eq!(snapshot.events.len(), 1);
app.active_thread_id = Some(origin);
for event in snapshot.events {
app.handle_thread_event_replay(event);
}
assert_snapshot!(
format!("mcp_login_switched_thread_{success}"),
next_history_message(&mut events)
);
server.shutdown().await.unwrap();
}
}
#[tokio::test]
async fn rejected_mcp_login_retry_preserves_previous_result() {
let (mut app, mut events, _op_rx) = make_test_app_with_channels().await;
while events.try_recv().is_ok() {}
let mut server = crate::start_embedded_app_server_for_picker(app.chat_widget.config_ref())
.await
.unwrap();
let mut tui = crate::tui::test_support::make_test_tui().unwrap();
let thread_id = ThreadId::new();
app.primary_thread_id = Some(thread_id);
app.active_thread_id = Some(thread_id);
app.active_mcp_login_ids
.insert("enterprise".into(), "old".into());
app.pending_mcp_login_start = Some(PendingMcpLoginStart {
request_id: "typo".into(),
name: "typo".into(),
thread_id,
completions: Vec::new(),
});
app.handle_app_server_event(
&server,
codex_app_server_client::AppServerEvent::ServerNotification(Box::new(
ServerNotification::McpServerOauthLoginCompleted(
McpServerOauthLoginCompletedNotification {
name: "enterprise".into(),
thread_id: Some(thread_id.to_string()),
login_id: Some("old".into()),
success: true,
error: None,
},
),
)),
)
.await;
// The other server's result is already retained while this start is still pending.
assert_eq!(
app.thread_event_channels[&thread_id]
.store
.lock()
.await
.snapshot()
.events
.len(),
1
);
app.handle_event(
&mut tui,
&mut server,
AppEvent::McpLoginStarted {
request_id: "typo".into(),
result: Err("Unknown MCP server typo".into()),
},
)
.await
.unwrap();
let snapshot = app.thread_event_channels[&thread_id]
.store
.lock()
.await
.snapshot();
assert_eq!(snapshot.events.len(), 2);
for event in snapshot.events {
app.handle_thread_event_replay(event);
}
let messages = std::iter::from_fn(|| events.try_recv().ok())
.filter_map(|event| {
if let AppEvent::InsertHistoryCell(cell) = event {
Some(lines_to_single_string(&cell.display_lines(/*width*/ 80)))
} else {
None
}
})
.collect::<Vec<_>>();
assert_snapshot!("rejected_mcp_login_retry", messages.join("\n"));
server.shutdown().await.unwrap();
}
@@ -0,0 +1,5 @@
---
source: tui/src/app/tests/mcp_login_tests.rs
expression: next_history_message(&mut events)
---
• Signed in to enterprise.
@@ -0,0 +1,5 @@
---
source: tui/src/app/tests/mcp_login_tests.rs
expression: next_history_message(&mut events)
---
■ Enterprise sign-in failed.
@@ -0,0 +1,5 @@
---
source: tui/src/app/tests/mcp_login_tests.rs
expression: next_history_message(&mut events)
---
• Signed in to enterprise.
@@ -0,0 +1,5 @@
---
source: tui/src/app/tests/mcp_login_tests.rs
expression: next_history_message(&mut events)
---
• MCP sign-in is starting. Wait for it to finish before trying again.
@@ -0,0 +1,6 @@
---
source: tui/src/app/tests/mcp_login_tests.rs
expression: "messages.join(\"\\n\")"
---
• Signed in to enterprise.
■ Unknown MCP server typo
+1
View File
@@ -100,6 +100,7 @@ impl ThreadEventStore {
ServerNotification::HookStarted(_)
| ServerNotification::HookCompleted(_)
| ServerNotification::McpServerStatusUpdated(_)
| ServerNotification::McpServerOauthLoginCompleted(_)
),
ThreadBufferedEvent::HistoryEntryResponse(_) => false,
}
+11
View File
@@ -22,6 +22,7 @@ use codex_app_server_protocol::GetAccountRateLimitsResponse;
use codex_app_server_protocol::MarketplaceAddResponse;
use codex_app_server_protocol::MarketplaceRemoveResponse;
use codex_app_server_protocol::MarketplaceUpgradeResponse;
use codex_app_server_protocol::McpServerOauthLoginResponse;
use codex_app_server_protocol::McpServerStatus;
use codex_app_server_protocol::McpServerStatusDetail;
use codex_app_server_protocol::PluginInstallResponse;
@@ -1067,6 +1068,16 @@ pub(crate) enum AppEvent {
thread_id: Option<ThreadId>,
},
StartMcpLogin {
name: String,
thread_id: ThreadId,
},
McpLoginStarted {
request_id: String,
result: Result<McpServerOauthLoginResponse, String>,
},
/// Result of fetching MCP inventory via app-server RPCs.
McpInventoryLoaded {
result: Result<Vec<McpServerStatus>, String>,
@@ -9,7 +9,7 @@ Buffer {
" /model choose what model and reasoning effort to use ",
"› /memories configure memory use and generation ",
" /mention mention a file ",
" /mcp list configured MCP tools; use /mcp verbose for details ",
" /mcp list MCP tools; use /mcp verbose or /mcp login <name> ",
" ",
"› /m ",
" ",
@@ -32,7 +32,7 @@ Buffer {
x: 3, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: BOLD,
x: 4, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 13, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: DIM,
x: 68, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 66, y: 3, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
x: 0, y: 5, fg: Reset, bg: Reset, underline: Reset, modifier: BOLD,
x: 1, y: 5, fg: Reset, bg: Reset, underline: Reset, modifier: NONE,
]
@@ -41,7 +41,7 @@ expression: commands
/statusline - configure which items appear in the status line
/theme - choose a syntax highlighting theme
/pets - choose or hide the terminal pet
/mcp - list configured MCP tools; use /mcp verbose for details
/mcp - list MCP tools; use /mcp verbose or /mcp login <name>
/logout - log out of Codex
/exit - exit Codex
/feedback - send logs to maintainers
+14 -1
View File
@@ -44,6 +44,20 @@ impl ChatWidget {
self.restore_retry_status_header_if_present();
}
match notification {
ServerNotification::McpServerOauthLoginCompleted(notification) => {
if notification.success {
self.add_info_message(
format!("Signed in to {}.", notification.name),
/*hint*/ None,
);
} else {
self.add_error_message(
notification
.error
.unwrap_or_else(|| "MCP sign-in failed.".to_string()),
);
}
}
ServerNotification::ThreadTokenUsageUpdated(notification) => {
self.set_token_info(Some(token_usage_info_from_app_server(
notification.token_usage,
@@ -359,7 +373,6 @@ impl ChatWidget {
| ServerNotification::McpServerEventStream(_)
| ServerNotification::FileChangePatchUpdated(_)
| ServerNotification::McpToolCallProgress(_)
| ServerNotification::McpServerOauthLoginCompleted(_)
| ServerNotification::AppListUpdated(_)
| ServerNotification::EnvironmentConnected(_)
| ServerNotification::EnvironmentDisconnected(_)
+21 -4
View File
@@ -803,10 +803,27 @@ impl ChatWidget {
SlashCommand::Ide => {
self.handle_ide_command_args(trimmed);
}
SlashCommand::Mcp => match trimmed.to_ascii_lowercase().as_str() {
"verbose" => self.add_mcp_output(McpServerStatusDetail::Full),
_ => self.add_error_message("Usage: /mcp [verbose]".to_string()),
},
SlashCommand::Mcp => {
if trimmed.eq_ignore_ascii_case("verbose") {
self.add_mcp_output(McpServerStatusDetail::Full);
} else if let Some((command, name)) = trimmed.split_once(' ')
&& command.eq_ignore_ascii_case("login")
&& !name.trim().is_empty()
{
if let Some(thread_id) = self.thread_id {
self.app_event_tx.send(AppEvent::StartMcpLogin {
name: name.trim().to_string(),
thread_id,
});
} else {
self.add_error_message(
"MCP sign-in requires an active session.".to_string(),
);
}
} else {
self.add_error_message("Usage: /mcp [verbose | login <name>]".to_string());
}
}
SlashCommand::Keymap => match trimmed.to_ascii_lowercase().as_str() {
"" => self.open_keymap_picker(),
"debug" => {
@@ -2731,6 +2731,23 @@ async fn slash_mcp_verbose_requests_full_inventory_via_app_server() {
assert!(op_rx.try_recv().is_err(), "expected no core op to be sent");
}
#[tokio::test]
async fn slash_mcp_login_targets_the_active_thread() {
let (mut chat, mut rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
let thread_id = ThreadId::new();
chat.thread_id = Some(thread_id);
submit_composer_text(&mut chat, "/mcp login enterprise");
assert_matches!(rx.try_recv(), Ok(AppEvent::FollowTranscript));
assert_matches!(
rx.try_recv(),
Ok(AppEvent::StartMcpLogin { name, thread_id: actual_thread_id })
if name == "enterprise" && actual_thread_id == thread_id
);
assert!(op_rx.try_recv().is_err(), "expected no core op to be sent");
}
#[tokio::test]
async fn slash_mcp_invalid_args_show_usage() {
let (mut chat, mut rx, mut op_rx) = make_chatwidget_manual(/*model_override*/ None).await;
@@ -2744,7 +2761,7 @@ async fn slash_mcp_invalid_args_show_usage() {
.collect::<Vec<_>>()
.join("\n");
assert!(
rendered.contains("Usage: /mcp [verbose]"),
rendered.contains("Usage: /mcp [verbose | login <name>]"),
"expected usage message, got: {rendered:?}"
);
assert_eq!(recall_latest_after_clearing(&mut chat), "/mcp full");
+1 -1
View File
@@ -147,7 +147,7 @@ impl SlashCommand {
SlashCommand::Experimental => "toggle experimental features",
SlashCommand::AutoReview => "approve one retry of a recent auto-review denial",
SlashCommand::Memories => "configure memory use and generation",
SlashCommand::Mcp => "list configured MCP tools; use /mcp verbose for details",
SlashCommand::Mcp => "list MCP tools; use /mcp verbose or /mcp login <name>",
SlashCommand::Apps => "manage apps",
SlashCommand::Plugins => "browse plugins",
SlashCommand::Logout => "log out of Codex",