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

davsclaus pushed a commit to branch CAMEL-23514-ascii-diagram-metrics
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 71fb0a763d09a4b7cb72de31307fd01b9d796aa8
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu May 14 09:33:00 2026 +0200

    CAMEL-23514: Add metrics toggle to TUI diagram view
    
    Add 'm' key to toggle metrics on/off in the diagram view. When
    metrics are enabled and showing a text diagram, the diagram is
    automatically refreshed on each tick so counters update in real time.
    
    Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../dsl/jbang/core/commands/tui/CamelMonitor.java  | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

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 e97bdae7afa2..58129fe37824 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
@@ -176,6 +176,7 @@ public class CamelMonitor extends CamelCommand {
     // Diagram state
     private boolean showDiagram;
     private boolean diagramTextMode;
+    private boolean diagramMetrics = true;
     private List<String> diagramLines = Collections.emptyList();
     private int diagramScroll;
     private int diagramScrollX;
@@ -400,6 +401,14 @@ public class CamelMonitor extends CamelCommand {
                 return true;
             }
 
+            if (tab == TAB_ROUTES && showDiagram && ke.isCharIgnoreCase('m')) {
+                diagramMetrics = !diagramMetrics;
+                if (diagramTextMode) {
+                    loadDiagramForSelectedRoute();
+                }
+                return true;
+            }
+
             // Health tab: DOWN filter
             if (tab == TAB_HEALTH && ke.isCharIgnoreCase('d')) {
                 showOnlyDown = !showOnlyDown;
@@ -475,6 +484,9 @@ public class CamelMonitor extends CamelCommand {
             long interval = showDiagram ? Math.max(refreshInterval, 1000) : 
refreshInterval;
             if (now - lastRefresh >= interval) {
                 refreshData();
+                if (showDiagram && diagramTextMode && diagramMetrics) {
+                    loadDiagramForSelectedRoute();
+                }
                 return true;
             }
             // Skip re-render when showing image diagram to prevent flicker
@@ -1246,6 +1258,7 @@ public class CamelMonitor extends CamelCommand {
         // Capture state needed by the background thread
         String pid = selectedPid;
         boolean textMode = diagramTextMode;
+        boolean showMetrics = diagramMetrics;
         String routeId = selectedRoute.routeId;
 
         // Show loading state immediately
@@ -1259,14 +1272,14 @@ public class CamelMonitor extends CamelCommand {
 
         runner.scheduler().execute(() -> {
             try {
-                loadDiagramInBackground(pid, textMode, routeId);
+                loadDiagramInBackground(pid, textMode, routeId, showMetrics);
             } finally {
                 diagramLoading.set(false);
             }
         });
     }
 
-    private void loadDiagramInBackground(String pid, boolean textMode, String 
routeId) {
+    private void loadDiagramInBackground(String pid, boolean textMode, String 
routeId, boolean metrics) {
         Path outputFile = getOutputFile(pid);
         PathUtils.deleteFile(outputFile);
 
@@ -1324,7 +1337,7 @@ public class CamelMonitor extends CamelCommand {
         }
 
         if (textMode) {
-            String ascii = renderAscii(diagramRoutes, 
RouteDiagramLayoutEngine.DEFAULT_BOX_WIDTH, "CODE", true, true);
+            String ascii = renderAscii(diagramRoutes, 
RouteDiagramLayoutEngine.DEFAULT_BOX_WIDTH, "CODE", true, metrics);
             List<String> result = new ArrayList<>();
             for (String line : ascii.split("\n", -1)) {
                 if (!line.isEmpty()) {
@@ -1997,7 +2010,8 @@ public class CamelMonitor extends CamelCommand {
             hint(spans, closeKey + "/Esc", "close");
             hint(spans, "\u2191\u2193\u2190\u2192", "scroll");
             hint(spans, "PgUp/PgDn", "page");
-            hintLast(spans, "Home/End", "top/bottom");
+            hint(spans, "Home/End", "top/bottom");
+            hintLast(spans, "m", "metrics" + (diagramMetrics ? " [on]" : " 
[off]"));
         } else if (tab == TAB_ROUTES) {
             hint(spans, "Esc", "back");
             hint(spans, "\u2191\u2193", "navigate");

Reply via email to