Added image pasting capabilities for Wayland and X11 on Linux#17144
Added image pasting capabilities for Wayland and X11 on Linux#17144
Conversation
Summary of ChangesHello @devr0306, 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 CLI's functionality by introducing robust image pasting support for Linux users, covering both Wayland and X11 environments. The core of this enhancement is a new secure, stream-based utility for handling external command outputs, which not only enables the feature but also mitigates potential security vulnerabilities associated with shell commands. This change expands the platform compatibility for image handling and improves the overall user experience on Linux. 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
The pull request successfully introduces image pasting capabilities for Linux, supporting both Wayland (wl-paste) and X11 (xclip). The implementation correctly prioritizes Wayland and falls back to X11. A significant improvement is the use of a stream-based approach with spawn and explicit arguments in the saveFromCommand helper, which effectively mitigates potential shell injection risks. The associated test cases have been appropriately updated to include Linux as a supported platform. The changes are well-structured and enhance the cross-platform functionality of the clipboard utilities.
|
Size Change: +4.06 kB (+0.02%) Total Size: 23.2 MB
ℹ️ View Unchanged
|
jacob314
left a comment
There was a problem hiding this comment.
It would be good to add some true E2E tests for this.
…Wayland and X11 on Linux (google-gemini#17144)

Summary
This PR introduces support for pasting images from the clipboard on Linux, implementing fallbacks for both Wayland (wl-paste) and X11(xclip). The implementation correctly addresses potential security risks associated with shell commands by using a stream-based approach.
Details
I added a helper function to save the image to a temporary file instead of calling
sh -cwhich has a risk of shell injection. It also uses a stream-based approach with early exiting to prevent race conditions.Related Issues
Fixes #15250
How to Validate
Screen recording of manual testing
Pre-Merge Checklist