@bakapiano/ccsm 0.17.4 → 0.17.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/bin/ccsm.js +22 -14
  2. package/package.json +1 -1
  3. package/server.js +10 -4
package/bin/ccsm.js CHANGED
@@ -122,21 +122,29 @@ function isSameVersion(running) {
122
122
  // (b) bind port 7777 before the helper's own respawn does. Either
123
123
  // way the upgrade derails. Bail out instead — the helper's UI on
124
124
  // 7779 is already showing the user what's happening.
125
- const lockPath = path.join(HOME, '.upgrade.lock');
126
- try {
127
- const raw = fs.readFileSync(lockPath, 'utf8');
128
- const lock = JSON.parse(raw);
129
- const ageMs = Date.now() - (lock.startedAt || 0);
130
- const ownerAlive = lock.pid ? pidAlive(lock.pid) : false;
131
- if (ownerAlive && ageMs < 10 * 60_000) {
132
- console.log(`ccsm: upgrade in progress (helper pid=${lock.pid}, ${Math.round(ageMs/1000)}s ago, target=${lock.target || '?'})`);
133
- console.log(` see http://localhost:${lock.helperPort || 7779}/ for live progress`);
134
- process.exit(0);
125
+ //
126
+ // Exception: the helper itself spawns ccsm.cmd at the END of the
127
+ // upgrade (after npm install completes) to bring the new backend up.
128
+ // It sets CCSM_FROM_UPGRADE=1 in that child's env. We MUST skip the
129
+ // lock check in that case, otherwise we'd refuse our own respawn and
130
+ // the user would be stuck staring at "Backend not running".
131
+ if (process.env.CCSM_FROM_UPGRADE !== '1') {
132
+ const lockPath = path.join(HOME, '.upgrade.lock');
133
+ try {
134
+ const raw = fs.readFileSync(lockPath, 'utf8');
135
+ const lock = JSON.parse(raw);
136
+ const ageMs = Date.now() - (lock.startedAt || 0);
137
+ const ownerAlive = lock.pid ? pidAlive(lock.pid) : false;
138
+ if (ownerAlive && ageMs < 10 * 60_000) {
139
+ console.log(`ccsm: upgrade in progress (helper pid=${lock.pid}, ${Math.round(ageMs/1000)}s ago, target=${lock.target || '?'})`);
140
+ console.log(` see http://localhost:${lock.helperPort || 7779}/ for live progress`);
141
+ process.exit(0);
142
+ }
143
+ // Stale lock (pid dead OR > 10min) — clean up and continue.
144
+ try { fs.unlinkSync(lockPath); } catch {}
145
+ } catch {
146
+ // ENOENT or parse error → no lock, proceed.
135
147
  }
136
- // Stale lock (pid dead OR > 10min) — clean up and continue.
137
- try { fs.unlinkSync(lockPath); } catch {}
138
- } catch {
139
- // ENOENT or parse error → no lock, proceed.
140
148
  }
141
149
 
142
150
  // Case 1: existing instance on the preferred port
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bakapiano/ccsm",
3
- "version": "0.17.4",
3
+ "version": "0.17.6",
4
4
  "description": "Claude Code Session Manager — Windows web UI to manage many concurrent claude sessions: live list, snapshot/restore, focus existing window, new session in an isolated workspace with repo clones",
5
5
  "license": "MIT",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -1380,10 +1380,16 @@ function openInBrowser(url) {
1380
1380
  console.log(`clis: ${cfg.clis.map((c) => c.id).join(', ')} (default: ${cfg.defaultCliId})`);
1381
1381
 
1382
1382
  // CCSM_NO_BROWSER=1 (set by the ccsm:// protocol launcher) suppresses
1383
- // the auto-open entirely. Otherwise try app-mode (chromeless Edge/Chrome
1384
- // window); if no such browser is installed, openInBrowser falls back to
1385
- // the OS default browser on its own.
1386
- const opened = process.env.CCSM_NO_BROWSER === '1'
1383
+ // the auto-open entirely. CCSM_FROM_UPGRADE=1 (set by upgrade-helper
1384
+ // when it respawns ccsm post-install) does the same: the user is
1385
+ // already in the helper UI which redirects to this fresh backend, so
1386
+ // a second app-mode window would just shadow the first. Otherwise try
1387
+ // app-mode (chromeless Edge/Chrome window); if no such browser is
1388
+ // installed, openInBrowser falls back to the OS default browser on
1389
+ // its own.
1390
+ const suppressBrowser = process.env.CCSM_NO_BROWSER === '1'
1391
+ || process.env.CCSM_FROM_UPGRADE === '1';
1392
+ const opened = suppressBrowser
1387
1393
  ? { kind: 'none', child: null }
1388
1394
  : openInBrowser(FRONTEND_URL);
1389
1395