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

davsclaus pushed a commit to branch chore-tui-about-strip-order
in repository https://gitbox.apache.org/repos/asf/camel.git

commit efa70b0d7820ef6364445baaf17b0eaa59289961
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Nov 9 18:17:01 2026 +0100

    chore: camel-jbang - the strips of What happened are in the order of the 
routes, a called route after its caller
    
    The integration lists its routes by id, and the strips took that order: in
    the enrich-and-dedupe example audit came before incoming-orders, the route
    everything starts with, and in dynamic-routing the entry route was the third
    of eight. The strips follow the Routes panel now, where a route comes after
    the one that calls it, then the routes the panel does not have.
    
    Co-Authored-By: Claude Opus 5.5 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../dsl/jbang/core/commands/tui/AboutView.java     | 23 ++++++++++--
 .../dsl/jbang/core/commands/tui/AboutViewTest.java | 41 ++++++++++++++++++++++
 2 files changed, 62 insertions(+), 2 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/AboutView.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/AboutView.java
index 61a3aede2c51..281b3c5eaef7 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/AboutView.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/AboutView.java
@@ -443,8 +443,27 @@ final class AboutView {
         return last;
     }
 
-    private static List<String> routeOrder(IntegrationInfo info) {
-        return info.routes.stream().map(r -> r.routeId).filter(id -> id != 
null).toList();
+    /**
+     * The routes in the order of the Routes panel, where a route comes after 
the one that calls it, then those it does
+     * not have; the integration lists its routes by id, which puts a called 
route before its caller.
+     */
+    private List<String> routeOrder(IntegrationInfo info) {
+        List<String> running = info.routes.stream().map(r -> 
r.routeId).filter(id -> id != null).toList();
+        List<String> order = new ArrayList<>();
+        About.Model m = model;
+        if (m != null) {
+            for (About.RouteLine r : m.routes()) {
+                if (running.contains(r.routeId()) && 
!order.contains(r.routeId())) {
+                    order.add(r.routeId());
+                }
+            }
+        }
+        for (String id : running) {
+            if (!order.contains(id)) {
+                order.add(id);
+            }
+        }
+        return order;
     }
 
     /**
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/AboutViewTest.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/AboutViewTest.java
index e70c554163ad..00a015c271b7 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/AboutViewTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/AboutViewTest.java
@@ -290,6 +290,47 @@ class AboutViewTest {
         return List.of(TuiTestHelper.borderColor(buffer, " In "), 
TuiTestHelper.borderColor(buffer, " Routes "));
     }
 
+    @Test
+    void theStripsAreInTheOrderOfTheRoutesACalledRouteAfterItsCaller() throws 
Exception {
+        Files.writeString(dir.resolve("orders.camel.yaml"), """
+                - route:
+                    id: incoming
+                    from:
+                      uri: timer:orders
+                      steps:
+                        - wireTap: direct:audit
+                - route:
+                    id: audit
+                    from:
+                      uri: direct:audit
+                      steps:
+                        - log: audited
+                """);
+        IntegrationInfo info = new IntegrationInfo();
+        info.pid = "1234";
+        info.name = "orders";
+        info.directory = dir.toString();
+        // the integration lists its routes by id: the called one first
+        for (String id : List.of("audit", "incoming")) {
+            RouteInfo r = new RouteInfo();
+            r.routeId = id;
+            r.state = "Started";
+            info.routes.add(r);
+        }
+        MonitorContext ctx = new MonitorContext(new 
AtomicReference<>(List.of(info)), new AtomicReference<>(List.of()));
+        ctx.timeline.merge("1234", TimelineTabRenderTest.outage(T0 / 1000 + 
59, 60, 0).json(), true);
+        AboutView about = new AboutView(ctx);
+
+        await().atMost(20, TimeUnit.SECONDS).untilAsserted(() -> {
+            List<String> strips = render(about, info).lines()
+                    .dropWhile(l -> !l.contains("What happened"))
+                    .filter(l -> l.contains("    incoming ") || l.contains("   
 audit ")).toList();
+            assertThat(strips).hasSize(2);
+            assertThat(strips.get(0)).contains("incoming");
+            assertThat(strips.get(1)).contains("audit");
+        });
+    }
+
     @Test
     void aboutAnIntegrationWithWhatHasHappened() throws Exception {
         Files.writeString(dir.resolve("shop.camel.yaml"), """

Reply via email to