From b41ffe40560a9b48409288a770a4bad23742ff5e Mon Sep 17 00:00:00 2001 From: Oleg Samarin Date: Thu, 16 Apr 2026 19:35:17 +0300 Subject: [PATCH] Fixed SaveAndSwitchDialog showing stale session name when new session has no JSONL yet When a new session hasn't sent any prompts, it hasn't written a JSONL file yet. findMostRecent() was returning the previous session, causing the name field to be pre-filled with the old session's name and that session to be excluded from the Resume Specific table. Fix: compare the most recent JSONL's lastAt timestamp against processStartedAt; if the JSONL predates the current process, treat it as stale (empty name, not excluded). Co-Authored-By: Claude Sonnet 4.6 --- pom.xml | 2 +- .../controller/ClaudeSessionController.java | 3 +++ .../io/github/nbclaudecodegui/ui/ClaudeSessionTab.java | 10 ++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pom.xml b/pom.xml index 7a45e222..7b164bb2 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ io.github.nbclaudecodegui netbeans-claude-code-gui - 0.21.52-SNAPSHOT + 0.21.53-SNAPSHOT nbm Netbeans Claude Code GUI NetBeans plugin that provides a GUI for Claude Code CLI — run claude code sessions directly inside the IDE. diff --git a/src/main/java/io/github/nbclaudecodegui/controller/ClaudeSessionController.java b/src/main/java/io/github/nbclaudecodegui/controller/ClaudeSessionController.java index 9dfc0686..b434df5e 100644 --- a/src/main/java/io/github/nbclaudecodegui/controller/ClaudeSessionController.java +++ b/src/main/java/io/github/nbclaudecodegui/controller/ClaudeSessionController.java @@ -1222,6 +1222,9 @@ public boolean hasLiveProcess() { return claudeProcess != null && claudeProcess.isRunning(); } + /** Returns the timestamp (ms) when the current PTY process was launched, or 0 if none. */ + public long getProcessStartedAt() { return processStartedAt; } + /** * Reads the Claude CLI version string from the running process. * diff --git a/src/main/java/io/github/nbclaudecodegui/ui/ClaudeSessionTab.java b/src/main/java/io/github/nbclaudecodegui/ui/ClaudeSessionTab.java index 7b57bc56..76571ec0 100644 --- a/src/main/java/io/github/nbclaudecodegui/ui/ClaudeSessionTab.java +++ b/src/main/java/io/github/nbclaudecodegui/ui/ClaudeSessionTab.java @@ -974,8 +974,14 @@ public void openSwitchDialog(SessionMode initialMode) { io.github.nbclaudecodegui.model.SavedSession recent = io.github.nbclaudecodegui.process.ClaudeSessionStore.findMostRecent( workingDir.toPath(), claudeConfigDir); - String currentName = recent != null ? recent.displayName() : ""; - String currentId = recent != null ? recent.sessionId() : null; + long procStart = controller.getProcessStartedAt(); + // If a process is running and the most recent JSONL predates it, it's an OLD session — + // not the currently running one (which hasn't written its JSONL yet) + boolean isCurrentSession = recent != null + && (procStart == 0 || (recent.lastAt() != null + && recent.lastAt().toEpochMilli() >= procStart)); + String currentName = isCurrentSession ? recent.displayName() : ""; + String currentId = isCurrentSession ? recent.sessionId() : null; final ClaudeSessionTab self = this; final Path configDir = claudeConfigDir;