Repository navigation
fix(mobile): handle Android terminal keyboard chords in OTA sessions - #31666
Merged
Merged
Conversation
Claim live-field keydown controls before RNWeb edits or moves focus, reuse accessory ordering and stale-target guards, and leave IME/text input alone. Fixes #25496 Co-authored-by: Sangrak Choi <[email protected]> Co-authored-by: zenghaolun02 <[email protected]>
Contributor
|
Warning Review limit reachedYou'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 3 minutes. View limit details
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. Comment |
Exercise pending-text acknowledgement, terminal switch, disconnect and listener cleanup through the live hooks.
This was referenced Oct 22, 2026
This was referenced Oct 26, 2026
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.
What changed (ELI5)
Android keyboards can send Ctrl+C, Esc, Tab, and arrows, but the live input treated them like a normal text box. Ctrl+C disappeared and Tab moved focus away, so the next arrow never reached the terminal. Capture those controls on the Android live field, encode them with the existing shortcut builder, and send them through the existing accessory queue. Enter, deletion, ordinary typing, composition, AltGr, and platform shortcuts retain their existing handling.
The Android session runs the desktop OTA React Native Web bundle inside its native WebView. This extends that route's existing field binding. The capture gate is Android-only; iOS and standalone web keep their current keyboard behavior. It adds no native module or RPC method and reuses the pending-text acknowledgement queue and terminal/disconnect generations.
Before / after
Same API35 x86_64 headless Android emulator, Unexpected Keyboard2.1.0, paired v2 encrypted test host, and production-built OTA bundles. Tapped Ctrl then C; swiped Q→Esc, A→Tab, and the directional key upward. The host echoes only bytes received through
terminal.send.Before: only Esc (
1b) and Tab (09) arrive; Tab dismisses the keyboard and the arrow is lost. After: Ctrl+C (03), Esc (1b), Tab (09), and Up (1b 5b 41) arrive once each, and the live field stays focused. Both runs use Orca's existing DOM renderer fallback, enabled only at runtime because Swiftshader clips WebGL glyphs. No renderer source changes or synthetic CDP key events are used.Verification
a,b, Backspace (7f) and Enter (0d). After native composition ends, Ctrl+C, Shift+Tab and Ctrl+Up arrive once as03,1b 5b 5a,1b 5b 31 3b 35 41.compositionstart, updates,isComposing=trueand keyCode229. Native Ctrl+C whileniis composing sends no interrupt. Candidate selection commits你.n,i,7f 7f,你. Existing Android preedit mirroring forwards the preedit and replaces it with delete bytes; the visually blank host row is those two deletes, not an empty payload. This PR preserves that behavior and does not claim atomic CJK transport.TerminalWebView.tsx; no diagnostics remain in changed files. All applicable CI checks pass on published head418acb40ef15, including canonical mobile verification, static analysis/typecheck, and OTA bundle validation.Native CJK regression comparison (same IME/configuration; candidate tapped on the native keyboard). A fresh build of base
0b82f88e9f2bproduced4e067e1ad1ba; rebuilding published418acb40ef15reproduced the tested gated bundle5aa3f46ae070exactly:Review and merge risk
Low after full-host Android verification. The Android-only binding, composition/default-prevented/AltGraph guards, send-queue lifecycle tests and previous native Unexpected Keyboard/Fcitx Pinyin baseline comparison remain covered.
The same published OTA
5aa3f46ae070now runs against a full source-built Orca host with its production encrypted RPC, input floor, real terminal daemon and macOS Bash PTY; no fixture RPC adapter. Actual Android key events interruptedsleep 30with Ctrl+C, recalled it with Up, and completedb5-completion-markerwith Tab. A raw-mode process in that real PTY recorded F1=1b 4f 50, Left=1b 5b 44, Ctrl+A=01, Alt+Left=1b 5b 31 3b 33 44, Tab=09, Ctrl+D=04, once per input. Ordinary native text and Enter also reached Bash. This closes the fixture-host limitation in the prior proof.Physical Bluetooth keyboards, additional IMEs and a broad TUI/shell matrix remain untested. The headless emulator's Swiftshader renderer clips terminal glyphs, so this pass uses production host terminal readback for exact output/byte assertions; no claim of resolving that unrelated rendering issue. Existing preedit forwarding is preserved. Current-head CI passes. No automatic merge requested.
Community credit
Continues the keyboard work from #23418 by Sangrak Choi, with composition guard inspiration from #27257 (zenghaolun02's composition fix). Both are credited as co-authors. The native-module approach was adapted to today's OTA architecture and existing send queue.
Fixes #25496
Earlier fixture-host screenshot: native Android → encrypted RPC → real Bash PTY (bundle
5aa3f46ae070; runtime DOM fallback for Swiftshader). The full production-host verification above uses actual PTY readback:(screenshot removed: contained real product data)