fix(terminal): read pty client identity via list-clients instead of display-message -c#165
Open
0x79H wants to merge 1 commit into
Open
fix(terminal): read pty client identity via list-clients instead of display-message -c#1650x79H wants to merge 1 commit into
0x79H wants to merge 1 commit into
Conversation
…isplay-message -c - display-message -p -c expands formats against the most recently active client's session, not the -c client (verified on tmux 3.4 and 3.5a), causing false ERR_TMUX_SWITCH_FAILED whenever another tmux client on the server was more recently active - resolve the identity from list-clients -F filtered by client_tty, the same approach discoverClientTty already uses - teach the spawn harness to answer list-clients per requested format like real tmux (its display-message -c mock implemented the semantics the code assumed, which is how this survived the unit tests), and add a regression test where a foreign client is the most recently active one
0x79H
commented
Jul 22, 2026
| spawnSyncCalls.push({ args, options: _options }) | ||
| const command = getTmuxCommand(args) | ||
| if (command === 'list-clients') { | ||
| // Real tmux expands list-clients formats per client, so answer by the |
Author
There was a problem hiding this comment.
The old canned two-field reply here is what made this harness assert the wrong reality: combined with the display-message -c branch below (which replays the last switch-client target), the fake tmux behaved exactly as the production code assumed — so the bug in #161 was invisible to these tests. Answering per requested format matches what real list-clients does; none of the existing assertions changed.
0x79H
commented
Jul 22, 2026
| expect(proxy.getCurrentWindow()).toBe('@2') | ||
| }) | ||
|
|
||
| test('switchTo verifies against our own client when another client is more recently active', async () => { |
Author
There was a problem hiding this comment.
Regression tripwire for #161: the foreign client is listed first and is the most recently active — the row display-message -p -c semantics would pick. Verified by mutation: this test fails against master's implementation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #161.
What
display-message -p -c <tty>expands formats against the most-recently-active client's session, not the-cclient (verified on tmux 3.4 and 3.5a — minimal repro in the issue). This made pty-mode switch verification report falseERR_TMUX_SWITCH_FAILEDwhenever any other tmux client on the server was more recently active — i.e. whenever the user also uses tmux locally while agentboard is open.readClientIdentity()now enumerateslist-clients -F '#{client_tty}\t#{session_name}\t#{window_id}'and picks the row matching our client tty — the same approachdiscoverClientTty()already relies on. Rows that don't parse (e.g. control-mode clients with an empty tty) are skipped. No other behavior change.Test changes
The spawn harness in
isolated/terminalProxy.test.tsneeded two deliberate changes (context in this comment on #161):display-message -cbranch replays the lastswitch-clienttarget — it implements the semantics the production code assumed, which is how this bug survived with all unit tests green. Thelist-clientsbranch now answers per requested-Fformat like real tmux does. No existing assertion was loosened; all 12 prior test cases are unchanged and still pass.switchTo verifies against our own client when another client is more recently active— the harness lists a foreign, more recently active client first, the exact condition that fooleddisplay-message -p -c. Sanity-checked by mutation: this test fails against master's implementation, as intended.Verification
HOSTNAME=127.0.0.1): full suite including the real-tmux integration layer that CI skips — green; coverage mode andvite buildalso pass.list-clients -Fis available on all supported versions, including the 3.2a from PTY mode fails on tmux 3.2a with ERR_TMUX_SWITCH_FAILED and display-message usage error #156).Feel free to rework or take this over entirely — happy either way.