Skip to content

Commit 2a05912

Browse files
davsclausclaude
andauthored
Camel 23517 tui history tab 2 (#23236)
* CAMEL-23517: Add exchange properties to History tab detail panel Add 'p' key to toggle exchange properties display on/off in the History tab detail panel. Properties shown before headers with same type prefix format (dimmed, 20 chars, shortTypeName). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com> * 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) <noreply@anthropic.com> Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com> --------- Signed-off-by: Claus Ibsen <claus.ibsen@gmail.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1beefe3 commit 2a05912

1 file changed

Lines changed: 98 additions & 1 deletion

File tree

  • dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui

dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ public class CamelMonitor extends CamelCommand {
181181
// History state
182182
private volatile List<HistoryEntry> historyEntries = Collections.emptyList();
183183
private final TableState historyTableState = new TableState();
184+
private boolean showHistoryProperties;
185+
private boolean showHistoryVariables;
184186
private boolean showHistoryHeaders = true;
185187
private boolean showHistoryBody = true;
186188
private boolean historyWordWrap;
@@ -497,8 +499,16 @@ private boolean handleEvent(Event event, TuiRunner runner) {
497499
}
498500
}
499501

500-
// History tab: headers/body toggle and refresh
502+
// History tab: properties/headers/body toggle and refresh
501503
if (tab == TAB_HISTORY) {
504+
if (ke.isCharIgnoreCase('p')) {
505+
showHistoryProperties = !showHistoryProperties;
506+
return true;
507+
}
508+
if (ke.isCharIgnoreCase('v')) {
509+
showHistoryVariables = !showHistoryVariables;
510+
return true;
511+
}
502512
if (ke.isCharIgnoreCase('h')) {
503513
showHistoryHeaders = !showHistoryHeaders;
504514
return true;
@@ -2256,6 +2266,51 @@ private void renderHistoryDetail(Frame frame, Rect area, List<HistoryEntry> curr
22562266
}
22572267
lines.add(Line.from(Span.raw("")));
22582268

2269+
// Headers
2270+
// Exchange Properties
2271+
if (showHistoryProperties && entry.exchangeProperties != null && !entry.exchangeProperties.isEmpty()) {
2272+
lines.add(Line.from(Span.styled(" Exchange Properties:", Style.EMPTY.fg(Color.GREEN).bold())));
2273+
for (Map.Entry<String, Object> p : entry.exchangeProperties.entrySet()) {
2274+
String type = entry.exchangePropertyTypes != null ? entry.exchangePropertyTypes.get(p.getKey()) : null;
2275+
String typeLabel;
2276+
if (type != null) {
2277+
String t = "(" + type + ")";
2278+
t = truncate(t, 20);
2279+
typeLabel = String.format("%-20s ", t);
2280+
} else {
2281+
typeLabel = String.format("%-21s", "");
2282+
}
2283+
lines.add(Line.from(
2284+
Span.styled(" " + typeLabel, Style.EMPTY.dim()),
2285+
Span.styled(p.getKey(), Style.EMPTY.fg(Color.CYAN)),
2286+
Span.raw(" = "),
2287+
Span.raw(p.getValue() != null ? p.getValue().toString() : "null")));
2288+
}
2289+
lines.add(Line.from(Span.raw("")));
2290+
}
2291+
2292+
// Exchange Variables
2293+
if (showHistoryVariables && entry.exchangeVariables != null && !entry.exchangeVariables.isEmpty()) {
2294+
lines.add(Line.from(Span.styled(" Exchange Variables:", Style.EMPTY.fg(Color.GREEN).bold())));
2295+
for (Map.Entry<String, Object> v : entry.exchangeVariables.entrySet()) {
2296+
String type = entry.exchangeVariableTypes != null ? entry.exchangeVariableTypes.get(v.getKey()) : null;
2297+
String typeLabel;
2298+
if (type != null) {
2299+
String t = "(" + type + ")";
2300+
t = truncate(t, 20);
2301+
typeLabel = String.format("%-20s ", t);
2302+
} else {
2303+
typeLabel = String.format("%-21s", "");
2304+
}
2305+
lines.add(Line.from(
2306+
Span.styled(" " + typeLabel, Style.EMPTY.dim()),
2307+
Span.styled(v.getKey(), Style.EMPTY.fg(Color.CYAN)),
2308+
Span.raw(" = "),
2309+
Span.raw(v.getValue() != null ? v.getValue().toString() : "null")));
2310+
}
2311+
lines.add(Line.from(Span.raw("")));
2312+
}
2313+
22592314
// Headers
22602315
if (showHistoryHeaders && entry.headers != null && !entry.headers.isEmpty()) {
22612316
lines.add(Line.from(Span.styled(" Headers:", Style.EMPTY.fg(Color.GREEN).bold())));
@@ -2444,6 +2499,8 @@ private void renderFooter(Frame frame, Rect area) {
24442499
hint(spans, "Esc", "back");
24452500
hint(spans, "\u2191\u2193", "navigate");
24462501
hint(spans, "PgUp/PgDn", "scroll detail");
2502+
hint(spans, "p", "properties" + (showHistoryProperties ? " [on]" : " [off]"));
2503+
hint(spans, "v", "variables" + (showHistoryVariables ? " [on]" : " [off]"));
24472504
hint(spans, "h", "headers" + (showHistoryHeaders ? " [on]" : " [off]"));
24482505
hint(spans, "b", "body" + (showHistoryBody ? " [on]" : " [off]"));
24492506
hint(spans, "w", "wrap" + (historyWordWrap ? " [on]" : " [off]"));
@@ -2945,6 +3002,42 @@ private HistoryEntry parseHistoryEntry(JsonObject json, String pid) {
29453002
} else if (bodyObj != null) {
29463003
entry.body = bodyObj.toString();
29473004
}
3005+
3006+
Object propsObj = message.get("exchangeProperties");
3007+
if (propsObj instanceof List<?> propList) {
3008+
entry.exchangeProperties = new LinkedHashMap<>();
3009+
entry.exchangePropertyTypes = new LinkedHashMap<>();
3010+
for (Object p : propList) {
3011+
if (p instanceof JsonObject pObj) {
3012+
String key = String.valueOf(pObj.get("key"));
3013+
entry.exchangeProperties.put(key, pObj.get("value"));
3014+
Object type = pObj.get("type");
3015+
if (type != null) {
3016+
entry.exchangePropertyTypes.put(key, TuiHelper.shortTypeName(type.toString()));
3017+
}
3018+
}
3019+
}
3020+
} else if (propsObj instanceof Map) {
3021+
entry.exchangeProperties = new LinkedHashMap<>((Map<String, Object>) propsObj);
3022+
}
3023+
3024+
Object varsObj = message.get("exchangeVariables");
3025+
if (varsObj instanceof List<?> varList) {
3026+
entry.exchangeVariables = new LinkedHashMap<>();
3027+
entry.exchangeVariableTypes = new LinkedHashMap<>();
3028+
for (Object v : varList) {
3029+
if (v instanceof JsonObject vObj) {
3030+
String key = String.valueOf(vObj.get("key"));
3031+
entry.exchangeVariables.put(key, vObj.get("value"));
3032+
Object type = vObj.get("type");
3033+
if (type != null) {
3034+
entry.exchangeVariableTypes.put(key, TuiHelper.shortTypeName(type.toString()));
3035+
}
3036+
}
3037+
}
3038+
} else if (varsObj instanceof Map) {
3039+
entry.exchangeVariables = new LinkedHashMap<>((Map<String, Object>) varsObj);
3040+
}
29483041
}
29493042

29503043
// Exception
@@ -3361,6 +3454,10 @@ static class HistoryEntry {
33613454
String exception;
33623455
Map<String, Object> headers;
33633456
Map<String, String> headerTypes;
3457+
Map<String, Object> exchangeProperties;
3458+
Map<String, String> exchangePropertyTypes;
3459+
Map<String, Object> exchangeVariables;
3460+
Map<String, String> exchangeVariableTypes;
33643461
}
33653462

33663463
record VanishingInfo(IntegrationInfo info, long startTime) {

0 commit comments

Comments
 (0)