Fix dictation: use clipboard paste for all transcripts#24
Merged
Conversation
The previous threshold-based path (< 50 chars → CGEvent unicode insertion, ≥ 50 chars → clipboard paste) reliably dropped short transcripts in VS Code and other Electron apps: CGEvent.postToPid returned success but the events never landed in the focused field, so utterances like "Hello." or "I wonder why that is." silently vanished. The 50-char threshold in commit ee82c43 only narrowed the failure window — it didn't close it. Route every utterance through clipboard paste (single Cmd+V, one event, no chunking race). The existing save/restore of pasteboard contents already mitigates the clipboard side effect. Delete the now-unused insertTextBulk / insertTextBulkHID paths and the cgEventUnicodeLimit / clipboardPasteThreshold constants. Also restore the DebugFileLog scaffolding (dropped in 7f110d7) and wire it through the dictation lifecycle — toggleDictation, DictationManager.start / startMicCapture / appendSamples / stop, DictationHUD show/hide, HotkeyManager pressed/released, TextInjector inject. NSLog under macOS 15+ isn't reliably reaching `log stream`, so the file at ~/Library/Application Support/Heard/dict-debug.log is the guaranteed observation channel — kept in master for future debugging instead of being re-added/removed each time something goes wrong. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
CGEvent.postToPidreported success but the chunked unicode events never landed. Route every utterance through clipboard paste instead, removing the threshold and the now-deadinsertTextBulk/insertTextBulkHIDpaths.DebugFileLog(dropped in 7f110d7) and wire it through the full dictation lifecycle. NSLog under macOS 15+ isn't reliably reachinglog stream, so the file logger is the guaranteed observation channel for future debugging — kept in master rather than re-added each time.Root cause
A diagnostic session over the file log showed all five test sessions reached
TextInjector.inject … axTrusted=trueand reported success, but only the three with text length ≥ 50 actually appeared in the editor:The 50-char threshold from
ee82c43only narrowed the failure window. Clipboard paste is one Cmd+V regardless of length, and the existing save/restore mitigates the clipboard side effect.Test plan
🤖 Generated with Claude Code