Preserve dictation's cursor-anchored insertion when the mic button steals focus - #186
Merged
Merged
Conversation
…eals focus Focusing the dictation button on start (so Enter/Space toggles it) meant the editor was no longer reported as focused when insertDictatedText ran, so every chunk fell back to appending at the end of the note instead of landing where the cursor was. Capture the cursor's block synchronously right before dictation starts — the last moment the editor still reports itself focused for that click — and anchor the session's inserts there. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019ssxort6KYBGuGLWikh3k4
davior
marked this pull request as ready for review
September 10, 2026 06:20
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
Follow-up to #185, which shipped focusing the note editor's dictation mic button on start/stop (so Enter/Space toggles it). That had a regression: since the editor is no longer "focused" once the button has focus,
insertDictatedTextalways fell back to appending dictated text at the end of the note, instead of inserting it wherever the user's cursor was — breaking "click anywhere in the note, then dictate at that position."insertBlocksAtCursornow accepts an optional anchor block id; when given and the block still exists, blocks are inserted after it regardless of the editor's current focus state.handleDictationTogglewrapper inEditorView.tsxcaptures the cursor's block synchronously, right before a dictation session starts — the last moment the editor still reports itself focused for that click, before focus moves to the mic button — and stores it indictationAnchorBlockIdRef.insertDictatedTextpasses that captured anchor through for the session's first inserted block, so all subsequent chunks (which continue to merge into that same block via the existingdictationSessionBlockIdReftracking) land in the right place.If dictation is started without the editor ever having had focus (e.g. clicking straight into the mic button), behavior is unchanged: it falls back to appending at the end of the note.
Test plan
tsc --noEmitpasses🤖 Generated with Claude Code
https://claude.ai/code/session_019ssxort6KYBGuGLWikh3k4
Generated by Claude Code