Skip to content

Mark Blurt's clipboard writes so history apps skip them - #313

Open
theluckystrike wants to merge 1 commit into
AssemblyAI:mainfrom
theluckystrike:fix/transient-clipboard-writes
Open

theluckystrike wants to merge 1 commit into
AssemblyAI:mainfrom
theluckystrike:fix/transient-clipboard-writes

Conversation

@theluckystrike

Copy link
Copy Markdown

Fixes #310.

Blurt pastes by putting the transcript on the clipboard, pressing Cmd-V and restoring the old contents 400 ms later. Neither write was marked, so clipboard history apps such as Raycast saved every dictation (also text dictated into a password field), credited it to the app in front, and then added the old clipboard again as a new entry.

SystemClipboard now follows the nspasteboard.org markers that these apps read.

  • The transcript written for a paste carries org.nspasteboard.TransientType and org.nspasteboard.AutoGeneratedType, so it is not recorded.
  • The restore (also used by the read-aloud copy fallback) carries TransientType. The old contents are already in the history, so they no longer come back as a duplicate on top.
  • Every write Blurt makes sets org.nspasteboard.source to Blurt's bundle identifier.
  • The degraded path that leaves the transcript on the clipboard for a manual paste is not marked transient, because the user needs to paste it and may want it in their history.

SystemClipboard takes an optional pasteboard name (default .general), so the new tests in SystemClipboardMarkerTests run on a private, uniquely named pasteboard and never touch the clipboard of the person running them. The existing SystemClipboardTests still use the general pasteboard as before.

How I checked it. swift build passes and swift format lint is clean. The machine I used has the Command Line Tools only, without the Testing module, so I could not run swift test. I compiled SystemClipboard.swift on its own into a small test program that runs the same 4 cases on a private pasteboard, and all pass with the general pasteboard left untouched. Please run the suite in CI or Xcode.

The paste path writes the transcript to the clipboard and restores the
old contents afterwards. Neither write was marked, so clipboard history
apps recorded every dictation and then added the old clipboard again as
a new entry.

The transcript written for a paste now carries the nspasteboard.org
TransientType and AutoGeneratedType markers, the restore carries
TransientType, and every write sets org.nspasteboard.source to the app's
bundle identifier. The manual paste fallback is left unmarked.

SystemClipboard takes an optional pasteboard name (default .general) so
the new tests run on a private pasteboard.

Fixes AssemblyAI#310

This branch has not been deployed

No deployments
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.

dictations are saved to clipboard history apps

1 participant