This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch CAMEL-23517-tui-history-tab-2 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 36cadc7e76e4bf4b4841466ec515877c15352161 Author: Claus Ibsen <[email protected]> AuthorDate: Thu May 14 21:45:05 2026 +0200 CAMEL-23517: Add exchange variables to History tab detail panel Add 'v' key to toggle exchange variables display on/off in the History tab detail panel. Variables shown after properties and before headers, with same type prefix format. 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 | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) 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 471ce6a82923..99bb52adc022 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 @@ -182,6 +182,7 @@ public class CamelMonitor extends CamelCommand { private volatile List<HistoryEntry> historyEntries = Collections.emptyList(); private final TableState historyTableState = new TableState(); private boolean showHistoryProperties; + private boolean showHistoryVariables; private boolean showHistoryHeaders = true; private boolean showHistoryBody = true; private boolean historyWordWrap; @@ -504,6 +505,10 @@ public class CamelMonitor extends CamelCommand { showHistoryProperties = !showHistoryProperties; return true; } + if (ke.isCharIgnoreCase('v')) { + showHistoryVariables = !showHistoryVariables; + return true; + } if (ke.isCharIgnoreCase('h')) { showHistoryHeaders = !showHistoryHeaders; return true; @@ -2284,6 +2289,28 @@ public class CamelMonitor extends CamelCommand { lines.add(Line.from(Span.raw(""))); } + // Exchange Variables + if (showHistoryVariables && entry.exchangeVariables != null && !entry.exchangeVariables.isEmpty()) { + lines.add(Line.from(Span.styled(" Exchange Variables:", Style.EMPTY.fg(Color.GREEN).bold()))); + for (Map.Entry<String, Object> v : entry.exchangeVariables.entrySet()) { + String type = entry.exchangeVariableTypes != null ? entry.exchangeVariableTypes.get(v.getKey()) : null; + String typeLabel; + if (type != null) { + String t = "(" + type + ")"; + t = truncate(t, 20); + typeLabel = String.format("%-20s ", t); + } else { + typeLabel = String.format("%-21s", ""); + } + lines.add(Line.from( + Span.styled(" " + typeLabel, Style.EMPTY.dim()), + Span.styled(v.getKey(), Style.EMPTY.fg(Color.CYAN)), + Span.raw(" = "), + Span.raw(v.getValue() != null ? v.getValue().toString() : "null"))); + } + lines.add(Line.from(Span.raw(""))); + } + // Headers if (showHistoryHeaders && entry.headers != null && !entry.headers.isEmpty()) { lines.add(Line.from(Span.styled(" Headers:", Style.EMPTY.fg(Color.GREEN).bold()))); @@ -2473,6 +2500,7 @@ public class CamelMonitor extends CamelCommand { hint(spans, "\u2191\u2193", "navigate"); hint(spans, "PgUp/PgDn", "scroll detail"); hint(spans, "p", "properties" + (showHistoryProperties ? " [on]" : " [off]")); + hint(spans, "v", "variables" + (showHistoryVariables ? " [on]" : " [off]")); hint(spans, "h", "headers" + (showHistoryHeaders ? " [on]" : " [off]")); hint(spans, "b", "body" + (showHistoryBody ? " [on]" : " [off]")); hint(spans, "w", "wrap" + (historyWordWrap ? " [on]" : " [off]")); @@ -2992,6 +3020,24 @@ public class CamelMonitor extends CamelCommand { } else if (propsObj instanceof Map) { entry.exchangeProperties = new LinkedHashMap<>((Map<String, Object>) propsObj); } + + Object varsObj = message.get("exchangeVariables"); + if (varsObj instanceof List<?> varList) { + entry.exchangeVariables = new LinkedHashMap<>(); + entry.exchangeVariableTypes = new LinkedHashMap<>(); + for (Object v : varList) { + if (v instanceof JsonObject vObj) { + String key = String.valueOf(vObj.get("key")); + entry.exchangeVariables.put(key, vObj.get("value")); + Object type = vObj.get("type"); + if (type != null) { + entry.exchangeVariableTypes.put(key, TuiHelper.shortTypeName(type.toString())); + } + } + } + } else if (varsObj instanceof Map) { + entry.exchangeVariables = new LinkedHashMap<>((Map<String, Object>) varsObj); + } } // Exception @@ -3410,6 +3456,8 @@ public class CamelMonitor extends CamelCommand { Map<String, String> headerTypes; Map<String, Object> exchangeProperties; Map<String, String> exchangePropertyTypes; + Map<String, Object> exchangeVariables; + Map<String, String> exchangeVariableTypes; } record VanishingInfo(IntegrationInfo info, long startTime) {
