feat(cli): support /copy in remote sessions using OSC52#13471
feat(cli): support /copy in remote sessions using OSC52#13471scidomino merged 1 commit intogoogle-gemini:mainfrom
Conversation
Summary of ChangesHello @ismellpillows, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces OSC52 support for the /copy command, which is a great enhancement for users working in remote shells and terminal multiplexers. The implementation is thorough, considering various environments like SSH, tmux, screen, and WSL, and includes robust TTY handling and payload size management. I've found one area in the UTF-8 truncation logic that could be improved for correctness and efficiency. My feedback is detailed in the comment below.
|
I think this replaces #9966 too, which was just closed. |
scidomino
left a comment
There was a problem hiding this comment.
I tested this by running it locally in tmux and I couldn't get it to work. /copy didn't change my clipboard. Is there something I'm doing wrong?
9c0f359 to
caaea7a
Compare
caaea7a to
10d270a
Compare
Thanks! Some terminals may not support OSC52 or may require you to enable it. More likely, tmux 3.3+ requires adding |
10d270a to
642201e
Compare
|
@scidomino Can you review this when you have a chance? Let me know if you need anything from me. |
@ismellpillows I approved but there is a merge conflict. Please resolve. |
642201e to
d05c5f0
Compare
|
Nevermind, I resolved it myself. |
Summary
/copynow works reliably over SSH/tmux/screen/WSL by emitting an OSC-52 clipboard sequence to the user’s local terminal. Local behavior is unchanged (still usesclipboardy). The implementation is UTF-8 safe, respects terminal payload limits, and handles multiplexer passthrough correctly.Details
clipboardy./dev/ttywhen available (avoids interleaving with piped stdout), else fall back tostdout, elsestderr./4boundary./copystill copies the last message and takes no arguments. Prints a single warning if truncation occurs. No noisy logs otherwise.Related Issues
Fixes #5244
Fixes #13354
Related to #9978
Replaces #5416
Replaces #9966
How to Validate
Local macOS/Linux/Windows (no SSH)
/copy.clipboardy.SSH → remote (no tmux)
/copy.SSH → remote inside tmux
tmux new -s test, run/copy.setw -g allow-passthrough onto~/.tmux.confSSH → remote inside screen
screen, run/copy.VS Code Integrated Terminal (Remote-SSH)
/copy.ChromeOS Secure Shell (hterm)
/copy.Windows Terminal / WSL
/copy.Piped stdout (ensure we don’t lose OSC)
gemini ... | cat), then/copy./dev/tty).Large payload
Non-TTY / dumb terminal
TERM=dumb, run/copy.clipboardy(or no-op if unsupported by environment); no OSC emitted.