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


The following commit(s) were added to refs/heads/main by this push:
     new e39a3bb3647c CAMEL-23633: TUI auto-reselect integration after restart
e39a3bb3647c is described below

commit e39a3bb3647cd25aae0fe71ded0f3cceccc9cbe0
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu May 28 10:21:09 2026 +0200

    CAMEL-23633: TUI auto-reselect integration after restart
    
    When a selected integration disappears (process stopped), remember its
    name. When a process with the same name reappears and nothing else has
    been explicitly selected, auto-select it. This lets users stay on detail
    tabs while restarting integrations without losing context. The remembered
    name is cleared on Escape deselection or manual selection change.
    
    Closes #23587
---
 .../dsl/jbang/core/commands/tui/CamelMonitor.java  | 22 ++++++++++++++++++++++
 .../jbang/core/commands/tui/MonitorContext.java    |  1 +
 2 files changed, 23 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 b5388943a95b..d24b31eb7f5a 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
@@ -423,6 +423,7 @@ public class CamelMonitor extends CamelCommand {
                 }
                 if (ctx.selectedPid != null) {
                     ctx.selectedPid = null;
+                    ctx.lastSelectedName = null;
                     return true;
                 }
                 return true;
@@ -792,6 +793,7 @@ public class CamelMonitor extends CamelCommand {
         }
         if (newPid != null && !newPid.equals(ctx.selectedPid)) {
             ctx.selectedPid = newPid;
+            ctx.lastSelectedName = null;
             resetIntegrationTabState();
         }
     }
@@ -805,6 +807,7 @@ public class CamelMonitor extends CamelCommand {
         }
         if (newPid != null && !newPid.equals(ctx.selectedPid)) {
             ctx.selectedPid = newPid;
+            ctx.lastSelectedName = null;
             resetIntegrationTabState();
         }
     }
@@ -1953,6 +1956,13 @@ public class CamelMonitor extends CamelCommand {
                 boolean stillAlive = infos.stream()
                         .anyMatch(i -> ctx.selectedPid.equals(i.pid) && 
!i.vanishing);
                 if (!stillAlive) {
+                    // Remember the name for auto-reselect when the 
integration restarts
+                    IntegrationInfo gone = infos.stream()
+                            .filter(i -> ctx.selectedPid.equals(i.pid))
+                            .findFirst().orElse(null);
+                    if (gone != null) {
+                        ctx.lastSelectedName = gone.name;
+                    }
                     ctx.selectedPid = null;
                 }
             }
@@ -1964,12 +1974,24 @@ public class CamelMonitor extends CamelCommand {
                     if (!info.vanishing && 
autoSelect.equalsIgnoreCase(info.name)) {
                         ctx.selectedPid = info.pid;
                         ctx.infraTableFocused = false;
+                        ctx.lastSelectedName = null;
                         actionsPopup.clearPendingAutoSelect();
                         break;
                     }
                 }
             }
 
+            // Auto-reselect by remembered name when the integration restarts
+            if (ctx.selectedPid == null && ctx.lastSelectedName != null && 
!ctx.infraTableFocused) {
+                for (IntegrationInfo info : infos) {
+                    if (!info.vanishing && 
ctx.lastSelectedName.equalsIgnoreCase(info.name)) {
+                        ctx.selectedPid = info.pid;
+                        ctx.lastSelectedName = null;
+                        break;
+                    }
+                }
+            }
+
             // Discover running infra services
             refreshInfraData();
 
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/MonitorContext.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/MonitorContext.java
index ea5ca61f1a29..69105cfbff78 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/MonitorContext.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/MonitorContext.java
@@ -49,6 +49,7 @@ class MonitorContext {
     TuiRunner runner;
 
     String selectedPid;
+    String lastSelectedName;
     boolean infraTableFocused;
 
     MonitorContext(

Reply via email to