Skip to content

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

Merged
gabrielste1n merged 1 commit intoOpenWhispr:mainfrom
egsok:fix/clipboard-restore-non-text-clean
Mar 31, 2026
Merged

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

Conversation

@egsok
Copy link
Copy Markdown
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

@egsok egsok force-pushed the fix/clipboard-restore-non-text-clean branch from 7c02627 to 10020c3 Compare March 7, 2026 09:13
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@egsok egsok force-pushed the fix/clipboard-restore-non-text-clean branch from 10020c3 to bd6ab05 Compare March 31, 2026 17:05
@egsok
Copy link
Copy Markdown
Contributor Author

egsok commented Mar 31, 2026

@gabrielste1n Rebased on latest main — would appreciate a review when you get a chance 🙏

@gabrielste1n gabrielste1n self-requested a review March 31, 2026 17:47
@gabrielste1n
Copy link
Copy Markdown
Collaborator

taking a loook at this now! thanks @egsok

@gabrielste1n gabrielste1n merged commit 5029160 into OpenWhispr:main Mar 31, 2026
6 checks passed
@gabrielste1n
Copy link
Copy Markdown
Collaborator

great stuff thanks @egsok - merged

@egsok
Copy link
Copy Markdown
Contributor Author

egsok commented Apr 1, 2026

@gabrielste1n nice! happy to help 😄

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.

2 participants