This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 81f882461848 CAMEL-26699: camel-jbang - the chaos mark of an exchange
on the Activity tab is not cut (#29362)
81f882461848 is described below
commit 81f8824618482a8d6d8f116dbbebc42955b10088
Author: Claus Ibsen <[email protected]>
AuthorDate: Fri Nov 6 22:56:49 2026 +0100
CAMEL-26699: camel-jbang - the chaos mark of an exchange on the Activity
tab is not cut (#29362)
Signed-off-by: Claus Ibsen <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
---
.../camel/dsl/jbang/core/commands/tui/ActivityTab.java | 13 ++++++++++---
.../dsl/jbang/core/commands/tui/ChaosMarksTest.java | 17 +++++++++--------
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ActivityTab.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ActivityTab.java
index 1e42c8ced797..3d2775e59d1a 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ActivityTab.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ActivityTab.java
@@ -26,6 +26,7 @@ import dev.tamboui.layout.Layout;
import dev.tamboui.layout.Rect;
import dev.tamboui.style.Style;
import dev.tamboui.terminal.Frame;
+import dev.tamboui.text.CharWidth;
import dev.tamboui.text.Line;
import dev.tamboui.text.Span;
import dev.tamboui.text.Text;
@@ -145,6 +146,7 @@ class ActivityTab extends AbstractTableTab {
List<ActivityEntry> sorted = filteredActivity(info);
List<Row> rows = new ArrayList<>();
+ int exchangeWidth = 16;
for (ActivityEntry ae : sorted) {
String ago = ae.timestamp > 0
? TimeUtils.printSince(ae.timestamp) : "";
@@ -154,10 +156,15 @@ class ActivityTab extends AbstractTableTab {
String sends = ae.endpointSends.isEmpty() ? "" :
String.valueOf(ae.endpointSends.size());
+ String rule = ChaosMarks.ruleOf(ctx, info, ae.exchangeId, null);
+ if (rule != null) {
+ // the id and its mark, " 🎲r1": the dice is two columns wide
(CAMEL-26699)
+ exchangeWidth = Math.max(exchangeWidth,
+ CharWidth.of(shortExchangeId(ae.exchangeId) + " " +
TuiIcons.TAB_CHAOS + rule));
+ }
rows.add(Row
.from(
- ChaosMarks.cell(shortExchangeId(ae.exchangeId),
Style.EMPTY,
- ChaosMarks.ruleOf(ctx, info,
ae.exchangeId, null)),
+ ChaosMarks.cell(shortExchangeId(ae.exchangeId),
Style.EMPTY, rule),
Cell.from(Span.styled(ae.routeId != null ?
ae.routeId : "", Style.EMPTY.fg(Theme.accent()))),
Cell.from(Span.styled(status, statusStyle)),
Cell.from(elapsed),
@@ -203,7 +210,7 @@ class ActivityTab extends AbstractTableTab {
Cell.from(Span.styled(sortLabel("SINCE", "since"),
sortStyle("since"))),
Cell.from(Span.styled("ENDPOINT",
Style.EMPTY.bold()))))
.widths(
- Constraint.length(16),
+ Constraint.length(exchangeWidth),
Constraint.length(20),
Constraint.length(8),
Constraint.length(10),
diff --git
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/ChaosMarksTest.java
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/ChaosMarksTest.java
index 43c79a98c70b..da14322f138b 100644
---
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/ChaosMarksTest.java
+++
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/ChaosMarksTest.java
@@ -50,7 +50,7 @@ class ChaosMarksTest {
"rules": [{"id": "r1", "version": 1, "state": "active",
"rule": "endpoint=http:stock* error status=503"}],
"report": {"verdict": "PASS", "final": true, "seed": 42,
"recentFaults": [{"ago": 2000, "rule": "r1",
"fault": "error status 503", "hook": "send",
- "route": "orders", "exchangeId":
"3F2A85F3D4213-0000000000000001E"}]}}
+ "route": "orders", "exchangeId":
"3F2A85F3D4213-000000000000104E"}]}}
"""));
ctx = new MonitorContext(new AtomicReference<>(List.of(info)), new
AtomicReference<>(List.of()));
ctx.selectedPid = "1234";
@@ -59,13 +59,13 @@ class ChaosMarksTest {
@Test
void theRuleOfAnExchange() {
- assertThat(ChaosMarks.ruleOf(ctx, info,
"3F2A85F3D4213-0000000000000001E", null)).isEqualTo("r1");
+ assertThat(ChaosMarks.ruleOf(ctx, info,
"3F2A85F3D4213-000000000000104E", null)).isEqualTo("r1");
assertThat(ChaosMarks.ruleOf(ctx, info, "OTHER", null)).isNull();
// the property of the exchange, when there are properties
assertThat(ChaosMarks.ruleOf(ctx, info, "OTHER",
Map.of(ChaosMarks.PROPERTY, "r7"))).isEqualTo("r7");
// no marks without chaos
info.chaos = null;
- assertThat(ChaosMarks.ruleOf(ctx, info,
"3F2A85F3D4213-0000000000000001E", null)).isNull();
+ assertThat(ChaosMarks.ruleOf(ctx, info,
"3F2A85F3D4213-000000000000104E", null)).isNull();
}
@Test
@@ -88,15 +88,16 @@ class ChaosMarksTest {
@Test
void theMarksOfAStoppedIntegrationAreForgotten() {
ctx.chaosMarks.retain(Set.of("1234"));
- assertThat(ctx.chaosMarks.ruleOf("1234",
"3F2A85F3D4213-0000000000000001E")).isEqualTo("r1");
+ assertThat(ctx.chaosMarks.ruleOf("1234",
"3F2A85F3D4213-000000000000104E")).isEqualTo("r1");
ctx.chaosMarks.retain(Set.of("5678"));
- assertThat(ctx.chaosMarks.ruleOf("1234",
"3F2A85F3D4213-0000000000000001E")).isNull();
+ assertThat(ctx.chaosMarks.ruleOf("1234",
"3F2A85F3D4213-000000000000104E")).isNull();
}
@Test
void theActivityTabMarksTheExchange() {
ActivityEntry faulted = new ActivityEntry();
- faulted.exchangeId = "3F2A85F3D4213-0000000000000001E";
+ // a real id: the short form has four characters after the dash, so
the mark needs a wider column
+ faulted.exchangeId = "3F2A85F3D4213-000000000000104E";
faulted.routeId = "orders";
faulted.failed = true;
faulted.timestamp = System.currentTimeMillis();
@@ -111,7 +112,7 @@ class ChaosMarksTest {
tab.navigateDown();
// the dice is two columns wide: the screen has a blank cell after it
String screen = TuiTestHelper.renderToString(tab, 160,
40).replace(TuiIcons.TAB_CHAOS + " ", TuiIcons.TAB_CHAOS);
- assertThat(screen).contains("3F2A85…-1E " + TuiIcons.TAB_CHAOS + "r1");
+ assertThat(screen).contains("3F2A85…-104E " + TuiIcons.TAB_CHAOS + "r1
");
// the other exchange is not faulted
assertThat(screen).doesNotContain("3F2A85…-1F " + TuiIcons.TAB_CHAOS);
assertThat(screen).contains("injected by chaos rule
r1").contains("endpoint=http:stock* error status=503");
@@ -139,7 +140,7 @@ class ChaosMarksTest {
List<Line> lines = new ArrayList<>();
ChaosMarks.addDetailLine(lines, ctx, info, "OTHER", null);
assertThat(lines).isEmpty();
- ChaosMarks.addDetailLine(lines, ctx, info,
"3F2A85F3D4213-0000000000000001E", null);
+ ChaosMarks.addDetailLine(lines, ctx, info,
"3F2A85F3D4213-000000000000104E", null);
assertThat(lines).hasSize(1);
}
}