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

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

commit b396bad7d4771aec7fba4d2378b8628677343187
Author: Claus Ibsen <[email protected]>
AuthorDate: Sat May 16 20:26:09 2026 +0200

    TUI: add chart toggle between all integrations and selected only
    
    Press 'a' on the Overview tab to switch the throughput bar chart between
    aggregated stats for all running integrations [All] and stats for the
    currently selected integration only, with the name shown in yellow.
    
    Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
---
 .../dsl/jbang/core/commands/tui/CamelMonitor.java  | 56 ++++++++++++++++------
 1 file changed, 41 insertions(+), 15 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 cc81516c402b..a88e496e29b1 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
@@ -232,6 +232,7 @@ public class CamelMonitor extends CamelCommand {
     private String selectedPid;
 
     // Diagram state
+    private boolean chartAllIntegrations = true;
     private boolean showDiagram;
     private boolean diagramTextMode;
     private boolean diagramMetrics = true;
@@ -459,6 +460,11 @@ public class CamelMonitor extends CamelCommand {
                 overviewSort = OVERVIEW_SORT_COLUMNS[overviewSortIndex];
                 return true;
             }
+            // Overview tab: toggle chart between all integrations and 
selected only
+            if (tab == TAB_OVERVIEW && ke.isCharIgnoreCase('a')) {
+                chartAllIntegrations = !chartAllIntegrations;
+                return true;
+            }
 
             // Consumers tab: sort
             if (tab == TAB_CONSUMERS && ke.isCharIgnoreCase('s')) {
@@ -1072,20 +1078,25 @@ public class CamelMonitor extends CamelCommand {
             int innerBarCols = Math.max(2, barChartArea.width() - 2); // minus 
block borders
             int renderPoints = Math.min(MAX_SPARKLINE_POINTS, innerBarCols / 
2);
 
-            // Merge throughput histories across all PIDs
+            // Merge throughput histories: all PIDs or selected only
             long[] mergedTotal = new long[renderPoints];
             long[] mergedFailed = new long[renderPoints];
+            String chartPid = (!chartAllIntegrations && selectedPid != null) ? 
selectedPid : null;
             for (int i = 0; i < renderPoints; i++) {
-                for (LinkedList<Long> hist : throughputHistory.values()) {
-                    int idx = hist.size() - renderPoints + i;
-                    if (idx >= 0) {
-                        mergedTotal[i] += hist.get(idx);
+                for (Map.Entry<String, LinkedList<Long>> e : 
throughputHistory.entrySet()) {
+                    if (chartPid == null || chartPid.equals(e.getKey())) {
+                        int idx = e.getValue().size() - renderPoints + i;
+                        if (idx >= 0) {
+                            mergedTotal[i] += e.getValue().get(idx);
+                        }
                     }
                 }
-                for (LinkedList<Long> hist : failedHistory.values()) {
-                    int idx = hist.size() - renderPoints + i;
-                    if (idx >= 0) {
-                        mergedFailed[i] += hist.get(idx);
+                for (Map.Entry<String, LinkedList<Long>> e : 
failedHistory.entrySet()) {
+                    if (chartPid == null || chartPid.equals(e.getKey())) {
+                        int idx = e.getValue().size() - renderPoints + i;
+                        if (idx >= 0) {
+                            mergedFailed[i] += e.getValue().get(idx);
+                        }
                     }
                 }
             }
@@ -1099,12 +1110,26 @@ public class CamelMonitor extends CamelCommand {
             long curOk = Math.max(0, curTp - curFailed);
 
             // Styled legend in chart title
-            Line titleLine = Line.from(
-                    Span.raw(String.format(" Throughput: %d msg/s  ", curTp)),
-                    Span.styled("■", Style.EMPTY.fg(Color.GREEN)),
-                    Span.raw(String.format(" ok:%d  ", curOk)),
-                    Span.styled("■", Style.EMPTY.fg(Color.RED)),
-                    Span.raw(String.format(" fail:%d ", curFailed)));
+            Line titleLine;
+            if (!chartAllIntegrations && selectedPid != null) {
+                IntegrationInfo chartSel = findSelectedIntegration();
+                String chartName = chartSel != null ? 
TuiHelper.truncate(chartSel.name, 12) : selectedPid;
+                titleLine = Line.from(
+                        Span.raw(" ["),
+                        Span.styled(chartName, Style.EMPTY.fg(Color.YELLOW)),
+                        Span.raw(String.format("] Throughput: %d msg/s  ", 
curTp)),
+                        Span.styled("■", Style.EMPTY.fg(Color.GREEN)),
+                        Span.raw(String.format(" ok:%d  ", curOk)),
+                        Span.styled("■", Style.EMPTY.fg(Color.RED)),
+                        Span.raw(String.format(" fail:%d ", curFailed)));
+            } else {
+                titleLine = Line.from(
+                        Span.raw(String.format(" [All] Throughput: %d msg/s  
", curTp)),
+                        Span.styled("■", Style.EMPTY.fg(Color.GREEN)),
+                        Span.raw(String.format(" ok:%d  ", curOk)),
+                        Span.styled("■", Style.EMPTY.fg(Color.RED)),
+                        Span.raw(String.format(" fail:%d ", curFailed)));
+            }
 
             // Build bar groups (ok=green, failed=red), no bar value labels
             List<BarGroup> groups = new ArrayList<>();
@@ -3220,6 +3245,7 @@ public class CamelMonitor extends CamelCommand {
             hint(spans, "q", "quit");
             hint(spans, "\u2191\u2193", "navigate");
             hint(spans, "s", "sort");
+            hint(spans, "a", "chart " + (chartAllIntegrations ? "[all]" : 
"[single]"));
             hint(spans, "Enter", "details");
             if (selectedPid != null) {
                 hint(spans, "Esc", "unselect");

Reply via email to