feat: support Unicode input and history in terminal#3242
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df8443a13e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| .setInBinary(true) | ||
| .setOutBinary(true); |
There was a problem hiding this comment.
Avoid requiring BINARY for every Telnet session
When a Telnet client declines or does not implement the BINARY option, setting both directions as required prevents the Arthas shell from being created: TelnetTtyConnection.checkAccept() only calls the terminal handler after the requested binary directions are acknowledged. This means documented connections such as telnet 127.0.0.1 3658 can hang with no prompt on clients that answer WONT/DONT or ignore BINARY; the same required flags were also added to HttpTelnetTermServer. Please keep a non-binary fallback or make BINARY opportunistic rather than mandatory.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Pull request overview
This PR improves Arthas terminal Unicode support end-to-end by upgrading Termd, negotiating Telnet BINARY mode (to preserve UTF-8 bytes), making the client/batch paths UTF-8-aware, persisting history in UTF-8, adding regression tests, and documenting the behavior starting in Arthas 4.3.2.
Changes:
- Upgrade
termd-coreto1.1.7.16and enable Telnet BINARY negotiation for both server and client. - Persist and load command history explicitly as UTF-8 to preserve non-ASCII and supplementary Unicode characters.
- Add regression tests for Unicode readline, Telnet BINARY negotiation, batch prompt repaint handling, and UTF-8 history persistence; update FAQs.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| site/docs/en/doc/faq.md | Document direct Unicode input/editing support starting with Arthas 4.3.2 (English FAQ). |
| site/docs/doc/faq.md | Document direct Unicode input/editing support starting with Arthas 4.3.2 (Chinese FAQ). |
| pom.xml | Bump Termd dependency to 1.1.7.16. |
| core/src/main/java/com/taobao/arthas/core/util/FileUtils.java | Write/read int[] command history as UTF-8 bytes to preserve Unicode. |
| core/src/test/java/com/taobao/arthas/core/util/FileUtilsTest.java | Add regression test validating UTF-8 history persistence including supplementary code points. |
| core/src/test/java/com/taobao/arthas/core/shell/term/impl/TermImplUnicodeTest.java | Add regression test ensuring readline preserves Chinese input. |
| core/src/test/java/com/taobao/arthas/core/shell/term/impl/httptelnet/HttpTelnetTermServerTest.java | Add regression test verifying server requests/offers Telnet BINARY in both directions. |
| core/src/main/java/com/taobao/arthas/core/shell/term/impl/TelnetTermServer.java | Enable Telnet BINARY mode for the classic Telnet server bootstrap. |
| core/src/main/java/com/taobao/arthas/core/shell/term/impl/httptelnet/HttpTelnetTermServer.java | Enable Telnet BINARY mode for the HTTP-tunneled Telnet server bootstrap. |
| client/src/main/java/com/taobao/arthas/client/TelnetConsole.java | Use UTF-8 for batch file IO and Telnet I/O boundaries; add BINARY option negotiation and prompt-start detection. |
| client/src/main/java/com/taobao/arthas/client/IOUtil.java | Decode remote input as UTF-8 to preserve Unicode output. |
| client/src/test/java/com/taobao/arthas/client/TelnetConsoleBatchModeTest.java | Add regression coverage for Telnet BINARY negotiation, UTF-8 command bytes, and prompt repaint handling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| line.appendCodePoint(b); | ||
|
|
||
| // 检查到有 [arthas@ 时,意味着可以执行下一个命令了 | ||
| int index = line.indexOf(PROMPT); | ||
| int index = findPromptAtLineStart(line); | ||
| if (index >= 0) { |
Summary
1.1.7.16from feat: support Unicode line editing termd#73Why
Unicode input failed at several boundaries: the previous Termd readline path rejected characters whose display width was not one, non-binary Telnet input could turn each UTF-8 byte into a separate character, and command history persisted Java character values through
OutputStream.write(int), truncating non-ASCII data to one byte.Impact
Users can enter, edit, execute, and recall Chinese and other Unicode commands in Arthas Telnet and WebSocket terminals. Existing ASCII behavior remains covered by the original test suite.
Dependency
1.1.7.16Checks
FileUtilsTestpassed with both the default charset and-Dfile.encoding=ISO-8859-1mvn -pl core -am test(Arthas core: 272 tests, 0 failures/errors, 7 skipped)./as-package.sh --fast(25 modules built successfully)echo 中文echo 中文from a second terminal sessionmvn -pl core -am -DskipTests compileresolved Termd1.1.7.16and built all 11 reactor modules1.1.7.16(12 tests, 0 failures/errors)npm run docs:buildrendered all 154 documentation pages successfully