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

davsclaus pushed a commit to branch camel-jbang-diagram-zoom
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 1d565611d8334896ba44036f06fe81854ffac205
Author: Claus Ibsen <[email protected]>
AuthorDate: Sun Oct 25 14:30:41 2026 +0100

    chore: camel-jbang - route diagram: compact is the default zoom level
    
    Boxes of one line fit about twice the steps of the detailed level on a
    screen. The detailed level is kept as the setting once chosen.
    
    Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../modules/ROOT/pages/camel-jbang-tui-diagram.adoc    |  5 +++--
 .../dsl/jbang/core/commands/tui/RouteDiagramZoom.java  | 12 ++++++++----
 .../src/main/resources/tui/help/diagram.md             |  2 +-
 .../src/main/resources/tui/help/routes.md              |  2 +-
 .../jbang/core/commands/tui/RouteDiagramZoomTest.java  | 18 ++++++++++++++++--
 5 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/docs/user-manual/modules/ROOT/pages/camel-jbang-tui-diagram.adoc 
b/docs/user-manual/modules/ROOT/pages/camel-jbang-tui-diagram.adoc
index f38793542a4e..ce2c7b874ab8 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-jbang-tui-diagram.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-jbang-tui-diagram.adoc
@@ -60,11 +60,12 @@ image::jbang/camel-tui-diagram-route.png[The checkout route 
drilled into, with t
 A large route takes a lot of screen. Press *-* to zoom out and *+* to zoom in, 
through three levels:
 
 * *detailed*: a box per step, with up to three lines of text
-* *compact*: a box per step with one line of text, and the steps closer 
together: about twice as many steps fit
+* *compact* (the default): a box per step with one line of text, and the steps 
closer together: about twice as many
+steps fit
 * *bare*: no boxes, each step is a mark and its text on one row (`▶` the from, 
`◆` a step with steps in it, `◇` a
 branch, `●` a step), with the counts beside the lines between them
 
-Press *z* for fit: the most detailed level in which the whole route fits the 
screen. The view bar shows the level and
+The level you choose is kept for the next start. Press *z* for fit: the most 
detailed level in which the whole route fits the screen. The view bar shows the 
level and
 where it is among the three (`zoom: compact 2/3`, or `zoom: fit bare 3/3`), 
and the title of the diagram how many steps
 the route has, so you can tell a large route at a glance, and how many of them 
are folded (`38 steps · 12 folded`). Zooming keeps the selected step selected, 
on the same row of the screen, and
 the Info panel has the whole text of the selected step at every level.
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteDiagramZoom.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteDiagramZoom.java
index f4e6428f56bf..d6d28e1d63f4 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteDiagramZoom.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteDiagramZoom.java
@@ -56,7 +56,10 @@ final class RouteDiagramZoom {
     record Restore(int index, int row, int screenRow) {
     }
 
-    private volatile RouteDensity density = RouteDensity.DETAILED;
+    /** The density until another is chosen: boxes of one line, about twice 
the steps of the detailed on a screen. */
+    static final RouteDensity DEFAULT = RouteDensity.COMPACT;
+
+    private volatile RouteDensity density = DEFAULT;
     private volatile boolean fit;
     /** The folded blocks of each route: the ids of their first steps. */
     private final Map<String, Set<String>> folded = new ConcurrentHashMap<>();
@@ -91,17 +94,17 @@ final class RouteDiagramZoom {
         }
     }
 
-    /** The density, or fit; null for the default (detailed), so the file does 
not carry it. */
+    /** The density, or fit; null for the default (compact), so the file does 
not carry it. */
     String setting() {
         if (fit) {
             return "fit";
         }
-        return density == RouteDensity.DETAILED ? null : density.label();
+        return density == DEFAULT ? null : density.label();
     }
 
     void setting(String value) {
         fit = "fit".equals(value);
-        density = RouteDensity.DETAILED;
+        density = DEFAULT;
         for (RouteDensity d : RouteDensity.values()) {
             if (d.label().equals(value)) {
                 density = d;
@@ -143,6 +146,7 @@ final class RouteDiagramZoom {
 
     RouteDensity densityOf(LayoutRoute lr) {
         RouteDensity d = densities.get(lr);
+        // a layout the zoom did not make is the engine's
         return d != null ? d : RouteDensity.DETAILED;
     }
 
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/diagram.md 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/diagram.md
index 7c9c1f8702cd..7fca1ebd2ab5 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/diagram.md
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/diagram.md
@@ -242,7 +242,7 @@ you an at-a-glance view of where you are in the route.
   arrows into the steps
 - `g` — go to node (fuzzy search popup)
 - `+` / `-` — zoom in or out: detailed (boxes with up to three lines),
-  compact (boxes with one line, the steps closer together) and bare (a
+  compact (the default: boxes with one line, the steps closer together) and 
bare (a
   mark and the text of each step on one row, no boxes); the view bar
   shows the level and where it is (`compact 2/3`), the title how many
   steps the route has and how many are folded (`38 steps · 12 folded`);
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/routes.md 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/routes.md
index cf3300829696..763ddfd2a24a 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/routes.md
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/resources/tui/help/routes.md
@@ -163,7 +163,7 @@ in the diagram.
 - `d` — toggle detail panel (EIP/component catalog docs)
 - `g` — go to node (fuzzy search popup)
 - `+` / `-` — zoom in or out: detailed (boxes with up to three lines),
-  compact (boxes with one line, the steps closer together) and bare (a
+  compact (the default: boxes with one line, the steps closer together) and 
bare (a
   mark and the text of each step on one row, no boxes); the view bar
   shows the level and where it is (`compact 2/3`), the title how many
   steps the route has and how many are folded (`38 steps · 12 folded`);
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteDiagramZoomTest.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteDiagramZoomTest.java
index 74f6e64aeee4..e9e8f35dd14f 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteDiagramZoomTest.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/test/java/org/apache/camel/dsl/jbang/core/commands/tui/RouteDiagramZoomTest.java
@@ -142,9 +142,20 @@ class RouteDiagramZoomTest {
         return sb.toString();
     }
 
+    @Test
+    void theDefaultIsCompact() {
+        RouteDiagramZoom zoom = new RouteDiagramZoom();
+        assertThat(zoom.density()).isEqualTo(RouteDensity.COMPACT);
+        LayoutRoute lr = layout(zoom, 0);
+        assertThat(zoom.densityOf(lr)).isEqualTo(RouteDensity.COMPACT);
+        assertThat(zoom.label(lr)).isEqualTo("compact 2/3");
+    }
+
     @Test
     void zoomOutAndFit() {
         RouteDiagramZoom zoom = new RouteDiagramZoom();
+        zoom.zoomIn();
+        assertThat(zoom.density()).isEqualTo(RouteDensity.DETAILED);
         int detailed = RouteDensity.rows(layout(zoom, 0));
         zoom.zoomOut();
         LayoutRoute compact = layout(zoom, 0);
@@ -195,7 +206,10 @@ class RouteDiagramZoomTest {
         RouteDiagramZoom zoom = new RouteDiagramZoom();
         assertThat(zoom.setting()).isNull();
         zoom.zoomOut();
-        assertThat(zoom.setting()).isEqualTo("compact");
+        assertThat(zoom.setting()).isEqualTo("bare");
+        zoom.zoomIn();
+        zoom.zoomIn();
+        assertThat(zoom.setting()).isEqualTo("detailed");
         zoom.toggleFit();
         assertThat(zoom.setting()).isEqualTo("fit");
 
@@ -205,7 +219,7 @@ class RouteDiagramZoomTest {
         again.setting("fit");
         assertThat(again.isFit()).isTrue();
         again.setting("nonsense");
-        assertThat(again.density()).isEqualTo(RouteDensity.DETAILED);
+        assertThat(again.density()).isEqualTo(RouteDensity.COMPACT);
         assertThat(again.isFit()).isFalse();
     }
 }

Reply via email to