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
feat(ssh): write+source remote tmux.conf on connect, thread tmuxConfPath to -f
enesa63e8357d13f
diff --git a/src/main/pty-manager.ts b/src/main/pty-manager.tsindex 6c0847ba9..b4d79c237 100644--- a/src/main/pty-manager.ts+++ b/src/main/pty-manager.ts@@ -404,7 +404,10 @@ export class PtyManager {// An agent preset may pass a remote program to run inside the remote tmux; usually undefined.options.shell,options.shellArgs,- hookExtraEnv+ hookExtraEnv,+ // Source nodeterm's remote tmux.conf via `-f` (written on connect, Task 2) so a cold-start+ // session gets mouse/clipboard/scrollback. Fail-open: undefined → remote tmux host defaults.+ options.sshRemote.tmuxConfPath)} else if (this.tmuxPath && settings.tmuxEnabled && options.persistKey) {// attach-or-create the persistent session for this node.diff --git a/src/main/remote-ssh/control-master.test.ts b/src/main/remote-ssh/control-master.test.tsindex c29e70436..2c81bf69a 100644--- a/src/main/remote-ssh/control-master.test.ts+++ b/src/main/remote-ssh/control-master.test.ts@@ -105,6 +105,11 @@ describe('remoteTmuxPtyArgs', () => {const cmd = args[args.length - 1]expect(cmd).toContain('new-session -A -e NODETERM_HOOK_ENDPOINT=/r/ep.env -e NODETERM_NODE_ID=nt-x -s')})+ it('threads confPath to remoteTmuxCommand as a `-f` source before new-session', () => {+ const args = remoteTmuxPtyArgs(conn, '/s.sock', 'nt-x', '/srv/app', undefined, undefined, [], '/home/u/.nodeterm/tmux.conf')+ const cmd = args[args.length - 1]+ expect(cmd).toContain(`-f '/home/u/.nodeterm/tmux.conf' new-session -A`)+ })})describe('hook forwarding', () => {diff --git a/src/main/remote-ssh/control-master.ts b/src/main/remote-ssh/control-master.tsindex 4b2ca9308..1a26a725f 100644--- a/src/main/remote-ssh/control-master.ts+++ b/src/main/remote-ssh/control-master.ts@@ -132,9 +132,10 @@ export function remoteTmuxPtyArgs(remoteCwd: string,program?: string,programArgs?: string[],- extraEnv: string[] = []+ extraEnv: string[] = [],+ confPath?: string): string[] {- let cmd = remoteTmuxCommand({ sessionId, remoteCwd, program, programArgs, socket: RMT_TMUX_SOCKET })+ let cmd = remoteTmuxCommand({ sessionId, remoteCwd, program, programArgs, socket: RMT_TMUX_SOCKET, confPath })if (extraEnv.length) cmd = cmd.replace('new-session -A ', `new-session -A ${extraEnv.join(' ')} `)return ['-t', ...childArgs(conn, controlPath, cmd)]}diff --git a/src/main/remote-ssh/ssh-project.test.ts b/src/main/remote-ssh/ssh-project.test.tsindex 9f52553f8..18d33ddae 100644--- a/src/main/remote-ssh/ssh-project.test.ts+++ b/src/main/remote-ssh/ssh-project.test.ts@@ -107,6 +107,31 @@ describe('SshProjectManager', () => {expect(scpCalls[0].join(' ')).toContain(`u@h:'${out}'`)})+ it('connect writes + source-files the remote tmux.conf and returns its absolute path', async () => {+ const calls: { args: string[]; stdin?: string }[] = []+ const run = vi.fn(async (args: string[], stdin?: string) => {+ calls.push({ args, stdin })+ return args.join(' ').includes('printf %s')+ ? { code: 0, stdout: '/home/u' }+ : { code: 0, stdout: '' }+ })+ const mgr = new SshProjectManager({+ userDataDir: '/ud',+ spawnMaster: vi.fn(() => ({ kill: vi.fn(), on: vi.fn() })),+ run,+ runScp: vi.fn(async () => ({ code: 0 })),+ getHook: () => ({ port: 1, token: 't', version: '1' }),+ onStatus: vi.fn()+ })+ const { tmuxConfPath } = await mgr.connect('p1', conn)+ expect(tmuxConfPath).toBe('/home/u/.nodeterm/tmux.conf')+ // The conf was written via `cat >` (with the conf body as stdin) and then source-file'd.+ const write = calls.find((c) => c.args.join(' ').includes(`cat > '/home/u/.nodeterm/tmux.conf'`))+ expect(write).toBeDefined()+ expect(write?.stdin).toContain('set -g mouse on')+ expect(calls.some((c) => c.args.join(' ').includes(`source-file '/home/u/.nodeterm/tmux.conf'`))).toBe(true)+ })+it('uploadFile fails open (null) when not connected', async () => {const { mgr } = makeMgr()expect(await mgr.uploadFile('nope', '/x', 'x')).toBeNull()diff --git a/src/main/remote-ssh/ssh-project.ts b/src/main/remote-ssh/ssh-project.tsindex 540a71d17..aadaf84a8 100644--- a/src/main/remote-ssh/ssh-project.ts+++ b/src/main/remote-ssh/ssh-project.ts@@ -3,7 +3,7 @@ import path from 'path'import { spawn, execFile, execFileSync } from 'child_process'import { app, ipcMain, type BrowserWindow } from 'electron'import { IPC } from '../../shared/ipc'-import { parseLsDirs, posixQuote, type SshConnection } from '../../shared/ssh'+import { parseLsDirs, posixQuote, remoteTmuxConf, type SshConnection } from '../../shared/ssh'import type { SshProjectStatus } from '../../shared/types'import {controlPathFor,@@ -14,7 +14,8 @@ import {checkMasterArgs,remoteTmuxKillArgs,childArgs,- scpArgs+ scpArgs,+ RMT_TMUX_SOCKET} from './control-master'import { RemoteHooks } from './remote-hooks'import { hookServer } from '../agents/hook-server'@@ -38,6 +39,10 @@ interface Conn {controlPath: stringmaster: ReturnType<Runners['spawnMaster']>hookEndpointPath?: string+ /** The remote path of nodeterm's tmux.conf (`<remoteHome>/.nodeterm/tmux.conf`), written ++ * source-filed at connect. Threaded to `remoteTmuxCommand`'s `-f` so cold-start remote sessions+ * get mouse/clipboard/scrollback. Undefined if the write/source failed (fail-open). */+ tmuxConfPath?: string/** The remote `$HOME`, resolved at connect. Used (Phase 2b) to jail remote transcript reads* under `<remoteHome>/.claude/projects`. Undefined if it couldn't be resolved (fail-open). */remoteHome?: string@@ -115,7 +120,7 @@ export class SshProjectManager {projectId: string,conn: SshConnection,remoteCwd?: string- ): Promise<{ controlPath: string; hookEndpointPath?: string }> {+ ): Promise<{ controlPath: string; hookEndpointPath?: string; tmuxConfPath?: string }> {const existing = this.conns.get(projectId)if (existing) {// Verify the cached master is still alive before reusing it — a dropped/timed-out master@@ -126,7 +131,7 @@ export class SshProjectManager {// Keep the remote git cwd current even on an idempotent reuse (the folder may have changed).// Guard against a later connect without remoteCwd clearing a known cwd.existing.remoteCwd = remoteCwd ?? existing.remoteCwd- return { controlPath: existing.controlPath, hookEndpointPath: existing.hookEndpointPath }+ return { controlPath: existing.controlPath, hookEndpointPath: existing.hookEndpointPath, tmuxConfPath: existing.tmuxConfPath }}this.r.onStatus({ projectId, status: 'reconnecting' })existing.master.kill()@@ -161,13 +166,32 @@ export class SshProjectManager {} catch {// fail-open}+ // Write nodeterm's remote tmux.conf + source it into the (warm) server, best-effort. The+ // tmux server only reads `-f` when it starts; source-file pushes the options into an+ // already-running server (warm reattach) so existing + new sessions get mouse/clipboard.+ let tmuxConfPath: string | undefined+ if (remoteHome) {+ const confPath = `${remoteHome}/.nodeterm/tmux.conf`+ try {+ const dir = `${remoteHome}/.nodeterm`+ await this.r.run(+ childArgs(conn, controlPath, `mkdir -p ${posixQuote(dir)} && cat > ${posixQuote(confPath)}`),+ remoteTmuxConf(50000)+ )+ await this.r.run(childArgs(conn, controlPath, `tmux -L ${RMT_TMUX_SOCKET} source-file ${posixQuote(confPath)}`))+ tmuxConfPath = confPath+ } catch {+ /* fail-open: no conf → remote tmux uses host defaults */+ }+ }const entry = this.conns.get(projectId)if (entry) {entry.hookEndpointPath = hookEndpointPathentry.remoteHome = remoteHome+ entry.tmuxConfPath = tmuxConfPath}this.r.onStatus({ projectId, status: 'connected' })- return { controlPath, hookEndpointPath }+ return { controlPath, hookEndpointPath, tmuxConfPath }}await new Promise((res) => setTimeout(res, 100))}diff --git a/src/shared/types.ts b/src/shared/types.tsindex 205c7d309..982789bd6 100644--- a/src/shared/types.ts+++ b/src/shared/types.ts@@ -23,7 +23,7 @@ export interface PtyCreateOptions {*/agentId?: AgentId/** When set, this PTY runs on a remote host over the project's ssh ControlMaster, in remote tmux. */- sshRemote?: { controlPath: string; conn: import('./ssh').SshConnection; remoteCwd: string; hookEndpointPath?: string }+ sshRemote?: { controlPath: string; conn: import('./ssh').SshConnection; remoteCwd: string; hookEndpointPath?: string; tmuxConfPath?: string }}/**@@ -327,7 +327,7 @@ export interface SshProjectApi {projectId: string,server: import('./ssh').SshConnection,remoteCwd?: string- ): Promise<{ controlPath: string; hookEndpointPath?: string }>+ ): Promise<{ controlPath: string; hookEndpointPath?: string; tmuxConfPath?: string }>/** Tear down the master (remote tmux is unaffected). */disconnect(projectId: string): Promise<void>/**