[PR #12682] fix(desktop): add native clipboard image paste and fix text paste #14321

Closed
opened 2026-02-16 18:19:07 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12682

State: closed
Merged: Yes


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
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12682 **State:** closed **Merged:** Yes --- ## 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
yindo added the pull-request label 2026-02-16 18:19:07 -05:00
yindo closed this issue 2026-02-16 18:19:07 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14321