Title: fix: resolve CJK composition bug on iOS terminals (backspace packet splitting) by liante0904 · Pull Request #94 · lessweb/deepcode-cli · GitHub
Open Graph Title: fix: resolve CJK composition bug on iOS terminals (backspace packet splitting) by liante0904 · Pull Request #94 · lessweb/deepcode-cli
X Title: fix: resolve CJK composition bug on iOS terminals (backspace packet splitting) by liante0904 · Pull Request #94 · lessweb/deepcode-cli
Description: Why this is needed iOS terminal apps such as Moshi and Blink send CJK (Chinese, Japanese, Korean) composed characters in a single TCP packet when the iOS keyboard composes syllables. For example, when a user types the Korean syllable "가" followed by "나", the terminal may transmit the byte sequence: "가\x7f나" (character U+AC00 + backspace 0x7f + character U+B098) The current handleData in useTerminalInput.ts passes the entire concatenated buffer to parseTerminalInput() without splitting. Since parseTerminalInput treats the whole string as a single input event, the intermediate backspace (\x7f) is not interpreted as a delete action, and the composed character sequence gets corrupted. This results in garbled text and broken CJK input on iOS terminals. This is a long-standing, well-known issue affecting CJK users of Node.js TUI applications. What was changed In src/ui/prompt/useTerminalInput.ts, the handleData function now detects packets that contain one or more \x7f (backspace) bytes alongside other characters. When such a combined packet is received: The packet is split on \x7f. Each segment is dispatched individually through parseTerminalInput() and the input handler, in order: First the initial character(s) Then a properly parsed backspace event Then the subsequent character(s) (Repeating for multiple composition steps in a single packet) Normal input (without embedded backspaces) follows the original code path with zero overhead. Before const handleData = (data: Buffer | string) => { const { input, key } = parseTerminalInput(data); handlerRef.current(input, key); }; After const handleData = (data: Buffer | string) => { const raw = String(data); if (raw.includes("\x7f") && raw.length > 1) { const parts = raw.split("\x7f"); if (parts[0]) { const { input, key } = parseTerminalInput(parts[0]); handlerRef.current(input, key); } for (let i = 1; i < parts.length; i++) { const bs = parseTerminalInput("\x7f"); handlerRef.current(bs.input, bs.key); if (parts[i]) { const { input, key } = parseTerminalInput(parts[i]); handlerRef.current(input, key); } } return; } const { input, key } = parseTerminalInput(data); handlerRef.current(input, key); }; Testing npm run typecheck passes with no errors. eslint --fix and prettier --write pass via pre-commit hooks.
Open Graph Description: Why this is needed iOS terminal apps such as Moshi and Blink send CJK (Chinese, Japanese, Korean) composed characters in a single TCP packet when the iOS keyboard composes syllables. For example, w...
X Description: Why this is needed iOS terminal apps such as Moshi and Blink send CJK (Chinese, Japanese, Korean) composed characters in a single TCP packet when the iOS keyboard composes syllables. For example, w...
Opengraph URL: https://github.com/lessweb/deepcode-cli/pull/94
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:8d2148e5-2833-9f1c-4af1-6f3b554bce9e |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | ABE0:38840C:1CE67E:276098:6A4D3270 |
| html-safe-nonce | 20dae1d60976bfa1d8c9187b9446fdea354a53c68083eb7c058f9764ae2ae836 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQkUwOjM4ODQwQzoxQ0U2N0U6Mjc2MDk4OjZBNEQzMjcwIiwidmlzaXRvcl9pZCI6IjU5NzA2NzI5Njg5ODM3MjA1NjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 9b24ba94f64177763049d922d0855bd31d7f6d50227215d60d20359e21028458 |
| hovercard-subject-tag | pull_request:3713477810 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/lessweb/deepcode-cli/pull/94/files |
| twitter:image | https://avatars.githubusercontent.com/u/17792485?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/17792485?s=400&v=4 |
| og:image:alt | Why this is needed iOS terminal apps such as Moshi and Blink send CJK (Chinese, Japanese, Korean) composed characters in a single TCP packet when the iOS keyboard composes syllables. For example, w... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 92571a8944142227b7e19cd10918b1ddd06e5066c1ad5bc7e4769cf6140a87e6 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/lessweb/deepcode-cli git https://github.com/lessweb/deepcode-cli.git |
| octolytics-dimension-user_id | 118287711 |
| octolytics-dimension-user_login | lessweb |
| octolytics-dimension-repository_id | 1223512305 |
| octolytics-dimension-repository_nwo | lessweb/deepcode-cli |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1223512305 |
| octolytics-dimension-repository_network_root_nwo | lessweb/deepcode-cli |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 56fc8347865a14e2ec811533d68f929cf4e0ec19 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width