-
Notifications
You must be signed in to change notification settings - Fork 9.8k
add cross-platform clipboard image pasting support (#14647) #14651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ni#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 google-gemini#14647
|
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 ChangesHello @kishan705, 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 introduces significant enhancements by enabling cross-platform image pasting directly from the clipboard. It integrates a new native module for robust clipboard access across Windows, macOS, and Linux, ensuring a consistent and efficient workflow for users working with visual content. The changes include refactoring existing utilities, implementing intelligent fallbacks, and adding automated cleanup for temporary image files. 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.
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 cross-platform clipboard image pasting support by integrating the @crosscopy/clipboard package and implementing robust fallback mechanisms for macOS. The refactoring of clipboardUtils to handle different platforms and the addition of comprehensive test coverage are commendable. The implementation includes thoughtful error handling and automatic cleanup of temporary files, which enhances the overall reliability and maintainability of the feature.
|
|
||
| // Generate a unique filename with timestamp | ||
| const timestamp = new Date().getTime(); | ||
| const tempFilePath = path.join(tempDir, `clipboard-${timestamp}.png`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tempFilePath is hardcoded to use the .png extension. However, the saveMacOSClipboardImage fallback function (lines 124-186) explicitly handles various image formats (PNG, JPEG, TIFF, GIF) based on osascript output, indicating that the system clipboard can contain different image types. If the clipboardGetImageBase64() function from @crosscopy/clipboard can return base64 data for image types other than PNG, saving them all with a .png extension could lead to corrupted files or files with incorrect extensions. This is a correctness issue that could make saved images unusable for downstream applications. Please confirm that clipboardGetImageBase64() is guaranteed to only return PNG data, or implement logic to dynamically determine the image format from the base64 data and use the appropriate file extension.
feat: add cross-platform clipboard image pasting support (#14647)
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
@crosscopy/[email protected]- a Rust-based native module providing clipboard access across all platforms@crosscopy/clipboard@crosscopy/clipboardwith osascript fallback for maximum reliability.gemini-clipboard/directoryRelated Issues
Fixes #14647
How to Validate
Automated Testing:
npm run build npm run test -- clipboardUtils.test.ts npm run typecheck