This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch feature/CAMEL-23672-tui-diagram in repository https://gitbox.apache.org/repos/asf/camel.git
commit ccfcce14d17068fabc7268df73123a22de015945 Author: Claus Ibsen <[email protected]> AuthorDate: Thu Jun 4 07:20:50 2026 +0200 CAMEL-23672: camel-tui - Add burst mode for faster process scanning after actions After launching, stopping, restarting, or toggling routes, temporarily reduce the full process scan interval from 2s to 1s for 20 seconds, making the overview tab more responsive when changes are expected. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../dsl/jbang/core/commands/tui/ActionsPopup.java | 10 ++++++++-- .../dsl/jbang/core/commands/tui/CamelMonitor.java | 20 +++++++++++++++++--- .../dsl/jbang/core/commands/tui/StopAllPopup.java | 10 +++++++++- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ActionsPopup.java b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ActionsPopup.java index c37c0738799c..2404676351ce 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ActionsPopup.java +++ b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/ActionsPopup.java @@ -97,6 +97,7 @@ class ActionsPopup { private final Runnable toggleKeystrokes; private final Supplier<Boolean> keystrokesEnabled; private final Runnable toggleTapeRecording; + private final Runnable burstCallback; private Runnable resetStatsAction; private Runnable resetScreenAction; private final Supplier<Boolean> tapeRecordingActive; @@ -159,7 +160,8 @@ class ActionsPopup { ActionsPopup(Supplier<Set<String>> runningNames, Supplier<List<IntegrationInfo>> integrations, Supplier<List<InfraInfo>> infraServices, CaptionOverlay captionOverlay, Runnable screenshotAction, Runnable toggleKeystrokes, Supplier<Boolean> keystrokesEnabled, - Runnable toggleTapeRecording, Supplier<Boolean> tapeRecordingActive) { + Runnable toggleTapeRecording, Supplier<Boolean> tapeRecordingActive, + Runnable burstCallback) { this.runningNames = runningNames; this.integrations = integrations; this.infraServices = infraServices; @@ -169,7 +171,8 @@ class ActionsPopup { this.keystrokesEnabled = keystrokesEnabled; this.toggleTapeRecording = toggleTapeRecording; this.tapeRecordingActive = tapeRecordingActive; - this.stopAllPopup = new StopAllPopup(integrations, infraServices); + this.burstCallback = burstCallback; + this.stopAllPopup = new StopAllPopup(integrations, infraServices, burstCallback); } void setContext(MonitorContext ctx) { @@ -1300,6 +1303,7 @@ class ActionsPopup { Process process = pb.start(); pendingLaunches.add(new PendingLaunch(displayName, process, outputFile, System.currentTimeMillis())); pendingAutoSelect = displayName; + burstCallback.run(); setNotification("Starting: " + displayName, false); } catch (Exception e) { setNotification("Failed to start: " + folder + " - " + e.getMessage(), true); @@ -1801,6 +1805,7 @@ class ActionsPopup { pb.redirectOutput(outputFile.toFile()); Process process = pb.start(); pendingLaunches.add(new PendingLaunch(alias, process, outputFile, System.currentTimeMillis())); + burstCallback.run(); setNotification("Starting infra: " + alias, false); // force reload next time browser opens infraCatalog = null; @@ -1851,6 +1856,7 @@ class ActionsPopup { Process process = pb.start(); pendingLaunches.add(new PendingLaunch(displayName, process, outputFile, System.currentTimeMillis())); pendingAutoSelect = displayName; + burstCallback.run(); setNotification("Starting: " + displayName, false); } catch (Exception e) { setNotification("Failed to start: " + exampleName + " - " + e.getMessage(), true); 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 f3f03a59f330..d0ec5640685d 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 @@ -198,9 +198,10 @@ public class CamelMonitor extends CamelCommand { private final Map<String, LoadAvg> cpuLoadAvg = new ConcurrentHashMap<>(); private final Map<String, long[]> prevCpuSample = new ConcurrentHashMap<>(); - // Cached PID list — full process scan throttled to every 2 seconds + // Cached PID list — full process scan throttled to every 2 seconds (1 second in burst mode) private volatile List<Long> cachedPids = Collections.emptyList(); private volatile long lastFullScanTime; + private volatile long burstModeUntil; // Trace/history data — shared between CamelMonitor and tabs private final AtomicReference<List<TraceEntry>> traces = new AtomicReference<>(Collections.emptyList()); @@ -245,7 +246,8 @@ public class CamelMonitor extends CamelCommand { () -> recording = !recording, () -> recording, this::toggleTapeRecording, - () -> tapeRecorder != null && tapeRecorder.isActive()); + () -> tapeRecorder != null && tapeRecorder.isActive(), + this::enableBurstMode); private final AtomicBoolean refreshInProgress = new AtomicBoolean(false); private TuiRunner runner; @@ -1346,6 +1348,7 @@ public class CamelMonitor extends CamelCommand { } private void stopSelectedProcess(boolean forceKill) { + enableBurstMode(); if (ctx.selectedPid == null) { return; } @@ -1386,6 +1389,7 @@ public class CamelMonitor extends CamelCommand { } private void restartSelectedProcess() { + enableBurstMode(); if (ctx.selectedPid == null || isInfraSelected()) { return; } @@ -1466,6 +1470,14 @@ public class CamelMonitor extends CamelCommand { } } + private void enableBurstMode() { + burstModeUntil = System.currentTimeMillis() + 20_000; + } + + private boolean isBurstMode() { + return System.currentTimeMillis() < burstModeUntil; + } + private void setNotification(String message, boolean error) { monitorNotification = message; monitorNotificationError = error; @@ -1544,6 +1556,7 @@ public class CamelMonitor extends CamelCommand { } private void sendRouteCommand(String pid, String routeId, String command) { + enableBurstMode(); JsonObject root = new JsonObject(); root.put("action", "route"); root.put("id", routeId); @@ -1814,7 +1827,8 @@ public class CamelMonitor extends CamelCommand { List<IntegrationInfo> infos = new ArrayList<>(); long now = System.currentTimeMillis(); boolean wantFullScan = tabsState.selected() == TAB_OVERVIEW || showSwitchPopup || cachedPids.isEmpty(); - boolean fullScan = wantFullScan && (now - lastFullScanTime >= 2000); + long scanInterval = isBurstMode() ? 1000 : 2000; + boolean fullScan = wantFullScan && (now - lastFullScanTime >= scanInterval); List<Long> pids; if (fullScan) { pids = findPids(name); diff --git a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/StopAllPopup.java b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/StopAllPopup.java index bbf7d69750de..62de8db3b0bd 100644 --- a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/StopAllPopup.java +++ b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/StopAllPopup.java @@ -42,6 +42,7 @@ class StopAllPopup { private final Supplier<List<IntegrationInfo>> integrations; private final Supplier<List<InfraInfo>> infraServices; + private final Runnable burstCallback; private boolean visible; private boolean checkIntegrations = true; @@ -52,9 +53,11 @@ class StopAllPopup { private String notification; - StopAllPopup(Supplier<List<IntegrationInfo>> integrations, Supplier<List<InfraInfo>> infraServices) { + StopAllPopup(Supplier<List<IntegrationInfo>> integrations, Supplier<List<InfraInfo>> infraServices, + Runnable burstCallback) { this.integrations = integrations; this.infraServices = infraServices; + this.burstCallback = burstCallback; } boolean isVisible() { @@ -82,10 +85,12 @@ class StopAllPopup { if (integrationCount > 0 && infraCount == 0) { stopIntegrations(); + burstCallback.run(); return; } if (infraCount > 0 && integrationCount == 0) { stopInfraServices(); + burstCallback.run(); return; } @@ -175,6 +180,9 @@ class StopAllPopup { if (checkInfra) { stoppedInfra = stopInfraServices(); } + if (stoppedInt > 0 || stoppedInfra > 0) { + burstCallback.run(); + } if (stoppedInt == 0 && stoppedInfra == 0 && notification == null) { notification = "Nothing selected to stop"; }
