Skip to content

fix(desktop): add native clipboard image paste and fix text paste#12682

Merged
adamdotdevin merged 1 commit intoanomalyco:devfrom
invarrow:fix/desktop-clipboard-paste
Feb 8, 2026
Merged

fix(desktop): add native clipboard image paste and fix text paste#12682
adamdotdevin merged 1 commit intoanomalyco:devfrom
invarrow:fix/desktop-clipboard-paste

Conversation

@invarrow
Copy link
Contributor

@invarrow invarrow commented Feb 8, 2026

Summary

  • Add native clipboard image paste support for the desktop app using Tauri's clipboard-manager plugin
  • Fix a bug where text paste was broken because the native clipboard image check ran before checking for text

Problem

Fixes #9868 #12686

When pasting text on the desktop app, the handlePaste function was checking for native clipboard images (via platform.readClipboardImage) before checking if there was text on the clipboard. Since OS clipboards can hold multiple formats simultaneously, this caused stale image data to be returned even when the user copied text, resulting in:

  1. Text paste being skipped entirely
  2. An old/stale image being pasted instead

Solution

Reordered the paste logic so that:

  1. Browser-detected images are handled first
  2. Unsupported file types show a toast
  3. Plain text is extracted from clipboard
  4. Only if there's no text, the native Tauri clipboard is checked for images (e.g., screenshots copied outside the browser)
  5. Text is inserted if present

Changes

  • packages/app/src/components/prompt-input.tsx: Fixed paste order logic
  • packages/app/src/context/platform.tsx: Added readClipboardImage to Platform type
  • packages/desktop/src/index.tsx: Implemented readClipboardImage using Tauri plugin
  • packages/desktop/package.json: Added @tauri-apps/plugin-clipboard-manager dependency
  • packages/desktop/src-tauri/capabilities/default.json: Added clipboard-manager:allow-read-image capability

@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 8, 2026

The following comment was made by an LLM, it may be inaccurate:

Potential Related PRs Found

Based on the search results, here are PRs that appear related to clipboard and paste handling:

  1. feat: Pass through data URLs directly and gracefully handle unknown U… #12592 - feat: Pass through data URLs directly and gracefully handle unknown URLs

    • Related to clipboard image handling and data URL processing
  2. fix(desktop): windows clipboard images come thru as data not file #12549 - fix(desktop): windows clipboard images come thru as data not file

    • Directly related to desktop clipboard image handling, appears to be a similar issue
  3. fix: support reading furl (file URL) from macOS clipboard #6127 - fix: support reading furl (file URL) from macOS clipboard

    • Related to native clipboard image support on macOS
  4. fix(tui): support clipboard image paste with proper filename on WSL2 #8209 - fix(tui): support clipboard image paste with proper filename on WSL2

    • Related to clipboard image paste functionality (though for TUI, not desktop)

The most closely related PR is #12549, which also addresses desktop clipboard image issues and may be addressing a related or overlapping problem.

- Add @tauri-apps/plugin-clipboard-manager for native clipboard access
- Add readClipboardImage platform method to read images via Tauri
- Add clipboard-manager:allow-read-image capability
- Fix handlePaste to check for text before trying native clipboard image

The native clipboard fallback was running before checking for plain text,
causing stale image data to override text paste. Now the fallback only
runs when there's no text on the clipboard.
@invarrow
Copy link
Contributor Author

invarrow commented Feb 8, 2026

Fixes #9868 #12686

@invarrow invarrow force-pushed the fix/desktop-clipboard-paste branch from 29e1fd1 to fa1f87c Compare February 8, 2026 11:19
@adamdotdevin adamdotdevin enabled auto-merge (squash) February 8, 2026 11:23
@adamdotdevin adamdotdevin merged commit d5036cf into anomalyco:dev Feb 8, 2026
6 checks passed
jerome-benoit pushed a commit to jerome-benoit/opencode that referenced this pull request Feb 8, 2026
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.

ubuntu 25.10 cant paste image on desktop app

2 participants