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(speech): sendText reaches SSH-project nodes via remote tmux send-keys (dictation)
enesff9a2e3809a2
diff --git a/src/core/pty-manager.ts b/src/core/pty-manager.tsindex 4bfb52b16..d591bc682 100644--- a/src/core/pty-manager.ts+++ b/src/core/pty-manager.ts@@ -23,6 +23,7 @@ import {remoteTmuxHasSessionArgs,remoteTmuxKillArgs,remoteTmuxPtyArgs,+ remoteTmuxSendKeysArgs,remoteCapturePaneArgs} from './remote-ssh/control-master'import { TMUX_SOCKET, sessionName } from './tmux-naming'@@ -1734,11 +1735,30 @@ export class PtyManager {* note pushes) relies on the Enter being sent, so this stays bit-for-bit unless a caller opts* out. `enter: false` is for dictation's Insert action: it writes text into the terminal* WITHOUT submitting it, so the user can edit/append before running it themselves.+ *+ * An SSH-project node has no LOCAL tmux session to target (its pty program is `ssh -t '<remote+ * attach>'`) — so if the node's LIVE session is registered with `sshRemote`, this runs the+ * remote counterpart instead (`remoteTmuxSendKeysArgs`, over the project's ControlMaster),+ * mirroring how `remoteSessionExists` reuses `findSsh()` + `runAsync`. A node with no live+ * session at all (nothing mounted right now) still falls through to the local path and returns+ * false there, same as before this change — reaching a currently-unmounted SSH node's remote+ * session is not supported.*/async sendText(persistKey: string, text: string, opts?: { enter?: boolean }): Promise<boolean> {- if (!this.tmuxPath) return false- const target = sessionName(persistKey)const enter = opts?.enter ?? true+ const target = sessionName(persistKey)+ const sshRemote = this.sessionByPersistKey(persistKey)?.sshRemote+ if (sshRemote) {+ const ssh = findSsh()+ if (!ssh) return false+ try {+ await runAsync(ssh, remoteTmuxSendKeysArgs(sshRemote.conn, sshRemote.controlPath, target, text, enter))+ return true+ } catch {+ return false+ }+ }+ if (!this.tmuxPath) return falsetry {// The literal text and the Enter (when sent) must go in order, so await sequentially.await runAsync(this.tmuxPath, ['-L', TMUX_SOCKET, 'send-keys', '-t', target, '-l', text])diff --git a/src/core/remote-ssh/control-master.test.ts b/src/core/remote-ssh/control-master.test.tsindex ab71ec883..a557d5d74 100644--- a/src/core/remote-ssh/control-master.test.ts+++ b/src/core/remote-ssh/control-master.test.ts@@ -5,6 +5,7 @@ import {masterArgs,childArgs,remoteTmuxHasSessionArgs,+ remoteTmuxSendKeysArgs,probeSaysAbsent,remoteCapturePaneArgs,remoteTmuxPtyArgs,@@ -82,6 +83,35 @@ describe('remoteTmuxHasSessionArgs', () => {})})+describe('remoteTmuxSendKeysArgs', () => {+ it('sends literal text with -l -- (no Enter) when enter is false', () => {+ const args = remoteTmuxSendKeysArgs(conn, '/s.sock', 'nt-x', 'hello', false)+ expect(args).toEqual([+ '-o', 'ControlMaster=no', '-o', 'ControlPath=/s.sock', '-p', '2222',+ '[email protected]',+ `tmux -L ${RMT_TMUX_SOCKET} send-keys -t nt-x -l -- 'hello'`+ ])+ })+ it('appends a second send-keys Enter, joined by ;, when enter is true', () => {+ const args = remoteTmuxSendKeysArgs(conn, '/s.sock', 'nt-x', 'hello', true)+ expect(args[args.length - 1]).toBe(+ `tmux -L ${RMT_TMUX_SOCKET} send-keys -t nt-x -l -- 'hello'; tmux -L ${RMT_TMUX_SOCKET} send-keys -t nt-x Enter`+ )+ })+ it('single-quote-escapes a single quote in the text (the \'\\\'\' idiom)', () => {+ const args = remoteTmuxSendKeysArgs(conn, '/s.sock', 'nt-x', `it's`, false)+ expect(args[args.length - 1]).toBe(`tmux -L ${RMT_TMUX_SOCKET} send-keys -t nt-x -l -- 'it'\\''s'`)+ })+ it('keeps a multiline text as one literal token (single-quoted, newlines preserved)', () => {+ const args = remoteTmuxSendKeysArgs(conn, '/s.sock', 'nt-x', 'line one\nline two', false)+ expect(args[args.length - 1]).toBe(`tmux -L ${RMT_TMUX_SOCKET} send-keys -t nt-x -l -- 'line one\nline two'`)+ })+ it('guards leading-dash text from being read as a send-keys option (-l --)', () => {+ const args = remoteTmuxSendKeysArgs(conn, '/s.sock', 'nt-x', '-not-an-option', false)+ expect(args[args.length - 1]).toBe(`tmux -L ${RMT_TMUX_SOCKET} send-keys -t nt-x -l -- '-not-an-option'`)+ })+})+describe('remoteCapturePaneArgs', () => {it('captures the whole scrollback (-S -) when full', () => {const args = remoteCapturePaneArgs(conn, '/s.sock', 'nt-x', true)diff --git a/src/core/remote-ssh/control-master.ts b/src/core/remote-ssh/control-master.tsindex e5daaf650..746f198aa 100644--- a/src/core/remote-ssh/control-master.ts+++ b/src/core/remote-ssh/control-master.ts@@ -3,7 +3,7 @@import os from 'os'import path from 'path'import { createHash } from 'crypto'-import { quoteRemotePath, remoteTmuxCommand, type SshConnection } from '../../shared/ssh'+import { posixQuote, quoteRemotePath, remoteTmuxCommand, type SshConnection } from '../../shared/ssh'// 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. */@@ -75,6 +75,26 @@ export function exitMasterArgs(conn: SshConnection, controlPath: string): stringexport function remoteTmuxHasSessionArgs(conn: SshConnection, controlPath: string, sessionId: string): string[] {return childArgs(conn, controlPath, `tmux -L ${RMT_TMUX_SOCKET} has-session -t ${sessionId}`)}+/**+ * Send literal text (and optionally Enter) into a node's REMOTE tmux session — the remote+ * counterpart of `PtyManager.sendText`'s local `tmux send-keys` path (dictation insert, /rename,+ * /branch, note pushes). Built as ONE remote command so text and Enter run strictly in order on+ * the remote host without a second network round trip: `-l --` sends the text literally (`-l`)+ * and stops option parsing first (`--`, so text starting with `-` is never read as another+ * send-keys flag); `text` is single-quoted (`posixQuote`) so it survives the remote shell as one+ * token verbatim, multiline included.+ */+export function remoteTmuxSendKeysArgs(+ conn: SshConnection,+ controlPath: string,+ sessionId: string,+ text: string,+ enter: boolean+): string[] {+ let cmd = `tmux -L ${RMT_TMUX_SOCKET} send-keys -t ${sessionId} -l -- ${posixQuote(text)}`+ if (enter) cmd += `; tmux -L ${RMT_TMUX_SOCKET} send-keys -t ${sessionId} Enter`+ return childArgs(conn, controlPath, cmd)+}/*** Did a FAILED `tmux has-session` probe actually say the session is absent? Only tmux's own* exit 1 ("can't find session" / "no server running") does. Anything else — ssh's 255 (a dead