This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch tui-mcp-CAMEL-23606
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 4964c535742b1eb1af529c92bb90e9b73acfc230
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun May 24 22:13:31 2026 +0200

    CAMEL-23606: camel-tui - MCP footer connection status and daemon threads
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 .../dsl/jbang/core/commands/tui/ActionsPopup.java  |  2 +-
 .../dsl/jbang/core/commands/tui/CamelMonitor.java  | 24 +++++++++++++++-------
 .../dsl/jbang/core/commands/tui/TuiMcpServer.java  | 14 ++++++++++---
 3 files changed, 29 insertions(+), 11 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ActionsPopup.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ActionsPopup.java
index e567ae83972c..44d40c48c2b8 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ActionsPopup.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ActionsPopup.java
@@ -686,7 +686,7 @@ class ActionsPopup {
         String client = mcpConnectedClient != null ? mcpConnectedClient.get() 
: null;
         String status = client != null
                 ? "**Connected:** " + client
-                : "**Status:** Not connected";
+                : "**Status:** Waiting for connection";
         docContent = "# MCP Server\n\n"
                      + status + "\n\n"
                      + "The TUI has an embedded MCP (Model Context Protocol) 
server running at:\n\n"
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java
index c0ae386a3002..552f55752413 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java
@@ -1677,16 +1677,26 @@ public class CamelMonitor extends CamelCommand {
         if (mcp && !recording) {
             String client = mcpServer != null ? mcpServer.getConnectedClient() 
: null;
             boolean active = mcpServer != null && mcpServer.isRecentActivity();
-            String dot = active ? " ●" : " ○";
-            String mcpLabel = client != null
-                    ? "MCP :" + mcpPort + " (" + client + ")"
-                    : "MCP :" + mcpPort;
+            String mcpLabel = "MCP :" + mcpPort;
+            String suffix;
+            Style labelStyle;
+            Style suffixStyle;
+            if (client != null) {
+                suffix = active ? " ●" : " ○";
+                mcpLabel += " (" + client + ")";
+                labelStyle = Style.EMPTY.fg(Color.GREEN);
+                suffixStyle = Style.EMPTY.fg(active ? Color.GREEN : 
Color.DARK_GRAY);
+            } else {
+                suffix = " ✗";
+                labelStyle = Style.EMPTY.dim();
+                suffixStyle = Style.EMPTY.fg(Color.RED);
+            }
             int hintsWidth = spans.stream().mapToInt(s -> s.width()).sum();
-            int mcpWidth = mcpLabel.length() + dot.length() + 1;
+            int mcpWidth = mcpLabel.length() + suffix.length() + 1;
             int gap = Math.max(1, area.width() - hintsWidth - mcpWidth);
             spans.add(Span.raw(" ".repeat(gap)));
-            spans.add(Span.styled(mcpLabel, Style.EMPTY.fg(client != null ? 
Color.GREEN : Color.CYAN)));
-            spans.add(Span.styled(dot, Style.EMPTY.fg(active ? Color.GREEN : 
Color.DARK_GRAY)));
+            spans.add(Span.styled(mcpLabel, labelStyle));
+            spans.add(Span.styled(suffix, suffixStyle));
         }
 
         frame.renderWidget(Paragraph.from(Line.from(spans)), area);
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiMcpServer.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiMcpServer.java
index 9c1e9378cc03..0e6e92080529 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiMcpServer.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TuiMcpServer.java
@@ -81,13 +81,21 @@ class TuiMcpServer {
     void start() throws IOException {
         server = HttpServer.create(new InetSocketAddress("127.0.0.1", port), 
0);
         server.createContext("/mcp", this::handleMcp);
+        
server.setExecutor(java.util.concurrent.Executors.newCachedThreadPool(r -> {
+            Thread t = new Thread(r, "mcp-handler");
+            t.setDaemon(true);
+            return t;
+        }));
         server.start();
         log(LogLevel.INFO, "Server started on port " + port);
     }
 
     void stop() {
         if (server != null) {
-            server.stop(0);
+            server.stop(1);
+            if (server.getExecutor() instanceof 
java.util.concurrent.ExecutorService es) {
+                es.shutdownNow();
+            }
         }
     }
 
@@ -107,8 +115,8 @@ class TuiMcpServer {
     }
 
     String getConnectedClient() {
-        if (clientName != null && System.currentTimeMillis() - lastActivity < 
CLIENT_TIMEOUT_MS) {
-            return clientName;
+        if (System.currentTimeMillis() - lastActivity < CLIENT_TIMEOUT_MS) {
+            return clientName != null ? clientName : "unknown";
         }
         return null;
     }

Reply via email to