Skip to content

Added image pasting capabilities for Wayland and X11 on Linux#17144

Merged
devr0306 merged 11 commits intomainfrom
15250-linux-image-pasting
Jan 22, 2026
Merged

Added image pasting capabilities for Wayland and X11 on Linux#17144
devr0306 merged 11 commits intomainfrom
15250-linux-image-pasting

Conversation

@devr0306
Copy link
Copy Markdown
Contributor

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 -c which 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

  1. Open Gemini CLI on a Linux terminal open in a Cloudtop or Linux machine(no SSH)
  2. Copy an image from within the Linux machine
  3. Paste it into the terminal using CTRL+V

Screen recording of manual testing

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker
@devr0306 devr0306 requested a review from a team as a code owner January 20, 2026 21:45
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @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

  • Linux Image Pasting Support: Introduced the capability to paste images from the clipboard on Linux, supporting both Wayland (via wl-paste) and X11 (via xclip) environments.
  • Secure Command Execution Helper: Implemented a new saveFromCommand helper function that securely saves the output of shell commands to a file. This function uses a stream-based approach to prevent shell injection vulnerabilities and race conditions.
  • Platform Compatibility Updates: Updated existing clipboardHasImage and saveClipboardImage utility functions to incorporate Linux-specific logic, ensuring proper detection and saving of clipboard images across macOS, Windows, and now Linux.
  • Test Suite Expansion: Modified unit tests for clipboard utilities to include Linux in platform checks, ensuring the new functionality is covered.
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 👍 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

  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.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@gemini-cli gemini-cli bot added the area/core Issues related to User Interface, OS Support, Core Functionality label Jan 20, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 20, 2026

Size Change: +4.06 kB (+0.02%)

Total Size: 23.2 MB

Filename Size Change
./bundle/gemini.js 23.2 MB +4.06 kB (+0.02%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB
./bundle/sandbox-macos-permissive-open.sb 890 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB

compressed-size-action

Copy link
Copy Markdown
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to add some true E2E tests for this.

Copy link
Copy Markdown
Contributor

@jacob314 jacob314 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@devr0306 devr0306 added this pull request to the merge queue Jan 22, 2026
Merged via the queue into main with commit 7962801 Jan 22, 2026
28 of 43 checks passed
@devr0306 devr0306 deleted the 15250-linux-image-pasting branch January 22, 2026 17:14
thacio added a commit to thacio/auditaria that referenced this pull request Jan 24, 2026
sidwan02 pushed a commit to sidwan02/gemini-cli-gemma that referenced this pull request Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality

2 participants