From 90b8774ea80090414dadfbfce78190988fa2b6da Mon Sep 17 00:00:00 2001 From: OpenClaw Agent Date: Sun, 29 Mar 2026 22:35:40 +0000 Subject: [PATCH] fix: MCP Manager Add Stdio Server form improvements MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes two validated bounty challenge bugs: 1. MCP Manager Add Stdio Server form now shows '- Stdio' suffix in the header, matching other server type forms (HTTP, Registry). Fixes PlatformNetwork/bounty-challenge#40908 2. When Enter is pressed with empty Name or Command fields, a red error message now appears instead of silently doing nothing. Error clears automatically when user starts typing. Fixes PlatformNetwork/bounty-challenge#40906 收款地址:eB51DWp1uECrLZRLsE2cnyZUzfRWvzUzaJzkatTpQV9 --- src/cortex-tui/src/modal/mcp_manager/handlers.rs | 13 +++++++++++++ src/cortex-tui/src/modal/mcp_manager/mod.rs | 1 + src/cortex-tui/src/modal/mcp_manager/rendering.rs | 9 ++++++++- src/cortex-tui/src/modal/mcp_manager/types.rs | 2 ++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/cortex-tui/src/modal/mcp_manager/handlers.rs b/src/cortex-tui/src/modal/mcp_manager/handlers.rs index 81683d924..f69b17b0f 100644 --- a/src/cortex-tui/src/modal/mcp_manager/handlers.rs +++ b/src/cortex-tui/src/modal/mcp_manager/handlers.rs @@ -141,6 +141,7 @@ impl McpManagerModal { command: String::new(), args: String::new(), focus: AddStdioServerFocus::Name, + error: None, }; } else { // HTTP transport @@ -171,6 +172,7 @@ impl McpManagerModal { ref mut command, ref mut args, ref mut focus, + ref mut error, } = self.mode { match key.code { @@ -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 => { @@ -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 => { @@ -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), diff --git a/src/cortex-tui/src/modal/mcp_manager/mod.rs b/src/cortex-tui/src/modal/mcp_manager/mod.rs index f95ab7e56..f8dfcf01f 100644 --- a/src/cortex-tui/src/modal/mcp_manager/mod.rs +++ b/src/cortex-tui/src/modal/mcp_manager/mod.rs @@ -34,6 +34,7 @@ impl Modal for McpManagerModal { command, args, focus, + error: _, } => { match focus { AddStdioServerFocus::Name => name.push_str(text), diff --git a/src/cortex-tui/src/modal/mcp_manager/rendering.rs b/src/cortex-tui/src/modal/mcp_manager/rendering.rs index 8ed345b30..0fba94cab 100644 --- a/src/cortex-tui/src/modal/mcp_manager/rendering.rs +++ b/src/cortex-tui/src/modal/mcp_manager/rendering.rs @@ -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)); @@ -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); + } } } diff --git a/src/cortex-tui/src/modal/mcp_manager/types.rs b/src/cortex-tui/src/modal/mcp_manager/types.rs index f7ec63c60..a2c1f02f0 100644 --- a/src/cortex-tui/src/modal/mcp_manager/types.rs +++ b/src/cortex-tui/src/modal/mcp_manager/types.rs @@ -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, }, /// Step 3b: Adding an HTTP server AddHttpServer {