This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch fix/CAMEL-23633 in repository https://gitbox.apache.org/repos/asf/camel.git
commit bd86bff13378894f46e905d473ea02abe486eadb Author: Claus Ibsen <[email protected]> AuthorDate: Thu May 28 09:34:24 2026 +0200 CAMEL-23633: TUI auto-reselect integration after restart Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Claus Ibsen <[email protected]> --- .../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(
