Skip to content

Track keyboard field controllers to route dictation results correctly - #362

Closed
alexkroman wants to merge 1 commit into
mainfrom
claude/nifty-maxwell-dg78jk
Closed

alexkroman wants to merge 1 commit into
mainfrom
claude/nifty-maxwell-dg78jk

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

What & why

When a user dictates into a field and then taps into another field in the same keyboard app before the words arrive, they should go to the clipboard, not the new field. This change adds field-level tracking via controllerID throughout the dictation pipeline so results are routed to the exact field that requested them, not just the keyboard process.

Key changes:

  • KeyboardAddress struct wraps a keyboard process and its controller (field) to identify the target precisely
  • DictationResult now carries controllerID to specify which field within a process should receive the words
  • KeyboardCommand and CommandRouter.Decision propagate controllerID from the keyboard through the routing layer
  • DictationCoordinator.Press tracks both the pressing field's controller and the stop recipient's controller via resultAddress computed property
  • KeyboardModel rejects results meant for a different controller in the same process
  • KeyboardRelayInjector compares both process and controller when deciding whether to insert or copy to clipboard

The change is backward-compatible: controllerID is optional, and older keyboard builds that don't send it are treated as "any controller in that process" (matching current behavior).

How it was tested

  • scripts/check.sh passes (or CI will, if I'm not on a Mac)
  • I read AGENTS.md and this doesn't reintroduce anything deliberately removed
  • Docs updated if behavior changed

Test coverage:

  • relayToPressingField() verifies that words meant for one field don't insert when another field in the same keyboard is on screen
  • releaseAddressesField() confirms the stop command's controller is captured and routed with the result
  • endingNamesController() validates that accepted endings (release/cancel) name the field that sent them
  • KeyboardModelProtocolTests extended to verify results for another field are left in the store for the clipboard path

… keyboard process (#346)

A DictationResult named only a keyboard process, so a new controller in the
same process - the field the user tapped into while the words were still
processing - would insert them. The result now carries the controllerID of
the field that sent the accepted stop (else the press): the relay copies to
the clipboard at once when the presence record names another controller,
and a keyboard inserts only a result for its own controller (or none, from
an older build).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DS5B1TTNwsgcqxJKiGZw4b
@alexkroman
alexkroman enabled auto-merge November 24, 2026 22:50
@alexkroman
alexkroman disabled auto-merge November 24, 2026 22:58
@alexkroman

Copy link
Copy Markdown
Collaborator Author

Superseded by #375, which addresses results by documentIdentifier as well as controllerID — iOS can keep the same input controller when focus moves to another field in the same app, the main repro in #346.

@alexkroman alexkroman closed this Nov 24, 2026
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