Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/cortex-tui/src/modal/mcp_manager/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ impl McpManagerModal {
command: String::new(),
args: String::new(),
focus: AddStdioServerFocus::Name,
error: None,
};
} else {
// HTTP transport
Expand Down Expand Up @@ -171,6 +172,7 @@ impl McpManagerModal {
ref mut command,
ref mut args,
ref mut focus,
ref mut error,
} = self.mode
{
match key.code {
Expand All @@ -180,6 +182,7 @@ impl McpManagerModal {
AddStdioServerFocus::Command => AddStdioServerFocus::Args,
AddStdioServerFocus::Args => AddStdioServerFocus::Name,
};
*error = None; // Clear error on field switch
ModalResult::Continue
}
KeyCode::BackTab => {
Expand All @@ -200,6 +203,15 @@ impl McpManagerModal {
args: args_vec,
});
}
// Set error message for empty required fields
let err_msg = if name.is_empty() && command.is_empty() {
"Error: Name and Command are required"
} else if name.is_empty() {
"Error: Server name is required"
} else {
"Error: Command is required"
};
*error = Some(err_msg.to_string());
ModalResult::Continue
}
KeyCode::Esc => {
Expand All @@ -211,6 +223,7 @@ impl McpManagerModal {
ModalResult::Continue
}
KeyCode::Char(c) => {
*error = None; // Clear error when user starts typing
match focus {
AddStdioServerFocus::Name => name.push(c),
AddStdioServerFocus::Command => command.push(c),
Expand Down
1 change: 1 addition & 0 deletions src/cortex-tui/src/modal/mcp_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ impl Modal for McpManagerModal {
command,
args,
focus,
error: _,
} => {
match focus {
AddStdioServerFocus::Name => name.push_str(text),
Expand Down
9 changes: 8 additions & 1 deletion src/cortex-tui/src/modal/mcp_manager/rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,13 @@ impl McpManagerModal {
ref command,
ref args,
focus,
ref error,
} = self.mode
{
Clear.render(area, buf);

let block = Block::default()
.title(" Add MCP Server ")
.title(" Add MCP Server - Stdio ")
.borders(Borders::ALL)
.border_style(Style::default().fg(CYAN_PRIMARY))
.style(Style::default().bg(SURFACE_1));
Expand Down Expand Up @@ -408,6 +409,12 @@ impl McpManagerModal {
.hint("Enter", "save")
.hint("Esc", "back");
form_bar.render(chunks[4], buf);

// Render submission error message if present
if let Some(ref err_msg) = error {
let error_style = Style::default().fg(ERROR);
buf.set_string(chunks[4].x, chunks[4].y.saturating_sub(1), err_msg, error_style);
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/cortex-tui/src/modal/mcp_manager/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ pub enum McpMode {
command: String,
args: String,
focus: AddStdioServerFocus,
/// Submission error message (e.g., when required fields are empty)
error: Option<String>,
},
/// Step 3b: Adding an HTTP server
AddHttpServer {
Expand Down