feat(cli): Support wl-clipboard for wayland
TLDR
As documented, /copy uses xsel or xclip under the hood. They only works on X11.
This PR uses wl-copy for wayland session.
Dive Deeper
Reviewer Test Plan
- Run Linux with wayland compositor.
- install wl-clipboard
- try
/copy
Testing Matrix
| 🍏 | 🪟 | 🐧 | |
|---|---|---|---|
| npm run | ❓ | ❓ | ✔ |
| npx | ❓ | ❓ | ❓ |
| Docker | ❓ | ❓ | ❓ |
| Podman | ❓ | - | - |
| Seatbelt | ❓ | - | - |
Linked issues / bugs
Closes #11505
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
Summary of Changes
Hello @xcpky, I'm Gemini Code Assist[^1]! 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 /copy command's compatibility on Linux by introducing native support for Wayland display servers. Previously limited to X11 environments, the command can now seamlessly handle clipboard operations in Wayland sessions, ensuring a more consistent user experience across different Linux desktop setups.
Highlights
- Wayland Clipboard Support: The CLI's
/copycommand now supports Wayland display servers on Linux by integratingwl-clipboard. - Session Type Detection: The
copyToClipboardutility function has been updated to detect theXDG_SESSION_TYPEenvironment variable to determine if the current session is Wayland, and then usewl-copyaccordingly. - Improved Error Handling: Specific error handling has been added for cases where
wl-copyis not found, providing a clear message to the user to installwl-clipboard. - Documentation Update: The
docs/cli/commands.mdfile has been updated to inform users thatwl-clipboardis required for the/copycommand on Wayland sessions.
Using Gemini Code Assist
The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.
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 :thumbsup: and :thumbsdown: 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.
[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.
Hi @xcpky,
I've been testing the PR for my own needs and noticed a few issues with the Wayland clipboard implementation and its tests. I've made some fixes and added more comprehensive tests to ensure it works correctly across X11 and Wayland environments.
Specifically, I've addressed:
- A TypeScript error related to
process.env.XDG_SESSION_TYPEaccess. - Refactored the clipboard tests in
commandUtils.test.tsto accurately reflectwl-copybehavior on Wayland andxclip/xselon X11, including correct error handling.
I've pushed these changes to my fork on the support-wayland-jk branch. You can review them here:
https://github.com/jk-kashe/gemini-cli/tree/support-wayland-jk .
Would you be able to incorporate these fixes into your PR? Alternatively, if you're open to it, I'd be happy to contribute directly to your branch.
Please let me know what works best for you.
Thanks again!
Hi @xcpky,
I've been testing the PR for my own needs and noticed a few issues with the Wayland clipboard implementation and its tests. I've made some fixes and added more comprehensive tests to ensure it works correctly across X11 and Wayland environments.
Specifically, I've addressed:
* A TypeScript error related to `process.env.XDG_SESSION_TYPE` access. * Refactored the clipboard tests in `commandUtils.test.ts` to accurately reflect `wl-copy` behavior on Wayland and `xclip`/`xsel` on X11, including correct error handling.I've pushed these changes to my fork on the
support-wayland-jkbranch. You can review them here:https://github.com/jk-kashe/gemini-cli/tree/support-wayland-jk.Would you be able to incorporate these fixes into your PR? Alternatively, if you're open to it, I'd be happy to contribute directly to your branch.
Please let me know what works best for you.
Thanks again!
Hi. Thank you for bringing me the issues you met. Indeed somehow I didn't upload the fix for process.env.XDG_SESSION_TYPE. For the test I leave it not implemented because I don't have time and not familiar with js/ts tests. I am not sure your test implementation is correct, I just gave it a glance and found that it tests xsel fallback for wl-clipboard, which simply doesn't happen with my commit.
Did this pull request end up going anywhere? Started following the thread recently and was wondering if you all need some help on this? Would really like to see this implemented in the CLI, especially beacause GNOME is now fully on wayland, and a lot of linux distros are going wayland-only, meaning gemini-cli will essentially not have a copy functionality for users on more recent distributions! Again, let me know how I can help.
Did this pull request end up going anywhere? Started following the thread recently and was wondering if you all need some help on this?
The PR works already, but it lacks test code. I don't want to spend time on that.
@scidomino is now our resident expert on keyboard and clipboard support. I think this is worth landing even if we have to manually add the tests. Fingers crossed that Gemini 3.0 makes adding the tests a lot less painful than it would be in 2.5
We can't approve this until the @xcpky signs the cla. Thanks!
Did this pull request end up going anywhere? Started following the thread recently and was wondering if you all need some help on this?
The PR works already, but it lacks test code. I don't want to spend time on that.
Thank you @xcpky! How can I merge your PR with my local installation on my system?
I have signed cla. But I found there are conflicts. It seems gemini-cli is using clipboardy, which supports wayland. So I guess the latest gemini cli already works with wayland? I don't use gemini-cli recently so I don't know.
ok. If that's the case then it sounds like this is not longer needed. Feel free to open another PR in the future if you think changes are warranted. Thanks!