Skip to content

fix: preserve images and HTML in clipboard during paste-and-restore#381

Open
egsok wants to merge 1 commit intoOpenWhispr:mainfrom
egsok:fix/clipboard-restore-non-text-clean
Open

fix: preserve images and HTML in clipboard during paste-and-restore#381
egsok wants to merge 1 commit intoOpenWhispr:mainfrom
egsok:fix/clipboard-restore-non-text-clean

Conversation

@egsok
Copy link
Contributor

@egsok egsok commented Mar 6, 2026

Summary

  • Clipboard save/restore now handles images (screenshots), HTML (rich text from browser), and plain text — previously only plain text was preserved
  • Added _saveClipboard() that detects content type via clipboard.availableFormats() and reads the appropriate format
  • Added _restoreClipboard() helper that writes back the correct format after paste completes
  • All 6 platform-specific restore callsites (macOS CGEvent, macOS osascript, Windows fast-paste, Windows nircmd, Windows PowerShell, Linux) updated to use the new helper

Problem

If a user had a screenshot (Win+Shift+S) or rich HTML in the clipboard before dictation, readText() returned "", and after paste writeText("") overwrote the image/HTML with nothing.

Test plan

  • Copy a screenshot to clipboard → dictate → verify screenshot restores (Ctrl+V pastes the image)
  • Copy plain text to clipboard → dictate → verify text restores
  • Copy rich HTML from browser → dictate → verify HTML restores when pasting into a rich text editor
  • Verify dictated text still gets pasted correctly into the active app

🤖 Generated with Claude Code

Clipboard save/restore now handles images (screenshots), HTML (rich
text), and plain text. Previously only readText() was used, which
returned "" for non-text content, losing the original clipboard data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@egsok egsok force-pushed the fix/clipboard-restore-non-text-clean branch from 7c02627 to 10020c3 Compare March 7, 2026 09:13
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.

1 participant