feat(v0.3): H1 — tmux keepalive (sessions survive a server restart)
- src/session/tmux.ts: sync tmux CLI wrappers (available/has/kill), best-effort - config: useTmux from USE_TMUX env (1/0/auto→detect tmux on PATH) - session: when useTmux, spawn 'tmux new-session -A -s web_<id> <shell>' (the node-pty proc is a tmux CLIENT); createSession takes an optional id for re-attach; Session.tmuxName; kill() runs tmux kill-session - manager: handleAttach re-attaches to a surviving 'web_<id>' tmux session after a restart (Case 3.5); shutdown kills only the client pty for tmux sessions so the shell keeps running - tests: USE_TMUX:0 in shared integration cfg (no tmux leakage); unit CFGs useTmux:false; integration 'H1' (real tmux): set var → restart server → re-attach → var survived. 208 tests green.
This commit is contained in:
@@ -8,6 +8,15 @@
|
||||
|
||||
import os from 'node:os'
|
||||
import type { Config, EnvLike } from './types.js'
|
||||
import { tmuxAvailable } from './session/tmux.js'
|
||||
|
||||
/** USE_TMUX: '1'/'true'/'on' → on, '0'/'false'/'off' → off, else auto-detect tmux. */
|
||||
function resolveUseTmux(raw: string | undefined): boolean {
|
||||
const v = raw?.trim().toLowerCase()
|
||||
if (v === '1' || v === 'true' || v === 'on') return true
|
||||
if (v === '0' || v === 'false' || v === 'off') return false
|
||||
return tmuxAvailable() // unset / 'auto'
|
||||
}
|
||||
|
||||
// ── constants ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -141,6 +150,8 @@ export function loadConfig(env: EnvLike): Config {
|
||||
|
||||
const wsPath = env['WS_PATH'] ?? DEFAULT_WS_PATH
|
||||
|
||||
const useTmux = resolveUseTmux(env['USE_TMUX'])
|
||||
|
||||
const allowedOrigins = deriveAllowedOrigins(port, env['ALLOWED_ORIGINS'])
|
||||
|
||||
return Object.freeze({
|
||||
@@ -152,6 +163,7 @@ export function loadConfig(env: EnvLike): Config {
|
||||
scrollbackBytes,
|
||||
maxPayloadBytes,
|
||||
wsPath,
|
||||
useTmux,
|
||||
allowedOrigins,
|
||||
} satisfies Config)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user