This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch fix/camel-tui-routes in repository https://gitbox.apache.org/repos/asf/camel.git
commit c45e6e0d97784691cc91e7f7a9c8473e52ed14d3 Author: Claus Ibsen <[email protected]> AuthorDate: Sun May 17 09:09:23 2026 +0200 TUI: add p/P keys to start/stop/suspend/resume routes On the Routes tab, p toggles start/stop and P toggles suspend/resume for the selected route. The footer shows context-sensitive hints based on the current route state (p=stop/P=suspend when started, p=start/P=resume when suspended, p=start when stopped). On the Overview tab, p toggles start/stop all routes for the selected integration using stopAllRoutes/startAllRoutes. The footer hint updates dynamically (p=stop when routes are running, p=start when all stopped). Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --- .../dsl/jbang/core/commands/tui/CamelMonitor.java | 93 ++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java index 7e6bf1e6eb0e..10e77513a13e 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java +++ b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/CamelMonitor.java @@ -478,6 +478,15 @@ public class CamelMonitor extends CamelCommand { chartAllIntegrations = !chartAllIntegrations; return true; } + // Overview tab: start/stop all routes for selected integration + if (tab == TAB_OVERVIEW && ke.isChar('p') && selectedPid != null) { + IntegrationInfo selInfo = findSelectedIntegration(); + if (selInfo != null) { + String cmd = selInfo.routeStarted > 0 ? "stop" : "start"; + sendRouteCommand(selectedPid, "*", cmd); + } + return true; + } // Consumers tab: sort if (tab == TAB_CONSUMERS && ke.isCharIgnoreCase('s')) { @@ -541,6 +550,14 @@ public class CamelMonitor extends CamelCommand { } return true; } + if (tab == TAB_ROUTES && !showSource && !showDiagram && ke.isChar('p')) { + toggleRouteStartStop(); + return true; + } + if (tab == TAB_ROUTES && !showSource && !showDiagram && ke.isChar('P')) { + toggleRouteSuspendResume(); + return true; + } if (tab == TAB_ROUTES && showSource) { if (ke.isUp()) { sourceScroll = Math.max(0, sourceScroll - 1); @@ -2190,6 +2207,68 @@ public class CamelMonitor extends CamelCommand { }); } + private void toggleRouteStartStop() { + if (selectedPid == null) { + return; + } + IntegrationInfo info = findSelectedIntegration(); + if (info == null || info.routes.isEmpty()) { + return; + } + List<RouteInfo> sortedRoutes = new ArrayList<>(info.routes); + sortedRoutes.sort(this::sortRoute); + Integer sel = routeTableState.selected(); + RouteInfo route = (sel != null && sel >= 0 && sel < sortedRoutes.size()) + ? sortedRoutes.get(sel) : sortedRoutes.get(0); + // Started → stop; Stopped or Suspended → start + String command = "Started".equals(route.state) ? "stop" : "start"; + sendRouteCommand(selectedPid, route.routeId, command); + } + + private void toggleRouteSuspendResume() { + if (selectedPid == null) { + return; + } + IntegrationInfo info = findSelectedIntegration(); + if (info == null || info.routes.isEmpty()) { + return; + } + List<RouteInfo> sortedRoutes = new ArrayList<>(info.routes); + sortedRoutes.sort(this::sortRoute); + Integer sel = routeTableState.selected(); + RouteInfo route = (sel != null && sel >= 0 && sel < sortedRoutes.size()) + ? sortedRoutes.get(sel) : sortedRoutes.get(0); + // Started → suspend; Suspended → resume; Stopped → start + String command = switch (route.state != null ? route.state : "") { + case "Started" -> "suspend"; + case "Suspended" -> "resume"; + default -> "start"; + }; + sendRouteCommand(selectedPid, route.routeId, command); + } + + private void sendRouteCommand(String pid, String routeId, String command) { + JsonObject root = new JsonObject(); + root.put("action", "route"); + root.put("id", routeId); + root.put("command", command); + Path actionFile = getActionFile(pid); + org.apache.camel.dsl.jbang.core.common.PathUtils.writeTextSafely(root.toJson(), actionFile); + } + + private String selectedRouteState() { + IntegrationInfo info = findSelectedIntegration(); + if (info == null || info.routes.isEmpty()) { + return null; + } + List<RouteInfo> sortedRoutes = new ArrayList<>(info.routes); + sortedRoutes.sort(this::sortRoute); + Integer sel = routeTableState.selected(); + RouteInfo route = (sel != null && sel >= 0 && sel < sortedRoutes.size()) + ? sortedRoutes.get(sel) : sortedRoutes.get(0); + return route.state; + } + private void loadSourceInBackground(String pid, String routeId) { Path outputFile = getOutputFile(pid); PathUtils.deleteFile(outputFile); @@ -3463,6 +3542,10 @@ public class CamelMonitor extends CamelCommand { hint(spans, "a", "chart " + (chartAllIntegrations ? "[all]" : "[single]")); hint(spans, "Enter", "details"); if (selectedPid != null) { + IntegrationInfo selInfo = findSelectedIntegration(); + if (selInfo != null) { + hint(spans, "p", selInfo.routeStarted > 0 ? "stop" : "start"); + } hint(spans, "Esc", "unselect"); } hint(spans, "1-9", "tabs"); @@ -3490,6 +3573,16 @@ public class CamelMonitor extends CamelCommand { hint(spans, "c", "source"); hint(spans, "d", "diagram"); hint(spans, "D", "text diagram"); + String routeState = selectedRouteState(); + if ("Started".equals(routeState)) { + hint(spans, "p", "stop"); + hint(spans, "P", "suspend"); + } else if ("Suspended".equals(routeState)) { + hint(spans, "p", "start"); + hint(spans, "P", "resume"); + } else if (routeState != null) { + hint(spans, "p", "start"); + } hint(spans, "1-9", "tabs"); } else if (tab == TAB_CONSUMERS) { hint(spans, "Esc", "back");
