Repository navigation
Conversation
#432) RealClipboardPaster only ever saved pasteboard.string(forType: .string) before borrowing the clipboard for the dictated text. A copied image or a Finder file reference has no plain-string representation, so that came back nil - after the paste, the restore branch never fired and the user's original clipboard content was left cleared, not restored. Now saves the full item set (every type on every NSPasteboardItem) and writes it all back on restore. The existing changeCount race guard - skip the restore if the user copied something else while it was borrowed - is unchanged. Compile-verified only (swift build is clean); real NSPasteboard behaviour needs a Mac, checklist in docs/testing/clipboard-restore-432.md. Claude-Session: https://claude.ai/code/session_0144sxo5CJiyk99vaR7sgjuj
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.
Closes #432. Fixes a real data-loss bug in the paste-delivery rung, not a hypothetical one.
The bug
RealClipboardPaster.paste(rung 2 of delivery - used whenever a direct AX write isn't possible or fails verification, the common path for browsers, terminals, many Electron apps) borrows the clipboard for the dictated text, then restores whatever was there before. It only ever savedpasteboard.string(forType: .string). Anything without a plain-string representation - a copied image, a Finder file reference, anything with no.stringtype - made that come backnil. After the paste, the restore branch never fired, so the pasteboard was left cleared instead of restored: the user's original clipboard content silently and permanently gone.The existing race guard (skip restore if
changeCountmoved - added for #62) is a different protection and is untouched by this fix.The fix
Saves the full pasteboard item set before borrowing it - every type on every
NSPasteboardItem, not just the string coercion - and restores by writing freshNSPasteboardItems built from that saved data. A copied image, a file reference, or anything else with a non-string representation now survives a dictation the same way plain text already did.Tests
No unit test:
RealClipboardPastertalks to the realNSPasteboard.generaland has no existing test coverage (the fake used elsewhere coversInjectionEngine's call site, not this adapter).swift build --package-path native/accessibility-helperis clean. Manual checklist indocs/testing/clipboard-restore-432.md- needs a real Mac to actually exercise, same constraint as the other native-helper fixes this session (#137, #433).🤖 Generated with Claude Code