Skip to content

Add clipboard image paste support via Alt+V and /paste-image#1525

Closed
PatilSharvil wants to merge 1 commit into
QwenLM:mainfrom
PatilSharvil:feature/clipboard-image-paste
Closed

Add clipboard image paste support via Alt+V and /paste-image#1525
PatilSharvil wants to merge 1 commit into
QwenLM:mainfrom
PatilSharvil:feature/clipboard-image-paste

Conversation

@PatilSharvil

Copy link
Copy Markdown

Pull Request: Clipboard Image Paste Support

PR Title

feat(cli): Add clipboard image paste via /paste-image and Alt+V

PR Description

Problem

Currently, sharing visual content (screenshots, diagrams, error messages) with Qwen Code requires:

  1. Manually saving the image to a file
  2. Navigating to the correct directory
  3. Using the @path/to/image.png syntax to reference it

This friction discourages users from sharing visual context, reducing the AI's ability to help with UI bugs, error screenshots, and design feedback.

Solution

This PR introduces native clipboard image pasting - a seamless way to share images directly from the system clipboard.

Features

Feature Description
/paste-image command Primary method to paste clipboard images
Alt+V keyboard shortcut Quick paste for power users
Cross-platform support Windows (PowerShell), macOS (AppleScript), Linux (xclip/xsel/wl-paste)
Auto-cleanup Images are automatically deleted after 5 minutes
Privacy-first All images stay local in .qwen-clipboard/ directory

User Experience

> /paste-image

📎 Clipboard image loaded
• Path: .qwen-clipboard/clipboard-1768697710562.png
• Type: image/png
• Size: 60.3 KB
• Hash: 9ca7f144…3dfa
• Auto-delete: 5 minutes

📌 To reference this image, type: @.qwen-clipboard/clipboard-1768697710562.png

The image reference is automatically inserted into the input field, ready for the user to add their question.

Implementation Details

Architecture

┌─────────────────────────────────────────────────────────────┐
│                     User Interaction                        │
│              /paste-image  OR  Alt+V shortcut               │
└─────────────────────────┬───────────────────────────────────┘
                          │
                          ▼
┌─────────────────────────────────────────────────────────────┐
│                  pasteImageCommand.ts                       │
│           Slash command handler & orchestration             │
└─────────────────────────┬───────────────────────────────────┘
                          │
                          ▼
┌─────────────────────────────────────────────────────────────┐
│                   clipboardUtils.ts                         │
│              Cross-platform clipboard access                │
├─────────────────┬─────────────────┬─────────────────────────┤
│     Windows     │      macOS      │         Linux           │
│   PowerShell +  │   AppleScript   │  xclip / xsel /         │
│  System.Windows │   (osascript)   │  wl-paste (Wayland)     │
│     .Forms      │                 │                         │
└─────────────────┴─────────────────┴─────────────────────────┘

Files Changed

File Purpose
packages/cli/src/ui/utils/clipboardUtils.ts Cross-platform clipboard detection & image saving
packages/cli/src/ui/utils/clipboardUtils.test.ts Unit tests for clipboard utilities
packages/cli/src/ui/commands/pasteImageCommand.ts /paste-image slash command implementation
packages/cli/src/ui/components/InputPrompt.tsx Alt+V keybinding handler
packages/cli/src/ui/hooks/slashCommandProcessor.ts Support for update_input action type
packages/cli/src/ui/commands/types.ts Type definition for update_input action
docs/clipboard-paste-feature.md User documentation

Platform-Specific Implementation

Windows:

  • Uses System.Windows.Forms.Clipboard (more reliable than PresentationCore)
  • Runs PowerShell with -sta flag for COM compatibility
  • Saves directly as PNG using System.Drawing.Imaging

macOS:

  • Uses AppleScript to access clipboard data
  • Supports multiple formats: PNG, JPEG, TIFF, GIF
  • Falls back through formats if primary fails

Linux:

  • Supports both X11 (xclip, xsel) and Wayland (wl-paste)
  • Auto-detects available clipboard tool
  • Graceful fallback chain

Testing

Automated

  • npm run preflight passes (build, lint, type-check, tests)
  • Unit tests for clipboard utilities

Manual

  • Windows 11 (PowerShell): verified
  • macOS / Linux: designed and implemented, pending manual verification

Security Considerations

  • No external network requests - All clipboard operations are local
  • Short TTL - Auto-delete duration is currently fixed at 5 minutes and can be made configurable in a follow-up PR if desired.
  • Project-scoped - Images saved within project directory (.qwen-clipboard/)
  • No sensitive data logging - Only logs file metadata, not image contents

Documentation

Full user documentation added at docs/clipboard-paste-feature.md including:

  • Usage instructions for both methods
  • Platform requirements (Linux packages)
  • Troubleshooting guide
  • Example workflow

Breaking Changes

None. This is a purely additive feature.

Checklist

  • Code follows project style guidelines
  • Self-reviewed the code
  • Added documentation
  • Added tests
  • All existing tests pass
  • No new warnings

Demo

alt+v feature to paste images into qwen code cli

@LaZzyMan

Copy link
Copy Markdown
Collaborator

Hi @PatilSharvil,Thank you so much for this well-thought-out PR and the detailed documentation! We really appreciate the effort you've put into implementing cross-platform clipboard image paste support. 🙏However, after careful consideration, we've decided not to merge this PR at this time. Here are the reasons:
Keyboard shortcut approach: We prefer not to introduce additional slash commands like /paste-image or extra shortcuts like Alt+V for image pasting. The current issue where Cmd+V doesn't work for images is actually a bug - the clipboard paste is being intercepted by the text paste logic. We plan to fix this bug so that Cmd+V/Ctrl+V will naturally support both text and image pasting.
Cross-platform support: While we appreciate your multi-platform implementation, this area requires more extensive testing and validation before we can confidently ship it. Cross-platform clipboard handling is on our roadmap, but we want to ensure it's thoroughly tested.
Auto-cleanup mechanism: The 5-minute auto-delete approach could cause issues when users resume previous conversations - they wouldn't be able to access images from earlier in the session. We're leaning towards an LRU (Least Recently Used) cache mechanism to recycle images that haven't been accessed for a longer period.
Storage location: Simply renaming the temporary folder from "gemini" to "qwen" doesn't fully address the concern of adding extra files to user projects. We're planning to move the storage location to Qwen's dedicated temp folder at ~/.qwen/tmp instead.
On another note: We're actually working on a new UI for pasting images and PDFs that addresses these concerns. We'd love for you to review our PR #1612 when it's ready! Your input would be valuable given your experience implementing this feature.Thanks again for your contribution to Qwen Code! 🚀

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.

3 participants