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.

feat(ssh): remoteTmuxConf (mouse/clipboard via OSC 52) + remoteTmuxCommand -f confPath

enes8800b3ec7cb5
diff --git a/src/shared/ssh.test.ts b/src/shared/ssh.test.ts
index 02919877f..58f15b2a3 100644
--- a/src/shared/ssh.test.ts
+++ b/src/shared/ssh.test.ts
@@ -6,6 +6,7 @@ import {
posixQuote,
quoteRemotePath,
remoteTmuxCommand,
+ remoteTmuxConf,
parseLsDirs
} from './ssh'
@@ -130,6 +131,31 @@ describe('remoteTmuxCommand', () => {
})
})
+describe('remoteTmuxConf', () => {
+ const c = remoteTmuxConf(50000)
+ it('enables mouse + clipboard and uses OSC 52 (no pbcopy)', () => {
+ expect(c).toContain('set -g mouse on')
+ expect(c).toContain('set -g set-clipboard on')
+ expect(c).toContain('copy-pipe-and-cancel')
+ expect(c).not.toContain('pbcopy')
+ })
+ it('floors history-limit at 1000', () => {
+ expect(remoteTmuxConf(10)).toContain('set -g history-limit 1000')
+ expect(remoteTmuxConf(50000)).toContain('set -g history-limit 50000')
+ })
+})
+
+describe('remoteTmuxCommand confPath', () => {
+ it('adds -f <confPath> before new-session when given', () => {
+ const cmd = remoteTmuxCommand({ sessionId: 'nt-x', remoteCwd: '~/app', socket: 'nodeterm-rmt', confPath: '/home/u/.nodeterm/tmux.conf' })
+ expect(cmd).toContain(`-f '/home/u/.nodeterm/tmux.conf' new-session`)
+ })
+ it('omits -f when no confPath', () => {
+ const cmd = remoteTmuxCommand({ sessionId: 'nt-x', remoteCwd: '~/app', socket: 'nodeterm-rmt' })
+ expect(cmd).not.toContain('-f ')
+ })
+})
+
describe('parseLsDirs', () => {
it('keeps only directory entries from `ls -1Ap`, dropping ./ and ../', () => {
expect(parseLsDirs('./\n../\nsrc/\nREADME.md\n.git/\nbin/\n')).toEqual(['.git', 'bin', 'src'])
diff --git a/src/shared/ssh.ts b/src/shared/ssh.ts
index cf0fd132b..85395326b 100644
--- a/src/shared/ssh.ts
+++ b/src/shared/ssh.ts
@@ -78,6 +78,29 @@ export function quoteRemotePath(p: string): string {
return posixQuote(p)
}
+/** Remote variant of pty-manager's tmuxConf: mouse on (wheel reaches the in-tmux app), tuned
+ * scrollback, and clipboard via OSC 52 (set-clipboard on + copy-pipe-and-cancel with NO command —
+ * pbcopy is macOS-local and absent on the remote; the local terminal's OSC 52 handler writes the
+ * copied text to the Mac clipboard). */
+export function remoteTmuxConf(scrollback: number): string {
+ return `# auto-generated by node-terminal (remote) — do not edit
+set -g status off
+set -g mouse on
+set -g history-limit ${Math.max(1000, scrollback)}
+set -g default-terminal "xterm-256color"
+set -sg escape-time 10
+set -g destroy-unattached off
+setw -g aggressive-resize on
+set -g set-clipboard on
+bind -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel
+bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel
+bind -T copy-mode DoubleClick1Pane send-keys -X select-word \\; send-keys -X copy-pipe-and-cancel
+bind -T copy-mode-vi DoubleClick1Pane send-keys -X select-word \\; send-keys -X copy-pipe-and-cancel
+bind -T copy-mode TripleClick1Pane send-keys -X select-line \\; send-keys -X copy-pipe-and-cancel
+bind -T copy-mode-vi TripleClick1Pane send-keys -X select-line \\; send-keys -X copy-pipe-and-cancel
+`
+}
+
/** Build the remote shell command that attaches-or-creates this node's remote tmux session. */
export function remoteTmuxCommand(opts: {
sessionId: string
@@ -85,12 +108,15 @@ export function remoteTmuxCommand(opts: {
program?: string
programArgs?: string[]
socket?: string
+ /** When set, sources this remote conf via `-f` (spliced before `new-session`). */
+ confPath?: string
}): string {
const socket = opts.socket ?? 'nodeterm-rmt'
const parts = [
'tmux',
'-L',
socket,
+ ...(opts.confPath ? ['-f', posixQuote(opts.confPath)] : []),
'new-session',
'-A',
'-s',