/** * Foreign tmux adoption — the pure core. * * These pin the properties that were established by MEASUREMENT against a real * tmux (3.3a) while the feature was built, and that a plausible-looking refactor * would quietly undo. Each one has a comment naming what actually went wrong. */ import { describe, it, expect } from 'vitest'; import { buildForeignProbeScript, parseForeignProbeOutput, classifyForeignPaneMode, isCodemanOwnedPane, foreignSessionId, foreignViewSessionName, isAdoptableSessionName, isAdoptableSocketPath, buildForeignAttachCommand, buildForeignDockerAttachCommand, buildForeignRemoteAttachCommand, buildForeignTmuxInvocation, } from '../src/foreign-tmux.js'; // A probe transcript in exactly the shape a real run produces. The pane rows use // the LITERAL backslash-t that tmux's `-F` emits (verified on next-3.7 and 3.3a), // while the socket line is space-separated because `sh`'s builtin `echo` expands // a backslash-t to a real TAB — two different meanings for one escape, two lines // apart, which is why the socket marker carries no separator at all. const PROBE = [ 'CMFS /tmp/tmux-0/default', 'CMFP\\t/tmp/tmux-0/default\\t631\\t0\\t1\\t1788092494\\t1\\t%0\\tclaude\\twork\\t/srv/app', 'CMFP\\t/tmp/tmux-0/default\\t900\\t0\\t1\\t1788092500\\t0\\t%1\\tbash\\tscratch\\t/home/me', 'CMFP\\t/tmp/tmux-0/default\\t950\\t0\\t2\\t1788092600\\t0\\t%2\\tnode\\tcodex-work\\t/srv/app', 'CMFQ', ' 631 630 -bash', ' 4056 631 claude --dangerously-skip-permissions', ' 4104 4056 /usr/local/bin/ortg --repo /ortg mcp', ' 900 630 -bash', ' 950 630 node /opt/homebrew/bin/codex', ].join('\n'); describe('buildForeignProbeScript', () => { it('contains no single quote — it is wrapped in one to cross ssh and docker exec', () => { // The script is embedded as `ssh host '