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

davsclaus pushed a commit to branch CAMEL-23648-run-folder
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 056885cb60d6e52f1ea85d6e67d6a1837bc95cc9
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Jun 1 10:28:20 2026 +0200

    CAMEL-23648: camel-jbang - TUI Log tab avoid unnecessary render rebuilds
    
    Only reassign filteredLogEntries when log content actually changes (new
    lines arrived or older lines loaded). Previously a new ArrayList was
    created every refresh tick, causing the render to rebuild all styled
    Line objects every 100ms even when idle. Also only refresh the selected
    integration's status on non-Overview tabs, and skip infra discovery.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
---
 .../dsl/jbang/core/commands/tui/CamelMonitor.java  | 38 +++++++++++++++++++---
 1 file changed, 33 insertions(+), 5 deletions(-)

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 c3b48163029a..036e6dec3bfa 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
@@ -1727,6 +1727,7 @@ public class CamelMonitor extends CamelCommand {
             logTab.logLoading = true;
         }
         // Load older lines when scrolled to the top or Home pressed
+        boolean changed = false;
         boolean loadAll = logTab.loadAllRequested;
         if (logTab.logFileStartPos > 0
                 && (loadAll || (!logTab.followMode && logTab.scroll == 0))) {
@@ -1734,6 +1735,7 @@ public class CamelMonitor extends CamelCommand {
             List<String> olderLines = new ArrayList<>();
             logTab.readOlderLogLines(logFileName, loadAll, olderLines);
             if (!olderLines.isEmpty()) {
+                changed = true;
                 List<LogEntry> olderEntries = new ArrayList<>();
                 for (String line : olderLines) {
                     olderEntries.add(LogTab.parseLogLine(line));
@@ -1745,7 +1747,8 @@ public class CamelMonitor extends CamelCommand {
         }
         List<String> newRawLines = new ArrayList<>();
         logTab.readNewLogLinesFromFile(logPid, logFileName, newRawLines);
-        if (!newRawLines.isEmpty()) {
+        changed |= !newRawLines.isEmpty();
+        if (changed) {
             logTab.logTotalLinesRead += newRawLines.size();
             for (String line : newRawLines) {
                 logTab.mutableFilteredEntries.add(LogTab.parseLogLine(line));
@@ -1755,7 +1758,9 @@ public class CamelMonitor extends CamelCommand {
                         .clear();
             }
         }
-        logTab.filteredLogEntries = new 
ArrayList<>(logTab.mutableFilteredEntries);
+        if (changed || logTab.logLoading) {
+            logTab.filteredLogEntries = new 
ArrayList<>(logTab.mutableFilteredEntries);
+        }
         logTab.logLoading = false;
     }
 
@@ -1793,7 +1798,19 @@ public class CamelMonitor extends CamelCommand {
             } else {
                 pids = cachedPids;
             }
-            for (Long pid : pids) {
+
+            // On non-Overview tabs, only refresh the selected integration for 
speed
+            List<Long> refreshPids;
+            if (!fullScan && ctx.selectedPid != null) {
+                try {
+                    refreshPids = List.of(Long.parseLong(ctx.selectedPid));
+                } catch (NumberFormatException e) {
+                    refreshPids = pids;
+                }
+            } else {
+                refreshPids = pids;
+            }
+            for (Long pid : refreshPids) {
                 JsonObject root = loadStatus(pid);
                 if (root != null) {
                     ProcessHandle ph = ProcessHandle.of(pid).orElse(null);
@@ -1811,6 +1828,15 @@ public class CamelMonitor extends CamelCommand {
                     }
                 }
             }
+            // Carry forward non-selected integrations from previous data so 
they don't vanish
+            if (!fullScan && ctx.selectedPid != null) {
+                List<IntegrationInfo> previous = data.get();
+                for (IntegrationInfo prev : previous) {
+                    if (!prev.vanishing && !ctx.selectedPid.equals(prev.pid)) {
+                        infos.add(prev);
+                    }
+                }
+            }
 
             // Detect disappeared integrations and start vanishing
             Set<String> livePids = infos.stream().map(i -> 
i.pid).collect(Collectors.toSet());
@@ -1912,8 +1938,10 @@ public class CamelMonitor extends CamelCommand {
                 }
             }
 
-            // Discover running infra services
-            refreshInfraData();
+            // Discover running infra services (only on Overview or switch 
popup)
+            if (fullScan) {
+                refreshInfraData();
+            }
 
             // Auto-select first infra service when no active integrations 
exist
             if (ctx.selectedPid == null && !infraData.get().isEmpty()

Reply via email to