Skip to content

iOS: insert a dictation only into the field it was made in (#346) - #375

Merged
alexkroman merged 1 commit into
mainfrom
fix/ios-result-addressed-to-field
Nov 25, 2026
Merged

alexkroman merged 1 commit into
mainfrom
fix/ios-result-addressed-to-field

Conversation

@alexkroman

Copy link
Copy Markdown
Collaborator

Fixes #346.

Problem

DictationResult was addressed to a keyboard process only. If the user released in field A and then tapped field B before "Pasted", a keyboard over B in the same process inserted A's words. That covers both cases: iOS often keeps the same input controller across fields in one app, or a new controller comes up in the same process. appeared() → resultArrived() hit the same hole.

Fix

  • KeyboardCommand now carries documentID (UITextDocumentProxy.documentIdentifier) beside the controllerID it already sent. controllerID alone wouldn't catch the main repro, since iOS can reuse one controller as focus moves between fields; the document identifier is what changes.
  • New ResultAddress (process + controller + document). The coordinator keeps one for the press and one for the accepted stop (stop wins, as recipient did). The relay puts it on DictationResult.
  • resultArrived() inserts only when result.isFor(controllerID:documentID:). Otherwise it leaves the result in the store (not taken), so the owner can still take it, and the app copies the words out at its delivery timeout with "Copied", the existing fallback when no keyboard takes them.
  • A field left nil by an older build matches anything, so a mixed-version app/keyboard behaves as before.
  • DESIGN.md's "result addressing" row is updated.

Tests

  • A result for another document in the same controller, or for another controller in the same process (including the appeared() path), is not inserted and stays in the store. Back over the right field, it inserts.
  • Results naming no field still go to whoever is up.
  • Coordinator: the result carries the press's field, or the accepted stop's field when that comes from elsewhere.
  • Commands carry the proxy's documentIdentifier.

Worth a hardware check

The behavior assumes documentIdentifier is stable for one field across a dictation (press → result). If some host app changed it mid-dictation, the outcome would be "Copied" instead of "Pasted", never words in the wrong field.

🤖 Generated with Claude Code

A result was addressed to a keyboard process only, so a keyboard over a
different field in the same process — the user tapped field B while the
words for field A were still being transcribed, with iOS keeping the
controller or bringing up a new one — inserted them there.

The press and stop commands now carry the field's
UITextDocumentProxy.documentIdentifier beside the controllerID they
already sent; the coordinator keeps a ResultAddress (process, controller,
document) for the press and for the accepted stop, and the relay puts it
on the DictationResult. A keyboard inserts only when the result names its
controller and document; otherwise it leaves the result, and the app
copies the words out at its delivery timeout ("Copied"), as when no
keyboard takes them. A part left nil by an older build matches anything.

Fixes #346

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexkroman
alexkroman enabled auto-merge November 24, 2026 22:58
@alexkroman
alexkroman added this pull request to the merge queue Nov 24, 2026
@alexkroman
alexkroman removed this pull request from the merge queue due to a manual request Nov 24, 2026
@alexkroman
alexkroman added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 0399051 Nov 25, 2026
13 checks passed
@alexkroman
alexkroman deleted the fix/ios-result-addressed-to-field branch November 25, 2026 00:34
alexkroman pushed a commit that referenced this pull request Nov 25, 2026
…eld-read test

#375 gave the relay a ResultAddress presser; the injected clock now sits
beside it, and the delivered test steps the clock while asserting the
controller. #370 independently moved the held-read test onto a TestClock
with its own press helper; its version is kept.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

iOS: dictation can land in a different field after you move focus while it’s still processing

2 participants