Skip to content

Preserve dictation's cursor-anchored insertion when the mic button steals focus - #186

Merged
davior merged 1 commit into
mainfrom
claude/dictation-focus-enter-qqp1j8
Sep 10, 2026
Merged

davior merged 1 commit into
mainfrom
claude/dictation-focus-enter-qqp1j8

Conversation

@davior

@davior davior commented Sep 10, 2026

Copy link
Copy Markdown
Owner

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, insertDictatedText always 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."

  • insertBlocksAtCursor now 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.
  • A new handleDictationToggle wrapper in EditorView.tsx captures 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 in dictationAnchorBlockIdRef.
  • insertDictatedText passes 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 existing dictationSessionBlockIdRef tracking) land in the right place.
  • The anchor is cleared whenever a dictation session ends, alongside the existing session-block cleanup.

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 --noEmit passes
  • Manually verify: click into the middle of a note, start dictation, confirm dictated text is inserted at that cursor position (not appended at the end)
  • Manually verify: start dictation without clicking into the note first, confirm it still appends at the end

🤖 Generated with Claude Code

https://claude.ai/code/session_019ssxort6KYBGuGLWikh3k4


Generated by Claude Code

…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
davior marked this pull request as ready for review September 10, 2026 06:20
@davior
davior merged commit 77e2f5a into main Sep 10, 2026
2 checks passed
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.

2 participants