Skip to content

fix(terminal): send the whole string an iPhone dictation keyboard commits, not its first letter (#1488) - #2386

Merged
devswha merged 4 commits into
mainfrom
fix/ios-dictation-whole-string
Oct 29, 2026
Merged

devswha merged 4 commits into
mainfrom
fix/ios-dictation-whole-string

Conversation

@devswha

@devswha devswha commented Oct 29, 2026

Copy link
Copy Markdown
Owner

Closes #1488

Thanks to @blaker3115-Agri for the report. Your reading of the cause (a keypress sending the first letter, then _inputEvent dropping the whole insert) was right.

Problem

With a dictation keyboard such as FluidVoice, a sentence dictated straight into the terminal grid on an iPhone reached the pane as its first letter only. The chat composer and the input line got the whole sentence.

Cause

Such a keyboard commits the transcript with one insertText call. WebKit reports that as one key (recorded in the iOS 27.0 Simulator with a minimal keyboard extension, see the issue):

keydown     key="hello world this is a test" code=Unidentified keyCode=72
keypress    key="hello world this is a test" charCode=104 ('h')
beforeinput inputType=insertText data="hello world this is a test"
input       inputType=insertText data="hello world this is a test"
keyup

xterm's _keyPress sent String.fromCharCode(charCode) (h), and _inputEvent then ignored the insertion as a key already handled.

Fix

In the xterm patch (CoreBrowserTerminal):

  • A keypress whose key is longer than one character and starts with the character its charCode names is held. A key name never matches: Enter's charCode is 13, not E.
  • The insertText carrying that same string sends it whole, once. Its beforeinput skips the Hangul replacement path, so a whole Hangul string is text and is not composed as a syllable.
  • If no such insertion follows before the next keydown, keyup, other input event or blur, the held character is sent, which is what happened before.
  • reset() drops it.

Nothing else changes: normal typing has a one-character key, Android sends keyCode 229 without a keypress, and the Linux digit-candidate path keeps a one-character key.

Evidence

  • Fail first: the new case in scripts/terminal-ipad-ime-regression.ts failed on main's patch with 'h\x07' !== 'hello world this is a test\x07'.
  • After the fix, under all four replayed platforms (MacIntel, iPad, iPhone Safari and the iPhone app's user agent), it sends hello world this is a test, Yes and 안녕하세요 whole and once. Typing after it still works: hello world, then x, then 하 composed in the editor, then Space gives hello worldx하 . Every earlier case in that script passes (Hangul composition, dictation replacement, SwiftKey, key bar, blur, pane switch).
  • New cases, all passing on the four platforms:
    • a string that starts with an emoji or a CJK extension character (😀 hello, 𠮷野家): WebKit's charCode is the first code point;
    • the fallback: with no insertion, or a different one, the keypress's h still goes, at keyup;
    • a whole-string key right after a pending Hangul syllable: 하hello.
  • Each new case fails without its part of the fix:
    • main's patch sends h;
    • 7fa27e0 lost the emoji string (only BEL arrived);
    • a patch without the keyup flush aborts at the "no insertion" case.
  • terminal-safari-ime-regression.ts, terminal-composition-regression.ts and terminal-linux-ime-regression.ts pass.
  • iOS 27.0 Simulator on eamac, isolated herdr test session, raw-mode byte logger pane:
    • Setup: iPhone 17 Pro, iOS 27.0 (24A434), a minimal keyboard extension whose DICTATE button calls insertText("hello world this is a test").
    • Safari tab, DICTATE: b'hello world this is a test' (main: b'h').
    • Ovis iOS app (Debug build; its web view says no Safari), DICTATE: b'hello world this is a test'.
    • 2-set Korean ㅇ ㅏ ㄴ ㄴ ㅕ ㅇ Space, app and Safari: 안녕 (ec 95 88 eb 85 95 20), no lone jamo.
    • English a: a, once.
    • The Simulator ran 7fa27e0. The later commits change only the hold test (code point, not the first UTF-16 unit; nothing held while a composition is pending) and the fallback, and the replay covers each of them.
  • bun run check fast: green on df6365d (workflow syntax, generated files, typecheck, build, unit tests 8666 pass, 0 fail).

Reviews

Both reviewers ran on the brief "assume it breaks; reproduce failures", read-only, unit-level only.

  • omo-native-code-reviewer: three rounds, the last one APPROVE.
    • Round 1, APPROVE with one MEDIUM: the fallback (no matching insertion) had no test. Added the "no insertion" case, which waits for h right after keyup, and the "another insertion" case.
    • Round 1 LOWs, both taken: a held key is now sent before a following keypress, and nothing is held while a composition is pending (this closes a possible double send with a pending Hangul syllable).
    • Round 2 HIGH: 044bb84 had lost the keyup flush. My mutation check edited the installed package in place, and bun hardlinks that into its cache, so the "restore" brought the mutation back and bun patch --commit recorded it. 7ae9a50 restores the flush. The mutation check was re-run properly, from a patch file.
    • Round 2 LOW, taken: the fallback character is the whole code point (String.fromCodePoint).
  • Codex Sol 6.1 Fast xhigh: three rounds, the last one APPROVE (44/44 isolated handler tests).
    • Round 1 MEDIUM, fixed: a string starting outside the BMP (😀 hello, charCode 128512) was not held, because String.fromCharCode truncates it.
    • Round 2 MEDIUM: the same lost keyup flush, fixed in 7ae9a50.

Limits

Known limits (LOW, unchanged by this PR):

  • Screen reader mode keeps xterm's own handling, so only the first character goes there.
  • A dictated string that begins with a newline or a tab still sends that one key.
  • In the replay, the Hangul whole-string sequence uses keyCode 0 by analogy with the iPhone's keyboard; it is not a recording. The English sequence was recorded in the Simulator.
  • I did not try FluidVoice itself, which needs a physical iPhone. The keyboard extension in the Simulator commits text through the same insertText call.

…key (#1488)

A dictation keyboard (FluidVoice) or any keyboard extension calling insertText
commits a whole string as one key in WebKit: keydown with the string as its key,
a keypress with its first character's charCode, then insertText of the string.
xterm sent the keypress's character and dropped the insertion, so only the first
letter reached the pane. The xterm patch holds such a keypress and sends the
insertion's string once; with no matching insertion the character goes as before.
…nd test the fallback (#1488)

WebKit's charCode is the first code point, so a string starting with an emoji
or a CJK extension character was missed. Also flush a held key on the next
keypress, hold nothing while a composition is pending, and cover the fallback
(no insertion, a different insertion) in the replay.
#1488)

044bb84 dropped the keyup flush by mistake (a mutation check edited
node_modules, which bun hardlinks to its cache). Put it back, and send the
held character as its whole code point.
@coderabbitai

coderabbitai Bot commented Oct 29, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
Commits

Reviewing files that changed from the base of the PR and between fcb6c62 and df6365d.

Files selected for processing: 4
  • changelog.d/ios-whole-string-keyboard.md
  • docs/terminal-input.md
  • patches/@xterm%[email protected]
  • scripts/terminal-ipad-ime-regression.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@devswha

devswha commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

CodeRabbit did not review this head (review limit reached). The reviews that stand in for it, with how each finding was resolved:

omo-native-code-reviewer: APPROVE on 7ae9a50 (3 rounds)

  • MEDIUM (round 1): the fallback, where no matching insertion follows, was untested. Resolved in 044bb84 with the "no insertion" case, which waits for h right after keyup, and the "another insertion" (hey ) case.
  • LOW (round 1): a held key could be reordered by a second keypress. Resolved: a held key is sent at the start of _keyPress.
  • LOW (round 1): a possible double send with a pending Hangul syllable. Resolved: nothing is held while _compositionHelper.isComposing.
  • HIGH (round 2): 044bb84 lost the keyup flush. A mutation check edited the installed package in place, and bun hardlinks it to its cache, so the reinstall kept the mutation and bun patch --commit recorded it. Resolved in 7ae9a50. The mutation check was redone from a patch file (044bb84's): it aborts at "no insertion", and the real patch passes it.
  • LOW (round 2): the fallback character was truncated outside the BMP. Resolved: String.fromCodePoint(charCode).
  • Not changed (LOW, already so before this PR, listed under Limits in the PR body): screen reader mode, and a dictated string that starts with a newline or a tab.

Codex Sol 6.1 Fast xhigh: APPROVE on 7ae9a50 (3 rounds, 44/44 isolated handler tests)

  • MEDIUM (round 1): a string starting outside the BMP (😀 hello, charCode 128512) was not held. Resolved in 044bb84 by comparing ev.key.codePointAt(0) with the numeric charCode. Covered by the 😀 hello and 𠮷野家 replay cases, which fail on 7fa27e0.
  • MEDIUM (round 2): the same lost keyup flush. Resolved in 7ae9a50.

df6365d only adds a replay case (a whole-string key after a pending Hangul syllable, 하hello). bun run check fast and the four IME replays passed on df6365d.

@devswha

devswha commented Oct 29, 2026

Copy link
Copy Markdown
Owner Author

Merging df6365d (closes #1488, thanks @blaker3115-Agri for the report). On an iPhone/iPad keyboard, dictation (and other whole-string commits) fires a keypress whose key is the whole string; xterm sent only its first character ('h' for "hello world"). The xterm 6 patch now holds such a keypress and sends the insertText string once (falling back to the keypress's own text if no insertText follows, and flushing on blur), and the matching beforeinput is not treated as a preedit. Evidence from the lane: the replay case fails on main and passes on four platforms (emoji/CJK first, fallback, Hangul); iOS 27 Simulator dictation sends 'hello world this is a test' in Safari and in the iOS app; Korean 안녕 input is unchanged. Patch-only change in patches/@XTerm%[email protected] with docs/terminal-input.md and the iPad IME browser script; read by the merge pass.

@devswha
devswha merged commit 062ce38 into main Oct 29, 2026
12 checks passed
@devswha
devswha deleted the fix/ios-dictation-whole-string branch October 29, 2026 21:02
@devswha devswha mentioned this pull request Oct 30, 2026
devswha added a commit that referenced this pull request Oct 30, 2026
## Release 0.4.21

The release PR, prepared by step 1 of
[docs/development.md#releasing](https://github.com/devswha/ovis/blob/main/docs/development.md#releasing),
now re-folded on main `1ef6ea329108a0985b823e8235b03daddcd0a5f4` after
the owner held 0.4.21 for more work. The merge pass reported the 0.4.21
queue empty.

**Do not merge yet:** the owner judges the final build before release.
No tag and no Release run from this PR's author.

- **Version:** `version` is 0.4.21 in `package.json` and
`herdr-plugin.toml`.
- **Changelog:** `bun scripts/changelog-fold.ts 0.4.21 2026-10-30`
folded 63 fragments into the 2026-10-30 section of `CHANGELOG.md` (71
entries), linked their PRs and deleted the fragments; `changelog.d`
holds only `README.md`.
- `by @login` on every outside contributor's PR link: #2361 @eddieparc,
#2333 @IdrisGit, #2355 @imurfutur3, #2341 @sulthonzh, #2359 @YuuuXie,
#2377 @IdrisGit, #2269 @CharleoYang, #2405 @jpcarranza94, #2414
@homebodify, #2417 @cheol-95, #2418 @eddieparc, #2435 @cheol-95.
- Two outside PRs had no fragment and got an entry by hand: #2341
(OpenCode background commands, Added) and #2359 (installer test timing,
Maintenance).
- Issue reporters are credited in their entries: @blaker3115-Agri
(#1488), @Hyd3-14 (#2026), @osamahbeig (#2343), @Shunamxiao (#2329),
@matiemer (#2362), @kilhyeonjun (#2344), @eddieparc (#2360), @Ploppy3
(#2236), @sulthonzh (#2340), @WOULDU-pres (#2056), @odfalik (#2038),
@aNNdii (#511), @Noobear (#2281, fixed by #2424); #2435 fixes
@cheol-95's own #2434.
- Two fragments ran past the changelog's width (#2418, #2269); their
entries are re-wrapped, words unchanged. #2382's entry reads "OpenCode's
installer puts its folder first" (reviewed earlier on this PR).
- Maintainer PRs without a fragment and without a user-facing change
have no entry: #2353 (check tool), #2371 (guide docs), #2396 and #2397
(tests), #2403 and #2433 (server and client transport seams, no
behaviour change), #2437 (test-only fix for #2435's check). #2438's own
entry (the sidebar selection marked by its fill again) is dropped: the
stroke #2352 added never shipped, so users see no change; #2352's entry
keeps only the Windows high-contrast Highlight bar.
- **Release summaries:** en, ko, ja and zh each have 5 new, 5 improved
and 5 fixed lines. Since the first review: New lists the in-browser
Claude Code / Codex sign-in (#2428) in place of the tab/workspace
shortcut line; Improved lists Settings → Agents (#2427) in place of the
sidebar fold line; Fixed lists the Codex wrong-session fix (#2426,
#2430) in place of the phone screenshot paste line. The Artifacts and
Claude status-line lines keep their reviewed wording (turned on in
Settings). Not in 0.4.21: #2420 (Codex chat behind Kiro), #2065 (Portal
sign-in) and #2436 (relay foundations) stay open for a later release.
- **Remote bundle:** `REMOTE_BUNDLE_VERSION` rises from 39 to 40 because
the bundle inputs (`server/`, `shared/`, `patches/`) changed since
remote-v39. After merge: push `remote-v40` on the merged commit and wait
for the Remote PC bundles workflow before running Release.
- **iOS:** `CURRENT_PROJECT_VERSION` stays 3 (#2370 changed
`Info.plist`; build 3 is not known to be uploaded yet).

## Validation

- `bun scripts/release-guards.ts --base v0.4.20`: "Release 0.4.21:
remote bundle, telemetry Worker and release metadata are in order."
- `dori heavy … bun run check fast` on this branch: workflow syntax,
generated types and themes, typecheck, build, unit tests all ok. Unit:
9166 pass, 0 fail, 36 skip in 591 files.
- Every PR in `v0.4.20..main` was pre-run for the owner's hands-on guide
on isolated copies (own herdr session, fresh state, never the owner's
live session). Items that need a real device (iPhone tap dictation
#2370, dictation keyboards #2386, the installed desktop app's title-bar
overlay #2381) are left for the owner's final check.

This is a release-metadata PR: it changes no code path. Per the release
steps, merge it after CI and the owner's go, then push `remote-v40`,
wait for its bundles, and run Release with `0.4.21`.
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.

iPhone dictation keyboard: only the first letter reaches the terminal grid (chat box and input line are fine)

1 participant