Description
On my iPhone the keyboard suggestions don't work in the terminal. When I tap one, only its first letter shows up. Holding delete is broken too: it never switches to deleting word by word.
Setup: iPhone on iOS 26.5.2, Safari (not added to the home screen), Codeman 1.51.0.
I saw it in an OMP session, but from what I found it shouldn't depend on the session type.
What happens
| What I do on the iPhone keyboard | What I get in Codeman |
|---|---|
type hel, tap the suggestion hello |
hell |
type hello, space, tap a next-word suggestion (inspection) |
hello i |
type hello without a space, tap a next-word suggestion |
only a space |
| hold delete | it deletes letter by letter and never goes word by word |
Every time, only the first character of what the keyboard inserts gets through.
What I tested
I put together a small test page that loads the same xterm and keycode229 recovery scripts as Codeman. It isn't connected to any session, and it logs every key/input event on xterm's hidden textarea along with what xterm emits in onData. I ran the cases above on the phone with it.
When I tap a suggestion, iOS sends one key event that carries the whole text, then an insertText with the same text:
8127 keydown key="lo" code=Unidentified keyCode=76 textarea=""
8132 keypress key="lo" charCode=108 textarea=""
8133 onData "l" <- only the first letter
8141 beforeinput inputType=insertText data="lo" composed=true
8143 input inputType=insertText data="lo" composed=true textarea="lo"
That was hel + the hello suggestion, so iOS only sends the missing part (lo). xterm sends the first letter from the keypress (String.fromCharCode(charCode)) and then ignores the input. In 6.0.0 _inputEvent only forwards insertText when !ev.composed || !this._keyDownSeen, and iOS sets composed=true right after a keydown. The keydown on its own does nothing either, because evaluateKeyboardEvent only accepts a key of length 1. The keycode229 recovery sees the same input, but xterm already emitted something for that keystroke (the l), so it backs off. The rest of the text is lost.
The other cases look the same: hello + space + the gives onData "t", and the whole-phrase suggestion Hello World gives onData "H".
The underlying problem is that the hidden textarea never contains what I typed. Normal letters are handled by xterm on keydown and then cancelled (preventDefault), so they never reach the textarea, and only spaces end up in it. iOS predicts from its own memory of what I typed, but its edits land in a box that doesn't hold that text. That's also why a suggestion meant to replace a word (I typed helloworl and tapped Hello World) comes through as a plain insertText and not insertReplacementText: there's nothing in the box to replace. The session ended up with helloworlH.
Hold delete: each repeat is a normal keydown Backspace, and xterm turns it into one DEL. When iOS switches to word by word, it keeps sending one Backspace keydown per repeat and adds a burst of deleteContentBackward input events with no key (I counted 14 in about 0.4 s). xterm ignores those because _inputEvent only handles insertText, so the session keeps getting one DEL per repeat.
I never saw keyCode=229, any composition events, insertReplacementText or deleteWordBackward. isComposing was always false.
A desktop simulation (headless Chromium posing as an iPhone) missed part of this. It gave hello iinspection instead of hello i, because the synthetic events didn't have composed: true. A test for this needs to replay the events exactly, including that flag.
The xterm side looks like a bug for any iOS keyboard, so it may be worth reporting there too. Related: xtermjs/xterm.js#6284 (macOS Safari 26.2, replacements dropped) and xtermjs/xterm.js#5704 (insertReplacementText, not merged).
Activity
Ark0N commentedon Nov 17, 2026
Thanks for the detailed trace. It made this quick to confirm.
The code confirms it, and I replayed the event sequence you logged. That was in headless Chromium rather than on an iPhone, against the
vendor/xterm.min.jsandterminal-keycode229-recovery.jsthat 1.51.0 ships, withcomposed: trueon the input events.helplus alosuggestion comes out ashell, aHello Worldsuggestion asH, and three Backspace keydowns followed by 14deleteContentBackwardevents send exactly three DELs.The cause is the one you describe:
String.fromCharCodein_keyPress), becauseevaluateKeyboardEventonly takes a one-characterkeyon keydown._inputEventthen refuses theinsertText. There is one more guard than thecomposedcheck:_inputEventalso returns early while_keyPressHandledis set, and that flag stays set from the keypress until keyup. In my replay (keyup after theinput) the text was refused even withcomposed: false, so a fix cannot rely on thecomposedflag alone.src/web/public/terminal-keycode229-recovery.jsis active on an iPhone (it is created whenever(pointer: coarse)matches), but it stands down because xterm emitted the first letter after the keydown snapshot (thecanonicalCount > candidate.snapshotcheck). Its edit-based diff replaces xterm's_handleAnyTextareaChanges, which xterm only calls fromCompositionHelper.keydownfor keyCode 229, so it never runs here. Itsinputlistener also ignores everyinputTypeexceptinsertText, so nothing in the terminal path reacts todeleteContentBackward.Your #815 branch is not involved: that PR does not touch the key handler,
onDataor the recovery module.For now, Compose in the accessory bar is the way to type with suggestions on an iPhone, as you found.
A PR is welcome. A few things matter for one:
terminal-ui.js(initTerminal()) for the main terminal and interminal-tile.js(_createKeyCode229Recovery()) for grid tiles and the split pane. A change has to keep both in step.test/terminal-keycode229-recovery.browser.test.ts, is outside thenpm testgate, so run it withnpm run test:browser -- test/terminal-keycode229-recovery.browser.test.ts. A case there that replays your logged sequence (keydownkey="lo", keypresscharCode=108, theninsertTextwithcomposed: true) would pin this.fix(web): address Ark0N#839 review for the iOS keyboard fix (Ark0N#830)