Skip to content

Commit 42e3142

Browse files
committed
feat(cortex-tui): use interactive panel for /mcp instead of modal
Change the /mcp command and KeyAction::OpenMcp to use the interactive mode (displayed in the input area) instead of the modal overlay system. This provides a consistent UX with the /settings command which already uses this pattern. Changes: - ModalType::McpManager now enters interactive mode using build_mcp_selector - KeyAction::OpenMcp uses interactive mode instead of modal_stack.push - Implement McpServerAction handler to display server status on selection
1 parent 1c5978c commit 42e3142

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

cortex-tui/src/runner/event_loop.rs

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1978,10 +1978,11 @@ impl EventLoop {
19781978
self.open_sessions_modal();
19791979
}
19801980
KeyAction::OpenMcp => {
1981-
// Open MCP manager modal
1982-
// MCP servers would come from a dedicated MCP manager in production
1983-
let servers = Vec::new(); // Placeholder - MCP integration pending
1984-
self.open_mcp_manager(servers);
1981+
// Open MCP manager using interactive mode (like settings panel)
1982+
use crate::interactive::builders::build_mcp_selector;
1983+
let servers = self.app_state.mcp_servers.clone();
1984+
let interactive = build_mcp_selector(&servers);
1985+
self.app_state.enter_interactive_mode(interactive);
19851986
}
19861987

19871988
// Transcript
@@ -4127,9 +4128,11 @@ impl EventLoop {
41274128
self.open_sessions_modal();
41284129
}
41294130
ModalType::McpManager => {
4130-
// Get MCP servers from app state
4131+
// Use interactive mode for MCP servers (like settings panel)
4132+
use crate::interactive::builders::build_mcp_selector;
41314133
let servers = self.app_state.mcp_servers.clone();
4132-
self.open_mcp_manager(servers);
4134+
let interactive = build_mcp_selector(&servers);
4135+
self.app_state.enter_interactive_mode(interactive);
41334136
}
41344137
ModalType::Form(cmd_name) => {
41354138
// Some commands use interactive mode instead of forms
@@ -6021,7 +6024,34 @@ impl EventLoop {
60216024
return false;
60226025
}
60236026
InteractiveAction::McpServerAction => {
6024-
// TODO: handle MCP server action (start/stop/restart)
6027+
// Handle MCP server selection
6028+
if item_id == "__add__" {
6029+
// Show add server form
6030+
self.app_state
6031+
.toasts
6032+
.info("Use /mcp add <name> <command> [args] to add a server");
6033+
return false;
6034+
}
6035+
6036+
// Find the selected server and toggle its state
6037+
let server = self
6038+
.app_state
6039+
.mcp_servers
6040+
.iter()
6041+
.find(|s| s.name == item_id);
6042+
6043+
if let Some(server) = server {
6044+
// For now show the server status, actual start/stop would need MCP integration
6045+
let status_text = server.status.text();
6046+
self.app_state.toasts.info(&format!(
6047+
"{}: {} ({} tools)",
6048+
item_id, status_text, server.tool_count
6049+
));
6050+
} else {
6051+
self.app_state
6052+
.toasts
6053+
.error(&format!("Server not found: {}", item_id));
6054+
}
60256055
return false;
60266056
}
60276057
InteractiveAction::AddContextFiles => {

0 commit comments

Comments
 (0)