Skip to content

feat: support Unicode input and history in terminal#3242

Merged
hengyunabc merged 4 commits into
masterfrom
codex/arthas-terminal-unicode
Jul 19, 2026
Merged

feat: support Unicode input and history in terminal#3242
hengyunabc merged 4 commits into
masterfrom
codex/arthas-terminal-unicode

Conversation

@hengyunabc

@hengyunabc hengyunabc commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • upgrade Termd to 1.1.7.16 from feat: support Unicode line editing termd#73
  • negotiate Telnet BINARY mode in both directions so UTF-8 input is not decoded byte by byte
  • make the Arthas Telnet client and batch mode use UTF-8 at their byte/character boundaries
  • preserve Unicode command history by reading and writing history files explicitly as UTF-8
  • avoid treating prompt repaint output as a completed command response
  • add regression coverage for Telnet, HTTP/WebSocket terminal, prompt repaint, and persisted history behavior
  • document direct Unicode input support starting with Arthas 4.3.2 in the Chinese and English FAQs

Why

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

Checks

  • targeted Unicode, Telnet BINARY, batch-client, HTTP/WebSocket, and history tests passed
  • FileUtilsTest passed with both the default charset and -Dfile.encoding=ISO-8859-1
  • mvn -pl core -am test (Arthas core: 272 tests, 0 failures/errors, 7 skipped)
  • ./as-package.sh --fast (25 modules built successfully)
  • real Telnet batch, interactive PTY, and WebSocket sessions executed echo 中文
  • isolated restart test persisted UTF-8 history bytes and displayed echo 中文 from a second terminal session
  • mvn -pl core -am -DskipTests compile resolved Termd 1.1.7.16 and built all 11 reactor modules
  • Unicode terminal and history regression suite passed against Termd 1.1.7.16 (12 tests, 0 failures/errors)
  • npm run docs:build rendered all 154 documentation pages successfully

@hengyunabc
hengyunabc marked this pull request as ready for review July 18, 2026 17:12

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +49 to +50
.setInBinary(true)
.setOutBinary(true);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-core to 1.1.7.16 and 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.

Comment on lines 388 to 392
line.appendCodePoint(b);

// 检查到有 [arthas@ 时,意味着可以执行下一个命令了
int index = line.indexOf(PROMPT);
int index = findPromptAtLineStart(line);
if (index >= 0) {
@hengyunabc
hengyunabc merged commit 90d7052 into master Jul 19, 2026
18 checks passed
@hengyunabc
hengyunabc deleted the codex/arthas-terminal-unicode branch July 19, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants