gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

add cross-platform clipboard image pasting support (#14647)

Open kishan705 opened this issue 2 months ago • 2 comments

feat: add cross-platform clipboard image pasting support (#14647)

  • Added @crosscopy/clipboard package for Windows/Linux clipboard support
  • Refactored clipboardUtils to support Windows, macOS, and Linux
  • Maintained macOS fallback using osascript for reliability
  • Added comprehensive test coverage (12 new tests)
  • Users can now paste screenshots with Ctrl+V on all platforms

Fixes #14647

Summary

Implements cross-platform clipboard image pasting support for Windows, macOS, and Linux. Users can now paste screenshots directly from the clipboard using Ctrl+V (or right-click) on all platforms, significantly improving workflow efficiency when working with visual content.

Details

  • New Dependency: Added @crosscopy/[email protected] - a Rust-based native module providing clipboard access across all platforms
  • Cross-Platform Support:
    • Windows: Uses native Windows clipboard APIs via @crosscopy/clipboard
    • Linux: Supports both X11 and Wayland display systems
    • macOS: Uses @crosscopy/clipboard with osascript fallback for maximum reliability
  • Implementation:
    • Images retrieved as base64 and saved as PNG files in .gemini-clipboard/ directory
    • Automatic cleanup of files older than 1 hour
    • Graceful error handling with platform-specific fallbacks
    • Maintains backward compatibility with existing macOS implementation

Related Issues

Fixes #14647

How to Validate

Automated Testing:

npm run build
npm run test -- clipboardUtils.test.ts
npm run typecheck

kishan705 avatar Dec 06 '25 16:12 kishan705