Skip to content

Fix dictation: use clipboard paste for all transcripts#24

Merged
execsumo merged 1 commit into
masterfrom
claude/dictation-short-text-fix-7ECF
May 28, 2026
Merged

Fix dictation: use clipboard paste for all transcripts#24
execsumo merged 1 commit into
masterfrom
claude/dictation-short-text-fix-7ECF

Conversation

@execsumo

Copy link
Copy Markdown
Owner

Summary

  • Short transcripts (< 50 chars) were silently dropped by VS Code and other Electron apps — CGEvent.postToPid reported success but the chunked unicode events never landed. Route every utterance through clipboard paste instead, removing the threshold and the now-dead insertTextBulk / insertTextBulkHID paths.
  • Restore DebugFileLog (dropped in 7f110d7) and wire it through the full dictation lifecycle. NSLog under macOS 15+ isn't reliably reaching log 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=true and reported success, but only the three with text length ≥ 50 actually appeared in the editor:

Length Result
50 / 63 / 64 chars clipboard path → ✓ inserted
21 / 24 chars CGEvent path → ✗ silently dropped

The 50-char threshold from ee82c43 only 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

  • Short utterances ("Hey.", "Me.", "When") inserted into VS Code
  • Longer paragraph inserted into VS Code
  • Spot-check in a non-Electron app (Notes / Mail / TextEdit)
  • Verify dict-debug.log keeps recording sessions over time

🤖 Generated with Claude Code

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>
@execsumo
execsumo merged commit ddb09d9 into master May 28, 2026
2 checks passed
@execsumo
execsumo deleted the claude/dictation-short-text-fix-7ECF branch May 28, 2026 06:40
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.

1 participant