mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-08 16:39:42 +02:00
fix: unset $TMUX env for nested tmux session creation
When running the dev server inside a tmux session, $TMUX is inherited
and tmux refuses to create new sessions ("sessions should be nested
with care, unset $TMUX to force"). Production (systemd) has a clean
env so this only affects dev/test. Strip $TMUX from the execSync env
when calling tmux new-session.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+6
-2
@@ -154,7 +154,7 @@ function buildOpenCodeCommand(config?: OpenCodeConfig): string {
|
|||||||
if (config?.continueSession) {
|
if (config?.continueSession) {
|
||||||
const safeId = /^[a-zA-Z0-9_-]+$/.test(config.continueSession) ? config.continueSession : undefined;
|
const safeId = /^[a-zA-Z0-9_-]+$/.test(config.continueSession) ? config.continueSession : undefined;
|
||||||
if (safeId) parts.push('--session', safeId);
|
if (safeId) parts.push('--session', safeId);
|
||||||
if (config.forkSession) parts.push('--fork');
|
if (safeId && config.forkSession) parts.push('--fork');
|
||||||
}
|
}
|
||||||
|
|
||||||
return parts.join(' ');
|
return parts.join(' ');
|
||||||
@@ -405,9 +405,13 @@ export class TmuxManager extends EventEmitter implements TerminalMultiplexer {
|
|||||||
// 1. Create session with default shell (starts tmux server, stays alive)
|
// 1. Create session with default shell (starts tmux server, stays alive)
|
||||||
// 2. Set remain-on-exit (server now exists, session won't vanish on exit)
|
// 2. Set remain-on-exit (server now exists, session won't vanish on exit)
|
||||||
// 3. Replace shell with actual command via respawn-pane (no terminal echo)
|
// 3. Replace shell with actual command via respawn-pane (no terminal echo)
|
||||||
|
// Unset $TMUX so nested sessions work when the dev server itself runs inside tmux.
|
||||||
|
// (Production uses systemd which has a clean env, but dev/test may be nested.)
|
||||||
|
const cleanEnv = { ...process.env };
|
||||||
|
delete cleanEnv.TMUX;
|
||||||
execSync(
|
execSync(
|
||||||
`tmux new-session -ds "${muxName}" -c "${workingDir}" -x 120 -y 40`,
|
`tmux new-session -ds "${muxName}" -c "${workingDir}" -x 120 -y 40`,
|
||||||
{ cwd: workingDir, timeout: EXEC_TIMEOUT_MS, stdio: 'ignore' }
|
{ cwd: workingDir, timeout: EXEC_TIMEOUT_MS, stdio: 'ignore', env: cleanEnv }
|
||||||
);
|
);
|
||||||
|
|
||||||
// Set remain-on-exit now that the server is running — must be before respawn-pane
|
// Set remain-on-exit now that the server is running — must be before respawn-pane
|
||||||
|
|||||||
Reference in New Issue
Block a user