From 9c322f7506ce387b94b0e19df6439692f01b7f92 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 23 Jan 2026 22:22:27 +0100 Subject: [PATCH] fix: make session numbering per-case instead of global The w1/w2/s1/s2 session counter was scanning all sessions regardless of case name, causing cross-case number inflation. Now only counts sessions belonging to the same case when determining the next number. Co-Authored-By: Claude Opus 4.5 --- src/web/public/app.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/web/public/app.js b/src/web/public/app.js index 2fb65b2d..5105952f 100644 --- a/src/web/public/app.js +++ b/src/web/public/app.js @@ -1122,11 +1122,11 @@ class ClaudemanApp { if (!workingDir) throw new Error('Case path not found'); let firstSessionId = null; - // Find the highest existing w-number for this case to avoid duplicates + // Find the highest existing w-number for THIS case to avoid duplicates let startNumber = 1; for (const [, session] of this.sessions) { - const match = session.name && session.name.match(/^w(\d+)-/); - if (match) { + const match = session.name && session.name.match(/^w(\d+)-(.+)$/); + if (match && match[2] === caseName) { const num = parseInt(match[1]); if (num >= startNumber) { startNumber = num + 1; @@ -1202,11 +1202,11 @@ class ClaudemanApp { const workingDir = caseData.path; if (!workingDir) throw new Error('Case path not found'); - // Find the highest existing s-number for shells to avoid duplicates + // Find the highest existing s-number for THIS case to avoid duplicates let startNumber = 1; for (const [, session] of this.sessions) { - const match = session.name && session.name.match(/^s(\d+)-/); - if (match) { + const match = session.name && session.name.match(/^s(\d+)-(.+)$/); + if (match && match[2] === caseName) { const num = parseInt(match[1]); if (num >= startNumber) { startNumber = num + 1;