Skip to content

Conversation

@LearningCoding101
Copy link

TLDR

This PR adds Windows support for clipboard image functionality, allowing users on Windows to paste images from the clipboard using the existing shortcut (Ctrl+V). The implementation supports PowerShell environments.

Dive Deeper

This PR adds Windows support by:

  • Using PowerShell to access [System.Windows.Forms.Clipboard]::ContainsImage() for image detection
  • Using PowerShell to save clipboard images via System.Drawing.Imaging
  • Properly escaping Windows file paths for PowerShell execution

Reviewer Test Plan

  • Windows machine with PowerShell (default on Windows)
  1. Build the CLI: npm run build
  2. Copy an image to clipboard using one of these methods:
    • Take a screenshot with Win+Shift+S
    • Copy image from web browser (right-click → Copy Image)
    • Copy image file in File Explorer
  3. Start qwen CLI and press Ctrl+V in the input prompt
  4. Verify that @.gemini-clipboard/clipboard-{timestamp}.png is inserted
  5. Verify the file exists and is a valid image

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman -
Seatbelt -

Copilot AI review requested due to automatic review settings December 12, 2025 08:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends clipboard image functionality to support Windows platforms using PowerShell, complementing the existing macOS implementation. The changes enable Windows users to paste images from the clipboard using Ctrl+V.

Key Changes:

  • Added Windows-specific implementation using PowerShell's System.Windows.Forms and System.Drawing assemblies for clipboard image detection and saving
  • Refactored both clipboardHasImage() and saveClipboardImage() functions to support platform-specific implementations
  • Maintained existing macOS functionality while adding fallback for unsupported platforms
Comments suppressed due to low confidence (1)

packages/cli/src/ui/utils/clipboardUtils.ts:70

  • The description says the PR is for "qwen" but the testing instructions mention "@.gemini-clipboard/clipboard-{timestamp}.png". This inconsistency suggests either the documentation is incorrect or there's confusion about the project naming. The file path format should match the actual implementation.
    // This avoids security restrictions on paths outside the target directory
    const baseDir = targetDir || process.cwd();
    const tempDir = path.join(baseDir, '.gemini-clipboard');
    await fs.mkdir(tempDir, { recursive: true });

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@xuewenjie123
Copy link
Collaborator

thanks for your contribution! I followed the testing instructions as described:

Switched to this PR branch
Ran npm run build
Copied an image to the clipboard
Pressed Ctrl+V in the qwen CLI input line to paste
Result: On Windows, there was no response at all (the input line remained unchanged), while on macOS, the image path (e.g., .gemini-clipboard/clipboard-xxx.png) appeared as expected.

Additionally, I noticed an inconsistency: the PR description states this is for qwen, but the implementation creates a temp directory named .gemini-clipboard, and the testing instructions also reference @.gemini-clipboard/.... This suggests a possible naming mismatch—should this be aligned with qwen? If it’s a shared utility module, please clarify this in the documentation.

Could you please verify whether the Windows implementation has been fully tested and working? In particular, check the clipboard monitoring and paste event handling logic on Windows. Looking forward to your investigation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants