macOS: a paste error discards the completed dictation from History and Paste Last

Open Beginner friendly
#1,437 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
76/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
macos, rust
Domain
backend, desktop

Research direction

Read finish_output in src/parakeet.rs around lines 981–989 and trace how the paste result, last_transcript, and record_history are handled. Check the existing output tests or reproduce the controlled failure described in the issue. Done means a failed paste still returns its original error and leaves History unchanged, while Paste Last can retry the completed transcript.

Written by the indexing model from the issue text.

Description

Hex version

dev at 334af30119bb4e3a18133e05fe180cc63c193353

Platform

macOS

System details

macOS 27.3, Apple silicon

What happened?

A completed dictation is dropped from normal recovery when pasting fails. History receives no entry, and Paste Last still contains the previous successful dictation. Retrying Paste Last therefore inserts the old text.

Expected: keep the completed result available for copying or retrying, while still reporting the paste failure.

A second writer changing a private macOS pasteboard reproduced these errors in the production paster:

clipboard changed while Hex was preserving it
could not inspect clipboard format (status -25130)
Steps to reproduce

The native clipboard failure and output handling were reproduced separately, using production code with controlled inputs. The installed app and general clipboard were not used.

  1. Give finish_output an earlier Paste Last value and a newly completed transcript.
  2. Exercise src/paste.rs against a unique private pasteboard while another writer changes it. Supply the resulting native error through finish_output's existing paste callback.
  3. Observe the failure return before the History recording call or Paste Last update.
  4. Run the Paste Last output job. It uses the earlier transcript:
completed text: "completed new dictation"
history entries: []
Paste Last retry: "earlier dictation"

The ordinary trigger is another copy or clipboard update while Hex prepares the paste; its frequency in real use is unmeasured.

Additional context

In src/parakeet.rs, finish_output calls paste at line 981 and propagates its error with ? at line 989. Both last_transcript and record_history are updated only afterwards. The completed result is consumed on the error path.

Suggested minimal fix: retain the paste result temporarily, update last_transcript for a non-cancelled Paste/RawPaste result, then propagate the original error. Leave History's success-only behavior unchanged. This restores Paste Last recovery without counting a failed paste as successful History.

With the proposed fix, tested against the same native error, the error still returned, History remained empty, and Paste Last retried completed new dictation. Successful-output and deliberately injected cancellation controls also passed. The cancellation control is a fixture check of the guard, not evidence of a user-facing cancel action.

Windows and Linux have similar post-paste retention ordering in source; their native paths were not exercised.

Proof limits: the native pasteboard failure and production output function were executed. History persistence was replaced with a call recorder, so this is not a disk-backed History or installed-app integration test. Diagnostic logs may contain raw text; the demonstrated loss is recovery through History and Paste Last.

Dominant language
Rust
Stars
5.7k
Forks
337
Avg merge
2h 57m
Merged PRs (30d)
891

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from anomalyco/hex

All issues in anomalyco/hex

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.