From ca98b33d6a2b66d51daa8b13a1b28279f67ab48b Mon Sep 17 00:00:00 2001 From: arkon Date: Mon, 19 Jan 2026 04:27:57 +0100 Subject: [PATCH] feat: use w1/w2/s1/s2 naming convention for sessions - Claude sessions: w1-casename, w2-casename, etc. - Shell sessions: s1-casename, s2-casename, etc. - Never reuses numbers - always increments from highest existing Co-Authored-By: Claude Opus 4.5 --- src/web/public/app.js | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/web/public/app.js b/src/web/public/app.js index 30346634..8a5034e5 100644 --- a/src/web/public/app.js +++ b/src/web/public/app.js @@ -719,9 +719,21 @@ class ClaudemanApp { const workingDir = caseData.path || `${process.env.HOME}/claudeman-cases/${caseName}`; let firstSessionId = null; - // Create multiple sessions - for (let i = 1; i <= tabCount; i++) { - const sessionName = tabCount > 1 ? `${i}-${caseName}` : caseName; + // 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 num = parseInt(match[1]); + if (num >= startNumber) { + startNumber = num + 1; + } + } + } + + // Create multiple sessions with unique w-numbers + for (let i = 0; i < tabCount; i++) { + const sessionName = `w${startNumber + i}-${caseName}`; // Create session const createRes = await fetch('/api/sessions', { @@ -780,11 +792,24 @@ class ClaudemanApp { const caseData = await caseRes.json(); const workingDir = caseData.path || process.cwd(); + // Find the highest existing s-number for shells to avoid duplicates + let startNumber = 1; + for (const [, session] of this.sessions) { + const match = session.name && session.name.match(/^s(\d+)-/); + if (match) { + const num = parseInt(match[1]); + if (num >= startNumber) { + startNumber = num + 1; + } + } + } + const sessionName = `s${startNumber}-${caseName}`; + // Create session with shell mode const createRes = await fetch('/api/sessions', { method: 'POST', headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ workingDir, mode: 'shell' }) + body: JSON.stringify({ workingDir, mode: 'shell', name: sessionName }) }); const createData = await createRes.json(); if (!createData.success) throw new Error(createData.error);