fix(desktop): add native clipboard image paste and fix text paste #12682
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Problem
Fixes #9868 #12686
When pasting text on the desktop app, the
handlePastefunction was checking for native clipboard images (viaplatform.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:Solution
Reordered the paste logic so that:
Changes
packages/app/src/components/prompt-input.tsx: Fixed paste order logicpackages/app/src/context/platform.tsx: AddedreadClipboardImageto Platform typepackages/desktop/src/index.tsx: ImplementedreadClipboardImageusing Tauri pluginpackages/desktop/package.json: Added@tauri-apps/plugin-clipboard-managerdependencypackages/desktop/src-tauri/capabilities/default.json: Addedclipboard-manager:allow-read-imagecapability