Skip to content

Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.

Merge origin/main into feat/tmux-control-shadows

enes270b20214208
diff --cc src/main/index.ts
index 79609bbae,36492cc4a..c0f08bbeb
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@@ -1525,12 -1526,20 +1526,26 @@@ app.whenReady().then(async () =>
// budget). Attached sessions are never touched; a reaped node cold-restores on next open.
// Local sockets only — a remote SSH host's sessions are reaped by that host's own
// nodeterm-server, never across the wire. Timer is unref'd; no explicit stop needed.
- const sessionReaper = createSessionReaper({ tmuxBin: () => ptyManager.getTmuxBin() })
+ // `shadowed` subtracts our own control-mode shadows from tmux's attached flag: a shadow is a real
+ // tmux client but NOT a watcher, so a shadowed session must stay exactly as cullable as an idle
+ // detached one (see PtyManager.shadowedTmuxSessions).
- createSessionReaper({
++ const sessionReaper = createSessionReaper({
+ tmuxBin: () => ptyManager.getTmuxBin(),
+ shadowed: (socket) => ptyManager.shadowedTmuxSessions(socket)
++ })
+ sessionReaper.start()
+ // Memory pressure (core/memory-pressure.ts): the reaper's own 10-minute timer is the steady
+ // state; this is the fast path. On a watermark crossing the renderer runs its reclaim levers
+ // (hidden WebGL contexts, parked terminals) and a CRITICAL reading also sweeps the reaper NOW
+ // rather than waiting out its timer. Both levers are idempotent and the monitor re-fires at most
+ // once a minute. The send goes through `sendToMain`, which resolves the window AT SEND TIME and
+ // no-ops while it is closed (macOS keeps the app alive without one) — the monitor's own
+ // try/catch is the backstop, not the primary.
+ createMemoryPressureMonitor({
+ onPressure: (severity) => {
+ sendToMain(IPC.appMemoryPressure, severity)
+ if (severity === 'critical') void sessionReaper.sweep()
+ }
}).start()
const ackSweeper = createAckSweeper({
handlers: { ackDone, onUnreadClear: (id) => sendToMain(IPC.agentUnreadClear, id) }
diff --cc src/server/index.ts
index 4a2d7a7a4,122de6500..1358948f8
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@@ -440,14 -441,21 +441,27 @@@ export async function startServer
// and this standing process is the natural owner of reaping them (field report: 95 sessions /
// 34 GB idle claude). Attached sessions are never touched; a reaped node cold-restores on next
// open. Kill switch + tuning via NODETERM_SESSION_* env (core/session-budget.ts).
- const sessionReaper = createSessionReaper({ tmuxBin: () => ptyManager.getTmuxBin() })
+ // `shadowed` subtracts our own control-mode shadows from tmux's attached flag: a shadow is a real
+ // tmux client but NOT a watcher, so a shadowed session must stay exactly as cullable as an idle
+ // detached one (see PtyManager.shadowedTmuxSessions).
+ const sessionReaper = createSessionReaper({
+ tmuxBin: () => ptyManager.getTmuxBin(),
+ shadowed: (socket) => ptyManager.shadowedTmuxSessions(socket)
+ })
sessionReaper.start()
+ // Memory pressure (core/memory-pressure.ts): only the reaper leg on this shell. A CRITICAL
+ // reading sweeps NOW instead of waiting out the reaper's 10-minute timer — that is the whole
+ // responder chain here. The renderer levers the desktop also runs (hidden WebGL contexts,
+ // parked terminals) are deliberately NOT pushed to attached browsers: a tab's own memory is the
+ // browser's to manage, and it already discards on its own terms (see the documented no-op in
+ // renderer/bridge/stubs.ts). Stopped on close beside the reaper — the timer is unref'd, but a
+ // test that starts and closes several servers must not leave sweepers behind.
+ const pressure = createMemoryPressureMonitor({
+ onPressure: (severity) => {
+ if (severity === 'critical') void sessionReaper.sweep()
+ }
+ })
+ pressure.start()
// Headless notification host: every core service above (incl. the loopback hook server, which
// is its own listener and MUST run) is booted, but we bind NO public HTTP/WS listener — no