feat: preserve non-text clipboard content during paste-and-restore#1231
Open
egsok wants to merge 2 commits intocjpais:mainfrom
Open
feat: preserve non-text clipboard content during paste-and-restore#1231egsok wants to merge 2 commits intocjpais:mainfrom
egsok wants to merge 2 commits intocjpais:mainfrom
Conversation
Save and restore images, HTML, files (not just text) when pasting transcribed text via clipboard. Uses arboard directly for multi-format clipboard access while keeping tauri plugin for writing transcription. Detection order: files → image → HTML → text → empty. Wayland text restore still uses wl-copy for umlaut compatibility. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Owner
|
Curious, have you tested all of these, just want to make sure I've tested a branch that tried this before without success so just curious. I am open to this for sure though |
Author
|
@cjpais yes, sir! Tested every case (pics, html, files) on Win11. authored a similar PR for Openwhispr recently (OpenWhispr/openwhispr#381), Handy is even better suited for this because of use of arboard (so we get support for random files from explorer as well, unlike Openwhispr). |
Owner
Author
|
@cjpais cool! let me know if anything needs fixing |
Owner
|
One possible thing to consider, in case of regressions is adding a toggle to change back to the old method. Could be done in debug potentially. I will test this myself first, I would prefer not to have this path. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
When using clipboard-based paste methods (Ctrl+V, Shift+Insert, etc.), Handy saves the clipboard, writes transcribed text, sends the paste keystroke, then restores the original clipboard content. Currently it only handles plain text —
read_text()returns an empty string for anything else.This means if you had a screenshot, copied files, or rich HTML in the clipboard before transcribing, it was silently replaced with an empty string. Your clipboard content was lost.
Solution
Use
arboard(already a transitive dependency viatauri-plugin-clipboard-manager, so zero extra compile cost) to detect and restore all clipboard formats:Detection order is most-specific-first: files → image → HTML → text → empty. This prevents false matches (e.g., browser copies set both HTML and text fallback — text-first would lose formatting).
On Wayland, text restore still uses
wl-copyfor umlaut compatibility.Files changed
src-tauri/Cargo.toml— addarboardas direct dependencysrc-tauri/src/clipboard.rs— addSavedClipboardenum +save_clipboard()/restore_clipboard(), replace text-only save/restore inpaste_via_clipboard()Test plan
CopyToClipboardsetting still works (leaves transcribed text in clipboard, no restore)