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(tmux): mouse off — selection belongs to the terminal emulator, not tmux copy-mode
enes5fe2873e63c1
diff --git a/src/core/pty-manager.ts b/src/core/pty-manager.tsindex 08c15bc9f..6773b879d 100644--- a/src/core/pty-manager.ts+++ b/src/core/pty-manager.ts@@ -40,26 +40,24 @@ const runAsync = promisify(execFile)// Minimal tmux config so the user's ~/.tmux.conf never interferes. The tmux server// (under our socket) keeps sessions alive while no client is attached, which is what// gives us continuity across node remounts and full app restarts.-function tmuxConf(scrollback: number): string {+//+// The mouse is deliberately OFF: with it on, a drag became a tmux copy-mode selection,+// which the terminal emulator cannot see (so xterm's own selection + Cmd+C never worked,+// and copying depended on a macOS-only pbcopy pipe). With it off, a drag is xterm's own+// selection. Applications that request mouse tracking themselves (vim, htop) still get+// their mouse events — tmux forwards those regardless of this option.+export function tmuxConf(scrollback: number): string {return `# auto-generated by node-terminal — do not editset -g status off-set -g mouse on+set -g mouse offset -g history-limit ${Math.max(1000, scrollback)}set -g default-terminal "xterm-256color"set -sg escape-time 10set -g destroy-unattached offsetw -g aggressive-resize on+# Not our copy path any more (the emulator owns selection), but kept so an app that emits+# OSC 52 itself (vim "+y, gh, yazi) still reaches the local clipboard via the client's handler.set -g set-clipboard on-# With mouse on, a drag in a normal-screen shell makes a tmux copy-mode selection (not an-# xterm one), so the renderer's Cmd+C can't see it. Pipe the selection straight to the macOS-# clipboard when the drag ends — so mouse-select copies like a native terminal (iTerm-style).-bind -T copy-mode MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "/usr/bin/pbcopy"-bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "/usr/bin/pbcopy"-# Double-click word / triple-click line also copy to the clipboard.-bind -T copy-mode DoubleClick1Pane send-keys -X select-word \\; send-keys -X copy-pipe-and-cancel "/usr/bin/pbcopy"-bind -T copy-mode-vi DoubleClick1Pane send-keys -X select-word \\; send-keys -X copy-pipe-and-cancel "/usr/bin/pbcopy"-bind -T copy-mode TripleClick1Pane send-keys -X select-line \\; send-keys -X copy-pipe-and-cancel "/usr/bin/pbcopy"-bind -T copy-mode-vi TripleClick1Pane send-keys -X select-line \\; send-keys -X copy-pipe-and-cancel "/usr/bin/pbcopy"`}diff --git a/src/core/tmux-conf.test.ts b/src/core/tmux-conf.test.tsnew file mode 100644index 000000000..006b2945b--- /dev/null+++ b/src/core/tmux-conf.test.ts@@ -0,0 +1,21 @@+import { describe, it, expect } from 'vitest'+import { tmuxConf } from './pty-manager'++describe('tmuxConf', () => {+ const c = tmuxConf(50000)+ it('leaves the mouse off so drags are xterm\'s own selection', () => {+ expect(c).toContain('set -g mouse off')+ expect(c).not.toContain('set -g mouse on')+ })+ it('binds no mouse keys and no longer shells out to pbcopy', () => {+ expect(c).not.toContain('MouseDragEnd1Pane')+ expect(c).not.toContain('copy-pipe-and-cancel')+ expect(c).not.toContain('pbcopy')+ })+ it('keeps OSC 52 as a safety net for apps that emit it themselves', () => {+ expect(c).toContain('set -g set-clipboard on')+ })+ it('floors history-limit at 1000', () => {+ expect(tmuxConf(10)).toContain('set -g history-limit 1000')+ })+})diff --git a/src/main/remote-ssh/ssh-project.test.ts b/src/main/remote-ssh/ssh-project.test.tsindex 597ec2916..0128bfdb7 100644--- a/src/main/remote-ssh/ssh-project.test.ts+++ b/src/main/remote-ssh/ssh-project.test.ts@@ -128,7 +128,7 @@ describe('SshProjectManager', () => {// 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(write?.stdin).toContain('set -g mouse off')expect(calls.some((c) => c.args.join(' ').includes(`source-file '/home/u/.nodeterm/tmux.conf'`))).toBe(true)})diff --git a/src/shared/ssh.test.ts b/src/shared/ssh.test.tsindex 193ac62a5..0bd31a065 100644--- a/src/shared/ssh.test.ts+++ b/src/shared/ssh.test.ts@@ -145,13 +145,18 @@ 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('leaves the mouse off so drags are the emulator\'s own selection', () => {+ expect(c).toContain('set -g mouse off')+ expect(c).not.toContain('set -g mouse on')+ })+ it('binds no mouse keys (dead with the mouse off)', () => {+ expect(c).not.toContain('MouseDragEnd1Pane')+ expect(c).not.toContain('DoubleClick1Pane')+ expect(c).not.toContain('TripleClick1Pane')+ expect(c).not.toContain('copy-pipe-and-cancel')})- it('advertises the OSC 52 clipboard-set capability via terminal-overrides (Ms)', () => {+ it('keeps OSC 52 as a safety net for apps that emit it themselves', () => {+ expect(c).toContain('set -g set-clipboard on')expect(c).toContain('terminal-overrides')expect(c).toContain('Ms=')})diff --git a/src/shared/ssh.ts b/src/shared/ssh.tsindex d60ae3d44..cf05bfa16 100644--- a/src/shared/ssh.ts+++ b/src/shared/ssh.ts@@ -89,14 +89,14 @@ 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). */+/** Remote variant of pty-manager's tmuxConf. Mouse OFF: a drag is the emulator's own selection,+ * not a tmux copy-mode one (see tmuxConf). `set-clipboard on` + the OSC 52 `Ms` capability stay+ * as a safety net for applications that emit OSC 52 themselves; the client's OSC 52 handler+ * writes those to the local clipboard. */export function remoteTmuxConf(scrollback: number): string {return `# auto-generated by node-terminal (remote) — do not editset -g status off-set -g mouse on+set -g mouse offset -g history-limit ${Math.max(1000, scrollback)}set -g default-terminal "xterm-256color"set -sg escape-time 10@@ -104,12 +104,6 @@ set -g destroy-unattached offsetw -g aggressive-resize onset -g set-clipboard onset -ag terminal-overrides ',xterm*:Ms=\\E]52;%p1%s;%p2%s\\007'-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`}