Repository navigation
fix(remote): copies leave the agent's tmux; exact-text clipboard tool for agents - #824
Merged
Merged
Conversation
…act-text clipboard tool Copy/paste from executor panes on placed hosts was broken two ways. The agent's own tmux dropped clipboard writes. ty set `set-clipboard on` on the outer (UI) server only. Under the agent server's default, `external`, an OSC 52 from an application in the pane (Claude Code's copy, an editor, a printf) is swallowed and never reaches the view. Now, when a view opens, the agent server (local, or the placed host's tmux via the attach chain) gets `set-clipboard on`, terminal-features entries saying ty's nested view (TERM tmux*/screen*) has a clipboard, and `allow-passthrough on` on the task's window. A two-server tmux test shows the copy dropped without these options and delivered with them. Terminal selections still pick up hard line breaks wherever the agent's UI wrapped its output, and no tmux option can undo those. The new MCP tool taskyou_copy_to_clipboard carries text over ty's own channel (the MCP relay for placed tasks) to the scheduling machine. There it goes to the system clipboard (pbcopy/wl-copy/xclip/xsel/clip.exe) and, when a ty view is open, out as OSC 52 through it. The task log records only the size, never the text. Agents are told to use it in both local and relayed guidance. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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 copy/paste to and from executor panes, especially on placed hosts (found in InfluenceKit task 5547).
What was wrong
set-clipboard onon the outer (UI) server only. The server the agent runs on (the local agent server, or the placed host's tmux) kept tmux's default,external. Under that default an OSC 52 written by an application in the pane is dropped: Claude Code's copy, an editor yank,printf '\e]52;…'. It never reaches the view. I reproduced this with two nested tmux servers, and it is now a test.copy-mode -J,capture-pane -J) can join them. The fix has to avoid the terminal altogether.Changes
tmuxctl.AgentClipboardArgs/PassthroughArgs, applied whenever a view opens, both locally (ensureViewSession) and on the placed host (the attach chain). They set:set-clipboard onon the agent server.terminal-features[90|91]=tmux*:clipboard,screen*:clipboard, so an older tmux on a host, or one whose feature query was lost over ssh, still knows ty's view can take OSC 52. These use fixed indices, so they overwrite rather than append each time a view opens.allow-passthrough onscoped to the task's window, for programs that wrap OSC 52 in tmux passthrough.All of these are set before the client attaches, because tmux reads terminal features on connect. On the host, errors are discarded so an older tmux still attaches.
New MCP tool
taskyou_copy_to_clipboard(text)and a newinternal/clipboardpackage. The tool runs where the task was scheduled; placed tasks reach it over the existing MCP relay. It delivers the text byte for byte:pbcopy,wl-copy,xclip,xselorclip.exe),load-buffer -b ty-clipboard -w), which covers a TUI reached over ssh.There are no terminal escapes from the agent and no secret written to a file on the host. The task log records only the byte count. The tool is auto-approved, and agents are told to use it in both the local guidance and the relayed-host guidance.
Docs:
docs/remote-execution.mdanddocs/mcp-tools-reference.md.Tests
internal/tmuxctl: a real two-server test. An app's OSC 52 inside the inner server reaches the outer server withAgentClipboardArgs, and a control test shows it is dropped without them. Also an idempotency test against real tmux.internal/executor: the attach chain sets every option, before the attach, scoped to the task's window, and silences errors. I also ran the generated chain by hand against an isolated tmux to check the quoting.internal/clipboard: choice of route per OS and session, fallback when a command fails, the OSC 52 route, the no-route error, and the size limits.internal/mcp: the tool is advertised, delivers the exact text, keeps the text out of the task log, and returns failures as tool errors.TestEnsureTaskWindow_ExportedEnvVarsReachLiveShellPanefails on the host I ran this on (mona), with or without this change. It is environmental and unrelated.Not in this PR
🤖 Generated with Claude Code