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 (#431 wave) into feat/lead-pane-width

enesf8cc59fc6d27
diff --cc src/core/pty-manager.ts
index 2680cd9b5,8b0a33824..c15a4dd97
--- a/src/core/pty-manager.ts
+++ b/src/core/pty-manager.ts
@@@ -247,10 -247,30 +248,33 @@@ function runWithStdin(file: string, arg
// payload with `terminal-features`). The renderer's OSC 52 handler writes the system clipboard, so
// this is the copy path on EVERY platform and over SSH — no `pbcopy` pipe (that was macOS-only,
// and half of why copying was broken).
+ /**
+ * Session-identity env names the LOCAL conf's `update-environment` carries on top of the stock +
+ * gateway list (issue #419). The point is the REMOVAL half of update-environment's contract: the
+ * shared tmux server inherits the env of whichever client STARTS it, so a server started by a
+ * managed-account node's client held that account's `CLAUDE_CONFIG_DIR` in its GLOBAL env — and
+ * every later session created withOUT a `-e` override (system-account nodes, plain terminals, and
+ * the missing-dir fallback) inherited it and silently ran as that account ("the system account is
+ * entangled with the next account in the list"). With the names listed, tmux copies each one from
+ * the creating CLIENT's env — set for the node that owns it, and STRIPPED from the session when
+ * the client lacks it (measured in session-env.realtmux.test.ts, seeded-server case included).
+ * The auth-strip names ride along for the same reason: deleting them from the client env alone
+ * never touched a seeded server's global copy, so a managed-OAuth node could still run on an
+ * inherited API key. LOCAL conf only — see `tmuxUpdateEnvironmentLine` for why the remote conf
+ * must not get these.
+ */
+ export const ACCOUNT_SCOPE_UPDATE_ENV: readonly string[] = [
+ 'CLAUDE_CONFIG_DIR',
+ ...AUTH_ENV_STRIP,
+ 'CODEX_HOME',
+ 'NODETERM_CODEX_ACCOUNT_ID',
+ ...CODEX_AUTH_ENV_STRIP
+ ]
+
-export function tmuxConf(scrollback: number): string {
+// LEAD-PANE WIDTH (issue #119): `leadPaneWidth` (settings.tmuxLeadPaneWidth) is OPT-IN and 0 by
+// default — `leadPaneHookLines` returns '' then, so the default conf is byte-identical to the
+// pre-feature output (pinned in tmux-conf.test.ts). See shared/tmux-lead-pane.ts for the story.
+export function tmuxConf(scrollback: number, leadPaneWidth: number = 0): string {
return `# auto-generated by node-terminal — do not edit
set -g status off
set -g mouse on
diff --cc src/core/tmux-conf.test.ts
index fcf470781,ca5d61db9..7b029603f
--- a/src/core/tmux-conf.test.ts
+++ b/src/core/tmux-conf.test.ts
@@@ -1,7 -1,6 +1,7 @@@
import { describe, it, expect } from 'vitest'
- import { tmuxConf } from './pty-manager'
+ import { ACCOUNT_SCOPE_UPDATE_ENV, tmuxConf } from './pty-manager'
+import { leadPaneHookLines } from '../shared/tmux-lead-pane'
describe('tmuxConf', () => {
const c = tmuxConf(50000)
@@@ -56,21 -55,18 +56,36 @@@
expect(c).toContain('set -g history-limit 50000')
})
+ it('lead-pane width OFF (default/0/invalid) is byte-identical and carries no set-hook (issue #119)', () => {
+ // The opt-in guarantee enes set for the feature: with the setting off, the generated conf is
+ // bit-for-bit the pre-feature output — nodeterm ships no tmux hooks unless asked to.
+ expect(tmuxConf(50000, 0)).toBe(c)
+ expect(tmuxConf(50000, NaN)).toBe(c)
+ expect(tmuxConf(50000, -3)).toBe(c)
+ expect(c).not.toContain('set-hook')
+ })
+
+ it('lead-pane width ON only APPENDS the shared guarded hook pair — nothing above changes', () => {
+ const on = tmuxConf(50000, 72)
+ expect(on.startsWith(c)).toBe(true)
+ expect(on).toContain(leadPaneHookLines(72))
+ // Same builder as remoteTmuxConf, so the local and SSH sockets cannot drift.
+ expect(on).toContain('set-hook -g after-resize-pane')
+ expect(on).toContain('set-hook -g after-split-window')
+ })
++
+ it('lists every account-scope env name in update-environment (issue #419)', () => {
+ // The REMOVAL half of update-environment's contract is the fix: the shared server's global
+ // env is inherited from whichever client STARTED it, so without these names a server seeded
+ // by a managed-account client leaked that account's CLAUDE_CONFIG_DIR into every session
+ // created without a `-e` override — system-account nodes silently ran as a managed account.
+ const line = c.split('\n').find((l) => l.startsWith('set -g update-environment '))
+ expect(line).toBeDefined()
+ for (const name of ACCOUNT_SCOPE_UPDATE_ENV) expect(line).toContain(name)
+ // Deduped: the overlap names (ANTHROPIC_AUTH_TOKEN is in the gateway list AND the claude
+ // auth strip; OPENAI_API_KEY likewise) must appear exactly once.
+ for (const dup of ['ANTHROPIC_AUTH_TOKEN', 'OPENAI_API_KEY']) {
+ expect(line!.split(dup).length - 1).toBe(1)
+ }
+ })
})
diff --cc src/shared/ssh.test.ts
index b66a69d23,46282b873..6c0486cf4
--- a/src/shared/ssh.test.ts
+++ b/src/shared/ssh.test.ts
@@@ -285,18 -284,17 +285,29 @@@ describe('remoteTmuxConf', () =>
expect(remoteTmuxConf(10)).toContain('set -g history-limit 1000')
expect(remoteTmuxConf(50000)).toContain('set -g history-limit 50000')
})
+ it('lead-pane width OFF (default/0/invalid) is byte-identical and carries no set-hook (issue #119)', () => {
+ // The opt-in guarantee: nodeterm ships no tmux hooks unless the user turned the setting on,
+ // and the off path must be bit-for-bit the pre-feature conf.
+ expect(remoteTmuxConf(50000, 0)).toBe(c)
+ expect(remoteTmuxConf(50000, NaN)).toBe(c)
+ expect(c).not.toContain('set-hook')
+ })
+ it('lead-pane width ON only APPENDS the shared guarded hook pair', () => {
+ const on = remoteTmuxConf(50000, 72)
+ expect(on.startsWith(c)).toBe(true)
+ expect(on).toContain(leadPaneHookLines(72))
+ })
+ it('does NOT list the account-scope names in update-environment (they are LOCAL-conf only)', () => {
+ // A remote session's account env arrives via `-e` on the ssh-exec'd create; the attaching
+ // client's own env is the remote LOGIN SHELL's, which never carries our account dirs. Listing
+ // the names here would make every reattach copy/strip against that wrong environment —
+ // stripping a managed remote account's CLAUDE_CONFIG_DIR out of its own session. The local
+ // conf lists them (ACCOUNT_SCOPE_UPDATE_ENV in pty-manager, issue #419); this pin is what
+ // keeps a future "unify the two confs" cleanup from exporting the fix to the wrong side.
+ for (const name of ['CLAUDE_CONFIG_DIR', 'CODEX_HOME', 'NODETERM_CODEX_ACCOUNT_ID']) {
+ expect(c).not.toContain(name)
+ }
+ })
})
describe('remoteTmuxCommand confPath', () => {