Repository navigation
fix(terminal): copy from pi on a remote host reaches the viewer's clipboard - #34102
Conversation
|
No actionable comments were generated in the recent review.
|
…pboard Remote viewers get PI_CLIPBOARD_OSC52=1 in every pane so pi's in-app selection also sends OSC 52 instead of only the host's clipboard. The Codex SSH_CONNECTION marker stays limited to Orca-launched Codex. Refs #33937
c3cda45 to
b189e55
Compare
…selection # Conflicts: # src/main/runtime/remote-viewer-launch-env.test.ts
ELI5
When you watch an Orca terminal on another machine and copy text inside pi's full-screen view, pi put the text on the clipboard of the machine pi runs on, not the one you're sitting at. Now Orca tells pi that the viewer is somewhere else, so pi also sends the copy to your terminal and it lands on your clipboard.
What Changed
PI_CLIPBOARD_OSC52=1. This is pi's own documented switch: it keeps pi's normal host clipboard write and also sends the text as OSC 52. Orca's terminal already writes OSC 52 to the viewer's clipboard.applyRemoteViewerClipboardEnv. It covers both remote paths: headless/SSH-managed hosts (buildPtyHostEnv) and terminals a remote client creates on a desktop host (applyRemoteViewerLaunchEnv). The pi variable is set in every shell because people startpiby hand, and nothing else reads it. The fakeSSH_CONNECTIONmarker is still only for Orca-launched Codex, so bare-shell prompts don't change. WSL panes forward the variable throughWSLENV. If you already setPI_CLIPBOARD_OSC52yourself, your value wins.Why
The reporter's pi case matches pi's copy routing: pi only sends OSC 52 when it sees SSH variables or
PI_CLIPBOARD_OSC52=1, and an Orca server pane has neither. Claude Code already sends OSC 52 on every copy, and Orca-launched Codex was fixed in #27605, so this change doesn't explain or address their failures. For pi, Orca's own drag selection (Shift-drag, or Option-drag on macOS) behaves the same on local and remote panes: one renderer and the same xterm options. So for pi, the difference is where its copy goes, not mouse handling. Setting the agent's own opt-in is host-side only: no new wire fields, and it works with any client version.Linked Issue
Refs #33937
This covers only the pi part of the report. Claude Code already sends OSC 52 on every copy, and Codex started by hand is unchanged, so the reporter's Claude Code and Codex failures are still unexplained. That part of the issue stays open.
Thanks to @henjuese for the report and the clear repro steps.
Visual Proof
N/A: this only changes the environment of remote terminals, with no UI change. It's covered by unit tests on both remote launch paths.
Testing
I manually tested these changes locally
Automated tests added/updated, or explained why not below
New cases in
remote-viewer-clipboard-env.test.ts,remote-viewer-launch-env.test.tsandpty-spawn-env-terminal-basics.test.ts: a plain shell on a headless host and a remote caller's plain shell both getPI_CLIPBOARD_OSC52=1, local viewers don't, and an explicit user value is kept. These fail on main.Existing Codex marker tests still pass.
pnpm tc(including the CI bun compiler), changed-code quality gate, oxfmt, and the static-analysis steps pass. The root oxlint errors are pre-existingmax-lineserrors in untouched files.Not done: a live run of pi against a paired server.
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
terminalAllowOsc52Clipboardgate, and queries stay blocked.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)