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 aacc30ccaa31 CAMEL-24372: Fix Spring Boot logging config for TUI log 
tab
aacc30ccaa31 is described below

commit aacc30ccaa31e7fa9877039da17105f202b1b83e
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Aug 10 20:59:53 2026 +0200

    CAMEL-24372: Fix Spring Boot logging config for TUI log tab
    
    Write a logback config to ~/.camel/.tui-logback-spring-boot.xml that
    logs to ~/.camel/PID.log (same as JBang) and reference it via
    file: protocol instead of classpath: which doesn't exist in Spring
    Boot projects.
    
    CAMEL-24372: Fix Source tab stale files after integration restart
    
    Detect PID changes in the Source tab render loop and trigger
    onIntegrationChanged to refresh the file list and source viewer
    when the selected integration restarts with a new PID.
    
    CAMEL-24372: Fix Source tab stale files after integration restart
    
    Detect PID changes in the Source tab render loop and trigger
    onIntegrationChanged to refresh the file list and source viewer
    when the selected integration restarts with a new PID. Initialize
    lastSeenPid in onTabSelected and onIntegrationChanged to avoid
    false triggers on first render.
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../dsl/jbang/core/commands/tui/LaunchManager.java | 31 +++++++++++++++++++++-
 .../dsl/jbang/core/commands/tui/SourceTab.java     |  9 +++++++
 2 files changed, 39 insertions(+), 1 deletion(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/LaunchManager.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/LaunchManager.java
index 6ac7d6e5e2c5..8b196dd055b0 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/LaunchManager.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/LaunchManager.java
@@ -281,6 +281,32 @@ class LaunchManager {
         }
     }
 
+    private static Path writeSpringBootLogbackConfig() {
+        try {
+            Path camelDir = Path.of(System.getProperty("user.home"), ".camel");
+            Files.createDirectories(camelDir);
+            Path logbackFile = 
camelDir.resolve(".tui-logback-spring-boot.xml");
+            String config = """
+                    <?xml version="1.0" encoding="UTF-8"?>
+                    <configuration>
+                        <include 
resource="org/springframework/boot/logging/logback/defaults.xml"/>
+                        <include 
resource="org/springframework/boot/logging/logback/console-appender.xml"/>
+                        <include 
resource="org/springframework/boot/logging/logback/file-appender.xml"/>
+                        <property name="LOG_FILE" 
value="${user.home}${file.separator}.camel${file.separator}${PID}.log"/>
+                        <property name="FILE_LOG_PATTERN" 
value="${CONSOLE_LOG_PATTERN}"/>
+                        <root level="INFO">
+                            <appender-ref ref="CONSOLE"/>
+                            <appender-ref ref="FILE"/>
+                        </root>
+                    </configuration>
+                    """;
+            Files.writeString(logbackFile, config);
+            return logbackFile;
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
     void launchCamelRun(String sourceDir, String displayName, List<String> 
extraArgs) {
         try {
             List<String> cmd = new 
ArrayList<>(LauncherHelper.getCamelCommand());
@@ -314,7 +340,10 @@ class LaunchManager {
         List<String> mvnArgs = new ArrayList<>();
         StringBuilder jvmArgs = new StringBuilder();
         if ("spring-boot".equals(projectType)) {
-            
jvmArgs.append("-Dlogging.config=classpath:logback-camel-jbang.xml");
+            Path logbackFile = writeSpringBootLogbackConfig();
+            if (logbackFile != null) {
+                jvmArgs.append("-Dlogging.config=file:").append(logbackFile);
+            }
         }
         for (String arg : extraArgs) {
             if (arg.startsWith("--prop=")) {
diff --git 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceTab.java
 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceTab.java
index 0586cf23e60f..4c56aea0bd9d 100644
--- 
a/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceTab.java
+++ 
b/dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceTab.java
@@ -78,6 +78,7 @@ import org.apache.camel.util.json.JsonObject;
  */
 class SourceTab extends AbstractTab {
 
+    private String lastSeenPid;
     private Path rootDir;
     private Path currentDir;
     private final ListState listState = new ListState();
@@ -160,11 +161,13 @@ class SourceTab extends AbstractTab {
 
     @Override
     public void onTabSelected() {
+        lastSeenPid = ctx.selectedPid;
         refreshFiles();
     }
 
     @Override
     public void onIntegrationChanged() {
+        lastSeenPid = ctx.selectedPid;
         rootDir = null;
         currentDir = null;
         entries = Collections.emptyList();
@@ -326,9 +329,15 @@ class SourceTab extends AbstractTab {
     public void render(Frame frame, Rect area) {
         sourceViewer.setValidateOnSave(ctx.validateOnSave);
         if (ctx.selectedPid == null) {
+            lastSeenPid = null;
             renderNoSelection(frame, area);
             return;
         }
+        // Detect PID change (e.g. after restart) and refresh stale file 
references
+        if (!ctx.selectedPid.equals(lastSeenPid)) {
+            lastSeenPid = ctx.selectedPid;
+            onIntegrationChanged();
+        }
 
         if (sourceViewer.isPlainMode() && sourceViewer.isVisible()) {
             leftArea = null;

Reply via email to