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

commit 5b4f56b088b1dd90d2615926bb258cc6763b91cc
Author: Claus Ibsen <[email protected]>
AuthorDate: Tue Jul 14 15:18:55 2026 +0200

    camel-tui - Make tui_get_table read data without switching the visible tab
    
    getTableData() was calling navigateToTab() which changed the screen the
    user sees. Add MonitorTab reference to TabEntry and use the existing tab
    registry to look up tab instances by name, so tui_get_table reads data
    in the background without any visible navigation side-effect.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../dsl/jbang/core/commands/tui/McpFacade.java     |  8 +++--
 .../dsl/jbang/core/commands/tui/TabRegistry.java   | 39 ++++++++++++++++------
 2 files changed, 33 insertions(+), 14 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/McpFacade.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/McpFacade.java
index ef5d9983e424..29a19a97f7a1 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/McpFacade.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/McpFacade.java
@@ -382,13 +382,15 @@ class McpFacade {
     // ---- Data access ----
 
     JsonObject getTableData(String tabName) {
+        MonitorTab tab;
         if (tabName != null && !tabName.isBlank()) {
-            String switched = navigateToTab(tabName);
-            if (switched == null) {
+            tab = tabRegistry.findTabByName(tabName);
+            if (tab == null) {
                 return null;
             }
+        } else {
+            tab = bridge.activeTab();
         }
-        MonitorTab tab = bridge.activeTab();
         return tab != null ? tab.getTableDataAsJson() : null;
     }
 
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TabRegistry.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TabRegistry.java
index 06c9d3ffdeff..1a62be602b91 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TabRegistry.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/TabRegistry.java
@@ -194,6 +194,15 @@ class TabRegistry {
         };
     }
 
+    MonitorTab findTabByName(String name) {
+        for (TabEntry entry : allTabEntries()) {
+            if (entry.name().equalsIgnoreCase(name)) {
+                return entry.tab();
+            }
+        }
+        return null;
+    }
+
     MonitorTab getActiveMoreTab() {
         return activeMoreTab;
     }
@@ -353,7 +362,12 @@ class TabRegistry {
 
     // ---- Tab entries for Go-to and MCP ----
 
-    record TabEntry(String icon, String name, String description, String 
shortcut, int tabIndex, int moreIndex) {
+    record TabEntry(String icon, String name, String description, String 
shortcut, int tabIndex, int moreIndex,
+            MonitorTab tab) {
+
+        TabEntry(String icon, String name, String description, String 
shortcut, int tabIndex, int moreIndex) {
+            this(icon, name, description, shortcut, tabIndex, moreIndex, null);
+        }
     }
 
     /**
@@ -401,20 +415,23 @@ class TabRegistry {
 
     List<TabEntry> allTabEntries() {
         List<TabEntry> entries = new ArrayList<>();
-        entries.add(new TabEntry(icon(TAB_OVERVIEW), "Overview", 
overviewTab.description(), "1", TAB_OVERVIEW, -1));
-        entries.add(new TabEntry(icon(TAB_LOG), "Log", logTab.description(), 
"2", TAB_LOG, -1));
-        entries.add(new TabEntry(icon(TAB_ACTIVITY), "Activity", 
activityTab.description(), "3", TAB_ACTIVITY, -1));
-        entries.add(new TabEntry(icon(TAB_DIAGRAM), "Diagram", 
diagramTab.description(), "4", TAB_DIAGRAM, -1));
-        entries.add(new TabEntry(icon(TAB_ROUTES), "Routes", 
routesTab.description(), "5", TAB_ROUTES, -1));
-        entries.add(new TabEntry(icon(TAB_ENDPOINTS), "Endpoints", 
endpointsTab.description(), "6", TAB_ENDPOINTS, -1));
-        entries.add(new TabEntry(icon(TAB_HTTP), "HTTP", 
httpTab.description(), "7", TAB_HTTP, -1));
-        entries.add(new TabEntry(icon(TAB_HISTORY), "Inspect", 
historyTab.description(), "8", TAB_HISTORY, -1));
-        entries.add(new TabEntry(icon(TAB_ERRORS), "Errors", 
errorsTab.description(), "9", TAB_ERRORS, -1));
+        entries.add(
+                new TabEntry(icon(TAB_OVERVIEW), "Overview", 
overviewTab.description(), "1", TAB_OVERVIEW, -1, overviewTab));
+        entries.add(new TabEntry(icon(TAB_LOG), "Log", logTab.description(), 
"2", TAB_LOG, -1, logTab));
+        entries.add(
+                new TabEntry(icon(TAB_ACTIVITY), "Activity", 
activityTab.description(), "3", TAB_ACTIVITY, -1, activityTab));
+        entries.add(new TabEntry(icon(TAB_DIAGRAM), "Diagram", 
diagramTab.description(), "4", TAB_DIAGRAM, -1, diagramTab));
+        entries.add(new TabEntry(icon(TAB_ROUTES), "Routes", 
routesTab.description(), "5", TAB_ROUTES, -1, routesTab));
+        entries.add(new TabEntry(
+                icon(TAB_ENDPOINTS), "Endpoints", endpointsTab.description(), 
"6", TAB_ENDPOINTS, -1, endpointsTab));
+        entries.add(new TabEntry(icon(TAB_HTTP), "HTTP", 
httpTab.description(), "7", TAB_HTTP, -1, httpTab));
+        entries.add(new TabEntry(icon(TAB_HISTORY), "Inspect", 
historyTab.description(), "8", TAB_HISTORY, -1, historyTab));
+        entries.add(new TabEntry(icon(TAB_ERRORS), "Errors", 
errorsTab.description(), "9", TAB_ERRORS, -1, errorsTab));
         for (int i = 0; i < moreTabs.size(); i++) {
             MoreTab mt = moreTabs.get(i);
             entries.add(new TabEntry(
                     mt.icon(), mt.name(), mt.tab().description(), 
String.valueOf(mt.shortcut()),
-                    TAB_MORE, i));
+                    TAB_MORE, i, mt.tab()));
         }
         return entries;
     }

Reply via email to