Repository navigation
[Bugfix #1886] Stop dropping repeated hardware keys on touch devices - #1888
Merged
Merged
Conversation
…ices The #517 duplicate guard was always on for (pointer: coarse), against xterm's textarea emitters double-firing on soft-keyboard input. Since the IME bridge (#1883) owns soft-keyboard text on touch devices, keeping it away from those emitters, the guard only saw hardware keys, paste and terminal replies there. It dropped real repeats: a held key's auto-repeat and fast double letters on an iPad keyboard. The guard is now composition-window only, and the composition arm is unchanged. Failing-first tests: jsdom (double letters, held Backspace/arrow, Enter twice on a touch device) and Playwright (real hardware keydowns on an emulated touch device; on main "hello"+3 Backspace+"p!" arrived as "help!").
… on touch devices
Contributor
Author
|
Tight fix, thank you. The guard is now composition-window only, the desktop CJK arm is untouched, and the failing-first tests cover held Backspace, arrows, double letters and Enter twice on touch, plus real hardware keydowns in Chromium. The comment correctly records why the old tradeoff note was wrong (initial repeat delay versus repeat interval). Nothing to change. CI is still running; merge waits on green and the owner's word. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On a touch device (an iPad with a hardware keyboard, for example), the dashboard terminal dropped repeated keys. Holding Backspace or an arrow key deleted or moved a fraction of what the user expected, and fast double letters lost a letter (
helloarrived ashelo). Now every key arrives.Fixes #1886
Root Cause
The exact-duplicate guard from #517 drops any
onDatapayload equal to the previous one within 150 ms. #517 made it always on for(pointer: coarse), against late duplicates from xterm's multiple textarea emitters (keydown,compositionend, input event) double-firing on soft-keyboard input.Since PR #1884 (the fix for issue #1883, mobile autocomplete duplicating text), the IME bridge owns soft-keyboard text on touch devices:
So on a touch device the always-on arm only ever saw hardware keys, paste and terminal replies, and the only thing it caught was real repeats. The #517 comment's tradeoff note ("default keyboard repeat rates (>250ms) are above the 150ms window") confused the initial repeat delay with the repeat interval, which is ~30–80 ms.
Fix
apps/web/src/components/Terminal.tsx: the guard is composition-window only. The composition arm (during a composition, and up to 150 ms aftercompositionend) is unchanged, so desktop CJK input and the #517 doubled period keep their protection on desktop.On a touch device this means the guard is off. The bridge's capture-phase shield stops composition events before the guard's listeners see them, so the composition window never opens there. That was already true since PR #1884; the touch arm was the only part still active. The comment now records both.
Test Plan
Terminal.ime-dedup.test.tsx, on a touch device): fast double letters (h e l l o), a held Backspace and arrow, and Enter twice. All three fail on main. They replace the Mobile: duplicate letters and extra periods when typing #517 touch tests that pinned dropping the secondlof "hell". The Mobile: duplicate letters and extra periods when typing #517 "extra period" test moved to the composition suite, where it still passes. The touch "same character after 150 ms" test was removed: with no composition it passed whatever the timing, so it pinned nothing.playwright/ime-replace.spec.ts): real hardware keydowns on an emulated touch device.hello, three auto-repeat Backspaces, thenp!. On main the line arrived ashelp!(the secondland two of three repeats dropped). With the fix it ishep!, and the frames are exactly one per key, which also shows the IME bridge never double-sends a hardware key.apps/web: 582 unit tests pass;tsc --noEmitis clean; Playwright 12/12 (36/36 under--repeat-each=3).helloquickly.Not covered here, because it needs a real device: whether an iOS soft keyboard ever sends letters as real keydowns whose default insert xterm's cancel doesn't stop. If it does, the bridge would see that insert too. The guard's touch arm could not have caught that case either, because bridge edits bypass it.