mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-06 07:29:42 +02:00
fix(statusline): unique temp name per exporter refresh, so concurrent creates stay in tmux
ensureStatusLineExporterScript() rewrites ~/.codeman/statusline-exporter.sh via a temp file + rename whenever the script content changes (a fresh data dir, or a release that changes it). The temp name was pid + Date.now(), so claude sessions created in the same millisecond (spawn_workers, a multi-tab Run) shared one temp path: the first rename consumed it and every other writer failed with ENOENT on chmod or rename. createSession() treats that as a mux failure and falls back to a direct PTY, so those sessions silently ran outside tmux (no reattach after a server restart) while quick-start still reported success. Measured on a fresh isolated instance, 4 concurrent claude quick-starts: master put 2 of 4 in tmux in both rounds; with this change 4 of 4, both rounds. The temp suffix now comes from randomBytes, like the skill writer in the same file and user-store.ts already do. The new test freezes Date.now() and runs eight refreshes at once; it fails on master with the same ENOENT. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+5
-1
@@ -1031,7 +1031,11 @@ export async function ensureStatusLineExporterScript(): Promise<string> {
|
||||
// render, and a truncate-then-write (plus a chmod AFTER the write) opened two
|
||||
// windows in which Claude Code could run an empty or non-executable file.
|
||||
// rename() swaps the complete, already-executable file in atomically.
|
||||
const tmpPath = `${scriptPath}.${process.pid}.${Date.now()}.tmp`;
|
||||
// ⚠️ The temp name must be unique per CALL, not per millisecond: sessions created
|
||||
// concurrently (spawn_workers, a multi-tab Run) refresh this together, a shared
|
||||
// name let the first rename consume the others' temp file, and their ENOENT
|
||||
// dropped those sessions from tmux to the direct-PTY fallback.
|
||||
const tmpPath = `${scriptPath}.${process.pid}.${randomBytes(6).toString('hex')}.tmp`;
|
||||
await writeFile(tmpPath, desired);
|
||||
await chmod(tmpPath, 0o755);
|
||||
await rename(tmpPath, scriptPath);
|
||||
|
||||
Reference in New Issue
Block a user