fix(xserv-chat): UTF-8/CJK-aware line input

Cooked-mode read_line() left line editing to the terminal, so Backspace on a
multi-byte 汉字/かな/한글 deleted a byte (or behaved inconsistently across TTYs).
Replace with a raw-mode reader (libc termios): Backspace pops a whole char,
multi-byte input is reassembled from its continuation bytes, and a full-line
redraw renders double-width glyphs correctly. Non-TTY input falls back to a
plain read; raw mode is restored after each line. libc is already a locked
transitive dep, so this builds offline.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-29 11:36:54 +08:00
parent 7b8b520cda
commit c2362df1f1
3 changed files with 141 additions and 9 deletions

View File

@@ -18,6 +18,7 @@ license = "MIT"
[workspace.dependencies]
half = "2"
smallvec = "1"
libc = "0.2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
safetensors = "0.5"